P3Script (Postal 3 Script) is the scripting language used in Postal III
Preliminary Notes[]
The following is written based on observations of the code in regards to Postal III. As of this writing, there exist no known original documentation of P3Script with a previous developer at Trashmasters admitting that the "internal wiki" which hosted the bulk of the information is currently lost. Due to this, the information presented is admittedly incomplete.
Whackjob Interactive has compiled their own notes on the in's and out's of the language via github which can be found here.
Furthermore, the language has nothing to do with Vscript or any Valve Developer Languages.
Introduction[]
All gameplay elements in Postal III are scripted in P3Script. They are basic text files with "p3s" filename extension. P3S files are placed in the "p3/scripts" subfolder in the Postal III installation directory. Their purpose is to quickly and efficiently script gameplay elements similar to Unrealscript in POSTAL 2
Scripting Structure[]
Scripting in Postal III is very simple. It has two types of structs: Constants and Behavior.
Constants[]
As the name implies, constants are default variables capable of holding various functions and giving entities certain attributes. They are usually placed at the top of a given script though are not necessary for writing a given script. They can be used for various functions but are normally used to set default values at the beginning of missions.
Example code (taken from player AI):
Constants (Placed at the beginning of a Constant struct) { Const BRUTALITY_MAX,3 (Maximum amount of Brutality a player can have) Const BRUTALITY_DECR_TIMER,30 (Time it takes for Brutality to cool off) }
Behaviors[]
This block deals with variables. It is made of six blocks:
Block #1: Name and Inheritance[]
Where the name of a given entity is declared and any inheritance from other scripts is coded. Names have "bh_" prefix. Inheritance is declared via "inherited" followed by the name of the inherited Behavior.
Block#2: States[]
Where various entity states can be declared (default, death, hostage, etc.). States have the "st_" prefix.
Block#3: Group[]
Which tells how a given entity is treated by NPCs based on the given entities current state. Known group states are Neutral, Alert, and Combat.
Block#4: Patterns[]
Where patterns can be coded for a given entity based on player and NPC actions, usually beginning with “pt_default” which holds the default pattern. Patterns begin with “pt_”.
Block#5 Actions[]
The actual scripting begins here. Various functions based on player and NPC actions can be placed here such as “IfAttr”, “SetAttr”, and “Pattern”
Block#6 Events[]
Similar to actions, but allows jumping from one pattern to another. Its primary function is as a scripted trigger based on Player/NPC actions.
Example code (taken from player AI)
Behavior \\Placed at the beginning of a behavior struct { name bh_player \\Name of a given entity inherited default_behavior \\Inherited behavior States \\ Beginning of the States block { st_player \\Name of state { group Alert \\Group block where “alert” is declared. Patterns \\Beginning of pattern block { pt_default \\Beginning of default pattern { Actions \\Beginning of actions block { SetAttr "active 1" \\ Setting attribute Timer "tRegenerate,0.5,repeated" \\ Setting a timer Pattern .pt_update \\ Executing a pattern } Events \\Beginning of event block { OnAttrChange_ea_status "ExecutePattern .xpt_OnStatusChange" \\Pattern executed on attribute change } } } } } }
Syntax notes[]
- Constants and Behavior are declared first with code being placed in curly brackets { }
- Text placed after a Backslash (\) is ignored and can be used for leaving notes
- Unlike Valve Developer Languages , P3scripts not found in "AI_scripts.txt" are still recognized by the game.
- Currently known usable operators are: =, ==, <, >, <=, >=, +, -, and !=.