• 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.

Detect Unit taking Damage

Status
Not open for further replies.
I've browsed the various threads on this subject and the below was my attempt. It doesn't work.

  • Marked Foe Damage
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Spell Book (Marked Foe) for (Triggering unit)) Greater than 0
      • ((Owner of (Triggering unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Trigger - Add to (This trigger) the event (Unit - (Attacked unit) Takes damage)
      • Set Marked_Foe_Damage = (Integer((Damage taken)))
      • Set Marked_Foe_Damage_Real = (Real(Marked_Foe_Damage))
      • Unit - Cause (Attacking unit) to damage (Triggering unit), dealing (0.25 x Marked_Foe_Damage_Real) damage of attack type Normal and damage type Magic
      • Floating Text - Create floating text that reads (String(Marked_Foe_Damage)) at (Position of (Triggering unit)) with Z offset 0.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 25.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
 
Why don't you use a damage detection system? (Like Bribe's)

It would make life a bit easier.

Anyway, the problem with it is that it won't pass the condition here:
  • ((Owner of (Triggering unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
When that trigger is fired for damage. You should instead add the event to a separate trigger with separate conditions, then it should work. :)
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
The reason the condition causes it to fail is because Attacking unit would be null in the damage taken event (You have to use Damage Source).
Also, if it did work, it would cause an infinite looping trigger since you also deal damage with that event (Disable the trigger before dealing damage and enable it afterwards).

Like Purge said, a standard damage detection system would be much easier to use than trying to do this on your own.

If you do want it like this, have your on attack trigger only have this line:
  • Trigger - Add to (MyDamageDetectTrigger) the event (Unit - (Attacked unit) Takes damage)
(along with checking that the attacked unit didn't have that event registered and then having to remove that event later) and the rest of the lines in that damage event trigger.
 
Where am I wrong?

  • Marked Foe Damage
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Spell Book (Marked Foe) for (Triggering unit)) Greater than 0
      • ((Owner of (Triggering unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Trigger - Add to Marked Foe Damage II <gen> the event (Unit - (Attacked unit) Takes damage)
  • Marked Foe Damage II
    • Events
    • Conditions
      • (Level of Spell Book (Marked Foe) for (Triggering unit)) Greater than 0
    • Actions
      • Set Marked_Foe_Damage = (Integer((Damage taken)))
      • Set Marked_Foe_Damage_Real = (Real(Marked_Foe_Damage))
      • Trigger - Turn off Marked Foe Damage <gen>
      • Unit - Cause (Damage source) to damage (Triggering unit), dealing (0.25 x Marked_Foe_Damage_Real) damage of attack type Normal and damage type Magic
      • Trigger - Turn on Marked Foe Damage <gen>
      • Floating Text - Create floating text that reads (String(Marked_Foe_Damage)) at (Position of (Triggering unit)) with Z offset 0.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 25.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
 
Status
Not open for further replies.
Top