Skip to Content
The Alchemy Project

src/field/field_actor_motion.c

Actors' motion each tick: their scripts, steering toward a target, falling, floating and riding a platform, and being sent somewhere. More…

Included by field.c.

Macros

NameDescription
#defineSCRIPT_COMMAND_MAX 63The highest script word read as a command, an index of ActorScriptCommandTable; a larger one is stepped over.
#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
Sint32fdActorScriptGoto (ACTOR *interpreter)SC_GOTO(script): goes on in script, from its first command, this tick.
Sint32fdActorScriptHideSprites (ACTOR *interpreter)SC_HIDE_SPRITES: clears spriteStorageKind, hiding the sprites, and moves on to the next command.
Sint32fdActorScriptShowSprite (ACTOR *interpreter)SC_SHOW_SPRITE: shows the actor's one sprite again (ACTOR_SPRITE_ONE) and moves on to the next command.
voidfdActorWaitForMove (ACTOR *actor)Waits, at most ACTOR_WAIT_TICKS_MAX ticks, for an actor to reach where it is going.
BoolfdActorIsTargetUnset (ACTOR *actor)TRUE 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.
Sint32fdActorHasArrived (ACTOR *actor)fdActorIsTargetUnset, for the scenes: 1 once the actor has reached its destination.
static __inline__ Sint32fdSquare (Sint32 value)A whole-pixel distance squared.
voidfdActorUpdateAllOnField (void)Advances every actor by one tick: their scripts and their motion, with free flight in 3D, following the ground, floating, and solid actors that refuse to overlap.
voidfdActorMoveWithCarriers (void)Each tick: an actor that walks on platforms (ACTOR_PRIORITY_WALKS_ON_PLATFORMS) and rides one, its carrier, moves with the carrier's last step; one standing on it as it rises or sinks is set on its top, 16 pixels up.
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.
voidfdActorListRunning (ACTOR *actor, ACTOR **out)Lists those of the first RUNNING_LIST_SLOTS actors whose script is running, in slot order, ended by NULL; out holds one more.

Variables

NameDescription
extern const SCRIPT_COMMAND_FNActorScriptCommandTable []The handler of each command.
extern const Sint32ActorScriptCycleTable []A floating actor's bob up and down, one period of a triangle wave.

Description

Actors' motion each tick: their scripts, steering toward a target, falling, floating and riding a platform, and being sent somewhere. Part of field.c.

Macros in detail

SCRIPT_COMMAND_MAX

#define SCRIPT_COMMAND_MAX 63

The highest script word read as a command, an index of ActorScriptCommandTable; a larger one is stepped over.

Referenced by fdActorUpdateAllOnField().

Definition at line 86 of file field_actor_motion.c.

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 90 of file field_actor_motion.c.

FLOAT_DIVISOR

#define FLOAT_DIVISOR 64

Referenced by fdActorUpdateAllOnField().

Definition at line 91 of file field_actor_motion.c.

FLOAT_HIGH_DIVISOR

#define FLOAT_HIGH_DIVISOR 16

Referenced by fdActorUpdateAllOnField().

Definition at line 92 of file field_actor_motion.c.

Functions in detail

fdActorScriptGoto

Sint32 fdActorScriptGoto(ACTOR *interpreter)

SC_GOTO(script): goes on in script, from its first command, this tick.

References Sint32.

Referenced by ActorScriptCommandTable.

Definition at line 7 of file field_actor_motion.c.

fdActorScriptHideSprites

Sint32 fdActorScriptHideSprites(ACTOR *interpreter)

SC_HIDE_SPRITES: clears spriteStorageKind, hiding the sprites, and moves on to the next command.

References Sint32.

Referenced by ActorScriptCommandTable.

Definition at line 17 of file field_actor_motion.c.

fdActorScriptShowSprite

Sint32 fdActorScriptShowSprite(ACTOR *interpreter)

SC_SHOW_SPRITE: shows the actor's one sprite again (ACTOR_SPRITE_ONE) and moves on to the next command.

References Sint32.

Referenced by ActorScriptCommandTable.

Definition at line 26 of file field_actor_motion.c.

fdActorWaitForMove

void fdActorWaitForMove(ACTOR *actor)

Waits, at most ACTOR_WAIT_TICKS_MAX ticks, for an actor to reach where it is going.

References fdActorIsTargetUnset(), Sint32 and sySynch().

Referenced by scAirsRockBlowGust(), scAirsRockInsideBlowGust(), scAirsRockInsideRideWhirlwind(), scAirsRockInsideRiseOnLift(), scAnemosInnerSanctumDullahanOpenTheWay(), scAquaRockRideStreamUp(), scDehkanPlateauCannonDropsPoundCube(), scFieldActorWaitForMove(), scGabombaStatueChamberDropIntoHole(), scGabombaStatueChamberGabombaNamesWitchDoctor(), scIsletCaveRideLog(), scKandoreanTempleClimbDownTheLadder(), scKibomboClimbDownLadder(), scKibomboEnterDoor(), scTrialRoadPushLog(), scTundariaTowerSlidePillar() and scYampiDesertClimbDownLadder().

Definition at line 35 of file field_actor_motion.c.

fdActorIsTargetUnset

Bool fdActorIsTargetUnset(ACTOR *actor)

TRUE 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 fdActorHasArrived(), fdActorScriptWaitForArrival() and fdActorWaitForMove().

Definition at line 50 of file field_actor_motion.c.

fdActorHasArrived

Sint32 fdActorHasArrived(ACTOR *actor)

fdActorIsTargetUnset, for the scenes: 1 once the actor has reached its destination. Airs Rock waits on it while the lift carries the leader up.

References fdActorIsTargetUnset() and Sint32.

Referenced by scAirsRockBlowGust(), scAirsRockInsideBlowGust(), scAirsRockInsideRiseOnLift(), scEasternAlhafraPoundStake(), scLeaderSlideOnIceFromEdge(), scSeaOfTimeFollowChannel() and scSeaOfTimePushBackInRoughWater().

Definition at line 76 of file field_actor_motion.c.

fdSquare

static __inline__ Sint32 fdSquare(Sint32 value)

A whole-pixel distance squared.

References Sint32.

Referenced by fdActorUpdateAllOnField().

Definition at line 95 of file field_actor_motion.c.

fdActorUpdateAllOnField

void fdActorUpdateAllOnField(void)

Advances every actor by one tick: their scripts and their motion, with free flight in 3D, following the ground, floating, and solid actors that refuse to overlap.

References ActorScriptCommandTable, ActorScriptCycleTable, fdActorScriptCheckOverlap(), fdMapGridGetTerrainHeight(), fdSquare(), Sint32, syAtan(), syDivFX(), syIWRAMMulFX(), sySquartFX() and sySquartIWRAM().

Referenced by fdActorSystemInit().

Definition at line 103 of file field_actor_motion.c.

fdActorMoveWithCarriers

void fdActorMoveWithCarriers(void)

Each tick: an actor that walks on platforms (ACTOR_PRIORITY_WALKS_ON_PLATFORMS) and rides one, its carrier, moves with the carrier's last step; one standing on it as it rises or sinks is set on its top, 16 pixels up.

References Sint32.

Referenced by fdActorSystemInit().

Definition at line 524 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(), fdActorScriptResetToOrigin(), fdActorScriptSetPosAndResetMotion(), scCrumblingPillarStep(), scCrumblingPillarStepWithStandIn(), scDehkanPlateauInitEntrance(), scDehkanPlateauStepOnCrack(), scEasternAlhafraShipBriggsIsCaught(), scFieldActorSetPosAndResetMotion(), scIsletsTradeWithCow(), scJupiterLighthouseUpdateBeam(), scKandoreanTempleSinkIntoTheSteam(), scKandoreanTempleStartVentRoom(), scKibomboAkafubuOffersCrystal(), scKibomboCarryBlackCrystal(), scKibomboGabombaNotPleased(), scKibomboGabombaRespondsToGift(), scKibomboInitStatueGroundsByDay(), scKibomboInitStatueGroundsCeremony(), scKibomboPresentJewelToGabomba(), scKibomboSetStatueMouth(), scKibomboSetStatueTongue(), scKibomboShakeInPlace(), scLeaderCheckCrumblingStep(), scLemurianShipSetUpHold(), scLemurianShipSetUpPipeRoom(), scLemurianShipSetUpTwoJellyRoom(), scMagmaRockInsideStepOnTrap(), scMagmaRockStepOnCrumblingPillar(), scMagmaRockStepOnTrap(), scShamanVillageSetUpNorthEnd(), scShrineOfTheSeaGodInitBrokenBridges(), scShrineOfTheSeaGodLandBrokenBridge(), scTrialRoadCrumblePillar(), scTrialRoadStepOnTrap(), scYampiDesertCavePushLog(), scYampiDesertCaveStopLeaderAtLog() and scYampiDesertDropScoopGem().

Definition at line 570 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(), sySquartFX() and sySquartIWRAM().

Referenced by fdActorApproachWatchedActor(), fdActorCrossRope(), fdActorCrossTightrope(), fdActorFlyOnWorldMap(), fdActorMoveAsSand(), fdActorMoveAsSandOnWorldMap(), fdActorMoveByKeys(), fdActorMoveOnWorldMap(), fdActorSailOnMap(), fdActorSailOnWorldMap(), fdActorScriptMove(), fdActorScriptMoveBy(), fdActorScriptMoveLocal(), fdActorScriptMoveToWatched(), fdActorScriptMoveXZ(), fdActorScriptWanderNearHome(), fdActorUpdateHoverControl(), fdActorUpdatePlayerControl(), fdActorUpdateWalkingControl(), fdActorWander(), scAirsRockBlowGust(), scAirsRockInsideBlowGust(), scAirsRockInsideRideWhirlwind(), scAirsRockInsideRiseOnLift(), scAnemosInnerSanctumDullahanOpenTheWay(), scAquaRockPickRandomSpot(), scAquaRockRideStreamUp(), scFieldActorSetMoveTargetFX(), scGabombaStatueChamberGabombaNamesWitchDoctor(), scIsletCaveRideLog(), scKibomboEnterDoor(), scLeaderSlideOnIceFromEdge(), scLemurianShipWalkIntoPassage(), scMadraCatacombsEnterDoor(), scMadraCatacombsOpenDoorAndEnter(), scSeaOfTimeFollowChannel(), scSeaOfTimePushBackInRoughWater(), scShamanVillageEnterDoor(), scTrialRoadGaspFlees(), scTrialRoadMoveRival(), scTrialRoadPushLog(), scTrialRoadReachPeakFirst(), scTundariaTowerSlidePillar(), scYallamRunSongPath(), scYampiDesertCavePushLog() and scYampiDesertClimbDownLadder().

Definition at line 583 of file field_actor_motion.c.

fdActorListRunning

void fdActorListRunning(ACTOR *actor, ACTOR **out)

Lists those of the first RUNNING_LIST_SLOTS actors whose script is running, in slot order, ended by NULL; out holds one more.

Referenced by fdActorUpdateAllMotion().

Definition at line 653 of file field_actor_motion.c.