Skip to Content
The Alchemy Project

src/field/script_commands_movement_types.c

Included by script_commands.c.

Macros

NameDescription
#defineFACING_TARGET_REACH 40fdActorFindNearestFacingTarget's reach in pixels, and the distance past which an actor counts only within 3/16 turn of the facing.
#defineFACING_TARGET_NEAR 23

Functions

NameDescription
voidfdEffectSetAttached (Sint32 actorId, Sint32 flags)The script command "actor set attached effect", by ATTACHED_EFFECT_FLAG: removes the actor attached to an actor, attaches one (SPRITE_RAY_ARC, animation 1) unless one already is, or shows a one-off one (animation 2) that ends by itself (ActorWaitScript).
Sint32fdActorClearSpriteAndCollisionFlags (void *object)The SC_CALL function of MOVEMENT_TYPE_CLEAR_COLLISION: clears an actor's sprite flags and its collision flags, so nothing collides with it.
Sint32fdActorClearSpriteFlags (ACTOR *object)Actor script hook: clears the actor's sprite flags (outline and shadow).
Sint32fdActorIgnoreRises (ACTOR *actor)Actor script hook: the actor takes its metatiles' priority even where the ground in front rises.
Sint32fdActorMoveTowardTarget (ACTOR *actor)The SC_CALL function of MOVEMENT_TYPE_FOLLOW_WATCHED: walks toward the watched actor, setting out each tick for 16/timer of the way there, and stands once within its timer's pixels of it.
Sint32fdActorTurnTowardWatchedActor (ACTOR *actor)The SC_CALL function of MOVEMENT_TYPE_FACE_LEADER: turns the actor toward its watched actor, at most 1/16 turn a tick.
voidfdActorWatchActor (ACTOR *actor, ACTOR *target)Keeps an actor turning to face another.
Sint32fdActorTakeLeaderLayer (ACTOR *actor)Gives an actor the leader's sprite priority, so it is drawn in front of and behind what he is, and keeps it there.
voidfdActorSetMovementType (ACTOR *actor, Sint32 kind)Starts an actor's movement type: an MOVEMENT_TYPE, or any other value as the actor script to run itself.
ACTOR *fdActorFindNearestFacingTarget (ACTOR *self, Sint32 id)Finds the nearest animated actor to self within FACING_TARGET_REACH and 48 pixels of height, ignoring actors more than 3/16 turn to either side once they are past FACING_TARGET_NEAR; returns it if its first sprite animation is sprite id, as The Broken Seal's.

Variables

NameDescription
extern const Uint8ActorWaitScript []Actor movement helpers and movement types.
extern const Uint8MovementTypeStandScript []MOVEMENT_TYPE_STAND: the actor stands where it was placed.
extern const Uint8MovementTypeWanderScript []MOVEMENT_TYPE_WANDER: wanders near home, pausing between steps.
extern const Uint8MovementTypeWanderNearScript []MOVEMENT_TYPE_WANDER_NEAR: wanders a shorter way near home.
extern const Uint8MovementTypeWanderCloseScript []MOVEMENT_TYPE_WANDER_CLOSE: wanders near home without pausing.
extern const Uint8MovementTypeFollowWatchedScript []MOVEMENT_TYPE_FOLLOW_WATCHED: moves the actor toward its watched actor every tick.
extern const Uint8MovementTypeFaceLeaderScript []MOVEMENT_TYPE_FACE_LEADER: turns the actor toward its watched actor, the leader, every tick.
extern const Uint8MovementTypeClearCollisionScript []MOVEMENT_TYPE_CLEAR_COLLISION: clears the actor's sprite and collision flags.
extern const Uint8MovementTypeSquashScript []MOVEMENT_TYPE_SQUASH: the actor bounces on the spot, squashing and stretching, for ever.
extern const Uint8MovementTypeTakeLeaderLayerScript []MOVEMENT_TYPE_TAKE_LEADER_LAYER: keeps the leader's display layer, every tick.
extern const Uint8MovementTypeIgnoreRisesScript []MOVEMENT_TYPE_IGNORE_RISES: the actor takes its metatiles' priority even where the ground in front rises.
extern const Uint8MovementTypeClearSpriteFlagsScript []MOVEMENT_TYPE_CLEAR_SPRITE_FLAGS: clears the actor's sprite flags.

Macros in detail

FACING_TARGET_REACH

#define FACING_TARGET_REACH 40

fdActorFindNearestFacingTarget's reach in pixels, and the distance past which an actor counts only within 3/16 turn of the facing.

Referenced by fdActorFindNearestFacingTarget().

Definition at line 252 of file script_commands_movement_types.c.

FACING_TARGET_NEAR

#define FACING_TARGET_NEAR 23

Referenced by fdActorFindNearestFacingTarget().

Definition at line 253 of file script_commands_movement_types.c.

Functions in detail

fdEffectSetAttached

void fdEffectSetAttached(Sint32 actorId, Sint32 flags)

The script command "actor set attached effect", by ATTACHED_EFFECT_FLAG: removes the actor attached to an actor, attaches one (SPRITE_RAY_ARC, animation 1) unless one already is, or shows a one-off one (animation 2) that ends by itself (ActorWaitScript).

References ActorWaitScript, fdActorCreateStub(), fdActorIsNotAttachedEffect(), fdActorLookup(), fdActorReleaseStub(), fdActorSelectAnimationStub(), fdActorStartScriptStub(), fdEffectCopyWatchedActorPos() and Sint32.

Referenced by fdActorSetAttachedEffect(), fdMadPlantLeapAtLeader(), fdUpdateWalking(), scAirsRockInsideLandInHall(), scAlhafraMadransArrive(), scAlhafraPirateSeesMadrasMayor(), scAlhafraSailorToldToWork(), scAncientLemuriaMeetTheLemurians(), scAquaRockDropDownFalls(), scChampaCliffCavesObabaForgesTrident(), scChampaCliffCavesObabaMournsSalamander(), scContigoReturnToNewHome(), scContigoScatterWeedsOverBrambleSeed(), scDehkanPlateauCannonCornered(), scDehkanPlateauLandFromFall(), scGabombaStatueChamberWhereIsTheOrb(), scIzumoScatterWeedsOverFirstAntidote(), scIzumoScatterWeedsOverLuckyMedal(), scIzumoScatterWeedsOverSecondAntidote(), scKandoreanTempleLandFromAbove(), scKandoreanTempleMeetPoi(), scKandoreanTempleSinkIntoTheSteam(), scKandoreanTempleTestTheStudents(), scKibomboAkafubuOffersCrystal(), scKibomboGabombaNotPleased(), scKibomboGabombaRespondsToGift(), scKibomboPiersJoinsParty(), scKibomboPiersTakesPartyForEnemies(), scShrineOfTheSeaGodRockOnBridge(), scShrineOfTheSeaGodThrowRopeAgain(), scTundariaTowerJumpDownSlide(), scTundariaTowerLandFromSlide(), scYampiDesertLandAndFightKingScorpion() and scYampiDesertTrapKingScorpion().

Definition at line 8 of file script_commands_movement_types.c.

fdActorClearSpriteAndCollisionFlags

Sint32 fdActorClearSpriteAndCollisionFlags(void *object)

The SC_CALL function of MOVEMENT_TYPE_CLEAR_COLLISION: clears an actor's sprite flags and its collision flags, so nothing collides with it.

References fdActorSetSpriteFlagsStub() and Sint32.

Referenced by MovementTypeClearCollisionScript.

Definition at line 75 of file script_commands_movement_types.c.

fdActorClearSpriteFlags

Sint32 fdActorClearSpriteFlags(ACTOR *object)

Actor script hook: clears the actor's sprite flags (outline and shadow).

References fdActorSetSpriteFlagsStub() and Sint32.

Referenced by MovementTypeClearSpriteFlagsScript.

Definition at line 83 of file script_commands_movement_types.c.

fdActorIgnoreRises

Sint32 fdActorIgnoreRises(ACTOR *actor)

Actor script hook: the actor takes its metatiles' priority even where the ground in front rises.

References Sint32.

Referenced by MovementTypeIgnoreRisesScript.

Definition at line 91 of file script_commands_movement_types.c.

fdActorMoveTowardTarget

Sint32 fdActorMoveTowardTarget(ACTOR *actor)

The SC_CALL function of MOVEMENT_TYPE_FOLLOW_WATCHED: walks toward the watched actor, setting out each tick for 16/timer of the way there, and stands once within its timer's pixels of it.

References fdActorSelectAnimationStub(), Sint32 and sySquartIWRAM().

Referenced by MovementTypeFollowWatchedScript.

Definition at line 100 of file script_commands_movement_types.c.

fdActorTurnTowardWatchedActor

Sint32 fdActorTurnTowardWatchedActor(ACTOR *actor)

The SC_CALL function of MOVEMENT_TYPE_FACE_LEADER: turns the actor toward its watched actor, at most 1/16 turn a tick.

References Sint32 and syAtan().

Referenced by fdActorWatchActor() and MovementTypeFaceLeaderScript.

Definition at line 142 of file script_commands_movement_types.c.

fdActorWatchActor

void fdActorWatchActor(ACTOR *actor, ACTOR *target)

Keeps an actor turning to face another.

References fdActorTurnTowardWatchedActor().

Referenced by scChampaCliffCavesSailorSurrenders().

Definition at line 171 of file script_commands_movement_types.c.

fdActorTakeLeaderLayer

Sint32 fdActorTakeLeaderLayer(ACTOR *actor)

Gives an actor the leader's sprite priority, so it is drawn in front of and behind what he is, and keeps it there.

References fdActorLookup(), MainRoutineStateWork and Sint32.

Referenced by MovementTypeTakeLeaderLayerScript, scAlhafraManorKeepToTheLeadersLayer(), scAlhafranCaveTakeLeadersLayer(), scAlhafraTakeLeadersLayer() and scLemuriaTakeLeaderLayer().

Definition at line 179 of file script_commands_movement_types.c.

fdActorSetMovementType

void fdActorSetMovementType(ACTOR *actor, Sint32 kind)

Starts an actor's movement type: an MOVEMENT_TYPE, or any other value as the actor script to run itself.

References fdActorGetById(), fdActorStartScriptStub(), MainRoutineStateWork, MovementTypeClearCollisionScript, MovementTypeClearSpriteFlagsScript, MovementTypeFaceLeaderScript, MovementTypeFollowWatchedScript, MovementTypeIgnoreRisesScript, MovementTypeSquashScript, MovementTypeStandScript, MovementTypeTakeLeaderLayerScript, MovementTypeWanderCloseScript, MovementTypeWanderNearScript, MovementTypeWanderScript and Sint32.

Referenced by fdActorSetMovementTypeAndWaitById(), fdActorSetMovementTypeById(), fdActorWatchAndSetScript(), fdScriptSpawnActorTable(), fdTalkToActor(), scAirsRockInsideReadRevealTablet(), scAlhafranCaveChauchaAndEoleoVisit(), scAlhafranCaveSetUpCave(), scChampaCliffCavesSailorTurnsAway(), scChampaTalkToPracticingBoy(), scInit(), scMagmaRockInsideReadBlazeTablet() and scSuhallaGateSetUpRoad().

Definition at line 209 of file script_commands_movement_types.c.

fdActorFindNearestFacingTarget

ACTOR *fdActorFindNearestFacingTarget(ACTOR *self, Sint32 id)

Finds the nearest animated actor to self within FACING_TARGET_REACH and 48 pixels of height, ignoring actors more than 3/16 turn to either side once they are past FACING_TARGET_NEAR; returns it if its first sprite animation is sprite id, as The Broken Seal's.

References Sint32, syAtan() and sySquartIWRAM().

Referenced by fdTryJumpForward().

Definition at line 259 of file script_commands_movement_types.c.