field_obj.h
games/tbs/include/field_obj.h on GitHub
Structures
FieldActor
struct FieldActor
A field actor: a person or thing on the field with a position, motion toward a target, sprites and an update callback.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[6] | The object's script pointer (nonzero while the object is live) and its cursor, which ObjectRuntime names script and step. |
facing | u16 facing | 1/65536 turns |
x | union FieldCoordinate x | 16.16 fixed-point pixels |
y | union FieldCoordinate y | 16.16 fixed-point pixels |
z | union FieldCoordinate z | 16.16 fixed-point pixels |
terrainHeight | s32 terrainHeight | 16.16 fixed-point pixels |
scaleX | s32 scaleX | 16.16 fixed point, 0x10000 full size |
scaleY | s32 scaleY | 16.16 fixed point, 0x10000 full size |
radius | u16 radius | Collision radius in pixels: 16, or half the sprite metadata's boxY, when created; the overlap checks use it less 2. |
terrainId | u8 terrainId | The map layer (0 to 3) its ground height is read from, which the scrolling camera updates from the cell under it; the fixed camera passes it as the sprite's draw slot. |
priorityFlags | u8 priorityFlags | ActorPriorityFlag bits, read by the scrolling camera. bits: 2 sorted as if 320 pixels lower | 1 sorted as if 320 pixels higher | 0 sprite priority from the cell under it |
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 |
speed | s32 speed | speed limit, 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; 0x10000 when created. |
targetX | s32 targetX | 16.16 fixed-point pixels; ACTOR_NO_TARGET when unset |
targetY | s32 targetY | 16.16 fixed-point pixels; ACTOR_NO_TARGET when unset |
targetZ | s32 targetZ | 16.16 fixed-point pixels; ACTOR_NO_TARGET when unset |
bounce | s32 bounce | The share of its falling speed kept as it bounces on landing, 16.16 fixed point (0x4000 when created); a floating object's phase instead. |
gravity | s32 gravity | Taken off the vertical velocity each frame while it is above the ground, in 16.16 fixed-point pixels per frame (0x10000 when created); also scales a floating object's bob. |
riseBaseY | s32 riseBaseY | Zeroed by FieldObject_Create and not read by the engine; scene code keeps a resting height, a sway or a countdown here. |
sprite, sprites | union { struct AnimationObject *sprite; ///< spriteStorageKind 1 void **sprites; ///< spriteStorageKind 2: four sprites, empty ones null } | |
spriteStorageKind | u8 spriteStorageKind | Zero hides sprites; one draws a single sprite, two draws a group. The engine reads the low four bits; SC_B54_ON and SC_B54_OFF set 1 and 0. |
motionFlags | u8 motionFlags | ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation. bits: 4 no slowdown on slopes | 3 bigger float | 2 floats | 1 falls | 0 follows the terrain |
unk56 | u8 unk56[3] | The ARRIVAL_AXIS_* watched for arrival, the object script's last flag test (ScriptInterpreter.conditionResult), and whether it snaps onto its target on arrival: ScriptMotionObject names 0x56 and 0x58. |
collisionFlags | u8 collisionFlags | bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psynergy target | 2 nearer to talk to | 1 the player pushes it | 0 solid |
steeringFlags | u8 steeringFlags | ActorSteeringFlag bits |
paused | u8 paused | nonzero skips its script and motion, not its update |
retainSpriteCache | u8 retainSpriteCache | Nonzero keeps its sprite's VRAM cache entry while sprites are suspended or it is off screen (ObjectSystem_UpdateCamera). |
repeatCount | u8 repeatCount | the object script's SC_LOOP count (ScriptInterpreter) |
wait | u16 wait | the object script's wait, in frames (ScriptMotionObject) |
refused | u8 refused | Frames a solid object has refused its move (ScriptMotionObject's refused); SC_SYNC stops waiting after 60. |
frozen | u8 frozen | Nonzero skips steering, terrain, gravity and floating; its velocity still moves it (ScriptMotionObject.frozen). |
riseCounter | u8 riseCounter | not read by the engine; scene code's own counter |
riseEnabled | u8 riseEnabled | not read by the engine; scene code's own state |
timer | s16 timer | The parameter its action script reads (a follow distance or an angle to face), the player's frames to its next footprint, or scene scratch. |
work | u16 work | The side of the player's next footprint (2 after a stop), or scene scratch. |
linkedObject | struct FieldActor *linkedObject | The object its action script follows or faces. |
update | void (*update)(union FieldObject *object) | Called each frame before the object's script, while the object is live. |
Used by Actor_CopyPosition, Actor_Get, Actor_IsParked, Actor_JumpDownLedge, Actor_SetSpriteFlags, AltmillerCave_BeginRetreat, AltmillerCave_CheckFrostTargetCollision, AltmillerCave_FreezePuddle, AltmillerCave_HopSelectedActor, AltmillerCave_Initialize, AltmillerCave_MatchLeaderPriority, AltmillerCave_MeetInvisibleBabi, AltmillerCave_PlaceLight, AltmillerCave_PulseLight, AltmillerCave_RestoreBabiAndInviteParty, AltmillerCave_TurnRock, AltmillerCave_UpdateMovedObstacle, BabiLighthouse_AdvanceNearbyPair, BabiLighthouse_ClimbDownOrAdvancePair, BabiLighthouse_ClimbOrAdvancePair, BabiLighthouse_FallToExit, BabiLighthouse_FindActorAhead, BabiLighthouse_JumpFromLedge, BabiLighthouse_LandWithParticles, BabiLighthouse_MatchLeaderPriority, BabiLighthouse_RefreshMovableBlockTiles, BabiLighthouse_RegroupPartyMember, BabiLighthouse_SetupScene, BabiLighthouse_UpdateMovedBlock, BabiPalace_ApplyEntryState, BabiPalace_MeetBabiAfterColosso, BabiPalace_RestInPalaceBeds, BabiPalace_ShowBeds, BabiPalace_TalkToIndigestedWarrior, BabiPalace_WakeAfterFinals, BabiPalace_WakeFromFinalsDream, BattleEffect_ClearAllObjects, BattleEffect_ClearOutOfBoundsObjects, BattleEffect_PauseObject, BattleEffect_SpawnBurstParticleField and 858 more.
Enumerations
ActorLinkFlag
enum ActorLinkFlag
Preserves the current action and motion when assigning a linked target.
| Value | = | |
|---|---|---|
ACTOR_LINK_KEEP_MOTION | 0x10000 |
ActorPriorityFlag
enum ActorPriorityFlag
FieldActor.priorityFlags bits.
| Value | = | |
|---|---|---|
ACTOR_PRIORITY_AUTOMATIC | 0x01 | The sprite takes its priority from the map cell under it. |
ACTOR_PRIORITY_UNDERFOOT | 0x02 | The depth sort treats it as 320 pixels higher on the screen. |
ActorMotionFlag
enum ActorMotionFlag
FieldActor.motionFlags bits.
| Value | = | |
|---|---|---|
ACTOR_FOLLOWS_TERRAIN | 0x01 | moves with the ground height under it |
ACTOR_FALLS | 0x02 | falls by its gravity and bounces |
ActorSteeringFlag
enum ActorSteeringFlag
FieldActor.steeringFlags bits.
| Value | = | |
|---|---|---|
ACTOR_FACES_MOTION | 0x01 | turns toward its velocity, 1/16 turn a frame |
Also, enumerations without a comment: SceneTransitionStyle.
Macros
ACTOR_NO_TARGET
#define ACTOR_NO_TARGET ((s32)0x80000000)
A target coordinate that is not set: the object has no target.
Used by Actor_IsParked, BabiLighthouse_JumpFromLedge, Colosso_RestoreCompetitor, CrossboneIslePillarRooms_SettleActorOnGround, CrossboneIslePillarRooms_StopAtGroundOrHeight, Djinn_RunBattleStartHop, Event_CenterStatueMoved, Event_FinalsBegin, Event_PsynergyStoneIsGone, Event_SetBlockOnBalance, FieldFx_RunRetreat, Field_ProcessStep, FloatingBlock_Settle, GomaCaveEntrance_LeapStump, GomaCaveWaterway_LeapStump, GondowanCave_RunSpinningLeap, Leader_StopMoving, Marker_MoveLeaderAway, MercuryLighthouse_FollowLeader, ObjectMotion_SetHorizontalPositionWithTerrain, ObjectMotion_SetPositionWithTerrain, Object_ResetTargetAndSetMode1, OverlayObject_ResetMotionFields, ReceiveBlackOrb, SceneEffect_AdvanceAngleUntilIdle, Scene_RunEntrySetup, SolSanctumEruption_FadeCameraTo, SolSanctumEruption_PlayWiseOneRescue, SolSanctumEruption_StepEmbers, SolSanctumEruption_ThrowEruptionRing, SuhallaDesert_ChaseLeader, TolbiShipDeck_HoverAndDiveAtOuranos, TolbiShipDeck_HoverAndDiveAtSean, TolbiShipDeck_LeapAtOuranos, TolbiShipDeck_LeapAtSean, TolbiShipInteriors_HasArrived, TolbiShipInteriors_ResetActor, TolbiShipMast_StopDriftingActor, TunnelRuins_WaitForActorToLand, ValeStorm_ShowBoulderSweepingDownriver and 8 more.
Also, macros without a comment: SCENE_TRANSITION.
Globals, without a comment: gEventWork.