AFSM (File Format): Difference between revisions
>Skysurf3000 m (condition names are zeo terminated) |
>Embyr 75 m ({{research}}) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
The '''AFSM format''' controls AI behavior; it stands for '''A'''I '''F'''inite '''S'''tate '''M'''achine. AI-controlled creatures have a limited number of possible states they can be in. The AFSM file defines those states, and what triggers can cause it to | The '''AFSM format''' controls AI behavior; it stands for '''A'''I '''F'''inite '''S'''tate '''M'''achine. AI-controlled creatures have a limited number of possible states they can be in. The AFSM file defines those states, and what triggers can cause it to transition to another state. | ||
{{ | {{research|1|We should have a list of possible states and triggers and a short explanation of what they generally do on this page somewhere. Also, the float settings on conditions is unknown.}} | ||
__TOC__ | __TOC__ | ||
Line 9: | Line 9: | ||
=== Header === | === Header === | ||
The format first defines a list of states, then defines each | The format first defines a list of states, then defines the triggers for each transition attached to each state. There are no state/trigger type IDs; rather, the name string itself is used as an identifier to fetch the corresponding AI function. It starts with a short header listing each state and then providing a trigger count. Note that the trigger count isn't actually used to parse the file; it's present merely because the game uses it to allocate space for each trigger ahead of time. | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 26: | Line 26: | ||
| long | | long | ||
| 1 | | 1 | ||
| ''' | | '''Trigger count''' | ||
|} | |} | ||
=== State | === State Transitions === | ||
Following that, it iterates through each state, defining the | Following that, it iterates through each state, defining the transitions associated with each one. Transitions are composed of a target state index and a number of triggers; when all the triggers associated with a transition are satisfied, it advances to the targeted state. The state transitions are structured like this: | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 40: | Line 40: | ||
| long | | long | ||
| 1 | | 1 | ||
| ''' | | '''Transition count''' (TC) | ||
|- | |- | ||
| | | Transition | ||
| TC | | TC | ||
| ''' | | '''Transitions''' | ||
|} | |} | ||
=== | === Transitions === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 56: | Line 56: | ||
| long | | long | ||
| 1 | | 1 | ||
| ''' | | '''Trigger count''' (TC) | ||
|- | |- | ||
| Trigger | | Trigger | ||
| | | TC | ||
| ''' | | '''Triggers''' | ||
|} | |} | ||
=== | === Trigger === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 72: | Line 72: | ||
| string | | string | ||
| 1 | | 1 | ||
| ''' | | '''Trigger name''' (zero-terminated) | ||
|- | |- | ||
| float | | float | ||
Line 80: | Line 80: | ||
| long | | long | ||
| 1 | | 1 | ||
| '''Target state index''' (note: this is ONLY present on the first | | '''Target state index''' (note: this is ONLY present on the first trigger for each transition!) | ||
|} | |} | ||
Latest revision as of 15:04, 14 March 2015
The AFSM format controls AI behavior; it stands for AI Finite State Machine. AI-controlled creatures have a limited number of possible states they can be in. The AFSM file defines those states, and what triggers can cause it to transition to another state.
![]() |
This file format is almost completely documented We should have a list of possible states and triggers and a short explanation of what they generally do on this page somewhere. Also, the float settings on conditions is unknown. |
Format
Header
The format first defines a list of states, then defines the triggers for each transition attached to each state. There are no state/trigger type IDs; rather, the name string itself is used as an identifier to fetch the corresponding AI function. It starts with a short header listing each state and then providing a trigger count. Note that the trigger count isn't actually used to parse the file; it's present merely because the game uses it to allocate space for each trigger ahead of time.
Type | Count | Description |
---|---|---|
long | 1 | State count (SC) |
string | SC | State names (each zero-terminated) |
long | 1 | Trigger count |
State Transitions
Following that, it iterates through each state, defining the transitions associated with each one. Transitions are composed of a target state index and a number of triggers; when all the triggers associated with a transition are satisfied, it advances to the targeted state. The state transitions are structured like this:
Type | Count | Description |
---|---|---|
long | 1 | Transition count (TC) |
Transition | TC | Transitions |
Transitions
Type | Count | Description |
---|---|---|
long | 1 | Trigger count (TC) |
Trigger | TC | Triggers |
Trigger
Type | Count | Description |
---|---|---|
string | 1 | Trigger name (zero-terminated) |
float | 1 | Unknown (possibly AI function parameter) |
long | 1 | Target state index (note: this is ONLY present on the first trigger for each transition!) |