Getting Unit Damage

Status
Not open for further replies.
Level 12
Joined
May 22, 2015
Messages
1,051
  • Untitled Trigger 001
    • Events
      • Unit - TEST 0049 <gen> Is attacked
    • Conditions
    • Actions
      • Set TEST = (1000.00 - (Life of (Attacked unit)))
This simple trigger dont seem to work for some reason.
TEST is a Real, not integer.

Now what i am trying to do now is to display the damage of the TEST unit in the multiboard.

You want the amount of damage dealt to TEST 0049 <gen>?

If you need it for any particular unit, you will probably need a damage detection system or some kind of simple one that you code yourself (might take a bit of learning if you don't know where to start).

However, if you only need to detect how much damage this single unit - TEST 0049 <gen> - takes, change the event to "Unit - TEST 0049 <gen> Is damaged". It should be in the list of events. Note that this event does not exist in the "Any units ..." or "A unit owned by Player 1 (Red) ...".

EDIT:
And for the amount to detect, there is an event variable called "Event Response - Damage" or something like that. Set TEST to that (it is a Real variable) and use that in the multiboard.
 
A damage detection system would make this trigger a cake walk. Here's an example using Bribe's DDS:

  • Display Damage Dealt
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Damage Dealt: + (String(DamageEventAmount)))
DamageEventAmount is a real variable that literally has the damage that was dealt. You even have variables for the target and damage dealer.

Taken from Bribe's DDS:
JASS:
// - Detect damage: use the event "DamageEvent Equal to 1.00"
// - To change damage before it's dealt: use the event "DamageModifierEvent Equal to 1.00"
// - Detect damage after it was applied, use the event "AfterDamageEvent Equal to 1.00"
// - Detect spell damage: use the condition "IsDamageSpell Equal to True"
// - Detect zero-damage: use the event "DamageEvent Equal to 2.00" (an AfterDamageEvent will not fire for this)

change the event to "Unit - TEST 0049 <gen> Is damaged". It should be in the list of events. Note that this event does not exist in the "Any units ..." or "A unit owned by Player 1 (Red) ...".

Uhmm... what? Not sure if you're being sarcastic, but no such event exists. If there were, there wouldn't be a need for these complex damage detection systems.
 
Level 13
Joined
Jan 2, 2016
Messages
978
Uhmm... what? Not sure if you're being sarcastic, but no such event exists. If there were, there wouldn't be a need for these complex damage detection systems.

Lol, really?
  • asd
    • Events
      • Unit - Footman 0002 <gen> Takes damage
    • Conditions
    • Actions
The problem is that you can't use it for units created after the game has started.
That's why damage detecting systems are needed.

In a matter of fact - DDS use THIS event to work, they simply create a trigger, with this event for every unit that enters the playable map area, and they destroy this trigger when the unit leaves the playable map area. They also create such triggers for pre-placed units :p

Or atleast the GDD does that :p
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
If its just for a single unit, and you really need the "attacked event" instead the "damaged event" or you want to do it without a system, you might try something like:

  • event = Unit is attacked
  • set Unit = AttackedUnit
  • set Life = Life of Unit
  • Wait 0.2 seconds // just a little wait so that the dmg is dealt
  • set NewLife = Life of Unit
  • set NewLife = Life - NewLife
  • // NewLife would be the amount of dmg taken now
note, that u might also just change AttackedUnit by simply directly selecting its gg variable in the editor. Other than that all stated names are global variables (Life is a real)
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
Using, A unit is attacked is a bad bethod of retrieving the damage a unit takes.


For checking the damage amount, you must use Unit - "Specific Unit" Takes Damage event. There is no generic event for detecting damage taken.

  • Damage Get
    • Events
      • Unit - Spell Breaker 0006 <gen> Takes damage
    • Conditions
    • Actions
      • Set Temp_Real = (Damage taken)
      • Game - Display to (All players) the text: (Damage Taken: + (String(Temp_Real)))

Alternative is to use a frequent timer that checks the hp of unit every 0.xx seconds, then display a text if it differs from a stored real variable.
 
Using, A unit is attacked is a bad bethod of retrieving the damage a unit takes.


For checking the damage amount, you must use Unit - "Specific Unit" Takes Damage event. There is no generic event for detecting damage taken.

Oh cool, that seems to work.

About the DDS thing, i am not entirely familiar with it, or how to use it. I tried it but it ended up updating all the time because it gets the damage dealt to ANY UNIT who are getting damage, what i am trying to get is the damage dealt by someone to the SINGLE UNIT, specifically the TEST Unit which is a rifleman.

Moved to Triggers & Scripts.
Oh apologies, i thought i am posting on the right place.

Anyway, i made something yesterday which is this one, and it seems to be working fine, but i dont know if it is efficient, or probably i am doing it in a hard way.

  • Custom Damage Detection System
    • Events
      • Unit - DamageDetectSystem 0009 <gen> Is attacked
    • Conditions
    • Actions
      • Set Game_SurvWpnDamage = (Integer((125.00 - (Life of DamageDetectSystem 0009 <gen>))))
      • Unit - Set life of DamageDetectSystem 0049 <gen> to 100.00%
      • Unit - Set life of DamageDetectSystem 0009 <gen> to 100.00%
(125 is the full health of the dummy)
(DamageDetectSystem is a dummy unit)


Both units dont have armors and throws normal damage.
 
Level 8
Joined
Jan 28, 2016
Messages
486
I don't know if this will help your case but you can use a custom Barrage to detect when a unit attacks and the amount of damage it has.

The catch? Barrage doesn't stack with orb effects/buff placers or crit/bash abilities unfortunately :(
The catch catch? Orb effects technically work but all abilities that have orb effects also have buff placers. Except one; Searing Arrows! :D

Okay, so I know this is a bold assumption but at the moment I don't know what abilities your units have and such. However if the units that will attack your "TEST" unit don't have these abilities, then this should work. I have a test map (which was an experiment I created a while ago) with some things edited to show you how it can work.
 

Attachments

  • Weaver Test Map.w3x
    11.2 KB · Views: 35
Level 24
Joined
Aug 1, 2013
Messages
4,658
Oh cool, that seems to work.

About the DDS thing, i am not entirely familiar with it, or how to use it. I tried it but it ended up updating all the time because it gets the damage dealt to ANY UNIT who are getting damage, what i am trying to get is the damage dealt by someone to the SINGLE UNIT, specifically the TEST Unit which is a rifleman.

For which you use conditions... or if statements in the actions.
Anyway, as condition, you check if the unit type of the damaged unit is a rifleman.
And potentially also check if the damage is phyical (which I assume is the name of basic attacks' damage instances in the DDS you are using).
 
Status
Not open for further replies.
Top