chain fishing refactored

This commit is contained in:
cawtds 2024-07-03 17:02:12 +02:00
parent 26395fe600
commit 91550eb75f
5 changed files with 17 additions and 83 deletions

View File

@ -42,8 +42,5 @@ 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

View File

@ -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));

View File

@ -67,7 +67,7 @@ const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnect
void InitMap(void)
{
ResetChainFishingDexNavStreak();
gChainFishingDexNavStreak = 0;
InitMapLayoutData(&gMapHeader);
SetOccupiedSecretBaseEntranceMetatiles(gMapHeader.events);
RunOnLoadMapScript();

View File

@ -1150,8 +1150,8 @@ 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 (I_FISHING_CHAIN && IsCurrentEncounterFishing())
totalRerolls += CalculateChainFishingShinyRolls();
if (I_FISHING_CHAIN && gIsFishingEncounter)
totalRerolls += (2 * gChainFishingDexNavStreak);
while (GET_SHINY_VALUE(value, personality) >= SHINY_ODDS && totalRerolls > 0)
{

View File

@ -51,14 +51,6 @@ 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 bool8 IsWildLevelAllowedByRepel(u8 level);
static void ApplyFluteEncounterRateMod(u32 *encRate);
@ -877,84 +869,29 @@ 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 2 * GetCurrentChainFishingDexNavStreak();
}
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)
{
if (!I_FISHING_CHAIN)
return;
HandleChainFishingStreak(species);
SetLastFishingSpecies(species);
if (species != sLastFishingSpecies)
{
gChainFishingDexNavStreak = 0;
return;
}
if (gChainFishingDexNavStreak >= FISHING_CHAIN_LENGTH_MAX)
return;
gChainFishingDexNavStreak++;
sLastFishingSpecies = species;
}
void FishingWildEncounter(u8 rod)
{
u16 species;
SetEncounterFishing();
gIsFishingEncounter = TRUE;
if (CheckFeebas() == TRUE)
{
u8 level = ChooseWildMonLevel(&sWildFeebas, 0, WILD_AREA_FISHING);