From 5e1c6e0f2520864a4c5dbb0d9439c7dd2f3fc576 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Sat, 30 Apr 2022 14:54:47 -0400 Subject: [PATCH 1/2] Fixed `GetFollowerObject` being able to sometimes return removed/inactive objects. --- src/event_object_movement.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 733c2a7b2b..d421da5605 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1680,7 +1680,7 @@ struct Pokemon * GetFirstLiveMon(void) { // Return address of first conscious pa struct ObjectEvent * GetFollowerObject(void) { // Return follower ObjectEvent or NULL u8 i; for (i=0; i < OBJECT_EVENTS_COUNT; i++) { - if (gObjectEvents[i].localId == OBJ_EVENT_ID_FOLLOWER) + if (gObjectEvents[i].localId == OBJ_EVENT_ID_FOLLOWER && gObjectEvents[i].active) return &gObjectEvents[i]; } return NULL; From 7d4015dc5f2ee5526686f941421f05c10a8fbd17 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Sat, 30 Apr 2022 16:48:18 -0400 Subject: [PATCH 2/2] Changed default follower elevation to player's current elevation. --- src/event_object_movement.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index d421da5605..9c7fc56985 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1762,7 +1762,8 @@ void UpdateFollowingPokemon(void) { // Update following pokemon if any .graphicsId = OBJ_EVENT_GFX_OW_MON, .x = gSaveBlock1Ptr->pos.x, .y = gSaveBlock1Ptr->pos.y, - .elevation = 3, + // If player active, copy player elevation + .elevation = gObjectEvents[gPlayerAvatar.objectEventId].active ? gObjectEvents[gPlayerAvatar.objectEventId].currentElevation : 3, .movementType = MOVEMENT_TYPE_FOLLOW_PLAYER, }; objEvent = &gObjectEvents[SpawnSpecialObjectEvent(&template)];