Behavior
Jump to navigation
Jump to search
A behavior basically is a script describing how an object shall behave. The original behavior scripts can be found in data/behavior_data.c.
Native code
Behavior script can do a lot with the object they are attached to. Additional code can be added natively in C. Original behavior code is located in src/game/behaviors.
Actors
Actors basically describe the appearance of an object, including 3D models, textures and animations. Original actors are located in sub-folders in actors.
An actor usual contains the following data:
- Unique texture files (might be hardcoded in C if exported from an editor)
- model.inc.c file describing 3D models including UV coordinates and vertex colors
- geo.inc.c file
- anims sub-folder
Behavior script commands
Command | Parameters | Description |
---|---|---|
BEGIN
|
objList | Defines the start of the behavior script as well as the object list the object belongs to. Has some special behavior for certain objects. |
DELAY
|
num | Delays the behavior script for a certain number of frames. |
CALL
|
addr | Jumps to a new behavior command and stores the return address in the object's stack. |
RETURN
|
Jumps back to the behavior command stored in the object's stack. | |
GOTO
|
addr | Jumps to a new behavior script without saving anything. |
BEGIN_REPEAT
|
count | Marks the start of a loop that will repeat a certain number of times. |
END_REPEAT
|
Marks the end of a repeating loop. | |
END_REPEAT_CONTINUE
|
Also marks the end of a repeating loop, but continues executing commands following the loop on the same frame. | |
BEGIN_LOOP
|
Marks the beginning of an infinite loop. | |
END_LOOP
|
Makrs the end of an infinite loop. | |
BREAK
|
Exits the behavior script. Often used to end behavior scripts that do not contain an infinite loop. | |
CALL_NATIVE
|
func | Executes a native game function. |
ADD_FLOAT
|
field, value | Adds a float to the specified field. |
SET_FLOAT
|
field, value | Sets the specified field to a float. |
ADD_INT
|
field, value | Adds an integer to the specified field. |
SET_INT
|
field, value | Sets the specified field to an integer. |
OR_INT
|
field, value | Performs a bitwise OR with the specified field and the given itneger. Usually used to set an object's flags. |
BIT_CLEAR
|
field, value | Performs a bit clear with the specified short. Unused in favor of the 32-bit version. |
SET_INT_RAND_RSHIFT
|
field, min, rshift | Gets a random short, right shifts it the specified amoutn and adds min to it, then sets the specified field to that value. |
SET_RANDOM_FLOAT
|
field, min, range | Sets the specified field to a random float in the given range. |
SET_RANDOM_INT
|
field, min, range | Sets the specified field to a random integer in the given range. |
ADD_RANDOM_FLOAT
|
field, min, range | Adds a random float in the given range to the specified field. |
ADD_INT_RAND_RSHIFT
|
field, min, rshift | Gets a random short, right shifts it the specified amount and adds min to it, then adds the value to the specified field. |
SET_MODEL
|
modelID | Sets the current model ID of the object. |
DEACTIVATE
|
Exits the behavior script and despawns the object. Often used to end behavior scripts that do not contain an infinite loop. | |
DROP_TO_FLOOR
|
Finds the floor triangle directly under the object and moves the object down to it. | |
SUM_FLOAT
|
fieldDst, fieldSrc1, fieldSrc2 | Sets the destination float field to the sum of the values of the given float fields. |
SUM_INT
|
fieldDst, fieldSrc1, fieldSrc2 | Sets the destination integer field to the sum of the values of the given integer fields. |
BILLBOARD
|
Billboards the current object, making it always face the camera. | |
HIDE
|
Hides the current object. | |
SET_HITBOX
|
radius, height | Sets the size of the object's cylindrical hitbox. |
DELAY_VAR
|
field | Delays the behavior script for the number of frames given by the value of the specified field. |
LOAD_ANIMATIONS
|
field, anims | Loads the animations for the object. field is always set to oAnimations. |
ANIMATE
|
animIndex | Begins animation and sets the object's current animation index to the specified value. |
SPAWN_CHILD_WITH_PARAM
|
bhvParam, modelID, behavior | Spawns a child object with the specified model and behavior, plus a behavior param. |
LOAD_COLLISION_DATA
|
collisionData | Loads collision data for the object. |
SET_HITBOX_WITH_OFFSET
|
radius, height, downOffset | Sets the size of the object's cylindrical hitbox, and applies a downwards offset. |
SPAWN_OBJ
|
modelID, behavior | Spawns a new object with the specified model and behavior. |
SET_HOME
|
Sets the home position of the object to its current position. | |
SET_HURTBOX
|
radius, height | Sets the size of the object's cylindrical hurtbox. |
SET_INTERACT_TYPE
|
type | Sets the object's interaction type. |
SET_OBJ_PHYSICS
|
wallHitboxRadius, gravity, bounciness,
dragStrength, friction, buoyancy, unused1, unused2 |
Sets various parameters that the object uses for calculating physincs. |
SET_INTERACT_SUBTYPE
|
subtype | Sets the object's interaction subtype. |
SCALE
|
unused, percent | Sets the object's size to the specified percentage. |
PARENT_BIT_CLEAR
|
field, flags | Performs a bit clear on the object's parent's field with the specified value. Used for clearing active particle flags from Mario's object. |
ANIMATE_TEXTURE
|
field, rate | Animates an object using texture animation. field is always set to oAnimState. |
DISABLE_RENDERING
|
Disables rendering for the object. | |
SPAWN_WATER_DROPLET
|
dropletParams | Spawns a water droplet with the given parameters. |