• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to detect if a unit is damaged

Status
Not open for further replies.
Level 2
Joined
Feb 26, 2010
Messages
10
Well, first time ask question here, point me out if I have done something wrong.

Base on my topic, I want to ask that is there any way to detect that if a unit is being damaged instead of being attacked. If I put the event 'a unit is attacked', then my action will start when a unit is 'attempt' to attack another unit, this mean that even I stop the attack, the action will still run.

I am sure that this can be done but I don't know how, whether it need JASS or just GUI will do it.

Hope somebody can help me.
 
Level 8
Joined
Jan 8, 2010
Messages
493
if the unit you want to detect is damaged is already in-game at Map Initialization, you can use the Unit - Specific Unit event. it has a Takes Damage preset field.

if it is not, you should make two triggers. the first one would be a trigger saving that unit you want the damage detected in a variable and making it the event for the damage detecting trigger. the trigger below saves the unit created:
  • Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Set UnitDetect = (Last created unit)
    • Trigger - Add to (Damage Detection Trigger) the event (Unit - UnitDetect Takes damage)
UnitDetect is the unit detected (in this example the footman created)
Damage Detection Trigger is the trigger whose event is that Specific Unit event.
 
Level 2
Joined
Feb 26, 2010
Messages
10
Hey, I got myself into another trouble, my trigger cannot detects the so-called Damaging unit, how can I detect it?
 
Level 7
Joined
Jul 20, 2009
Messages
295
It can be done in 3 triggers.
First Trigger:
  • DamageDetectStartup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to DamageDetect <gen> the event (Unit - (Picked unit) Takes damage)
Second Trigger:
  • DamageDetectStartup2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to DamageDetect <gen> the event (Unit - (Triggering unit) Takes damage)
Last Trigger:
  • DamageDetect
    • Events
    • Conditions
    • Actions
      • ===Attacked_Position, is a Point Variable===
      • Set Attacked_Position = (Position of (Attacked unit))
      • Floating Text - Create floating text that reads (String((Integer((Damage taken))))) at Attacked_Position with Z offset 0.00, using font size 7.00, color (100.00%, 100.00%, 0.00%), and 25.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 40.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Custom script: call RemoveLocation(udg_Attacked_Position)
 
Level 8
Joined
Jan 8, 2010
Messages
493
kaizar's triggers will show you the damage taken of the attacked/damaged unit.

and, there is a unit action Event Response - Damage Source. you can use that action together with the Unit - Unit Takes Damage event to detect which unit deals the damage, or the damaging unit.
 
Level 7
Joined
Apr 12, 2009
Messages
188
GUI Damage Detection System

Go here:

GUI-Friendly Damage Detection System

This system allows you to use the event of a Real Number becoming equal to 0.00 to detect damage from a known source, a known target, and a known amount, all just by pasting this guys triggers into your map. There's a good set of instructions on the forum there that explain how to use the system to get the damaged unit, the source unit, and the amount of damage. It's really easy to implement and fully GUI friendly so if you don't know JASS you don't have to worry : )
 
Level 2
Joined
Feb 26, 2010
Messages
10
Thanks for all of you, I will try to make my trigger and if I encounter another problem I will ask u all again.
 
Bribe said:
You guys with your Trigger - add event actions... are you using WEU for this? It is not in World Editor, so careful when passing this kind of tip to a noob.
No, it's in the default Editor. It's the action Trigger - Add New Event. When you go to Actions, press "U" to lead yourself on the Unit actions and then press the Up arrow. There is the action Trigger - Add new event.
 
Status
Not open for further replies.
Top