Warcraft III resources & community, 2003–2006 · archived

How to make "takes damage" event to affect all uni

20 posts
#1

How to make "takes damage" event to affect all uni

I was going to make a spell that works if a unit takes damage, but it only works for a single unit. How to make it works to all unit like "Stout Shield" item or "Aphotic Shield + Borrowed Time" spell in DotA?
#2
heres the deal:
you're going to create 3 triggers

forst one picks the units already in the game
Event
-Map initialization
Actions
-Unit Group - pick every units in playable map area and do actions:
-add to (your trigger) the event [Picked unit takes damage]

secnd one picks each unit as they enter the game

event
-unit enters playable map area
actions
-add to (your trigger) the event [entering unit takes damage]

now you create the last and most important trigger: the one that will trigger the actions based off the damage taken

(Your trigger)
Event
(none)
Actions
-insert whatever you want here that will trigger off damage. any kind of damage, even from spells.

i hope it helps
#3
Halo halo... Gua jg butuh nih trigger.
Buat map apaan nih?

Anyone knows? I tried giving the unit a variable name, but the "take damage" event function won't let me choose the unit.
#4
look, the takes damage event only works on preset units.
the trick i did up there is to set all the units already on the map and the units that enter the map as a preset on the third trigger, so, if you create an action on the third trigger, you can select takes damage

this is the trick to show damage text too.

juts insert in the third trigger the actions for flating text show damage taken and stuff.
#5
know thou that this has an limit if you constantly create new units
#6
Raydrikheres the deal:
you're going to create 3 triggers

forst one picks the units already in the game
Event
-Map initialization
Actions
-Unit Group - pick every units in playable map area and do actions:
-add to (your trigger) the event [Picked unit takes damage]

secnd one picks each unit as they enter the game

event
-unit enters playable map area
actions
-add to (your trigger) the event [entering unit takes damage]

now you create the last and most important trigger: the one that will trigger the actions based off the damage taken

(Your trigger)
Event
(none)
Actions
-insert whatever you want here that will trigger off damage. any kind of damage, even from spells.

i hope it helps

Thanks! It really helps!
#7
-unit enters playable map area


this triggers when a hero revives, etc, etc, as well, so its not that great :?
#8
yeah, i know that if a hero dies and revives it will have another event for the same unit, triggering itmore than once, thus lagging the map. but this is the way i found.

you can, however, use the custom value of unit and do like , when a hero enters map, if his custom value is 0, then set to 1 and add it to trigger. if its 1, then d nothing.

BTW i think it was you who warned me about the hero reviving stuff, PurplePoot

PS: grats on mod stats
#9
ty, and the problem OTHER than lag is that the trigger will sometimes go off once for each event :?
#10
function Trig_Damage_Event takes nothing returns nothing
    local trigger t = GetTriggeringTrigger()
//this is where you put ur actions concerning the damage event
    call DestroyTrigger(t)
    set t = null
endfunction

function Trig_Damage_Actions takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterUnitEvent( t, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
    call TriggerAddAction( t, function Trig_Damage_Event )
    set t = null
endfunction

//====================================================================
function InitTrig_Damage takes nothing returns nothing 
    set gg_trg_Damage = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Damage, EVENT_PLAYER_UNIT_ATTACKED ) 
    call TriggerAddAction( gg_trg_Damage, function Trig_Damage_Actions ) 
endfunction


This trigger doesn't have any problems w/ hero revives and stuff. It exploits the fact that the event Unit is Attacked triggers BEFORE the unit actually takes damage and that the TriggerRegisterUnitEvent CAN take a function as its second parameter (don't ask me why blizz made it so that it takes functions but not variables).
#11
that isnt the greatest solution, as damage inbetween will interrupt this, as well as spell damage wont trigger this.
#12
I use this in my Damage Delay System:
function Trig_Damage_Event_Conditions takes nothing returns boolean
return GetEventDamageSource() == GetHandleUnit(GetTriggeringTrigger(), "Attacker")
endfunction

function Trig_Damage_Event takes nothing returns nothing 
local trigger t = GetTriggeringTrigger() 
//this is where you put ur actions concerning the damage event 
call FlushHandleLocals(t)
call DestroyTrigger(t) 
set t = null 
endfunction 

function Trig_Damage_Actions takes nothing returns nothing 
local trigger t = CreateTrigger() 
call SetHandleHandle(t, "Attacker", GetAttacker())
call TriggerRegisterUnitEvent( t, GetTriggerUnit(), EVENT_UNIT_DAMAGED ) 
call TriggerAddCondition(t, Condition( function Trig_Damage_Event_Conditions))
call TriggerAddAction( t, function Trig_Damage_Event ) 
call TriggerSleepAction(1)
call FlushHandleLocals(t)
call DestroyTrigger(t)
set t = null 
endfunction 

//==================================================================== 
function InitTrig_Damage takes nothing returns nothing 
set gg_trg_Damage = CreateTrigger( ) 
call TriggerRegisterAnyUnitEventBJ( gg_trg_Damage, EVENT_PLAYER_UNIT_ATTACKED ) 
call TriggerAddAction( gg_trg_Damage, function Trig_Damage_Actions ) 
endfunction


See... This would be a solution, but it uses handle vars, that make it a bit laggy. But it works properly.
AND also, if the unit misses or does not deal the damage, the trigger will not be destroyed! So i put a wait in the 'Attacked' trigger. (This is the only "crack" in the script.)
#13
lol paskovich u stole my solution :P, and I don't think it will lag - I use basically the same thing in my map and even when I have like 50 units attacking my hero all at once I can't feel any lag.

If u want spells to trigger this just add in another global trigger with the event UNIT_SPELL_CAST_EVENT(not sure if thts the correct wording...), and have the local trigger's event's second parameter to be GetSpellTargetUnit().

P.S. If for some reason the damage done by a unit is reduced to 0 (i.e. because of the hardened skin ability), the UNIT_TAKES_DAMAGE event will still trigger. Not sure about misses though.
#14
lol paskovich u stole my solution


on the other hand, his is about 10000x less buggy than yours is

though neither of yours really work, as they dont detect spell damage.

Here is THE damage detection system :D
#15
on the other hand, his is about 10000x less buggy than yours is


yep i was talking about the solution to the damage in-between problem, not the original detect damage problem, and also...

though neither of yours really work, as they dont detect spell damage


in my last post i explained how to make it detect spells.