SetBehavior

Sets an entity's behavior/AI on the fly.

Postal III Ultrapatch+Angel v1.3.0+ Feature

The following function will only work in Postal III Ultrapatch+Angel v1.3.0 or higher.

Syntax

SetBehavior [behavior] -- Sets only the behavior.

SetBehavior [behavior],[init_state] -- Sets the behavior and init state only.

SetBehavior [behavior],[init_state],[start_state] -- Sets behavior, init, and start state only.

SetBehavior [behavior],[init_state],[start_state],[faction] -- Sets behavior, init, start state, and the faction only.

SetBehavior [behavior],[init_state],[start_state],[faction],[manner] -- Sets everything for this entity.

Note

Will use 'st_init' and 'st_start' for init and start states if there weren't any defined.

Faction and Manner will be reused from current AI if it was never defined.

Will create 'setbehavior_lock' attribute to prevent spamming as it can crash the game. Set it to zero if you wish to set the AI once again.

Example


// This will make any NPC to use a Cat's AI/behavior
pt_meow
{
    actions
    {
        SetAttr "setbehavior_lock 0"
        SetBehavior bh_cat,st_init,st_start,Animals,PussyCat
        Wait 3
        State st_start
    }
}

// This will make the NPC to just only switch a behavior
pt_betterAI
{
    actions
    {
        SetAttr "setbehavior_lock 0"
        SetBehavior bh_npc_hulk
        Wait 3
        State st_start
    }
}

// This will make the Dog switch behavior and start with an unique init state
pt_friendly
{
    actions
    {
        SetAttr "setbehavior_lock 0"
        SetBehavior bh_dog,st_init_friendly
        Wait 3
        State st_start
    }
}