actor_motion.c
Actor scripts: moving, turning and the built-in actions.
games/tbs/src/object/psynergy_effects/actor_motion.c on GitHub
Actor scripts: moving, turning and the built-in actions. Part of psynergy_effects.c, compiled only through it.
Functions
Object_ClearChildAndCollisionFlags
s32 Object_ClearChildAndCollisionFlags(void *obj)
Script step of action 7: clears an object's sprite flags and its collision flags, so nothing collides with it. Returns 0, so SC_CALL moves on at once (gObjectMotion_ResetActionScript then ends).
ObjectMotion_MoveTowardTarget
s32 ObjectMotion_MoveTowardTarget(struct ObjectRuntime *object)
Script step of action 5: follows the linked object. While it is at least action pixels away the object walks (animation 2) toward a point 16 / action of the way there, so with action 16 it heads for the linked object itself; closer, it stands (animation 1). Returns 1, so SC_CALL runs it again every frame until the actor's script is replaced.
ObjectMotion_TurnTowardLinkedTarget
s32 ObjectMotion_TurnTowardLinkedTarget(struct ObjectRuntime *object)
Script step of action 6: turns the object toward its linked object, at most 1/16 turn a frame. Returns 1, so SC_CALL runs it again every frame until the actor's script is replaced.
ObjectMotion_SetActionCallback
void ObjectMotion_SetActionCallback(struct ObjectRuntime *object, s32 action)
Starts an actor's action script: 1 to 4 the fixed action scripts, 5 follow the linked object, 6 face the leader, 7 reset. Any other value is itself the script to run. In scripts.s, action 1's script only ends, and 2 to 4 wander about where the actor stands (SC_WANDER_HOME): 2 and 3 at the same speed, within 16 and 8 pixels, and 4 within 6 pixels at its own speed (field.h). Reached from a placement's behavior column (object/actors.c), from Scene_TalkToActor after a talk (object/events.c), from the actor commands and from Lalivero's interiors (Engine_ActorSetActionCallback).
Used by Event_SpawnObjectTable, ObjectMotion_EnableActionAndSetCallback, Object_LinkObjectAndSetCallback, Object_SetActionCallbackAndRefreshById, Scene_TalkToActor.
Object_FindNearestFacingTarget
struct ObjectRuntime *Object_FindNearestFacingTarget(struct ObjectRuntime *self, s32 sprite)
Finds the nearest animated object to self within 40 pixels and 48 pixels of height, ignoring objects more than 3/16 turn to either side once they are over 23 pixels away. Returns it if it shows sprite, otherwise NULL: the sprite is tested only on the nearest object, so a nearer object of another sprite hides a matching one. Field_TryJumpForward (climbing.c) asks it for a platform, sprite 207 or 205, where the leader lands.
Used by Field_TryJumpForward.