Hey, after 4 days and like 20 hours of fighting with (and against) chat, I gave up as it continously loops with suggesting same mistakes and errors.
I use TFS 1.3 but i think I'm missing some methods calls etc but i'm afraid to update it or change as everything for now works on my server
What I wish is working dawnport script for TFS 1.3:
(already read TFS 0.X - Convert SKILLS/ML when change vocation Dawnport (https://otland.net/threads/convert-skills-ml-when-change-vocation-dawnport.265155/page-3#post-2574482))
I want statues uid55550-55554 that on use will:
1) save players skill tries, and mana spent (IDK PRBLY DOESN'T WORK)
2) change vocations acording to specified uid (55550 to vocation 0, 55551 to vocation 1 etc) (IT DOES
)
3) if this is first change i wish it to add player specified items (and check if player has cap to take it) else display that items has already been granted (IT DOES but gives items all the time)
4) adjust (recalculate) players skills (with levels either set in vocations.xml or manually added to script, it may skip fishing and fist fighting, they're same for all voc on my serv) (IT DOES add insane skills, never downgrades)
5) adjust (recalculate) players max hp/mana/cap (i know I have it different than in rl tibia cause I set 100hp and 0 mana at level 0 so if you start as novoc at 1 level you have 105 hp and 5 mana, and when you change to 1 level druid you will have 110hp[100+510hp] and 30mp [0+30mp]) (IT DOES
)
6) adjust total mana spent to new magic level of vocation (IDK PRBLY NOT)
7) display info that you changed vocation, and skills has been adjusted to your new vocation (IT DOES
)
8) display in server log your adjusted skills and skill tries (Couldn't merge both codes)
9) if you use id 55555 it will reset all your skills to level 10, skill tries to 0 and magic level to 0 with mana spent also 0 (IT DOESN'T
)
Here are two codes that at least doesn't throw out errors in my game console:
PS skill tries shown in phpmyadmin->player are correct
As reseting skills didn't worked as intended, and it adds insane amount of skill tries i tried to make
*statue uid55556 that on use would print players actual skills and total skill tries, It includes all my vocation.xml multipliers
but it doesn't display it correct. Anyway this is more or less language what my server understands but I just can't fit proper math to it:
It has... I have this problem with math:
when you hit it displays 4 more skill tries (or 5x) same with mana instead of +20 it is +100, but when you advance in level it drops to strange value. Level 10 skill with no skill try at all shows as my base and multiplier egz i have 1.1 then it shows 110 1.5 it shows 150
I use TFS 1.3 but i think I'm missing some methods calls etc but i'm afraid to update it or change as everything for now works on my server
What I wish is working dawnport script for TFS 1.3:
(already read TFS 0.X - Convert SKILLS/ML when change vocation Dawnport (https://otland.net/threads/convert-skills-ml-when-change-vocation-dawnport.265155/page-3#post-2574482))
I want statues uid55550-55554 that on use will:
1) save players skill tries, and mana spent (IDK PRBLY DOESN'T WORK)
2) change vocations acording to specified uid (55550 to vocation 0, 55551 to vocation 1 etc) (IT DOES

3) if this is first change i wish it to add player specified items (and check if player has cap to take it) else display that items has already been granted (IT DOES but gives items all the time)
4) adjust (recalculate) players skills (with levels either set in vocations.xml or manually added to script, it may skip fishing and fist fighting, they're same for all voc on my serv) (IT DOES add insane skills, never downgrades)
5) adjust (recalculate) players max hp/mana/cap (i know I have it different than in rl tibia cause I set 100hp and 0 mana at level 0 so if you start as novoc at 1 level you have 105 hp and 5 mana, and when you change to 1 level druid you will have 110hp[100+

6) adjust total mana spent to new magic level of vocation (IDK PRBLY NOT)
7) display info that you changed vocation, and skills has been adjusted to your new vocation (IT DOES

8) display in server log your adjusted skills and skill tries (Couldn't merge both codes)
9) if you use id 55555 it will reset all your skills to level 10, skill tries to 0 and magic level to 0 with mana spent also 0 (IT DOESN'T

Here are two codes that at least doesn't throw out errors in my game console:
PS skill tries shown in phpmyadmin->player are correct
LUA:
-- Define vocationChange and statues tables at the top of the script
local vocationChange = {
[55550] = {vocationId = 0, hp = 5, mana = 5, cap = 20}, -- Unique ID 55550 changes to no vocation (vocation ID 0)
[55551] = {vocationId = 1, hp = 10, mana = 30, cap = 20}, -- Unique ID 55551 changes to Sorcerer (vocation ID 1)
[55552] = {vocationId = 2, hp = 10, mana = 30, cap = 20}, -- Unique ID 55552 changes to Druid (vocation ID 2)
[55553] = {vocationId = 3, hp = 20, mana = 15, cap = 20}, -- Unique ID 55553 changes to Paladin (vocation ID 3)
[55554] = {vocationId = 4, hp = 30, mana = 10, cap = 20}, -- Unique ID 55554 changes to Knight (vocation ID 4)
}
local statues = {
[55550] = {
vocid = 0,
needcap = (1.3 * 40),
extraItems = {
{itemID = 8704, count = 2} -- small health pot
}
},
[55551] = {
vocid = 1,
needcap = (1.35 + 15.00) * 40,
extraItems = {
{itemID = 7620, count = 1}, -- mana pot
{itemID = 23719, count = 1} -- scorcher
}
},
[55552] = {
vocid = 2,
needcap = (1.30 + 15.00) * 40,
extraItems = {
{itemID = 8474, count = 1}, -- ant pot
{itemID = 23721, count = 1} -- chiller
}
},
[55553] = {
vocid = 3,
needcap = (20.00 * 40),
extraItems = {
{itemID = 2389, count = 2} -- spear
}
},
[55554] = {
vocid = 4,
needcap = (13.00 * 40),
extraItems = {
{itemID = 2666, count = 2} -- meat
}
}
}
-- Function to calculate required skill tries for a given level
local function calculateRequiredSkillTries(level)
-- Example formula for skill progression, adjust as per your game's logic
local base = 1 -- Base value for skill tries calculation
local exponent = 2.0 -- Exponent for skill tries calculation
-- Calculate skill tries required for the given level
return math.floor(base * (level ^ exponent))
end
-- Function to reset skills to a specific level, excluding fishing, fist fighting, and magic
local function resetSkillsToLevel(player, level)
-- Define skills to exclude from reset
local excludedSkills = {
[SKILL_FISHING] = true,
[SKILL_FIST] = true,
[SKILL_MAGLEVEL] = true,
}
for skill = 0, 6 do
if not excludedSkills[skill] then
local currentTries = player:getSkillTries(skill)
-- Remove current tries and add 1 try for the desired level
player:addSkillTries(skill, -currentTries)
player:addSkillTries(skill, calculateRequiredSkillTries(level))
end
end
end
-- Function to calculate total skill tries since a specific level
local function getTotalSkillTries(player, skill, startLevel)
local totalTries = 0
for level = startLevel, player:getSkillLevel(skill) - 1 do
totalTries = totalTries + calculateRequiredSkillTries(level)
end
totalTries = totalTries + player:getSkillTries(skill)
return totalTries
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- Ensure vocationChange and statues are accessible within the function scope
local changeInfo = vocationChange[item:getUniqueId()]
local statueInfo = statues[item:getUniqueId()]
if not changeInfo or not statueInfo then
-- Handle case where item ID doesn't match any entries in vocationChange or statues
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "This item cannot be used for vocation change.")
return false
end
if item:getUniqueId() == 55555 then
-- Reset skills to level 10
resetSkillsToLevel(player, 10)
-- Print skill levels and skill tries after reset
local skillTries = {}
for skill = 0, 6 do
skillTries[skill] = getTotalSkillTries(player, skill, 0) -- Pass startLevel as 0 for initial level
end
-- Print to console
print("Skill Levels after reset:")
print("Sword: " .. player:getSkillLevel(SKILL_SWORD) .. ", Tries: " .. skillTries[SKILL_SWORD])
print("Axe: " .. player:getSkillLevel(SKILL_AXE) .. ", Tries: " .. skillTries[SKILL_AXE])
print("Club: " .. player:getSkillLevel(SKILL_CLUB) .. ", Tries: " .. skillTries[SKILL_CLUB])
print("Shielding: " .. player:getSkillLevel(SKILL_SHIELD) .. ", Tries: " .. skillTries[SKILL_SHIELD])
print("Distance: " .. player:getSkillLevel(SKILL_DISTANCE) .. ", Tries: " .. skillTries[SKILL_DISTANCE])
print("Total Mana Spent: " .. player:getManaSpent())
-- Log to server
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Skill Levels after reset:")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sword: " .. player:getSkillLevel(SKILL_SWORD) .. ", Tries: " .. skillTries[SKILL_SWORD])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Axe: " .. player:getSkillLevel(SKILL_AXE) .. ", Tries: " .. skillTries[SKILL_AXE])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Club: " .. player:getSkillLevel(SKILL_CLUB) .. ", Tries: " .. skillTries[SKILL_CLUB])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Shielding: " .. player:getSkillLevel(SKILL_SHIELD) .. ", Tries: " .. skillTries[SKILL_SHIELD])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Distance: " .. player:getSkillLevel(SKILL_DISTANCE) .. ", Tries: " .. skillTries[SKILL_DISTANCE])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Total Mana Spent: " .. player:getManaSpent())
player:sendTextMessage(MESSAGE_INFO_DESCR, "Your skills have been reset to level 10.")
return true
elseif player:getLevel() < 1 then
-- Check if player level is below minimum required level for vocation change
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You need to be at least level 1 to use this item.")
return false
else
-- Validate capacity requirement
local playerCap = player:getCapacity()
if playerCap < statueInfo.needcap then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You do not have enough capacity to perform this vocation change.")
return false
end
-- Perform vocation change logic
local currentVocationId = player:getVocation():getId()
local newVocationId = changeInfo.vocationId
-- Save skill tries for restoring later
local skillTries = {}
for skill = 0, 6 do
skillTries[skill] = getTotalSkillTries(player, skill, 0) -- Pass startLevel as 0 for initial level
end
-- Change vocation
player:setVocation(newVocationId)
-- Adjust player stats based on vocation change
local newLevel = player:getLevel()
local newHealth = 100 + (newLevel * changeInfo.hp)
local newMana = 0 + (newLevel * changeInfo.mana)
local newCapacity = 40000 + (newLevel * changeInfo.cap)
player:setMaxHealth(newHealth)
player:setMaxMana(newMana)
player:setCapacity(newCapacity)
-- Restore skill tries after vocation change
for skill = 0, 6 do
player:addSkillTries(skill, skillTries[skill] - player:getSkillTries(skill))
end
-- Add extra items associated with the new vocation
for _, extraItem in ipairs(statueInfo.extraItems) do
player:addItem(extraItem.itemID, extraItem.count)
end
-- Send confirmation message
local newVocation = player:getVocation()
player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now a " .. newVocation:getName() .. "! Your skills and stats have been adjusted.")
return true
end
end
As reseting skills didn't worked as intended, and it adds insane amount of skill tries i tried to make
*statue uid55556 that on use would print players actual skills and total skill tries, It includes all my vocation.xml multipliers
but it doesn't display it correct. Anyway this is more or less language what my server understands but I just can't fit proper math to it:
LUA:
-- Example function to get skill multipliers based on vocation
local function getSkillMultiplier(vocation, skill)
-- Replace with your actual logic to fetch skill multipliers based on vocation
local skillMultipliers = {
["None"] = {
[SKILL_FIST] = 1.5,
[SKILL_CLUB] = 2.0,
[SKILL_SWORD] = 2.0,
[SKILL_AXE] = 2.0,
[SKILL_DISTANCE] = 2.0,
[SKILL_SHIELD] = 1.5,
[SKILL_FISHING] = 1.1
},
["Sorcerer"] = {
[SKILL_FIST] = 1.5,
[SKILL_CLUB] = 2.0,
[SKILL_SWORD] = 2.0,
[SKILL_AXE] = 2.0,
[SKILL_DISTANCE] = 2.0,
[SKILL_SHIELD] = 1.5,
[SKILL_FISHING] = 1.1
},
["Druid"] = {
[SKILL_FIST] = 1.5,
[SKILL_CLUB] = 2.0,
[SKILL_SWORD] = 2.0,
[SKILL_AXE] = 2.0,
[SKILL_DISTANCE] = 2.0,
[SKILL_SHIELD] = 1.5,
[SKILL_FISHING] = 1.1
},
["Paladin"] = {
[SKILL_FIST] = 1.5,
[SKILL_CLUB] = 1.2,
[SKILL_SWORD] = 1.2,
[SKILL_AXE] = 1.2,
[SKILL_DISTANCE] = 1.1,
[SKILL_SHIELD] = 1.1,
[SKILL_FISHING] = 1.1
},
["Knight"] = {
[SKILL_FIST] = 1.5,
[SKILL_CLUB] = 1.1,
[SKILL_SWORD] = 1.1,
[SKILL_AXE] = 1.1,
[SKILL_DISTANCE] = 1.2,
[SKILL_SHIELD] = 1.1,
[SKILL_FISHING] = 1.1
}
}
-- Return the multiplier for the specified skill and vocation
return skillMultipliers[vocation][skill] or 1.0 -- Default to 1.0 if multiplier not found
end
-- Function to calculate required skill tries for a given level
local function calculateRequiredSkillTries(level, multiplier)
local baseTries = 10 -- Base tries needed from level 10 to level 11
local basePercentage = 10 -- Base percentage increase per hit
local maxLevel = 1000 -- Max level to cap
-- Calculate skill tries required for the given level with multiplier
local tries = baseTries
local percentage = basePercentage
for currentLevel = 10, level - 1 do
percentage = math.max(basePercentage * (1 - currentLevel / maxLevel), 1)
tries = math.floor(tries + (percentage / 100))
end
return math.floor(tries * multiplier)
end
-- Function to calculate total skill tries from level 0 to the current level
local function getTotalSkillTries(player, skill)
local totalTries = 0
local currentLevel = player:getSkillLevel(skill)
local vocation = player:getVocation():getName()
local multiplier = getSkillMultiplier(vocation, skill)
for level = 0, currentLevel - 1 do
totalTries = totalTries + calculateRequiredSkillTries(level, multiplier)
end
totalTries = totalTries + player:getSkillTries(skill)
return totalTries
end
-- Main function triggered on item use
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getUniqueId() == 55556 then
local vocation = player:getVocation():getName()
local stage = "2.0" -- Default stage, you should dynamically determine this based on vocation
-- Print skill levels and total skill tries after reset
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Skill levels and total tries:")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You spent a total of " .. player:getManaSpent() .. " mana")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Fist Fighting level " .. player:getSkillLevel(SKILL_FIST) .. ", with " .. getTotalSkillTries(player, SKILL_FIST) .. " tries.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Club Fighting level " .. player:getSkillLevel(SKILL_CLUB) .. ", with " .. getTotalSkillTries(player, SKILL_CLUB) .. " tries.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sword Fighting level " .. player:getSkillLevel(SKILL_SWORD) .. ", with " .. getTotalSkillTries(player, SKILL_SWORD) .. " tries.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Axe Fighting level " .. player:getSkillLevel(SKILL_AXE) .. ", with " .. getTotalSkillTries(player, SKILL_AXE) .. " tries.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Distance level " .. player:getSkillLevel(SKILL_DISTANCE) .. ", with " .. getTotalSkillTries(player, SKILL_DISTANCE) .. " tries.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Shielding level " .. player:getSkillLevel(SKILL_SHIELD) .. ", with " .. getTotalSkillTries(player, SKILL_SHIELD) .. " tries.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Fishing level " .. player:getSkillLevel(SKILL_FISHING) .. ", with " .. getTotalSkillTries(player, SKILL_FISHING) .. " tries.")
-- Inform the player
player:sendTextMessage(MESSAGE_INFO_DESCR, "Current skill levels and tries have been displayed in Local Chat.")
return true
end
return false
end
when you hit it displays 4 more skill tries (or 5x) same with mana instead of +20 it is +100, but when you advance in level it drops to strange value. Level 10 skill with no skill try at all shows as my base and multiplier egz i have 1.1 then it shows 110 1.5 it shows 150
Attachments
-
003051.png172.1 KB · Views: 18 · VirusTotal
Last edited: