diff --git a/include/constants/wild_encounter.h b/include/constants/wild_encounter.h index 8902f2ef43..ae669a2c35 100644 --- a/include/constants/wild_encounter.h +++ b/include/constants/wild_encounter.h @@ -8,6 +8,7 @@ #define NUM_ALTERING_CAVE_TABLES 9 -#define FISHING_CHAIN_LENGTH_MAX 20 +#define FISHING_CHAIN_LENGTH_MAX 200 +#define FISHING_CHAIN_SHINY_STREAK_MAX 20 #endif // GUARD_CONSTANTS_WILD_ENCOUNTER_H diff --git a/include/wild_encounter.h b/include/wild_encounter.h index 6a7c7a2cba..63289f081c 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -42,8 +42,6 @@ u16 GetLocalWaterMon(void); bool8 UpdateRepelCounter(void); bool8 TryDoDoubleWildBattle(void); bool8 StandardWildEncounter_Debug(void); -void ResetChainFishingDexNavStreak(void); -bool32 IsCurrentEncounterFishing(void); u32 CalculateChainFishingShinyRolls(void); #endif // GUARD_WILD_ENCOUNTER_H diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 82532881f2..b10ca6c599 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1997,7 +1997,7 @@ static bool8 Fishing_StartEncounter(struct Task *task) static bool8 Fishing_NotEvenNibble(struct Task *task) { - ResetChainFishingDexNavStreak(); + gChainFishingDexNavStreak = 0; AlignFishingAnimationFrames(); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); FillWindowPixelBuffer(0, PIXEL_FILL(1)); @@ -2008,7 +2008,7 @@ static bool8 Fishing_NotEvenNibble(struct Task *task) static bool8 Fishing_GotAway(struct Task *task) { - ResetChainFishingDexNavStreak(); + gChainFishingDexNavStreak = 0; AlignFishingAnimationFrames(); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); FillWindowPixelBuffer(0, PIXEL_FILL(1)); diff --git a/src/fieldmap.c b/src/fieldmap.c index 28c9602688..30daae49ca 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -67,7 +67,6 @@ const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnect void InitMap(void) { - ResetChainFishingDexNavStreak(); InitMapLayoutData(&gMapHeader); SetOccupiedSecretBaseEntranceMetatiles(gMapHeader.events); RunOnLoadMapScript(); diff --git a/src/overworld.c b/src/overworld.c index ca5a268a82..a9606578dc 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -907,6 +907,7 @@ if (I_VS_SEEKER_CHARGING != 0) RunOnTransitionMapScript(); UpdateLocationHistoryForRoamer(); MoveAllRoamersToOtherLocationSets(); + gChainFishingDexNavStreak = 0; if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_FLOOR) InitBattlePyramidMap(FALSE); else if (InTrainerHill()) diff --git a/src/pokemon.c b/src/pokemon.c index e5094c8925..1fd18f510e 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1158,7 +1158,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, totalRerolls += I_SHINY_CHARM_ADDITIONAL_ROLLS; if (LURE_STEP_COUNT != 0) totalRerolls += 1; - if (IsCurrentEncounterFishing()) + if (I_FISHING_CHAIN && gIsFishingEncounter) totalRerolls += CalculateChainFishingShinyRolls(); while (GET_SHINY_VALUE(value, personality) >= SHINY_ODDS && totalRerolls > 0) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 273f9f312a..ae7770aa3a 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -51,15 +51,7 @@ enum { static u16 FeebasRandom(void); static void FeebasSeedRng(u16 seed); -static u32 GetLastFishingSpecies(void); -static bool32 DoesSpeciesMatchLastFishingSpecies(u32 species); -static u32 GetCurrentChainFishingDexNavStreak(void); -static bool32 IsChainFishingStreakAtMax(void); -static void IncrementChainFishingDexNavStreak(void); -static void SetEncounterFishing(void); -static void SetLastFishingSpecies(u32 species); -static void HandleChainFishingStreak(u32 species); -static void UpdateChainFishingSpeciesAndStreak(u32 species); +static void UpdateChainFishingStreak(); static bool8 IsWildLevelAllowedByRepel(u8 level); static void ApplyFluteEncounterRateMod(u32 *encRate); static void ApplyCleanseTagEncounterRateMod(u32 *encRate); @@ -76,7 +68,6 @@ EWRAM_DATA static u32 sFeebasRngValue = 0; EWRAM_DATA bool8 gIsFishingEncounter = 0; EWRAM_DATA bool8 gIsSurfingEncounter = 0; EWRAM_DATA u8 gChainFishingDexNavStreak = 0; -EWRAM_DATA static u16 sLastFishingSpecies = 0; #include "data/wild_encounters.h" @@ -528,7 +519,7 @@ static u16 GenerateFishingWildMon(const struct WildPokemonInfo *wildMonInfo, u8 u16 wildMonSpecies = wildMonInfo->wildPokemon[wildMonIndex].species; u8 level = ChooseWildMonLevel(wildMonInfo->wildPokemon, wildMonIndex, WILD_AREA_FISHING); - UpdateChainFishingSpeciesAndStreak(wildMonSpecies); + UpdateChainFishingStreak(); CreateWildMon(wildMonSpecies, level); return wildMonSpecies; } @@ -877,84 +868,27 @@ bool8 DoesCurrentMapHaveFishingMons(void) return FALSE; } -static u32 GetLastFishingSpecies(void) -{ - return sLastFishingSpecies; -} - -static bool32 DoesSpeciesMatchLastFishingSpecies(u32 species) -{ - return (species == GetLastFishingSpecies()); -} - -static u32 GetCurrentChainFishingDexNavStreak(void) -{ - return gChainFishingDexNavStreak; -} - -static bool32 IsChainFishingStreakAtMax(void) -{ - return (GetCurrentChainFishingDexNavStreak() >= FISHING_CHAIN_LENGTH_MAX); -} - -static void IncrementChainFishingDexNavStreak(void) -{ - gChainFishingDexNavStreak++; -} - -void ResetChainFishingDexNavStreak(void) -{ - gChainFishingDexNavStreak = 0; -} - -bool32 IsCurrentEncounterFishing(void) -{ - return gIsFishingEncounter; -} - -static void SetEncounterFishing(void) -{ - gIsFishingEncounter = TRUE; -} - u32 CalculateChainFishingShinyRolls(void) { - return (1 + (2 * GetCurrentChainFishingDexNavStreak())); + return (2 * min(gChainFishingDexNavStreak, FISHING_CHAIN_SHINY_STREAK_MAX)); } -static void SetLastFishingSpecies(u32 species) -{ - sLastFishingSpecies = species; -} - -static void HandleChainFishingStreak(u32 species) -{ - if (!DoesSpeciesMatchLastFishingSpecies(species)) - { - ResetChainFishingDexNavStreak(); - return; - } - - if (IsChainFishingStreakAtMax()) - return; - - IncrementChainFishingDexNavStreak(); -} - -static void UpdateChainFishingSpeciesAndStreak(u32 species) +static void UpdateChainFishingStreak() { if (!I_FISHING_CHAIN) return; - HandleChainFishingStreak(species); - SetLastFishingSpecies(species); + if (gChainFishingDexNavStreak >= FISHING_CHAIN_LENGTH_MAX) + return; + + gChainFishingDexNavStreak++; } void FishingWildEncounter(u8 rod) { u16 species; - SetEncounterFishing(); + gIsFishingEncounter = TRUE; if (CheckFeebas() == TRUE) { u8 level = ChooseWildMonLevel(&sWildFeebas, 0, WILD_AREA_FISHING);