• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Ignoring damage on specific unit

Status
Not open for further replies.
Level 15
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.

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
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
This is a WC 3 bug, just add a 99k health ability then remove it after u heal the unit.
I would not call it a bug, rather a nice feature. When the trigger fires on a EVENT_UNIT_DAMAGED, its actually before the damage is done.

Dat-C3s solution is not optimal and may lead to bugs. If you want a post-heal instead of a pre-heal, a 0.00 timer will do.
 
Status
Not open for further replies.
Top