sallem
Member
- Joined
- Nov 18, 2024
- Messages
- 20
- Reaction score
- 14
change this script to tfs 036
weapon :
creaturescripts :
weapon :
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
<event type="healthchange" name="lifesteal" script="lifesteal.lua"/>
creaturescripts :
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