From 8f5bef1ec578192c58239748b837fb56b8d8a260 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 25 Oct 2020 09:46:28 -0600 Subject: [PATCH] follower attaches to riding player --- include/constants/global.h | 2 ++ src/field_effect.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/constants/global.h b/include/constants/global.h index 55830ae8b2..2f256e7bbc 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -117,4 +117,6 @@ #define DIR_NORTHWEST 7 #define DIR_NORTHEAST 8 +#define FOLLOW_ME_IMPLEMENTED FALSE + #endif // GUARD_CONSTANTS_GLOBAL_H diff --git a/src/field_effect.c b/src/field_effect.c index 1ecbeb482f..f524d90583 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -245,6 +245,10 @@ static bool8 RockClimb_WaitStopRockClimb(struct Task *task, struct ObjectEvent * static bool8 RockClimb_StopRockClimbInit(struct Task *task, struct ObjectEvent *objectEvent); // Static RAM declarations +#if FOLLOW_ME_IMPLEMENTED +static void TryAttachFollowerToPlayer(void); +#endif + static u8 sActiveList[32]; // External declarations @@ -1882,6 +1886,10 @@ static bool8 WaterfallFieldEffect_ContinueRideOrEnd(struct Task *task, struct Ob { if (!ObjectEventClearHeldMovementIfFinished(objectEvent)) return FALSE; + + #if FOLLOW_ME_IMPLEMENTED + TryAttachFollowerToPlayer(); + #endif if (MetatileBehavior_IsWaterfall(objectEvent->currentMetatileBehavior)) { @@ -4085,6 +4093,10 @@ static bool8 RockClimb_ContinueRideOrEnd(struct Task *task, struct ObjectEvent * if (!ObjectEventClearHeldMovementIfFinished(objectEvent)) return FALSE; + #if FOLLOW_ME_IMPLEMENTED + TryAttachFollowerToPlayer(); + #endif + PlayerGetDestCoords(&task->tDestX, &task->tDestY); MoveCoords(objectEvent->movementDirection, &task->tDestX, &task->tDestY); if (MetatileBehavior_IsRockClimbable(MapGridGetMetatileBehaviorAt(task->tDestX, task->tDestY))) @@ -4140,6 +4152,19 @@ bool8 IsRockClimbActive(void) } +#if FOLLOW_ME_IMPLEMENTED +static void TryAttachFollowerToPlayer(void) +{ + if (gFollowerState.inProgress) + { + //Keep the follow close by while its hidden to prevent it from going too far out of view + struct ObjectEvent* player = &gObjectEvents[gPlayerAvatar.eventObjectId]; + struct ObjectEvent* follower = &gObjectEvents[GetFollowerMapObjId()]; + MoveObjectEventToMapCoords(follower, player->currentCoords.x, player->currentCoords.y); + } +} +#endif + #undef tState #undef tDestX #undef tDestY