function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local damage = primaryDamage + secondaryDamage
if attacker:isPlayer() then
if math.random(100) <= cfg.chance then
local weapon = attacker:getSlotItem(CONST_SLOT_LEFT)
if weapon and weapon:getId() == cfg.weaponId then
attacker:addHealth(damage * (cfg.percent/100))
end
end
end
creature:unregisterEvent("lifesteal")
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Pergunta
Emooooo 0
weapon.lua
----------------------------------------
function onTargetCreature(creature, target)
return target:registerEvent("lifesteal")
end
local combat = Combat()
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
combat:setParameter(COMBAT_PARAM_BLOCKSHIELD, 1)
combat:setParameter(COMB, COMBAT_PHYSICALDAMAGE)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
function onUseWeapon(player, variant)
return combat:execute(player, variant)
end
---------------------------------------------------
creaturescripts/creaturescripts.xml
<event type="healthchange" name="lifesteal" script="lifesteal.lua"/>
----------------------------------------
creaturescripts/scripts/lifesteal.lua
local cfg = {
weaponId = 16162,
chance = 10,
percent = 10
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local damage = primaryDamage + secondaryDamage
if attacker:isPlayer() then
if math.random(100) <= cfg.chance then
local weapon = attacker:getSlotItem(CONST_SLOT_LEFT)
if weapon and weapon:getId() == cfg.weaponId then
attacker:addHealth(damage * (cfg.percent/100))
end
end
end
creature:unregisterEvent("lifesteal")
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados