E
Evil Puncker
Guest
script by jerryb1988 on github, posting it here in case anyone wants to use it:
just add the following code to your login.lua here
his words:
all credit to him;
just add the following code to your login.lua here
Lua:
-- Fix HP/Mana/Cap to match CIP, assume player left rook at level 8
if player:getVocation():getId() == 0 then
calchp = 5 * (player:getLevel() + 29)
calcmana = 5 * (player:getLevel() + 10)
calccap = 10 * (player:getLevel() + 39)
elseif player:getVocation():getId() == 1 or player:getVocation():getId() == 5 then
calchp = 5 * (player:getLevel() + 29)
calcmana = 5 * ((6 * player:getLevel()) - (5 * 8) + 10)
calccap = 10 * (player:getLevel() + 39)
elseif player:getVocation():getId() == 2 or player:getVocation():getId() == 6 then
calchp = 5 * (player:getLevel() + 29)
calcmana = 5 * ((6 * player:getLevel()) - (5 * 8) + 10)
calccap = 10 * (player:getLevel() + 39)
elseif player:getVocation():getId() == 3 or player:getVocation():getId() == 7 then
calchp = 5 * ((2 * player:getLevel()) - 8 + 29)
calcmana = 5 * ((3 * player:getLevel())- (2 * 8) + 10)
calccap = 10 * ((2 * player:getLevel()) - 8 + 39)
elseif player:getVocation():getId() == 4 or player:getVocation():getId() == 8 then
calchp = 5 *((3 * player:getLevel()) - (2 * 8) + 29)
calcmana = 5 *(player:getLevel() + 10)
calccap = 5 *((5 * player:getLevel()) - (5 * 8) + 94)
end
if player:getMaxHealth() ~= calchp then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Server detected your max health was wrongly set at " .. player:getMaxHealth() .. " and we adjusted it to " .. calchp .. " automatically.")
player:setMaxHealth(calchp)
player:addHealth(calchp)
end
if player:getMaxMana() ~= calcmana then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Server detected your max mana was wrongly set at " .. player:getMaxMana() .. " and we adjusted it to " .. calcmana .. " automatically.")
player:setMaxMana(calcmana)
player:addMana(calcmana)
end
if player:getCapacity() ~= (calccap * 100) then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Server detected your max capacity was wrongly set at " .. (player:getCapacity() / 100) .. " and we adjusted it to " .. calccap .. " automatically.")
player:setCapacity(calccap * 100)
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "For level " .. player:getLevel() .. ", your max HP should be: " .. calchp .. " max mana should be: " .. calcmana .. " max cap should be: " .. calccap .. ".")
his words:
These formulas were taken from the tibia wiki. They assume that for any character with a vocation, that they left rookgaard at level 8 (so there will be no handicap). Their may be a better way to do this via hardcoding, but this was a quick and easy solution to characters having incorrect values when being bumped levels from the start. The cap is multiplied by 100 to accommodate for the double since items can weigh #.## I realize this will trigger unnecessarily for every login and could potentially create a performance hit on a large server, so this could also be something that could become a talk action like !fixme or something of the sorts. Feel free to incorporate however you deem it fits.
all credit to him;