diff --git a/include/wild_encounter.h b/include/wild_encounter.h index 55bbaa7dd..a9479d34d 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -29,6 +29,8 @@ struct WildPokemonHeader const struct WildPokemonInfo *fishingMonsInfo; }; +extern bool8 gIsFishingEncounter; + extern const struct WildPokemonHeader gWildMonHeaders[]; void DisableWildEncounters(bool8 disabled); diff --git a/src/battle_main.c b/src/battle_main.c index 76bd6d877..9364c2385 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -47,6 +47,7 @@ #include "trig.h" #include "tv.h" #include "util.h" +#include "wild_encounter.h" #include "window.h" #include "constants/abilities.h" #include "constants/battle_move_effects.h" @@ -5195,6 +5196,7 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) { if (!gPaletteFade.active) { + gIsFishingEncounter = FALSE; ResetSpriteData(); if (gLeveledUpInBattle == 0 || gBattleOutcome != B_OUTCOME_WON) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 7e783bef5..ed4e210f2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -42,6 +42,8 @@ #include "constants/battle_string_ids.h" #include "battle_setup.h" #include "overworld.h" +#include "wild_encounter.h" +#include "rtc.h" #include "party_menu.h" #include "battle_arena.h" #include "battle_pike.h" @@ -10077,7 +10079,7 @@ static void atkEE_removelightscreenreflect(void) // brick break static void atkEF_handleballthrow(void) { - u8 ballMultiplier = 0; + u8 ballMultiplier = 10; if (gBattleControllerExecFlags) return; @@ -10099,7 +10101,7 @@ static void atkEF_handleballthrow(void) } else { - u32 odds; + u32 odds, i; u8 catchRate; if (gLastUsedItem == ITEM_SAFARI_BALL) @@ -10114,14 +10116,10 @@ static void atkEF_handleballthrow(void) case ITEM_NET_BALL: if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_BUG)) ballMultiplier = 30; - else - ballMultiplier = 10; break; case ITEM_DIVE_BALL: if (GetCurrentMapType() == MAP_TYPE_UNDERWATER) ballMultiplier = 35; - else - ballMultiplier = 10; break; case ITEM_NEST_BALL: if (gBattleMons[gBattlerTarget].level < 40) @@ -10130,16 +10128,10 @@ static void atkEF_handleballthrow(void) if (ballMultiplier <= 9) ballMultiplier = 10; } - else - { - ballMultiplier = 10; - } break; case ITEM_REPEAT_BALL: if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), FLAG_GET_CAUGHT)) ballMultiplier = 30; - else - ballMultiplier = 10; break; case ITEM_TIMER_BALL: ballMultiplier = gBattleResults.battleTurnCounter + 10; @@ -10148,8 +10140,70 @@ static void atkEF_handleballthrow(void) break; case ITEM_LUXURY_BALL: case ITEM_PREMIER_BALL: + case ITEM_FRIEND_BALL: + case ITEM_HEAL_BALL: + case ITEM_CHERISH_BALL: ballMultiplier = 10; break; + case ITEM_SPORT_BALL: + ballMultiplier = 15; + break; + case ITEM_LEVEL_BALL: + if (gBattleMons[gBattlerAttacker].level >= 4 * gBattleMons[gBattlerTarget].level) + ballMultiplier = 80; + else if (gBattleMons[gBattlerAttacker].level > 2 * gBattleMons[gBattlerTarget].level) + ballMultiplier = 40; + else if (gBattleMons[gBattlerAttacker].level > gBattleMons[gBattlerTarget].level) + ballMultiplier = 20; + break; + case ITEM_LURE_BALL: + if (gIsFishingEncounter) + ballMultiplier = 30; + break; + case ITEM_MOON_BALL: + for (i = 0; i < EVOS_PER_MON; i++) + { + if (gEvolutionTable[gBattleMons[gBattlerTarget].species][i].method == EVO_ITEM + && gEvolutionTable[gBattleMons[gBattlerTarget].species][i].param == ITEM_MOON_STONE) + ballMultiplier = 40; + } + break; + case ITEM_LOVE_BALL: + if (gBattleMons[gBattlerTarget].species == gBattleMons[gBattlerAttacker].species) + { + u8 gender1 = GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]); + u8 gender2 = GetMonGender(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]); + + if (gender1 != gender2 && gender1 != MON_GENDERLESS && gender2 != MON_GENDERLESS) + ballMultiplier = 80; + } + break; + case ITEM_HEAVY_BALL: + i = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1); + if (i < 1024) + ballMultiplier = 5; + else if (i < 2048) + ballMultiplier = 10; + else if (i < 3072) + ballMultiplier = 20; + else if (i < 4096) + ballMultiplier = 30; + else + ballMultiplier = 40; + break; + case ITEM_FAST_BALL: + if (gBaseStats[gBattleMons[gBattlerTarget].species].baseSpeed >= 10) + ballMultiplier = 40; + break; + case ITEM_QUICK_BALL: + if (gBattleResults.battleTurnCounter == 0) + ballMultiplier = 40; + break; + case ITEM_DUSK_BALL: + RtcCalcLocalTime(); + if ((gLocalTime.hours >= 20 && gLocalTime.hours <= 3) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND) + ballMultiplier = 30; + break; } } else @@ -10213,6 +10267,14 @@ static void atkEF_handleballthrow(void) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; + + if (gLastUsedItem == ITEM_HEAL_BALL) + { + MonRestorePP(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]); + HealStatusConditions(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], gBattlerPartyIndexes[gBattlerTarget], STATUS1_ANY, gBattlerTarget); + gBattleMons[gBattlerTarget].hp = gBattleMons[gBattlerTarget].maxHP; + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_HP, &gBattleMons[gBattlerTarget].hp); + } } else // not caught { diff --git a/src/wild_encounter.c b/src/wild_encounter.c index e42bf8a23..01b3378c8 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -38,6 +38,7 @@ static bool8 IsAbilityAllowingEncounter(u8 level); // EWRAM vars EWRAM_DATA static u8 sWildEncountersDisabled = 0; +EWRAM_DATA bool8 gIsFishingEncounter = 0; EWRAM_DATA static u32 sFeebasRngValue = 0; #include "data/wild_encounters.h" @@ -756,6 +757,7 @@ void FishingWildEncounter(u8 rod) } IncrementGameStat(GAME_STAT_FISHING_CAPTURES); SetPokemonAnglerSpecies(species); + gIsFishingEncounter = TRUE; BattleSetup_StartWildBattle(); }