Difference between revisions of "Behavior"
Jump to navigation
Jump to search
(Created page with "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...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 13: | Line 13: | ||
* [[Geometry layout|geo.inc.c]] file | * [[Geometry layout|geo.inc.c]] file | ||
* anims sub-folder | * anims sub-folder | ||
+ | |||
+ | == Behavior script commands == | ||
+ | {| class="wikitable sortable" | ||
+ | !Command | ||
+ | !Parameters | ||
+ | !Description | ||
+ | |- | ||
+ | !<code>BEGIN</code> | ||
+ | |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. | ||
+ | |- | ||
+ | !<code>DELAY</code> | ||
+ | |num | ||
+ | |Delays the behavior script for a certain number of frames. | ||
+ | |- | ||
+ | !<code>CALL</code> | ||
+ | |addr | ||
+ | |Jumps to a new behavior command and stores the return address in the object's stack. | ||
+ | |- | ||
+ | !<code>RETURN</code> | ||
+ | | | ||
+ | |Jumps back to the behavior command stored in the object's stack. | ||
+ | |- | ||
+ | !<code>GOTO</code> | ||
+ | |addr | ||
+ | |Jumps to a new behavior script without saving anything. | ||
+ | |- | ||
+ | !<code>BEGIN_REPEAT</code> | ||
+ | |count | ||
+ | |Marks the start of a loop that will repeat a certain number of times. | ||
+ | |- | ||
+ | !<code>END_REPEAT</code> | ||
+ | | | ||
+ | |Marks the end of a repeating loop. | ||
+ | |- | ||
+ | !<code>END_REPEAT_CONTINUE</code> | ||
+ | | | ||
+ | |Also marks the end of a repeating loop, but continues executing commands following the loop on the same frame. | ||
+ | |- | ||
+ | !<code>BEGIN_LOOP</code> | ||
+ | | | ||
+ | |Marks the beginning of an infinite loop. | ||
+ | |- | ||
+ | !<code>END_LOOP</code> | ||
+ | | | ||
+ | |Makrs the end of an infinite loop. | ||
+ | |- | ||
+ | !<code>BREAK</code> | ||
+ | | | ||
+ | |Exits the behavior script. Often used to end behavior scripts that do not contain an infinite loop. | ||
+ | |- | ||
+ | !<code>CALL_NATIVE</code> | ||
+ | |func | ||
+ | |Executes a native game function. | ||
+ | |- | ||
+ | !<code>ADD_FLOAT</code> | ||
+ | |field, value | ||
+ | |Adds a float to the specified field. | ||
+ | |- | ||
+ | !<code>SET_FLOAT</code> | ||
+ | |field, value | ||
+ | |Sets the specified field to a float. | ||
+ | |- | ||
+ | !<code>ADD_INT</code> | ||
+ | |field, value | ||
+ | |Adds an integer to the specified field. | ||
+ | |- | ||
+ | !<code>SET_INT</code> | ||
+ | |field, value | ||
+ | |Sets the specified field to an integer. | ||
+ | |- | ||
+ | !<code>OR_INT</code> | ||
+ | |field, value | ||
+ | |Performs a bitwise OR with the specified field and the given itneger. Usually used to set an object's flags. | ||
+ | |- | ||
+ | !<code>BIT_CLEAR</code> | ||
+ | |field, value | ||
+ | |Performs a bit clear with the specified short. Unused in favor of the 32-bit version. | ||
+ | |- | ||
+ | !<code>SET_INT_RAND_RSHIFT</code> | ||
+ | |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. | ||
+ | |- | ||
+ | !<code>SET_RANDOM_FLOAT</code> | ||
+ | |field, min, range | ||
+ | |Sets the specified field to a random float in the given range. | ||
+ | |- | ||
+ | !<code>SET_RANDOM_INT</code> | ||
+ | |field, min, range | ||
+ | |Sets the specified field to a random integer in the given range. | ||
+ | |- | ||
+ | !<code>ADD_RANDOM_FLOAT</code> | ||
+ | |field, min, range | ||
+ | |Adds a random float in the given range to the specified field. | ||
+ | |- | ||
+ | !<code>ADD_INT_RAND_RSHIFT</code> | ||
+ | |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. | ||
+ | |- | ||
+ | !<code>SET_MODEL</code> | ||
+ | |modelID | ||
+ | |Sets the current model ID of the object. | ||
+ | |- | ||
+ | !<code>DEACTIVATE</code> | ||
+ | | | ||
+ | |Exits the behavior script and despawns the object. Often used to end behavior scripts that do not contain an infinite loop. | ||
+ | |- | ||
+ | !<code>DROP_TO_FLOOR</code> | ||
+ | | | ||
+ | |Finds the floor triangle directly under the object and moves the object down to it. | ||
+ | |- | ||
+ | !<code>SUM_FLOAT</code> | ||
+ | |fieldDst, fieldSrc1, fieldSrc2 | ||
+ | |Sets the destination float field to the sum of the values of the given float fields. | ||
+ | |- | ||
+ | !<code>SUM_INT</code> | ||
+ | |fieldDst, fieldSrc1, fieldSrc2 | ||
+ | |Sets the destination integer field to the sum of the values of the given integer fields. | ||
+ | |- | ||
+ | !<code>BILLBOARD</code> | ||
+ | | | ||
+ | |Billboards the current object, making it always face the camera. | ||
+ | |- | ||
+ | !<code>HIDE</code> | ||
+ | | | ||
+ | |Hides the current object. | ||
+ | |- | ||
+ | !<code>SET_HITBOX</code> | ||
+ | |radius, height | ||
+ | |Sets the size of the object's cylindrical hitbox. | ||
+ | |- | ||
+ | !<code>DELAY_VAR</code> | ||
+ | |field | ||
+ | |Delays the behavior script for the number of frames given by the value of the specified field. | ||
+ | |- | ||
+ | !<code>LOAD_ANIMATIONS</code> | ||
+ | |field, anims | ||
+ | |Loads the animations for the object. field is always set to oAnimations. | ||
+ | |- | ||
+ | !<code>ANIMATE</code> | ||
+ | |animIndex | ||
+ | |Begins animation and sets the object's current animation index to the specified value. | ||
+ | |- | ||
+ | !<code>SPAWN_CHILD_WITH_PARAM</code> | ||
+ | |bhvParam, modelID, behavior | ||
+ | |Spawns a child object with the specified model and behavior, plus a behavior param. | ||
+ | |- | ||
+ | !<code>LOAD_COLLISION_DATA</code> | ||
+ | |collisionData | ||
+ | |Loads collision data for the object. | ||
+ | |- | ||
+ | !<code>SET_HITBOX_WITH_OFFSET</code> | ||
+ | |radius, height, downOffset | ||
+ | |Sets the size of the object's cylindrical hitbox, and applies a downwards offset. | ||
+ | |- | ||
+ | !<code>SPAWN_OBJ</code> | ||
+ | |modelID, behavior | ||
+ | |Spawns a new object with the specified model and behavior. | ||
+ | |- | ||
+ | !<code>SET_HOME</code> | ||
+ | | | ||
+ | |Sets the home position of the object to its current position. | ||
+ | |- | ||
+ | !<code>SET_HURTBOX</code> | ||
+ | |radius, height | ||
+ | |Sets the size of the object's cylindrical hurtbox. | ||
+ | |- | ||
+ | !<code>SET_INTERACT_TYPE</code> | ||
+ | |type | ||
+ | |Sets the object's interaction type. | ||
+ | |- | ||
+ | !<code>SET_OBJ_PHYSICS</code> | ||
+ | |wallHitboxRadius, gravity, bounciness, | ||
+ | dragStrength, friction, buoyancy, | ||
+ | |||
+ | unused1, unused2 | ||
+ | |Sets various parameters that the object uses for calculating physincs. | ||
+ | |- | ||
+ | !<code>SET_INTERACT_SUBTYPE</code> | ||
+ | |subtype | ||
+ | |Sets the object's interaction subtype. | ||
+ | |- | ||
+ | !<code>SCALE</code> | ||
+ | |unused, percent | ||
+ | |Sets the object's size to the specified percentage. | ||
+ | |- | ||
+ | !<code>PARENT_BIT_CLEAR</code> | ||
+ | |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. | ||
+ | |- | ||
+ | !<code>ANIMATE_TEXTURE</code> | ||
+ | |field, rate | ||
+ | |Animates an object using texture animation. field is always set to oAnimState. | ||
+ | |- | ||
+ | !<code>DISABLE_RENDERING</code> | ||
+ | | | ||
+ | |Disables rendering for the object. | ||
+ | |- | ||
+ | !<code>SPAWN_WATER_DROPLET</code> | ||
+ | |dropletParams | ||
+ | |Spawns a water droplet with the given parameters. | ||
+ | |} | ||
== See also == | == See also == | ||
Line 18: | Line 220: | ||
* [[Custom behavior]] | * [[Custom behavior]] | ||
* [[Geometry layout]] | * [[Geometry layout]] | ||
+ | [[Category:Level]] |
Latest revision as of 11:00, 9 November 2020
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. |