Basic Wait Logic Functions

Wait

A Timer to wait before execution

Note

Can use floats.

Syntax

Wait [float] -- Wait before executing

Wait [float]:[float] -- Randomized waiting time

Example


// from ai_mission_aa.p3s
st_tank
{
    Group Neutral
    Patterns
    {
        pt_default
        {
            actions
            {
                PlayVideo aa_2,1,1

                // Wait this much to not spawn the Boss immediately
                Wait 1.2

                MissionLog add_primary,tank,#P3_AA_LOG3
                EntFireInput muzak.battle,FadeIn:1
                EntFireInput hugo_spawner,Enable
                EntFireInput spawner_invaders,Enable
                ShowMessage #P3_AA_MSG3
            }
        }
    }
}


WaitForEnd

Wait for an ongoing activity before execution

Mostly used for sequences

Warning

Must be used for an activity that has animation, otherwise the function will fail to execute properly.

Highly recommended to check out Postal3Script files and analyze the function to understand it better.

Syntax

WaitForEnd 1 -- Wait for ending before execution

Example


// from ai_mission_cw.p3s
st_opencage_02
{
    Group Alert
    Patterns
    {
        pt_default
        {
            actions
            {
                Weapon disarm
                Sequence seq.env_checking

                // Wait for "env_checking" animation to end
                WaitForEnd 1

                Weapon arm

                EntFireInput "door_dogs_02,OpenAwayFrom:!activator"
                State st_start
            }
        }
    }
}


Repeat

Repeats a pattern every defined second

Note

Can use floats.

Syntax

Repeat [float] -- Repeat every [float] seconds

Example


// This will create a loop in pt_loop endlessly, unless we exit from out it
st_start
{
    Group Neutral
    Patterns
    {
        pt_default
        {
            actions
            {
                PlayerKarma hide
                MissionLog disable
                Pattern pt_loop
            }
        }

        pt_loop
        {
            actions
            {
                Repeat 2
            }
        }
    }
}


Return

Stops lines being executed from below

Syntax

Return 1 -- Stop execution from below

Example


st_somestate
{
    Group Neutral
    Patterns
    {
        pt_default
        {
            actions
            {
                // Return if health is more than 50!
                IfAttr "ea_health > 50 Return 1"

                // This will never execute if health is above 50!
                SetAttr "ea_health 100"

                Return 1

                // And this will never, ever execute
                SetAttr "ea_health 99999"
            }
        }
    }
}