- Joined
- Jun 7, 2006
- Messages
- 5
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?
Thanks! It really helps!Raydrik said: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
-unit enters playable map area
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
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
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
I didn't steal ur solution, i completed it... And as i said, i already used this "system".lol paskovich u stole my solution
Yes PurplePoot, you're right. This detects attack damage only, but i think this is what it is supposed to do! The other code detects every type of damage. This one is cool!as they dont detect spell damage.
I didn't steal ur solution, i completed it... And as i said, i already used this "system".