jareczekjsp
Member
Hello guys I have script for Dodge and work good but when Player have a MANASHIELD dont working Dodge ,only on HP how I can add when I have manashield Too working dodge?
LIB
Creaturescripts
LIB
Lua:-- Configuraçao DODGE = { STORAGE = 48900, -- player storage do sistema LEVEL_MAX = 100, -- máximo de dodge level que o player pode alcançar PERCENT = 1.0 -- porcentagem que irá defender o ataque [padrao 50% = 0.5] } CRITICAL = { STORAGE = 48901, -- player storage do sistema LEVEL_MAX = 100, -- máximo de critical level que o player pode alcançar PERCENT = 0.5 -- porcentagem que irá aumentar o ataque [padrao 50% = 0.5] } function Player.getDodgeLevel(self) return self:getStorageValue(DODGE.STORAGE) end function Player.setDodgeLevel(self, value) return self:setStorageValue(DODGE.STORAGE, value) end function Player.getCriticalLevel(self) return self:getStorageValue(CRITICAL.STORAGE) end function Player.setCriticalLevel(self, value) return self:setStorageValue(CRITICAL.STORAGE, value) end
Creaturescripts
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not isPlayer(creature) then return false end
if (creature:getDodgeLevel() * 3) >= math.random (0, 1000) and isCreature(attacker) then
if isInArray({ORIGIN_MELEE, ORIGIN_RANGED, ORIGIN_SPELL}, origin) and primaryType ~= COMBAT_HEALING then
primaryDamage = primaryDamage - math.ceil(primaryDamage * DODGE.PERCENT)
creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Last edited: