src/field/script_commands_movement_types.c
Actor scripts: moving, turning and the built-in movement types. More…
Included by script_commands.c.
Macros
| Name | Description | |
|---|---|---|
#define | FOLLOW_STRIDE 16 | A following actor (MOVEMENT_TYPE_FOLLOW_WATCHED) stays its timer's distance in pixels from the watched actor: from as far as that it walks toward a point this many pixels along the way for each timer's distance it is off, and nearer it stands. |
#define | FACING_TARGET_REACH 40 | fdActorFindNearestFacingTarget's reach in pixels, across and in height, and the distance beyond which an actor must be within FACING_TARGET_ANGLE of where it faces. |
#define | FACING_TARGET_HEIGHT 48 | |
#define | FACING_TARGET_NEAR 23 | |
#define | FACING_TARGET_ANGLE (TRIG_TURN * 3 / 16) |
Functions
| Name | Description | |
|---|---|---|
Sint32 | fdActorClearSpriteAndCollisionFlags (ACTOR *actor) | The SC_CALL function of MOVEMENT_TYPE_RESET_ACTION: clears an actor's sprite flags, so it has no shadow, and its collision flags, so nothing collides with it. |
Sint32 | fdActorMoveTowardTarget (ACTOR *actor) | The SC_CALL function of MOVEMENT_TYPE_FOLLOW_WATCHED: follows the watched actor. |
Sint32 | fdActorTurnTowardWatchedActor (ACTOR *actor) | The SC_CALL function of MOVEMENT_TYPE_FACE_LEADER: turns the actor toward its watched actor, at most FACING_STEP a tick. |
void | fdActorSetMovementType (ACTOR *actor, Sint32 movement) | 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 sprite) | Finds the nearest animated actor to self within FACING_TARGET_REACH pixels and under FACING_TARGET_HEIGHT of height, ignoring actors more than FACING_TARGET_ANGLE to either side once they are over FACING_TARGET_NEAR pixels away; returns it if its sprite is sprite (an SPR_ID), else NULL. |
Description
Actor scripts: moving, turning and the built-in movement types. Part of
script_commands.c.
Macros in detail
FOLLOW_STRIDE
#define FOLLOW_STRIDE 16
A following actor (MOVEMENT_TYPE_FOLLOW_WATCHED) stays its timer's distance
in pixels from the watched actor: from as far as that it walks toward a point
this many pixels along the way for each timer's distance it is off, and
nearer it stands.
Referenced by fdActorMoveTowardTarget().
Definition at line 10 of file script_commands_movement_types.c.
FACING_TARGET_REACH
#define FACING_TARGET_REACH 40
fdActorFindNearestFacingTarget's reach in pixels, across and in height, and
the distance beyond which an actor must be within FACING_TARGET_ANGLE of
where it faces.
Referenced by fdActorFindNearestFacingTarget().
Definition at line 14 of file script_commands_movement_types.c.
FACING_TARGET_HEIGHT
#define FACING_TARGET_HEIGHT 48
Referenced by fdActorFindNearestFacingTarget().
Definition at line 15 of file script_commands_movement_types.c.
FACING_TARGET_NEAR
#define FACING_TARGET_NEAR 23
Referenced by fdActorFindNearestFacingTarget().
Definition at line 16 of file script_commands_movement_types.c.
FACING_TARGET_ANGLE
#define FACING_TARGET_ANGLE (TRIG_TURN * 3 / 16)
Referenced by fdActorFindNearestFacingTarget().
Definition at line 17 of file script_commands_movement_types.c.
Functions in detail
fdActorClearSpriteAndCollisionFlags
Sint32 fdActorClearSpriteAndCollisionFlags(ACTOR *actor)
The SC_CALL function of MOVEMENT_TYPE_RESET_ACTION: clears an actor's sprite
flags, so it has no shadow, and its collision flags, so nothing collides with
it.
References fdActorSetSpriteFlagsStub() and Sint32.
Referenced by MovementTypeResetActionScript.
Definition at line 22 of file script_commands_movement_types.c.
fdActorMoveTowardTarget
Sint32 fdActorMoveTowardTarget(ACTOR *actor)
The SC_CALL function of MOVEMENT_TYPE_FOLLOW_WATCHED: follows the watched
actor.
References fdActorSelectAnimationStub(), fdActorSetMoveTargetStub(), Sint32 and sySquartIWRAM().
Referenced by MovementTypeFollowWatchedScript.
Definition at line 31 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 FACING_STEP a tick.
References Sint32 and syAtan().
Referenced by MovementTypeFaceLeaderScript.
Definition at line 72 of file script_commands_movement_types.c.
fdActorSetMovementType
void fdActorSetMovementType(ACTOR *actor, Sint32 movement)
Starts an actor's movement type: an MOVEMENT_TYPE, or any other value as the
actor script to run itself.
References fdActorGetById(), fdActorStartScriptStub(), MainRoutineStateWork, MovementTypeFaceLeaderScript, MovementTypeFollowWatchedScript, MovementTypeResetActionScript, MovementTypeStandScript, MovementTypeWanderCloseScript, MovementTypeWanderNearScript, MovementTypeWanderScript and Sint32.
Referenced by fdActorSetMovementTypeAndWaitById(), fdActorSetMovementTypeById(), fdActorWatchAndSetScript(), fdScriptSpawnActorPlacements(), fdTalkToActor() and scInit().
Definition at line 102 of file script_commands_movement_types.c.
fdActorFindNearestFacingTarget
ACTOR *fdActorFindNearestFacingTarget(ACTOR *self, Sint32 sprite)
Finds the nearest animated actor to self within FACING_TARGET_REACH pixels
and under FACING_TARGET_HEIGHT of height, ignoring actors more than
FACING_TARGET_ANGLE to either side once they are over FACING_TARGET_NEAR
pixels away; returns it if its sprite is sprite (an SPR_ID), else NULL.
References Sint32, syAtan() and sySquartIWRAM().
Referenced by fdTryJumpForward().
Definition at line 138 of file script_commands_movement_types.c.