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

How to detect units dealing damage?

Status
Not open for further replies.
Level 22
Joined
Jan 10, 2005
Messages
3,426
I need this for a spell, which fires back whenever a unit gets damaged.

I got the spell working, but the trigger is just huge. Because I got to think of all the different ranged units, with different missle speeds, etc.

So, is there a way to detect when a unit is losing life, and what unit is dealing the damage?
 
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable Map Area)) and do (Actions)
      • Loop - Actions
        • Trigger - Add to Trigger2 the event (Unit - (Picked unit) takes damage)
  • Trigger1
  • Events
    • Unit - A unit enters (Playable Map Area)
  • Conditions
  • Actions
    • Trigger - Add to Trigger2 the event (Unit - (Triggering unit) takes damage)
  • Trigger2
  • Events
  • Conditions
    • (Level of Fireback for (Triggering unit)) Greater than 0
  • Actions
    • Unit - Cause (Triggering unit) to damage (Damage source), dealing 100.00 damage of Attack type Spells and Damage type Normal
So, actually, what cboy123 said, but ala-triggered. :p
 
Alternative:
  • Trigger
  • Events
    • Unit - A unit learns a skill
  • Conditions
    • (Hero Learned Skill) Equal to Fireback
    • (Level of Fireback for (Triggering unit)) Equal to 1
  • Actions
    • Trigger - Add to Trigger2 <gen> the event (Unit - (Triggering unit) takes damage)
  • Trigger2
  • Events
  • Conditions
  • Actions
    • Unit - Cause (Triggering unit) to damage (Damage source), dealing 100.00 damage of Attack type Spells and Damage type Normal
This method is highly recommended than the previous one. This method will make less checks in-game.
 
Status
Not open for further replies.
Top