HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Question on triggers

04-17-2007, 12:44 AM#1
Joker
Would my local trigger run everytime the event happens when i do this?
Collapse JASS:
function Trig_Guarding_Angel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Guarding_Angel_Actions takes nothing returns nothing
    local trigger t = CreateTrigger()

    call TriggerRegisterUnitEvent( t, GetSpellAbilityUnit(), EVENT_UNIT_DAMAGED )
    call TriggerAddAction( t, function Trig_Guarding_Angel_Effect )
    
    set t = null
endfunction

//===========================================================================
function InitTrig_Guarding_Angel takes nothing returns nothing
    set gg_trg_Guarding_Angel = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Guarding_Angel, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Guarding_Angel, Condition( function Trig_Guarding_Angel_Conditions ) )
    call TriggerAddAction( gg_trg_Guarding_Angel, function Trig_Guarding_Angel_Actions )
endfunction

04-17-2007, 01:03 AM#2
Mezzer
Yes it would.
04-17-2007, 08:54 PM#3
Joker
how would i get it to stop?
04-17-2007, 09:35 PM#4
akolyt0r
OMFG I CANT READ
04-18-2007, 12:04 AM#5
Joker
Your just creating a timer. How would that stop the trigger? Mezzer said my local trigger would run everytime the event occured.
04-18-2007, 04:16 PM#6
akolyt0r
damn i cant READ


this one should work
(if you want Trig_Guarding_Angel_Effect to run only once)
Collapse JASS:
function Trig_Guarding_Angel_Effect takes nothing returns nothing
call DestroyTrigger(GetTriggeringTrigger())
//do stuff
endfunction

if you want Trig_Guarding_Angel_Effect more often things get more complicated ..(you would need a global variable (not MUI) or gamecache or ... )
04-18-2007, 08:21 PM#7
Joker
Would it work if i start a timer and destroy the trigger after the timer expires so that it would run more than once?

Edit: Another Question: Is it better to not use the InitTrig_Name?
04-18-2007, 08:57 PM#8
akolyt0r
let me think ....
i think it would work ..somehow..but ..you might want to ask one of the other "more advanced" guys her too...

EDIT2:IGNORE THIS!:
Collapse JASS:
function Trig_Guarding_Angel_Effect takes nothing returns nothing
local timer t=GetExpiredTimer()
//if t!=null then
//    call DestroyTrigger(GetTriggeringTrigger())
//    call PauseTimer(t)
//    call DestroyTimer(t)
//    return
//endif
//
//Do Stuff
endfunction

function Trig_Guarding_Angel_Actions takes nothing returns nothing
    local trigger t = CreateTrigger()
    local timer T=CreateTimer()
    call TriggerRegisterUnitEvent( t, GetSpellAbilityUnit(), EVENT_UNIT_DAMAGED )
    call TriggerAddAction( t, function Trig_Guarding_Angel_Effect )
    call TriggerRegisterTimerEventSingle(t,3.0)
    set t = null
    set T = null
endfunction

EDIT: i tried it, but i get a war3critical error when the unit is damaged...
EDIT2: found the error ,,cant be fixed -.-
04-18-2007, 09:23 PM#9
Joker
I was thinking more like this:

Collapse JASS:
function Trig_Guarding_Angel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Guarding_Angel_Effect takes nothing returns nothing
    call SetUnitState( GetDamagedUnit(), UNIT_STATE_LIFE, GetUnitState( GetDamagedUnit(), UNIT_STATE_LIFE ) + GetEventDamage() )
    //some game cache storing the damage to heal
    call PolledWait(15)
    call TriggerRemoveAction( Trig_Guarding_Angel_Actions )
endfunction

function Trig_Guarding_Angel_Actions takes nothing returns nothing
    local trigger t = CreateTrigger()

    call TriggerRegisterUnitEvent( t, GetSpellAbilityUnit(), EVENT_UNIT_DAMAGED )
    call TriggerAddAction( t, function Trig_Guarding_Angel_Effect )
    
    set t = null
endfunction

//===========================================================================
function InitTrig_Guarding_Angel takes nothing returns nothing
    set gg_trg_Guarding_Angel = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Guarding_Angel, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Guarding_Angel, Condition( function Trig_Guarding_Angel_Conditions ) )
    call TriggerAddAction( gg_trg_Guarding_Angel, function Trig_Guarding_Angel_Actions )
endfunction

would this work?
04-18-2007, 09:37 PM#10
akolyt0r
then dont give me the idea you want a timer -.-"

WRONG

Collapse JASS:
...WRONG
WRONG
04-18-2007, 09:43 PM#11
Joker
About the timers...I was going to make one, but then i remembered PolledWait did the same thing so i just used it. And i want the spell casted once like the cooldown would be higher than my PolledWait if thats what you mean
04-19-2007, 04:02 PM#12
akolyt0r
only once during the whole game ??

or

how many hits should this spell "absorb" ??

Collapse JASS:
    call SetUnitState( GetDamagedUnit(), UNIT_STATE_LIFE, GetUnitState( GetDamagedUnit(), UNIT_STATE_LIFE ) + GetEventDamage() )
//use GetTriggerUnit() here
04-19-2007, 08:42 PM#13
Joker
It should absorb until the wait is up
04-20-2007, 11:10 AM#14
akolyt0r
Collapse JASS:
function Trig_Guarding_Angel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Guarding_Angel_Effect takes nothing returns nothing
    call SetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE, GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) + GetEventDamage() )
endfunction

function Trig_Guarding_Angel_Actions takes nothing returns nothing
    local trigger t = CreateTrigger()
    local triggerevent ta
    call TriggerRegisterUnitEvent( t, GetSpellAbilityUnit(), EVENT_UNIT_DAMAGED )
    set ta=TriggerAddAction( t, function Trig_Guarding_Angel_Effect )
    call PolledWait(5)
    call TriggerRemoveAction(t,ta)
    set t = null
endfunction

//===========================================================================
function InitTrig_Guarding_Angel takes nothing returns nothing
    set gg_trg_Guarding_Angel = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Guarding_Angel, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Guarding_Angel, Condition( function Trig_Guarding_Angel_Conditions ) )
    call TriggerAddAction( gg_trg_Guarding_Angel, function Trig_Guarding_Angel_Actions )
endfunction