Alchemy

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.

FieldDeclared as
unk00u8 unk00[6]The object's script pointer (nonzero while the object is live) and its cursor, which ObjectRuntime names script and step.
facingu16 facing1/65536 turns
xunion FieldCoordinate x16.16 fixed-point pixels
yunion FieldCoordinate y16.16 fixed-point pixels
zunion FieldCoordinate z16.16 fixed-point pixels
terrainHeights32 terrainHeight16.16 fixed-point pixels
scaleXs32 scaleX16.16 fixed point, 0x10000 full size
scaleYs32 scaleY16.16 fixed point, 0x10000 full size
radiusu16 radiusCollision radius in pixels: 16, or half the sprite metadata's boxY, when created; the overlap checks use it less 2.
terrainIdu8 terrainIdThe 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.
priorityFlagsu8 priorityFlagsActorPriorityFlag 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
velocityXs32 velocityX16.16 fixed-point pixels per frame
velocityYs32 velocityY16.16 fixed-point pixels per frame
velocityZs32 velocityZ16.16 fixed-point pixels per frame
speeds32 speedspeed limit, 16.16 fixed-point pixels per frame
accelerations32 accelerationAdded 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.
targetXs32 targetX16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
targetYs32 targetY16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
targetZs32 targetZ16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
bounces32 bounceThe share of its falling speed kept as it bounces on landing, 16.16 fixed point (0x4000 when created); a floating object's phase instead.
gravitys32 gravityTaken 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.
riseBaseYs32 riseBaseYZeroed by FieldObject_Create and not read by the engine; scene code keeps a resting height, a sway or a countdown here.
sprite, spritesunion { struct AnimationObject *sprite; ///< spriteStorageKind 1 void **sprites; ///< spriteStorageKind 2: four sprites, empty ones null }
spriteStorageKindu8 spriteStorageKindZero 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.
motionFlagsu8 motionFlagsActorMotionFlag 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
unk56u8 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.
collisionFlagsu8 collisionFlagsbits: 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
steeringFlagsu8 steeringFlagsActorSteeringFlag bits
pausedu8 pausednonzero skips its script and motion, not its update
retainSpriteCacheu8 retainSpriteCacheNonzero keeps its sprite's VRAM cache entry while sprites are suspended or it is off screen (ObjectSystem_UpdateCamera).
repeatCountu8 repeatCountthe object script's SC_LOOP count (ScriptInterpreter)
waitu16 waitthe object script's wait, in frames (ScriptMotionObject)
refusedu8 refusedFrames a solid object has refused its move (ScriptMotionObject's refused); SC_SYNC stops waiting after 60.
frozenu8 frozenNonzero skips steering, terrain, gravity and floating; its velocity still moves it (ScriptMotionObject.frozen).
riseCounteru8 riseCounternot read by the engine; scene code's own counter
riseEnabledu8 riseEnablednot read by the engine; scene code's own state
timers16 timerThe parameter its action script reads (a follow distance or an angle to face), the player's frames to its next footprint, or scene scratch.
worku16 workThe side of the player's next footprint (2 after a stop), or scene scratch.
linkedObjectstruct FieldActor *linkedObjectThe object its action script follows or faces.
updatevoid (*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.

Line 30

Enumerations

ActorLinkFlag

enum ActorLinkFlag

Preserves the current action and motion when assigning a linked target.

Value=
ACTOR_LINK_KEEP_MOTION0x10000

Line 148

ActorPriorityFlag

enum ActorPriorityFlag

FieldActor.priorityFlags bits.

Value=
ACTOR_PRIORITY_AUTOMATIC0x01The sprite takes its priority from the map cell under it.
ACTOR_PRIORITY_UNDERFOOT0x02The depth sort treats it as 320 pixels higher on the screen.

Line 151

ActorMotionFlag

enum ActorMotionFlag

FieldActor.motionFlags bits.

Value=
ACTOR_FOLLOWS_TERRAIN0x01moves with the ground height under it
ACTOR_FALLS0x02falls by its gravity and bounces

Line 159

ActorSteeringFlag

enum ActorSteeringFlag

FieldActor.steeringFlags bits.

Value=
ACTOR_FACES_MOTION0x01turns toward its velocity, 1/16 turn a frame

Line 165

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.

Line 145

Also, macros without a comment: SCENE_TRANSITION.

Globals, without a comment: gEventWork.

On this page