D
Deleted 224045
Guest
Hi, guys!
I'm making a weapon that heals 25% of the damage dealt to the target.
Here's the script:
Can't figure out what I'm doing wrong guys. Could someone help me out?
Edit: I'm using OTHire 0.0.3 (tibia client 7.72)
I'm making a weapon that heals 25% of the damage dealt to the target.
Here's the script:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_SKILL , 0, 0, 1.0, 0)
-- Holds the last health of the target
lastTargetHealth = 0
-- Gets the targets health
function getTargetHealth(cid)
local target = getCreatureTarget(cid)
local health = getCreatureHealth(target)
return health
end
function onUseWeapon(cid, var)
local currentTargetHealth = getTargetHealth(cid)
local damage = lastTargetHealth - currentTargetHealth
lastTargetHealth = currentTargetHealth
-- To get around the first hit because lastTargetHealth = 0
if (damage > 0)
local addhealth = damage * 0.25
doCreatureAddHealth(cid, addhealth)
doSendAnimatedText(getPlayerPosition(cid), "+"..addhealth.."", TEXTCOLOR_GREEN)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
return doCombat(cid, combat, var)
end
Can't figure out what I'm doing wrong guys. Could someone help me out?
Edit: I'm using OTHire 0.0.3 (tibia client 7.72)