ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi again! I saw this critical system in a post and I wonder if someone can help me by setting up critical chances for axes, clubs, wands, all kind of distance weapons, and fist too, because is only running on sword skill local skill = attacker:getEffectiveSkillLevel(SKILL_SWORD). This is the script:
Going to register to monsters by using this way, I dont know if this would affect the performance of the script?
Thanks in advance!
Code:
local config = {
magic_effect = 15, -- magic effect you want to send when critical hit lands
damage_multiplier = 10 -- default damage * 10 = critical damage
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker == nil then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if not attacker:isPlayer() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local skill = attacker:getEffectiveSkillLevel(SKILL_SWORD)
local chance = (skill * 0.1)
if math.random(100) <= chance then
attacker:getPosition():sendMagicEffect(config.magic_effect)
return primaryDamage * config.damage_multiplier, primaryType, secondaryDamage, secondaryType
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Going to register to monsters by using this way, I dont know if this would affect the performance of the script?
- Open
data/events/events.xml
- Find
<event class="Creature" method="onTargetCombat" enabled="0" />
and changeenabled="0"
toenabled="1"
- Open
data/events/scripts/creature.lua
- Find
function Creature:onTargetCombat(target)
and add theretarget:registerEvent("criticalHitSystemXHP")
so you don't need to register every xml file
Thanks in advance!