Actions determine what an Object defined in a SOC does during a given state. They are used to control the interaction of Objects with the player and the level environment. During any state, an Object can perform one of the 118 actions coded into SRB2, although it does not need to perform one during every state. Some Objects, such as static scenery Objects, do not perform any actions at all because they do not need to interact with their environment in any way.
The Object that performs an action is called the actor. Additionally, actions can assign a target or a tracer Object as additional reference Objects. They are used for actions that need to be performed in relation to another Object. For example, a shooting action will fire a projectile at the target; a movement attack will make the actor move towards the target. The difference between the two is that the actor needs to see the target to perform an action related to it, while the tracer does not need to be in sight. Some actions will set these themselves if they are necessary, but they can also be set manually with the actions
Some actions allow for modifications of their behavior through two variables, called Var1 and Var2. Their effect depends entirely on the action they are used with. For some of the more complicated actions, SRB2 divides these variables into upper and lower bits, essentially creating four distinct parameters to allow for more flexible control. In these, the value of the variable is calculated as the desired upper bit value multiplied with 65536 plus the desired lower bit value.
Normally, only a single action can be performed during one state. However, the action
A_DualAction allows for two actions to be executed in one state while with a state duration of 0, meaning that the Object will change into the next state instantly, allowing it to perform the next action immediately. Objects can not perform actions in their
SpawnState unless they have the
MF_RUNSPAWNFUNC (value 2147483648) flag checked.
Powers and Monitors