Skip to content

Commit

Permalink
Add option to hide substitute followers
Browse files Browse the repository at this point in the history
  • Loading branch information
Bassoonian committed Jun 11, 2024
1 parent 0574d00 commit 3fadaaf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion include/config/overworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@
// Follower Pokémon
#define OW_FOLLOWERS_ENABLED TRUE // Enables follower Pokémon, HGSS style.
#define OW_MON_BOBBING TRUE // If true, follower pokemon will bob up and down during their idle & walking animations
#define LARGE_OW_SUPPORT TRUE // If true, adds a small amount of overhead to OW code so that large (48x48, 64x64) OWs will display correctly under bridges, etc.
#define OW_LARGE_OW_SUPPORT TRUE // If true, adds a small amount of overhead to OW code so that large (48x48, 64x64) OWs will display correctly under bridges, etc.
#define OW_FOLLOWERS_SHARE_PALETTE FALSE // [WIP!! NOT ALL PALETTES HAVE BEEN ADJUSTED FOR THIS!!] If TRUE, follower palettes are taken from battle sprites.
#define OW_MON_POKEBALLS TRUE // Followers will emerge from the pokeball they are stored in, instead of a normal pokeball
#define OW_GFX_COMPRESS TRUE // Adds support for compressed OW graphics, (Also compresses pokemon follower graphics).
// Compressed gfx are incompatible with non-power-of-two sprite sizes:
// (You should not use 48x48 sprites/tables for compressed gfx)
// 16x32, 32x32, 64x64 etc are fine
#define OW_SUBSTITUTE_PLACEHOLDER TRUE // Use a substitute OW for Pokémon that are missing overworld sprites

// Out-of-battle Ability effects
#define OW_SYNCHRONIZE_NATURE GEN_LATEST // In Gen8+, if a Pokémon with Synchronize leads the party, wild Pokémon will always have their same Nature as opposed to the 50% chance in previous games. Gift Pokémon excluded.
Expand Down
2 changes: 1 addition & 1 deletion src/data/object_events/object_event_subsprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ static const struct SubspriteTable sOamTables_88x32[] = {
{ARRAY_COUNT(sOamTable_88x32_3), sOamTable_88x32_3}
};

#if LARGE_OW_SUPPORT
#if OW_LARGE_OW_SUPPORT
// These tables allow (virtual) sprite sizes so that
// some space can be saved by making graphics smaller.
// Note: When using these for followers, the minimum
Expand Down
27 changes: 15 additions & 12 deletions src/event_object_movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,12 @@ static const struct ObjectEventGraphicsInfo *SpeciesToGraphicsInfo(u16 species,
break;
}
// Try to avoid OOB or undefined access
if (graphicsInfo->tileTag == 0 && species < NUM_SPECIES)
return &gSpeciesInfo[SPECIES_NONE].followerData;
else if (graphicsInfo->tileTag != TAG_NONE && species >= NUM_SPECIES)
return &gSpeciesInfo[SPECIES_NONE].followerData;
if ((graphicsInfo->tileTag == 0 && species < NUM_SPECIES) || (graphicsInfo->tileTag != TAG_NONE && species >= NUM_SPECIES))
{
if (OW_SUBSTITUTE_PLACEHOLDER)
return &gSpeciesInfo[SPECIES_NONE].followerData;
return NULL;
}
#endif
return graphicsInfo;
}
Expand Down Expand Up @@ -1983,7 +1985,7 @@ static void RefreshFollowerGraphics(struct ObjectEvent *objEvent)

if (graphicsInfo->oam->size != sprite->oam.size)
{
if (LARGE_OW_SUPPORT && !OW_GFX_COMPRESS)
if (OW_LARGE_OW_SUPPORT && !OW_GFX_COMPRESS)
ReallocSpriteTiles(sprite, graphicsInfo->images->size);
// Add difference in Y vectors
sprite->y += -(graphicsInfo->height >> 1) - sprite->centerToCornerVecY;
Expand Down Expand Up @@ -2077,6 +2079,7 @@ void UpdateFollowingPokemon(void)
// 3. flag is set
if (OW_FOLLOWERS_ENABLED == FALSE
|| !GetFollowerInfo(&species, &form, &shiny)
|| SpeciesToGraphicsInfo(species, 0) == NULL
|| (gMapHeader.mapType == MAP_TYPE_INDOOR && SpeciesToGraphicsInfo(species, 0)->oam->size > ST_OAM_SIZE_2)
|| FlagGet(FLAG_TEMP_HIDE_FOLLOWER))
{
Expand Down Expand Up @@ -2636,7 +2639,7 @@ static void ObjectEventSetGraphics(struct ObjectEvent *objectEvent, const struct
UpdateSpritePalette(&sObjectEventSpritePalettes[i], sprite);

// If gfx size changes, we need to reallocate tiles
if (LARGE_OW_SUPPORT && !OW_GFX_COMPRESS && graphicsInfo->oam->size != sprite->oam.size)
if (OW_LARGE_OW_SUPPORT && !OW_GFX_COMPRESS && graphicsInfo->oam->size != sprite->oam.size)
ReallocSpriteTiles(sprite, graphicsInfo->images->size);

#if OW_GFX_COMPRESS
Expand Down Expand Up @@ -7147,7 +7150,7 @@ bool8 MovementAction_ExitPokeball_Step1(struct ObjectEvent *objectEvent, struct
LoadFillColorPalette(RGB_WHITE, OBJ_EVENT_PAL_TAG_WHITE, sprite);
// Initialize affine animation
sprite->affineAnims = sAffineAnims_PokeballFollower;
if (LARGE_OW_SUPPORT && !IS_POW_OF_TWO(-sprite->centerToCornerVecX))
if (OW_LARGE_OW_SUPPORT && !IS_POW_OF_TWO(-sprite->centerToCornerVecX))
return FALSE;
sprite->affineAnims = sAffineAnims_PokeballFollower;
sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL;
Expand Down Expand Up @@ -7194,7 +7197,7 @@ bool8 MovementAction_EnterPokeball_Step1(struct ObjectEvent *objectEvent, struct
sprite->subspriteTableNum = 0;
// Only do affine if sprite width is power of 2
// (effect looks weird on sprites composed of subsprites like 48x48, etc)
if (LARGE_OW_SUPPORT && !IS_POW_OF_TWO(-sprite->centerToCornerVecX))
if (OW_LARGE_OW_SUPPORT && !IS_POW_OF_TWO(-sprite->centerToCornerVecX))
return FALSE;
sprite->affineAnims = sAffineAnims_PokeballFollower;
sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL;
Expand Down Expand Up @@ -9237,7 +9240,7 @@ static void UpdateObjectEventElevationAndPriority(struct ObjectEvent *objEvent,
{
// keep subspriteMode synced with player's
// so that it disappears under bridges when they do
if (LARGE_OW_SUPPORT)
if (OW_LARGE_OW_SUPPORT)
sprite->subspriteMode |= gSprites[gPlayerAvatar.spriteId].subspriteMode & SUBSPRITES_IGNORE_PRIORITY;
// if transitioning between elevations, use the player's elevation
if (!objEvent->currentElevation)
Expand Down Expand Up @@ -9269,7 +9272,7 @@ void ObjectEventUpdateElevation(struct ObjectEvent *objEvent, struct Sprite *spr
{
// Ignore subsprite priorities under bridges
// so all subsprites will display below it
if (LARGE_OW_SUPPORT)
if (OW_LARGE_OW_SUPPORT)
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
return;
}
Expand Down Expand Up @@ -9667,7 +9670,7 @@ static void DoGroundEffects_OnSpawn(struct ObjectEvent *objEvent, struct Sprite
#endif
{
flags = 0;
if (LARGE_OW_SUPPORT && !sprite->oam.affineMode)
if (OW_LARGE_OW_SUPPORT && !sprite->oam.affineMode)
sprite->subspriteMode = SUBSPRITES_ON;
UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnSpawn(objEvent, &flags);
Expand All @@ -9689,7 +9692,7 @@ static void DoGroundEffects_OnBeginStep(struct ObjectEvent *objEvent, struct Spr
#endif
{
flags = 0;
if (LARGE_OW_SUPPORT && !sprite->oam.affineMode)
if (OW_LARGE_OW_SUPPORT && !sprite->oam.affineMode)
sprite->subspriteMode = SUBSPRITES_ON;
UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnBeginStep(objEvent, &flags);
Expand Down
4 changes: 2 additions & 2 deletions src/field_effect_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ u32 FldEff_Shadow(void)
gSprites[spriteId].sLocalId = gFieldEffectArguments[0];
gSprites[spriteId].sMapNum = gFieldEffectArguments[1];
gSprites[spriteId].sMapGroup = gFieldEffectArguments[2];
#if LARGE_OW_SUPPORT
#if OW_LARGE_OW_SUPPORT
gSprites[spriteId].sYOffset = gShadowVerticalOffsets[graphicsInfo->shadowSize];
#else
gSprites[spriteId].sYOffset = (graphicsInfo->height >> 1) - gShadowVerticalOffsets[graphicsInfo->shadowSize];
Expand All @@ -376,7 +376,7 @@ void UpdateShadowFieldEffect(struct Sprite *sprite)
struct Sprite *linkedSprite = &gSprites[objectEvent->spriteId];
sprite->oam.priority = linkedSprite->oam.priority;
sprite->x = linkedSprite->x;
#if LARGE_OW_SUPPORT
#if OW_LARGE_OW_SUPPORT
// Read 'live' size from linked sprite
sprite->y = linkedSprite->y - linkedSprite->centerToCornerVecY - sprite->sYOffset;
#else
Expand Down

0 comments on commit 3fadaaf

Please sign in to comment.