HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

TriggerSleepAction( ) problems

03-06-2003, 05:38 PM#1
BoddoZerg
For some reason, putting Wait actions (TriggerSleepAction) into a callback function seems to cause BIG TROUBLE. For example, let's say I code this.
Code:
function CrappyFunction takes nothing returns nothing
    local unit KillMe = GetEnumUnit()
    call TriggerSleepAction(1.00)
    call KillUnit( KillMe )
endfunction

function Trig_BoddoZerg_Actions takes nothing returns nothing
    call ForGroup( udg_KillThisGroup, function CrappyFunction )
endfunction

What happens when the trigger "BoddoZerg" is fired is - exactly nothing! None of the units in "KillThisGroup" ever die. In fact, if I re-coded CrappyFunction like this:
Code:
function CrappyFunction takes nothing returns nothing
    call DisplayTextToForce(GetPlayersAll(), "Before Wait")
    call TriggerSleepAction(1.00)
    call DisplayTextToForce(GetPlayersAll(), "After Wait")
endfunction
then the game will display "Before Wait" but will NEVER display "After Wait" - not after 1 second, not after 10 minutes. I can set the wait length as short as I want - even TriggerSleepAction(0.00), but the wait action never finishes. As far as I can tell, the wait action acts like a return... it simply stops whatever the function was doing and never finishes.

Seems like the eternally-problematic Wait has even more trouble within Callback routines. =(

(How can Blizzard mess up something as simple as "Wait X Seconds"?)
03-06-2003, 07:13 PM#2
Guest
Have you found a work around? If not, you could use a loop like this...

Code:
function CrappyFunction takes unit kill_me returns nothing
    call TriggerSleepAction(1.00)
    call KillUnit( kill_me )
endfunction

function Trig_BoddoZerg_Actions takes nothing returns nothing
    local integer i = 1
    local integer exit
    local group crap_units = CreateGroup()
    local unit kill_me

    set crap_units = udg_KillThisGroup
    set exit = UnitsInGroup(crap_units)   //  *  func name?
    loop
         exitwhen i > exit
         set kill_me = GetRandomUnitInGroup(crap_units)  // *  func name?
         call CrappyFunction(kill_me)
         call RemoveUnitFromGroup(kill_me, crap_units)    // *  func name?
         set i = i + 1
    endloop
endfunction

I'm using similar functions to this in my triggers to grab specific units out of a unit group. Seems to out fine.