- Joined
- Jul 28, 2008
- Messages
- 211
I tried making a spell similar to one i saw in a map i played.
It's simple, it's supposed to block all damage the caster takes for some time.
But, it doesn't work. Here's my script :
Thx in advance
It's simple, it's supposed to block all damage the caster takes for some time.
But, it doesn't work. Here's my script :
JASS:
function Trig_Wave_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'shie'
endfunction
function Wave_Child takes nothing returns nothing
local real damage = GetEventDamage()
local unit u = GetHandleUnit( GetTriggeringTrigger(), "cache")
call SetUnitState( u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + damage )
endfunction
function Trig_Wave_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local timer time = CreateTimer()
local trigger trig = CreateTrigger()
local triggeraction ta
call SetHandleHandle(trig, "cache", caster)
set ta = TriggerAddAction( trig, function Wave_Child )
call TriggerRegisterUnitEvent( trig, caster, EVENT_UNIT_ATTACKED )
call TimerStart( time, 15, false, null )
loop
exitwhen TimerGetRemaining(time) == 0
call TriggerSleepAction(0.1)
endloop
set ta = null
set trig = null
set caster = null
call DestroyTimer(time)
set time = null
endfunction
//===========================================================================
function InitTrig_Shield takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition ( function Trig_Wave_Conditions ) )
call TriggerAddAction( t, function Trig_Wave_Actions )
endfunction
Thx in advance