script_motion.h
games/tbs/include/script_motion.h on GitHub
Structures
ScriptMotionWords
struct ScriptMotionWords
The words of an object's script, as its script pointer reads them.
| Field | Declared as | |
|---|---|---|
word | s32 word[1] |
Used by Object_UpdateAllThumb.
ScriptMotionObject
struct ScriptMotionObject
A field object as the motion code sees it: its script, position, motion toward a target, bounce and gravity, motion flags and wait, and its hook.
| Field | Declared as | |
|---|---|---|
script | const ScriptMotionWords *script | null when the object is free |
scriptCursor | u16 scriptCursor | in words; read signed |
facing | u16 facing | 1/65536 turns |
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | 16.16 fixed-point pixels |
terrainHeight | s32 terrainHeight | 16.16 fixed-point pixels |
unk18 | u8 unk18[0x0a] | the x and y scales and the radius; not named here |
terrainId | u8 terrainId | the map layer whose ground height it follows |
unk23 | u8 unk23 | FieldActor.priorityFlags; not named here |
velocityX | s32 velocityX | 16.16 fixed-point pixels per frame |
velocityY | s32 velocityY | 16.16 fixed-point pixels per frame |
velocityZ | s32 velocityZ | 16.16 fixed-point pixels per frame |
speedLimit | s32 speedLimit | 16.16 fixed-point pixels per frame |
acceleration | s32 acceleration | Added toward the target each frame, or taken off the speed when there is none, in 16.16 fixed-point pixels per frame. |
targetX | s32 targetX | 16.16 fixed-point pixels; 0x80000000 when unset |
targetY | s32 targetY | 16.16 fixed-point pixels; 0x80000000 when unset |
targetZ | s32 targetZ | 16.16 fixed-point pixels; 0x80000000 when unset |
bounce, phase, vertical | union { /// The share of the falling speed kept on landing, 16.16 fixed point. s32 bounce; /// A floating object's step along gScriptObject_CycleTable, low six bits. s32 phase; } vertical | |
gravity | s32 gravity | Taken off velocityY each frame above the ground, 16.16 fixed-point pixels per frame; also scales a floating object's bob. |
unk4c | u8 unk4c[9] | A spare word, the sprite pointer and the sprite kind; not named here. |
motionFlags | u8 motionFlags | bits: 4 no slowdown on slopes | 3 bigger float | 2 floats | 1 falls | 0 follows the terrain; zero is free flight in 3D |
arrivalAxis | u8 arrivalAxis | the ARRIVAL_AXIS_* that decides arrival |
unk57 | u8 unk57 | the object script's last flag test; not named here |
snapToTarget | u8 snapToTarget | nonzero lands it exactly on its target |
collisionFlags | u8 collisionFlags | bit 7: a solid object refuses its move |
steeringFlags | u8 steeringFlags | bit 0: turns toward its velocity, 1/16 turn a frame |
paused | u8 paused | nonzero skips its script and motion, not its hook |
unk5c | u8 unk5c[2] | The flag that keeps its sprite's VRAM, and the object script's SC_LOOP count; not named here. |
wait | s16 wait | frames left before its script runs again |
refused | u8 refused | frames in a row a solid object refused its move |
frozen | u8 frozen | nonzero skips steering, terrain, gravity and floating |
unk62 | u8 unk62[10] | Two bytes scene code uses, the action parameter, the footprint side and the linked object; not named here. |
hook | void (*hook)(union FieldObject *object) | Called each frame before its script. |
Used by BattleEffect_CleanupSceneObjects, BattleFx_SetupObjectPair, BattleFx_ShrinkObjectScaleUntilHalf, EffectRuntime_StopCurrentObject, FieldFx_EndCloak, FieldFx_RunForce, FieldFx_StartCloak, FieldObject_Create, ObjectGroup_ConfigureChildValue, Object_UpdateAll, Object_UpdateAllMotion, Object_UpdateAllThumb, gObjectSlots.