From 92b76a98cb6b8b60054f4da5191e635a5cb15d84 Mon Sep 17 00:00:00 2001 From: Ariel Antonitis Date: Wed, 24 Jun 2020 21:16:49 -0400 Subject: [PATCH] Fixed follower behavior when seen by trainers. --- include/event_object_movement.h | 1 + src/trainer_see.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 37b0f8c6c5..b6b1551950 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -97,6 +97,7 @@ struct Pokemon * GetFirstLiveMon(void); void UpdateFollowingPokemon(void); void RemoveFollowingPokemon(void); struct ObjectEvent * GetFollowerObject(void); +u8 GetDirectionToFace(s16, s16, s16, s16); void TrySpawnObjectEvents(s16, s16); u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction); u8 AddPseudoObjectEvent(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority); diff --git a/src/trainer_see.c b/src/trainer_see.c index 9ce25ce23b..b87e4dcb57 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -462,12 +462,23 @@ static bool8 TrainerSeeIdle(u8 taskId, struct Task *task, struct ObjectEvent *tr static bool8 TrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) { u8 direction; + struct ObjectEvent *followerObj = GetFollowerObject(); ObjectEventGetLocalIdAndMap(trainerObj, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON); direction = GetFaceDirectionMovementAction(trainerObj->facingDirection); ObjectEventSetHeldMovement(trainerObj, direction); - task->tFuncId++; // TRSEE_EXCLAMATION_WAIT + if (followerObj) { + struct ObjectEvent *playerObj = &gObjectEvents[gPlayerAvatar.objectEventId]; + s16 x = playerObj->currentCoords.x; + s16 y = playerObj->currentCoords.y; + // Move back player's location by facing direction + MoveCoords(GetOppositeDirection(playerObj->facingDirection), &x, &y); + direction = GetDirectionToFace(followerObj->previousCoords.x, followerObj->previousCoords.y, x, y); + followerObj->singleMovementActive = FALSE; + ObjectEventSetHeldMovement(followerObj, GetWalkNormalMovementAction(direction)); + } + task->tFuncId++; return TRUE; }