From d53d34b3c57b70607a028cf4bfcec1182fb2ba74 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 18 Jan 2024 09:36:39 -0300 Subject: [PATCH] Restored missing code --- src/event_object_movement.c | 68 ++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 6096186c89..43e3abb2de 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1977,35 +1977,55 @@ static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) return GetMonInfo(GetFirstLiveMon(), species, form, shiny); } -void UpdateFollowingPokemon(void) { // Update following pokemon if any - struct ObjectEvent *objEvent = GetFollowerObject(); - u16 species; - bool8 shiny; - u8 form; - // Avoid spawning large (>32x32) follower pokemon inside buildings - if (GetFollowerInfo(&species, &form, &shiny) && !(gMapHeader.mapType == MAP_TYPE_INDOOR && SpeciesToGraphicsInfo(species, 0)->height > 32) && !FlagGet(FLAG_TEMP_HIDE_FOLLOWER)) - { - if (objEvent == NULL) { // Spawn follower - struct ObjectEventTemplate template = { - .localId = OBJ_EVENT_ID_FOLLOWER, - .graphicsId = OBJ_EVENT_GFX_MON_BASE + species, - .flagId = 0, - .x = gSaveBlock1Ptr->pos.x, - .y = gSaveBlock1Ptr->pos.y, - // If player active, copy player elevation - .elevation = gObjectEvents[gPlayerAvatar.objectEventId].active ? gObjectEvents[gPlayerAvatar.objectEventId].currentElevation : 3, - .movementType = MOVEMENT_TYPE_FOLLOW_PLAYER, - // store form info in template - .trainerRange_berryTreeId = (form & 0x1F) | (shiny << 5), - }; - objEvent = &gObjectEvents[SpawnSpecialObjectEvent(&template)]; - objEvent->invisible = TRUE; +// Update following pokemon if any +void UpdateFollowingPokemon(void) +{ + struct ObjectEvent *objEvent = GetFollowerObject(); + struct Sprite *sprite; + u16 species; + bool8 shiny; + u8 form; + // Avoid spawning large (>32x32) follower pokemon inside buildings + if (GetFollowerInfo(&species, &form, &shiny) + && !(gMapHeader.mapType == MAP_TYPE_INDOOR + && SpeciesToGraphicsInfo(species, 0)->height > 32) + && !FlagGet(FLAG_TEMP_HIDE_FOLLOWER)) + { + if (objEvent == NULL) + { + // Spawn follower + struct ObjectEventTemplate template = + { + .localId = OBJ_EVENT_ID_FOLLOWER, + .graphicsId = OBJ_EVENT_GFX_MON_BASE + species, + .flagId = 0, + .x = gSaveBlock1Ptr->pos.x, + .y = gSaveBlock1Ptr->pos.y, + // If player active, copy player elevation + .elevation = gObjectEvents[gPlayerAvatar.objectEventId].active ? gObjectEvents[gPlayerAvatar.objectEventId].currentElevation : 3, + .movementType = MOVEMENT_TYPE_FOLLOW_PLAYER, + // store form info in template + .trainerRange_berryTreeId = (form & 0x1F) | (shiny << 5), + }; + objEvent = &gObjectEvents[SpawnSpecialObjectEvent(&template)]; + objEvent->invisible = TRUE; + } + sprite = &gSprites[objEvent->spriteId]; + // Follower appearance changed; move to player and set invisible + if (species != OW_SPECIES(objEvent) || shiny != objEvent->shiny || form != OW_FORM(objEvent)) + { + MoveObjectEventToMapCoords(objEvent, + gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x, + gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y); + FollowerSetGraphics(objEvent, species, form, shiny); + objEvent->invisible = TRUE; + } + sprite->data[6] = 0; // set animation data } else { RemoveFollowingPokemon(); } - } } // Remove follower object. Idempotent.