HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

another jass noob question, on "WaitForPlayerEvent"

07-27-2006, 04:59 PM#1
Linera
What do i type in for the boolexpr condition argument when i call this function?
Collapse JASS:
function WaitForPlayerEvent takes handle whichForceOrPlayer, playerevent whichPlayerEvent, boolexpr condition, real interval returns nothing
    local trigger bj_temp = bj_delayedSuspendDecayTrig
    local trigger t
    local triggercondition c
    local player whichPlayer = WaitForPlayerEvent_H2P(whichForceOrPlayer)
    local force whichForce = WaitForPlayerEvent_H2F(whichForceOrPlayer)
    if whichForceOrPlayer == null or whichPlayerEvent == null then
        set whichForce = null
        return
    elseif interval < 0 then
        set interval = 0
    endif
    set t = CreateTrigger()
    set bj_delayedSuspendDecayTrig = t
    set bj_forceCountPlayers = WaitForPlayerEvent_PE2I(whichPlayerEvent)
    call ForForce(whichForce, function WaitForPlayerEvent_Enum)
    call TriggerRegisterPlayerEvent(bj_delayedSuspendDecayTrig, whichPlayer, whichPlayerEvent)
    if condition != null then
        set c = TriggerAddCondition(bj_delayedSuspendDecayTrig, condition)
    endif
    set bj_delayedSuspendDecayTrig = bj_temp
    loop
        call TriggerSleepAction(interval)
        exitwhen GetTriggerExecCount(t) != 0
    endloop
    if condition != null then
        call TriggerRemoveCondition(t, c)
        set c = null
    endif
    call DestroyTrigger(t)
    set t = null
    set whichForce = null
endfunction
07-27-2006, 05:08 PM#2
Rising_Dusk
Collapse JASS:
Condition(function SomeConditionFunctionThatReturnsBoolean)
Something like that, with the function name being whatever you want it to be (Assuming you have it somewhere above this call).
07-27-2006, 05:10 PM#3
Linera
ummmm, huh?
07-27-2006, 05:13 PM#4
Rising_Dusk
You need to create a boolean expression for that argument.
Collapse JASS:
local boolexpr b = Condition(function MyBool)

It would look something like this in game.
Collapse JASS:
function MyBool takes nothing returns boolean
    return true
endfunction

function OtherFunc takes nothing returns nothing
    local player p = Player(0)
    local boolexpr b = Condition(function MyBool)
    call WaitForPlayerEvent(p, EVENT_UNIT_DAMAGED, b, 20.0)
endfunction

Or something like that, of course modified to fit your needs.
07-27-2006, 05:25 PM#5
Linera
well for this function i don't know what it wants
but thanks
07-27-2006, 06:20 PM#6
Sharingan
...
Waiting for PlayerEvents fails.
Why not plain create a new dynamic trigger which gets destroyed later?