feat: make follower sidestep or backstep with player during scripts

This commit is contained in:
Ariel A 2024-12-30 20:44:07 -05:00
parent 5536a5535c
commit 57a198bca0

View File

@ -5189,6 +5189,7 @@ bool8 MovementType_FollowPlayer_Moving(struct ObjectEvent *objectEvent, struct S
if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) {
#endif
objectEvent->singleMovementActive = 0;
objectEvent->facingDirectionLocked = FALSE;
if (sprite->sTypeFuncId) // restore nonzero state
sprite->sTypeFuncId = 1;
} else if (objectEvent->movementActionId < MOVEMENT_ACTION_EXIT_POKEBALL) {
@ -5258,6 +5259,15 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
// Follow player
direction = GetDirectionToFace(x, y, targetX, targetY);
// During a script, if player sidesteps or backsteps,
// mirror player's direction instead
if (ArePlayerFieldControlsLocked()
&& gObjectEvents[gPlayerAvatar.objectEventId].facingDirection != gObjectEvents[gPlayerAvatar.objectEventId].movementDirection
) {
direction = gObjectEvents[gPlayerAvatar.objectEventId].movementDirection;
objectEvent->facingDirectionLocked = TRUE;
}
MoveCoords(direction, &x, &y);
#ifdef MB_SIDEWAYS_STAIRS_RIGHT_SIDE // https://github.com/ghoulslash/pokeemerald/tree/sideways_stairs
GetCollisionAtCoords(objectEvent, x, y, direction); // Sets directionOverwrite for stairs