felzan
Caos manager
- Joined
- Dec 19, 2009
- Messages
- 38
- Reaction score
- 8
I'm trying to do a poison arrow that deals damage based on target health.
I can get the target health but only when i hit (with the arrow)
the question: How to get target health on each condition event?
I can get the target health but only when i hit (with the arrow)
the question: How to get target health on each condition event?
Code:
local combatArrow = Combat()
combatArrow:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
combatArrow:setParameter(COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
combatArrow:setFormula(COMBAT_FORMULA_SKILL, 1, 0, 1, 0)
local function onUseWeaponPoison(parameters)
local target = parameters.cid:getTarget()
if target == nil then
return true
else
local conditionPoison = Condition(CONDITION_POISON)
conditionPoison:setParameter(CONDITION_PARAM_DELAYED, true)
for i = 10, 1,-1 do
local hp = getCreatureHealth(target)
local hpp = .001
conditionPoison:addDamage(1, 1000, -hp*hpp*i)
end
combatArrow:setCondition(conditionPoison)
end
end
function onUseWeapon(player, var)
local cid = player:getId()
parameters = {cid = player, var = var}
combatArrow:execute(player, var)
addEvent(onUseWeaponPoison, 1000, parameters)
return true
end