HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

PolledWait stopping functions :/

08-04-2003, 06:03 AM#1
dataangel
I'm trying to make this function:

Code:
function AddSpecialEffectLocWithTimer takes location whichLocation, string whichEffect, real duration returns nothing
    local effect tempeffect

    call AddSpecialEffectLocBJ( whichLocation, whichEffect )

    set tempeffect = GetLastCreatedEffectBJ()
    call PolledWait ( duration )
    call DestroyEffectBJ( tempeffect )
endfunction

The problem is that, when I call it inside another function, that function waits the 1.8 seconds. I want you to be able to call this function, and then have it keep going. The only thing it should wait to do is to destroy the special effect.

Any ideas? I found this in blizzard.j:

Code:
//===========================================================================
// Arranges for a trigger to fire almost immediately, except that the calling
// trigger is not interrupted as is the case with a TriggerExecute call.
// Since the trigger executes normally, its conditions are still evaluated.
//
function PostTriggerExecuteBJ takes trigger trig, boolean checkConditions returns boolean

But that only works if I make it it's own trigger instead of a self contained function, and I can't pass arguments to triggers anyway. :P
08-04-2003, 07:56 AM#2
Smokenham
just checking out the thread and once again i see all the hardout confussing stuff, just wondering where one would learn about it all... any good tuts around, would greatly apreciate it :D
08-04-2003, 07:55 PM#3
dataangel
*bump*
08-04-2003, 08:18 PM#4
MasterMindManic
You prolly kno more than me, but this is jus a suggestion, i'm not sure if it'll work

you could try creating a trigger that calls the AddSpecialEffectLocWithTimer function. so when u want to call that function in another function call the PostTriggerExecuteBJ function to execute the trigger
08-04-2003, 08:29 PM#5
dataangel
Quote:
Originally posted by MasterMindManic
You prolly kno more than me, but this is jus a suggestion, i'm not sure if it'll work

you could try creating a trigger that calls the AddSpecialEffectLocWithTimer function. so when u want to call that function in another function call the PostTriggerExecuteBJ function to execute the trigger


I was thinking of doing, but because I can't pass arguments to a trigger I couldn't tell it how long the special effect is supposed to last.
08-04-2003, 08:43 PM#6
MasterMindManic
well could u use a global variable? set the variable in the function that executes the trigger, and when you call the function in the trigger use the global variable for duration
08-04-2003, 08:46 PM#7
Peppar
I'm sure I'm getting on peoples nerves soon with all my rambling
about blizzard globals :P. This function creates a new trigger
dynamically which it executes and later destroys. This makes the
new function appear in another thread, and the calling trigger
will not have to wait for it to end, but goes on executing as soon
as the child function hits the Wait-statement. It uses Blizzard.j
globals bj_lastCreatedEffect and bj_enumDestructableRadius to
pass the special effect and duration to the child function.

Code:
function AddSpecialEffectLocWithTimer_Child takes nothing returns nothing
    local effect tempeffect = bj_lastCreatedEffect
    local real duration     = bj_enumDestructableRadius
    call PolledWait( duration )
    call DestroyEffect( tempeffect )
endfunction

function AddSpecialEffectLocWithTimer takes location whichLocation, string whichEffect, real duration returns nothing
    local trigger dispatcher = CreateTrigger()
    set bj_enumDestructableRadius = duration
    call AddSpecialEffectLocBJ( whichLocation, whichEffect )
    call TriggerAddAction( dispatcher, function AddSpecialEffectLocWithTimer_Child )
    call TriggerExecute( dispatcher )
    call DestroyTrigger( dispatcher )
endfunction
08-04-2003, 09:00 PM#8
dataangel
Hmm.. since the bj_ variables are only used like for a fraction of a second (you immediately transfer them to locals) that should work fine.

Thanks =)
08-04-2003, 09:20 PM#9
Peppar
Yeah :). I don't think there's any possibility that the variables
would get "dirty" on their way to the child function. Besides, that's
how the functions in Blizzard.j does it, and I believe that they are
treated much the same as any function. Better learn from the
experts :P.