HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Damage Taken

04-06-2007, 09:16 PM#1
Castlemaster
I'm aware that the only way to find out the damage dealt by a unit is the JASS method. While shuffling through a real variable defining, I stumbled upon a "damage taken" command. My roommate said this was only for summons and doesn't do what it says. Anyone know exactly what this is?
04-06-2007, 09:32 PM#2
wantok
Are you talking about the Event Response - Damage Taken in GUI? You can detect when a unit takes damage in GUI. Damage Taken gives you the damage.
04-06-2007, 10:28 PM#3
Castlemaster
If that's so, then how come there are JASS codes to detect the same thing? Or do they detect something else.
04-06-2007, 10:43 PM#4
wantok
Here it is in GUI and JASS.

Trigger:
Untitled Trigger 002
Collapse Events
Unit - Footman 0000 <gen> Takes damage
Conditions
Collapse Actions
Set n = (Damage taken)

Collapse JASS:
function Trig_Untitled_Trigger_002_Copy_Actions takes nothing returns nothing
    set udg_n = GetEventDamage()
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_002_Copy takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002_Copy = CreateTrigger(  )
    call TriggerRegisterUnitEvent( gg_trg_Untitled_Trigger_002_Copy, gg_unit_hfoo_0000, EVENT_UNIT_DAMAGED )
    call TriggerAddAction( gg_trg_Untitled_Trigger_002_Copy, function Trig_Untitled_Trigger_002_Copy_Actions )
endfunction

There are Jass codes that do it because you can take care of leaks much easier. Besides, Jass is just better.
04-07-2007, 05:05 AM#5
Hydrolisk
This Event only takes SPECIFIC units.
It can be used for several things in GUI, though probably best for detection. A lot of triggers would do the trick.
04-07-2007, 06:04 AM#6
Jazradel
Something like:
Trigger:
Events: A Unit Enters the Playable Map Area
Actions:
Trigger - Add ((Triggering Unit) takes damage) to ShowDamage

ShowDamage
Trigger:
Actions:
Game - Display (Real to String(Event - Damge Taken)) to All players
Is one way to use it.