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

Detecting attack and amount of damage done

Status
Not open for further replies.
Level 9
Joined
Jun 26, 2007
Messages
659
the "attack" event is an "hit" event in fact
it is detected only when the attacked unit is injuried and each time the attacked unit is injuried.
I'm not sure that what you want to read because i don't unerstand if your 2th sentence is an explanation of what you want, or a complain about what you see.

and in the integer function list, you've an "event param - damage taken"
(my WE is in french, so that may be a bad translation, but you can find it easilt)
 
Level 8
Joined
May 13, 2007
Messages
392
the "attack" event is an "hit" event in fact
it is detected only when the attacked unit is injuried

I dont think so...

In a map of mine, where there was AI i set a trigger that when the enemy just attacked (not injured) the hero would flee back at some point. The unit is attacked event does apply to anyone that starts attacking
 
Level 9
Joined
Jun 26, 2007
Messages
659
-_-
i've not said the event is detected after the damage deal
of course it is detect before
but it is detected for each hit
0 hit (sample, order attack, order stop before hit) > no event
1 hit (sample, trigger teleporting the unit) > 1 event
10 hits > 10 events

i've tested it, and that's it
 
Level 9
Joined
Jun 26, 2007
Messages
659
because the event is detected before the damage deal
so the trigger is executed before the damage deal
so the attacked unit is killed before the damage deal
and the damage deal is required to init the cooldown tempo
(and i suppose that damages are pre-calculed)

like said: I'VE TESTED IT!

download the map i've done and you will see!
1 hit = 1 event detection
 
Last edited:

Lej

Lej

Level 3
Joined
Jun 5, 2004
Messages
36
If you want to detect when a unit is damaged you need to use the Specific Unit Event where you can choose a specific unit that will trigger the event when it takes damage.

  • Events
    • Unit - SPECIFIC_UNIT Takes damage
If you have one trigger, let's call it aUnitIsDamaged, that does something when a unit is damaged you will need to add every unit that you want to be able to trigger it to it's events. I guess you could do this by running a custom script everytime you create the unit that is supposed to be able to fire the trigger:

  • Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Custom script: call TriggerRegisterUnitEvent( gg_trg_aUnitIsDamaged, GetLastCreatedUnit(), EVENT_UNIT_DAMAGED )
This is without converting triggers to custom text.
 

Lej

Lej

Level 3
Joined
Jun 5, 2004
Messages
36
First an amendment to my last post. No need to use custom script:

  • Actions
    • Trigger - Add to aUnitIsDamaged <gen> the event (Unit - (Last created unit) Takes damage)

And secondly I don't think there's any easy way, if any at all, to determine what type of damage the unit took. Think the only event responses you got to work with are Damage Taken, Damage Source and Triggering Unit (i.e. unit taking dmg).

If you want to add all units to the trigger you simply do two triggers. One to add all in editor preplaced units and one to add all created units. Something like this:

  • AddPreplacedUnits
    • 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 aUnitIsDamaged <gen> the event (Unit - (Picked unit) Takes damage)
  • AddNewUnits
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Trigger - Add to aUnitIsDamaged <gen> the event (Unit - (Entering unit) Takes damage)
The custom script is just to prevent a group from leaking.
 
Status
Not open for further replies.
Top