Restored missing code
This commit is contained in:
parent
381a0bf8a1
commit
d53d34b3c5
1 changed files with 44 additions and 24 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue