- Joined
- Aug 7, 2013
- Messages
- 1,338
Hi,
I have tried to write a trigger that basically heals a unit whenever it is damaged for the damage it received.
The trigger sort of works, but for some reason it lets the unit take damage from the first hit of an attacker, then afterwards works correctly.
Thus if a unit hit it for 20 damage, it would have 80/100 health, but then after all attacks would be healed.
I have tried to write a trigger that basically heals a unit whenever it is damaged for the damage it received.
The trigger sort of works, but for some reason it lets the unit take damage from the first hit of an attacker, then afterwards works correctly.
Thus if a unit hit it for 20 damage, it would have 80/100 health, but then after all attacks would be healed.
JASS:
static method damageMain takes nothing returns boolean
local unit u = GetTriggerUnit()
call print("healed damage")
call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + GetEventDamage())
set u = null
return false
endmethod
method setInvuln takes nothing returns nothing
set invulnTrig = CreateTrigger()
call TriggerAddCondition(invulnTrig, Condition(function A.damageMain))
call TriggerRegisterUnitEvent(invulnTrig, u, EVENT_UNIT_DAMAGED)
endmethod