Forkz
Well-Known Member
- Joined
- Jun 29, 2020
- Messages
- 380
- Solutions
- 1
- Reaction score
- 89
Hello,
I'm using this critical system, but it doesn't work when the opponent has "utamo vita". Any soul want to help me?
I'm using this critical system, but it doesn't work when the opponent has "utamo vita". Any soul want to help me?
Lua:
local config = {
magic_effect = 173, -- magic effect you want to send when critical hit lands
damage_magic = 1.8, -- Sorcerers and Druids
damage_physical = 2.0 -- Paladins and Knights
}
local function getSkill(player)
local vocation = player:getVocation()
while vocation:getDemotion() do
vocation = vocation:getDemotion()
end
local vocId = vocation:getId()
if vocId == 1 or vocId == 2 then
return player:getMagicLevel() * 0.05, config.damage_magic
elseif vocId == 3 then
return player:getEffectiveSkillLevel(SKILL_DISTANCE) * 0.07, config.damage_physical
elseif vocId == 4 then
local sword = player:getEffectiveSkillLevel(SKILL_SWORD)
local club = player:getEffectiveSkillLevel(SKILL_CLUB)
local axe = player:getEffectiveSkillLevel(SKILL_AXE)
return math.max(sword, club, axe) * 0.07, config.damage_physical
end
return nil
end
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not attacker:isPlayer() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local chance, multiplier = getSkill(attacker)
if not chance then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if math.random(100) <= chance then
creature:getPosition():sendMagicEffect(config.magic_effect)
return primaryDamage * multiplier, primaryType, secondaryDamage, secondaryType
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end