Skip to Content
The Alchemy Project

src/field/field_actor_motion.c

Actor motion, each tick, and the first actor script commands. More…

Included by field.c.

Macros

NameDescription
#defineFLOAT_CYCLE_TICKS 64A floating actor's bob, one cycle of ActorScriptCycleTable over this many ticks; its rise and fall each tick is the table's value times its gravity over FLOAT_DIVISOR, or FLOAT_HIGH_DIVISOR with ACTOR_FLOATS_HIGH.
#defineFLOAT_DIVISOR 64
#defineFLOAT_HIGH_DIVISOR 16

Functions

NameDescription
Sint32fdActorScriptSetBase (ACTOR *interpreter)SC_BASE: restarts the script at the next word, and returns 1 to run on.
Sint32fdActorScriptHideSprites (ACTOR *interpreter)SC_HIDE_SPRITES: hides the actor's sprites and runs on.
Sint32fdActorScriptShowSprite (ACTOR *interpreter)SC_SHOW_SPRITE: shows the actor's one sprite and runs on.
voidfdActorWaitForMove (void *actor)Waits a tick at a time until an actor has arrived at its target, at most 600 ticks (ten seconds), after which it returns with the actor still on its way.
BoolfdActorIsTargetUnset (ACTOR *actor)Returns 1 when the actor has no movement target: none of its target coordinates set, or for an actor moved by the ground (any motion flag) neither its target x nor z.
static __inline__ Sint32fdActorSquare (Sint32 value)
voidfdActorUpdateAllOnField (void)Advances all 64 actors by one tick, as fdActorUpdateAll does for the eight script-driven actors, with the field's extras: free flight in 3D, following the ground, floating, and solid actors that refuse to overlap.
voidfdActorSetPosAndResetMotion (ACTOR *actor, FIXED x, FIXED y, FIXED z)Places the actor at (x, y, z), in 16.16 pixels, clears its movement target and stops it.
voidfdActorSetMoveTarget (ACTOR *actor, FIXED x, FIXED y, FIXED z)Sends an actor towards (x, y, z), in 16.16 pixels.
voidfdActorRunUpdateAllFromHeap (void)Unused: copies fdActorUpdateAll (ARM code) to the heap, runs it once and frees it.
voidfdActorUpdateAllMotion (void)Advances the battle's actors by one tick, without running their scripts: steering towards a target or braking, gravity and bouncing, arrival, and turning to face the direction of travel.

Description

Actor motion, each tick, and the first actor script commands. Part of field.c.

Macros in detail

FLOAT_CYCLE_TICKS

#define FLOAT_CYCLE_TICKS 64

A floating actor's bob, one cycle of ActorScriptCycleTable over this many ticks; its rise and fall each tick is the table's value times its gravity over FLOAT_DIVISOR, or FLOAT_HIGH_DIVISOR with ACTOR_FLOATS_HIGH.

Referenced by fdActorUpdateAllOnField().

Definition at line 73 of file field_actor_motion.c.

FLOAT_DIVISOR

#define FLOAT_DIVISOR 64

Referenced by fdActorUpdateAllOnField().

Definition at line 74 of file field_actor_motion.c.

FLOAT_HIGH_DIVISOR

#define FLOAT_HIGH_DIVISOR 16

Referenced by fdActorUpdateAllOnField().

Definition at line 75 of file field_actor_motion.c.

Functions in detail

fdActorScriptSetBase

Sint32 fdActorScriptSetBase(ACTOR *interpreter)

SC_BASE: restarts the script at the next word, and returns 1 to run on.

References Sint32.

Referenced by ActorScriptCommandTable.

Definition at line 7 of file field_actor_motion.c.

fdActorScriptHideSprites

Sint32 fdActorScriptHideSprites(ACTOR *interpreter)

SC_HIDE_SPRITES: hides the actor's sprites and runs on.

References Sint32.

Referenced by ActorScriptCommandTable.

Definition at line 15 of file field_actor_motion.c.

fdActorScriptShowSprite

Sint32 fdActorScriptShowSprite(ACTOR *interpreter)

SC_SHOW_SPRITE: shows the actor's one sprite and runs on.

References Sint32.

Referenced by ActorScriptCommandTable.

Definition at line 23 of file field_actor_motion.c.

fdActorWaitForMove

void fdActorWaitForMove(void *actor)

Waits a tick at a time until an actor has arrived at its target, at most 600 ticks (ten seconds), after which it returns with the actor still on its way.

References fdActorIsTargetUnset(), Sint32 and sySynch().

Referenced by scActorFloatLogWithLeader(), scAltinPeakRollCart(), scAltinPeakStopCartAndJumpOff(), scBilibinCavePushTorch(), scBilibinPushStatueOrCrates(), scColosseumAzartMatchDousePipe(), scColosseumAzartMatchMoveRidingLog(), scColosseumAzartMatchPushPipeworksPipe(), scColosseumAzartMatchTalkToPipeworksAttendant(), scColosseumNavampaMatchRollLongLog(), scColosseumNavampaMatchRunActorToAndStand(), scColosseumNavampaMatchShovedByPiston(), scColosseumNavampaMatchShovedOffWalkway(), scColosseumNavampaMatchTalkToFreeClimbAttendant(), scColosseumNavampaMatchTalkToScalesAttendant(), scColosseumSatrageMatchDemonstrateLogPush(), scColosseumSatrageMatchKnockDownLog(), scColosseumSatrageMatchMoveRidingLog(), scColosseumSatrageMatchRollLogToMetatile(), scColossoPushActorAhead(), scColossoWalkActorToAndStand(), scCrossboneIsleRideLog(), scKalayPushTunnelStatue(), scKolimaForestFloodgateRollLog(), scLamakanDesertSlipDownSand(), scLeaderSlideOnIce(), scPushedActorAdvancePair(), scPushedActorRoll(), scSolSanctumEntrancePushStatue(), scTolbiShipMastPlaySecondAttack(), scVaultCavePushPillarAhead(), scVenusLighthouseAerieCombineSaturosAndMenardi(), scVenusLighthouseDriftLeader(), scVenusLighthousePushPillarAhead() and scWorldMapUseBlackOrb().

Definition at line 32 of file field_actor_motion.c.

fdActorIsTargetUnset

Bool fdActorIsTargetUnset(ACTOR *actor)

Returns 1 when the actor has no movement target: none of its target coordinates set, or for an actor moved by the ground (any motion flag) neither its target x nor z.

References Sint32.

Referenced by fdActorScriptWaitForArrival() and fdActorWaitForMove().

Definition at line 46 of file field_actor_motion.c.

fdActorSquare

static __inline__ Sint32 fdActorSquare(Sint32 value)

References Sint32.

Referenced by fdActorUpdateAllOnField().

Definition at line 77 of file field_actor_motion.c.

fdActorUpdateAllOnField

void fdActorUpdateAllOnField(void)

Advances all 64 actors by one tick, as fdActorUpdateAll does for the eight script-driven actors, with the field's extras: free flight in 3D, following the ground, floating, and solid actors that refuse to overlap.

References ActorScriptCommandTable, ActorScriptCycleTable, fdActorScriptCheckOverlap(), fdActorSquare(), fdMapGridGetTerrainHeight(), Sint32, syAtan(), syDivFX(), syMulFX(), sySquartFX() and sySquartIWRAM().

Referenced by fdActorSystemInit().

Definition at line 85 of file field_actor_motion.c.

fdActorSetPosAndResetMotion

void fdActorSetPosAndResetMotion(ACTOR *actor, FIXED x, FIXED y, FIXED z)

Places the actor at (x, y, z), in 16.16 pixels, clears its movement target and stops it.

Referenced by fdActorCreate() and fdActorScriptSetPosAndResetMotion().

Definition at line 471 of file field_actor_motion.c.

fdActorSetMoveTarget

void fdActorSetMoveTarget(ACTOR *actor, FIXED x, FIXED y, FIXED z)

Sends an actor towards (x, y, z), in 16.16 pixels. Within a pixel it arrives at once.

References Sint32, syDivFX(), syMulFX(), sySquartFX() and sySquartIWRAM().

Referenced by fdActorApproachWatchedActor(), fdActorMoveByKeys(), fdActorMoveOnWorldMap(), fdActorScriptMove(), fdActorScriptMoveBy(), fdActorScriptMoveLocal(), fdActorScriptMoveToWatched(), fdActorScriptWanderNearHome(), fdActorUpdatePlayerControl(), fdActorWander(), scColosseumNavampaMatchRunActorTo(), scColosseumNavampaMatchRunActorToAndStand(), scColossoWalkActorTo(), scColossoWalkActorToAndStand() and scFieldActorSetMoveTargetFX().

Definition at line 484 of file field_actor_motion.c.

fdActorRunUpdateAllFromHeap

void fdActorRunUpdateAllFromHeap(void)

Unused: copies fdActorUpdateAll (ARM code) to the heap, runs it once and frees it.

References fdActorUpdateAll(), fdActorUpdateAllCodeSize and syHeapRelease().

Definition at line 560 of file field_actor_motion.c.

fdActorUpdateAllMotion

void fdActorUpdateAllMotion(void)

Advances the battle's actors by one tick, without running their scripts: steering towards a target or braking, gravity and bouncing, arrival, and turning to face the direction of travel.

References Sint32, syAtan(), syDivFX(), syMulFX() and sySquartIWRAM().

Referenced by fdActorSystemInit().

Definition at line 572 of file field_actor_motion.c.