ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi! I use TFS 1.5 by nekiro, and I wonder if someone can help me with this idea. I have a passive critical system on my server where players get a % of critical chance every 10 levels. This critical chance is not handled by sources, .lua is the way this works for my 8.6 server and this is the creaturescript that check the player hits.
What I need is to convert the formula of this script to a "leeching" formula. Where player gets a % of health based on their hit damage. and only use .lua to achieve this. Is it possible? I will read your answers and see where all this goes. Thanks in advance!
Regards
Lua:
--[[
Dodge & Critical fixado por Movie (Movie#4361)
Disponibilizado para o TibiaKing e não autorizo outras reproduções
Mantenha os créditos <3
--]]
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if (not attacker or not creature) then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if primaryType == COMBAT_HEALING then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if (attacker:isPlayer() and (attacker:getCriticalLevel() * 3) >= math.random (0, 1000)) then
primaryDamage = primaryDamage + math.ceil(primaryDamage * CRITICAL.PERCENT)
creature:getPosition():sendMagicEffect(CONST_ME_WATERCREATURE)
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Lua:
--[[
Dodge & Critical fixado por Movie (Movie#4361)
Disponibilizado para o TibiaKing e não autorizo outras reproduções
Mantenha os créditos <3
--]]
STORAGEVALUE_DODGE = 48900
STORAGEVALUE_CRITICAL = 48901
DODGE = {
LEVEL_MAX = 100, -- máximo de level que o dodge será
PERCENT = 0.2 -- porcentagem que irá defender o ataque
}
CRITICAL = {
LEVEL_MAX = 100, -- máximo de level que o critical será
PERCENT = 0.4 -- porcentagem que irá aumentar o ataque
}
function Player.getDodgeLevel(self)
return self:getStorageValue(STORAGEVALUE_DODGE)
end
function Player.setDodgeLevel(self, value)
return self:setStorageValue(STORAGEVALUE_DODGE, value)
end
function Player.getCriticalLevel(self)
return self:getStorageValue(STORAGEVALUE_CRITICAL)
end
function Player.setCriticalLevel(self, value)
return self:setStorageValue(STORAGEVALUE_CRITICAL, value)
end
What I need is to convert the formula of this script to a "leeching" formula. Where player gets a % of health based on their hit damage. and only use .lua to achieve this. Is it possible? I will read your answers and see where all this goes. Thanks in advance!
Regards