Hello!
It was requested by Eldin and a great example was given to him. Plus, I haven't found anyone making an article about it on here and I feel it should be.
You will have to register this with each monster in their own individual XML file, this is the downside to not using C++.
Math info, say I have 50 fist skill, that will be 50% critical strike chance and a capability of landing +50% damage.
It was requested by Eldin and a great example was given to him. Plus, I haven't found anyone making an article about it on here and I feel it should be.
You will have to register this with each monster in their own individual XML file, this is the downside to not using C++.
Math info, say I have 50 fist skill, that will be 50% critical strike chance and a capability of landing +50% damage.
Code:
Fist Skill Level: 50
22:48 Critical Hit: +4 DMG
22:48 A bug loses 12 hitpoints due to your attack.
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if(Monster(attacker) ~= nil) then --if attacker is monster, then don't crit
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if attacker == nil then --if attacker is dead, conditions apply after
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if math.random(100) < attacker:getSkillLevel(SKILL_FIST) then
local percDam = (attacker:getSkillLevel(SKILL_FIST) / 100) * primaryDamage
attacker:sendTextMessage((MESSAGE_DAMAGE_DEALT), "Critical Hit: +".. percDam .." DMG")
creature:getPosition():sendMagicEffect(CONST_ME_HITAREA)
return primaryDamage + percDam, primaryType, secondaryDamage, secondaryType
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Last edited: