Add more later gen fishing mechanics (#5518)

* Add new fishing bite odds and follower boost

* Sticky

* Update item.h

* Update field_player_avatar.c

* Update field_player_avatar.c
This commit is contained in:
kittenchilly 2024-10-18 09:45:31 -05:00 committed by GitHub
parent 358c0d0699
commit 04aa5b7c24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 67 additions and 14 deletions

View file

@ -38,9 +38,12 @@
// Vs. Seeker
#define I_VS_SEEKER_CHARGING 0 // If this flag is assigned, the Vs Seeker functionality will be enabled. When the player has the Vs. Seeker, Match Call rematch functions will stop working.
//Fishing
// Fishing
#define I_FISHING_BITE_ODDS GEN_LATEST // In Gen 1 and Gen 2, the Old Rod has a 100% chance for a bite, Good Rod has a 66% chance for a bite, and Super Rod has a 50% chance for a bite. In Gen 3, all rods have a base 50% chance for a bite. In Gen 4 onwards, the Old Rod has a base 25% chance for a bite, Good Rod has a 50% chance for a bite, and Super Rod has a 75% chance for a bite.
#define I_FISHING_MINIGAME GEN_3 // Each generation uses a variation of reeling in Pokémon once they have been hooked. NOTE: Only the Gen 1/2 and Gen 3 minigames are implemented right now!
#define I_FISHING_STICKY_BOOST GEN_LATEST // In Gen 3, a Pokemon with Suction Cups or Sticky Hold in the first slot of the party causes the chance for a bite to increase by about 35%. In Gen 4 onwards, it doubles the base bite chance.
#define I_FISHING_FOLLOWER_BOOST FALSE // In HGSS, fishing bite odds are increased depending on the friendship of the current following Pokémon.
#define I_FISHING_CHAIN FALSE // Introduced in XY, hooking the same Pokémon repeatedly will increase the odds of that mon being shiny. NOTE: This implementation is an approximation of the actual feature, as XY have not been throughoutly documented or datamined.
#define I_FISHING_MINIGAME GEN_3 // Each generation uses a variation of reeling in Pokémon once they have been hooked.
#define I_FISHING_PROXIMITY FALSE // Introduced in XY, fishing away from other people in enclosed areas will increase the chances of a Pokémon being hooked. NOTE: This implementation is an approximation of the actual feature, as XY have not been throughoutly documented or datamined.
#endif // GUARD_CONFIG_ITEM_H

View file

@ -146,8 +146,9 @@ static bool32 Fishing_EndNoMon(struct Task *);
static void AlignFishingAnimationFrames(void);
static bool32 DoesFishingMinigameAllowCancel(void);
static bool32 Fishing_DoesFirstMonInPartyHaveSuctionCupsOrStickyHold(void);
static bool32 Fishing_RollForBite(bool32);
static u32 CalculateFishingBiteOdds(bool32);
static bool32 Fishing_RollForBite(u32, bool32);
static u32 CalculateFishingBiteOdds(u32, bool32);
static u32 CalculateFishingFollowerBoost(void);
static u32 CalculateFishingProximityBoost(u32 odds);
static void GetCoordinatesAroundBobber(s16[], s16[][AXIS_COUNT], u32);
static u32 CountQualifyingTiles(s16[][AXIS_COUNT], s16 player[], u8 facingDirection, struct ObjectEvent *objectEvent, bool32 isTileLand[]);
@ -1725,7 +1726,20 @@ static void Task_WaitStopSurfing(u8 taskId)
#define FISHING_PROXIMITY_BOOST 4
#define FISHING_STICKY_BOOST 36
#define FISHING_DEFAULT_ODDS 50
#if I_FISHING_BITE_ODDS >= GEN_4
#define FISHING_OLD_ROD_ODDS 75
#define FISHING_GOOD_ROD_ODDS 50
#define FISHING_SUPER_ROD_ODDS 25
#elif I_FISHING_BITE_ODDS >= GEN_3
#define FISHING_OLD_ROD_ODDS 50
#define FISHING_GOOD_ROD_ODDS 50
#define FISHING_SUPER_ROD_ODDS 50
#else
#define FISHING_OLD_ROD_ODDS 0
#define FISHING_GOOD_ROD_ODDS 33
#define FISHING_SUPER_ROD_ODDS 50
#endif
enum
{
@ -1902,10 +1916,10 @@ static bool32 Fishing_CheckForBite(struct Task *task)
firstMonHasSuctionOrSticky = Fishing_DoesFirstMonInPartyHaveSuctionCupsOrStickyHold();
if(firstMonHasSuctionOrSticky)
bite = Fishing_RollForBite(firstMonHasSuctionOrSticky);
bite = Fishing_RollForBite(task->tFishingRod, firstMonHasSuctionOrSticky);
if (!bite)
bite = Fishing_RollForBite(FALSE);
bite = Fishing_RollForBite(task->tFishingRod, FALSE);
if (!bite)
task->tStep = FISHING_NOT_EVEN_NIBBLE;
@ -2127,22 +2141,58 @@ static bool32 Fishing_DoesFirstMonInPartyHaveSuctionCupsOrStickyHold(void)
return (ability == ABILITY_SUCTION_CUPS || ability == ABILITY_STICKY_HOLD);
}
static bool32 Fishing_RollForBite(bool32 isStickyHold)
static bool32 Fishing_RollForBite(u32 rod, bool32 isStickyHold)
{
return ((Random() % 100) > CalculateFishingBiteOdds(isStickyHold));
return ((Random() % 100) > CalculateFishingBiteOdds(rod, isStickyHold));
}
static u32 CalculateFishingBiteOdds(bool32 isStickyHold)
static u32 CalculateFishingBiteOdds(u32 rod, bool32 isStickyHold)
{
u32 odds = FISHING_DEFAULT_ODDS;
u32 odds;
if (rod == OLD_ROD)
odds = FISHING_OLD_ROD_ODDS;
if (rod == GOOD_ROD)
odds = FISHING_GOOD_ROD_ODDS;
if (rod == SUPER_ROD)
odds = FISHING_SUPER_ROD_ODDS;
odds -= CalculateFishingFollowerBoost();
if (isStickyHold)
{
if (I_FISHING_STICKY_BOOST >= GEN_4)
odds -= (100 - odds);
else
odds -= FISHING_STICKY_BOOST;
}
odds -= CalculateFishingProximityBoost(odds);
return odds;
}
static u32 CalculateFishingFollowerBoost()
{
u32 friendship;
struct Pokemon *mon = GetFirstLiveMon();
if (!I_FISHING_FOLLOWER_BOOST || !mon)
return 0;
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP);
if (friendship >= 250)
return 50;
else if (friendship >= 200)
return 40;
else if (friendship >= 150)
return 30;
else if (friendship >= 100)
return 20;
else
return 0;
}
static u32 CalculateFishingProximityBoost(u32 odds)
{
s16 player[AXIS_COUNT], bobber[AXIS_COUNT];