• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Ignoring damage on specific unit

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,342
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
 
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.
Back
Top