From e0b53f87fca30e0666f5cf3ba9221b4e26e2d2fa Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 4 Nov 2021 10:56:14 -0300 Subject: [PATCH 01/32] Primal Reversion Tweaks -Fixed the inconsistent Primal Reversion activation in double battles. -Optimized the primal weather checks in attackcanceler a little. -Fixed the issue with multi-target fire/water moves during primal rain/sun. --- data/battle_scripts_1.s | 4 ++++ include/constants/battle.h | 1 + src/battle_script_commands.c | 30 +++++++++++++----------------- src/battle_util.c | 10 ++++------ 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6d6c1dae8..6373a7750 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7697,8 +7697,10 @@ BattleScript_DesolateLandEvaporatesWaterTypeMoves:: attackstring pause B_WAIT_TIME_SHORT ppreduce + jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_STRING_PRINTED, BattleScript_MoveEnd printstring STRINGID_MOVEEVAPORATEDINTHEHARSHSUNLIGHT waitmessage B_WAIT_TIME_LONG + orword gHitMarker, HITMARKER_STRING_PRINTED goto BattleScript_MoveEnd BattleScript_PrimordialSeaActivates:: @@ -7715,8 +7717,10 @@ BattleScript_PrimordialSeaFizzlesOutFireTypeMoves:: attackstring pause B_WAIT_TIME_SHORT ppreduce + jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_STRING_PRINTED, BattleScript_MoveEnd printstring STRINGID_MOVEFIZZLEDOUTINTHEHEAVYRAIN waitmessage B_WAIT_TIME_LONG + orword gHitMarker, HITMARKER_STRING_PRINTED goto BattleScript_MoveEnd BattleScript_DeltaStreamActivates:: diff --git a/include/constants/battle.h b/include/constants/battle.h index 918c3e7f0..8841a3c12 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -200,6 +200,7 @@ #define HITMARKER_CHARGING (1 << 27) #define HITMARKER_FAINTED(battler) (gBitTable[battler] << 28) #define HITMARKER_FAINTED2(battler) ((1 << 28) << battler) +#define HITMARKER_STRING_PRINTED (1 << 29) // Per-side statuses that affect an entire party #define SIDE_STATUS_REFLECT (1 << 0) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ee9379d8d..0fb2e5599 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1337,24 +1337,20 @@ static void Cmd_attackcanceler(void) GET_MOVE_TYPE(gCurrentMove, moveType); - if (moveType == TYPE_FIRE - && (gBattleWeather & WEATHER_RAIN_PRIMAL) - && WEATHER_HAS_EFFECT - && gBattleMoves[gCurrentMove].power) + if (WEATHER_HAS_EFFECT && gBattleMoves[gCurrentMove].power) { - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_PrimordialSeaFizzlesOutFireTypeMoves; - return; - } - - if (moveType == TYPE_WATER - && (gBattleWeather & WEATHER_SUN_PRIMAL) - && WEATHER_HAS_EFFECT - && gBattleMoves[gCurrentMove].power) - { - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_DesolateLandEvaporatesWaterTypeMoves; - return; + if (moveType == TYPE_FIRE && (gBattleWeather & WEATHER_RAIN_PRIMAL)) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_PrimordialSeaFizzlesOutFireTypeMoves; + return; + } + else if (moveType == TYPE_WATER && (gBattleWeather & WEATHER_SUN_PRIMAL)) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_DesolateLandEvaporatesWaterTypeMoves; + return; + } } if (gBattleOutcome != 0) diff --git a/src/battle_util.c b/src/battle_util.c index f87e0a134..13908c209 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8884,12 +8884,10 @@ bool32 CanMegaEvolve(u8 battlerId) // Check if trainer already mega evolved a pokemon. if (mega->alreadyEvolved[battlerPosition]) return FALSE; - if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - { - if (IsPartnerMonFromSameTrainer(battlerId) - && (mega->alreadyEvolved[partnerPosition] || (mega->toEvolve & gBitTable[BATTLE_PARTNER(battlerId)]))) - return FALSE; - } + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && IsPartnerMonFromSameTrainer(battlerId) + && (mega->alreadyEvolved[partnerPosition] || (mega->toEvolve & gBitTable[BATTLE_PARTNER(battlerId)]))) + return FALSE; // Gets mon data. if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) From 19af517bbb4c8887e036bdf1e9ef7bf2355d9f04 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 30 Nov 2021 20:45:21 -0300 Subject: [PATCH 02/32] Edited pointless or useless Primal Reversion code Also added an equivalent to GetMegaEvolutionSpecies and GetWishMegaEvolutionSpecies for Primal Reversion. Also also modified how CanBattlerGetOrLoseItem checks for Primal Reversion. Also also also rewrote the check that triggers Primal Reversion in TryDoEventsBeforeFirstTurn. --- include/battle.h | 1 - include/battle_util.h | 1 + src/battle_main.c | 18 +++++++++++++----- src/battle_script_commands.c | 2 +- src/battle_util.c | 29 ++++++++++++++++------------- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/include/battle.h b/include/battle.h index 5658f603c..930578a50 100644 --- a/include/battle.h +++ b/include/battle.h @@ -475,7 +475,6 @@ struct MegaEvolutionData bool8 playerSelect; u8 triggerSpriteId; bool8 isWishMegaEvo; - bool8 isPrimalReversion; }; struct Illusion diff --git a/include/battle_util.h b/include/battle_util.h index b1a2a1534..ba4f20336 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -127,6 +127,7 @@ u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilit u16 GetTypeModifier(u8 atkType, u8 defType); s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId); u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId); +u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId); u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4); bool32 CanMegaEvolve(u8 battlerId); void UndoMegaEvolution(u32 monId); diff --git a/src/battle_main.c b/src/battle_main.c index 766736048..028237aa4 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -64,6 +64,8 @@ #include "constants/trainers.h" #include "cable_club.h" +extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; + extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; @@ -3541,12 +3543,18 @@ static void TryDoEventsBeforeFirstTurn(void) // Primal Reversion for (i = 0; i < gBattlersCount; i++) { - if (CanMegaEvolve(i) - && GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB) + if (GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB) { - gBattlerAttacker = i; - BattleScriptExecute(BattleScript_PrimalReversion); - return; + for (j = 0; j < EVOS_PER_MON; j++) + { + if (gEvolutionTable[gBattleMons[i].species][j].targetSpecies != SPECIES_NONE + && gEvolutionTable[gBattleMons[i].species][j].method == EVO_PRIMAL_REVERSION) + { + gBattlerAttacker = i; + BattleScriptExecute(BattleScript_PrimalReversion); + return; + } + } } } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8c328926d..640e75ed8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8331,7 +8331,7 @@ static void Cmd_various(void) gBattleStruct->mega.playerPrimalRevertedSpecies = gBattleStruct->mega.primalRevertedSpecies[gActiveBattler]; } // Checks Primal Reversion - primalSpecies = GetMegaEvolutionSpecies(gBattleStruct->mega.primalRevertedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item); + primalSpecies = GetPrimalReversionSpecies(gBattleStruct->mega.primalRevertedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item); gBattleMons[gActiveBattler].species = primalSpecies; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); diff --git a/src/battle_util.c b/src/battle_util.c index 725814a0d..3b95bb84c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9081,8 +9081,20 @@ u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId) for (i = 0; i < EVOS_PER_MON; i++) { - if ((gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION - || gEvolutionTable[preEvoSpecies][i].method == EVO_PRIMAL_REVERSION) + if (gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION + && gEvolutionTable[preEvoSpecies][i].param == heldItemId) + return gEvolutionTable[preEvoSpecies][i].targetSpecies; + } + return SPECIES_NONE; +} + +u16 GetPrimalReversionSpecies(u16 preEvoSpecies, u16 heldItemId) +{ + u32 i; + + for (i = 0; i < EVOS_PER_MON; i++) + { + if (gEvolutionTable[preEvoSpecies][i].method == EVO_PRIMAL_REVERSION && gEvolutionTable[preEvoSpecies][i].param == heldItemId) return gEvolutionTable[preEvoSpecies][i].targetSpecies; } @@ -9153,14 +9165,6 @@ bool32 CanMegaEvolve(u8 battlerId) gBattleStruct->mega.isWishMegaEvo = FALSE; return TRUE; } - - // Can undergo Primal Reversion. - if (holdEffect == HOLD_EFFECT_PRIMAL_ORB) - { - gBattleStruct->mega.isWishMegaEvo = FALSE; - gBattleStruct->mega.isPrimalReversion = TRUE; - return TRUE; - } } // Check if there is an entry in the evolution table for Wish Mega Evolution. @@ -9264,9 +9268,8 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId) // Mail can be stolen now if (itemId == ITEM_ENIGMA_BERRY) return FALSE; - else if (GET_BASE_SPECIES_ID(species) == SPECIES_KYOGRE && itemId == ITEM_BLUE_ORB) // includes primal - return FALSE; - else if (GET_BASE_SPECIES_ID(species) == SPECIES_GROUDON && itemId == ITEM_RED_ORB) // includes primal + // Primal Reversion inducing items cannot be lost if pokemon's base species can undergo primal reversion with it. + else if (holdEffect == HOLD_EFFECT_PRIMAL_ORB && (GetPrimalReversionSpecies(GET_BASE_SPECIES_ID(species), itemId) != SPECIES_NONE)) return FALSE; // Mega stone cannot be lost if pokemon's base species can mega evolve with it. else if (holdEffect == HOLD_EFFECT_MEGA_STONE && (GetMegaEvolutionSpecies(GET_BASE_SPECIES_ID(species), itemId) != SPECIES_NONE)) From 389a38b3cd3bffa87b6fec09c4f8daa8dd977005 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 12 Feb 2022 23:55:54 -0300 Subject: [PATCH 03/32] Config for Facade being affected by burns --- include/constants/battle_config.h | 1 + src/battle_util.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 6306ca687..ab5a613d8 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -116,6 +116,7 @@ // Damage settings #define B_BURN_DAMAGE GEN_7 // In Gen7+, burn damage is 1/16th of max HP instead of 1/8th. +#define B_BURN_FACADE_DMG GEN_7 // In Gen6+, burn's effect of lowering the Attack stat no longer applies to Facade. #define B_BINDING_DAMAGE GEN_7 // In Gen6+, binding damage is 1/8 of max HP instead of 1/16. (With Binding Band, 1/6 and 1/8 respectively.) #define B_PSYWAVE_DMG GEN_7 // Psywave's damage formula. See Cmd_psywavedamageeffect. #define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. diff --git a/src/battle_util.c b/src/battle_util.c index 4127b9bd4..d9831f8f6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8869,7 +8869,8 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move // check burn if (gBattleMons[battlerAtk].status1 & STATUS1_BURN && IS_MOVE_PHYSICAL(move) - && gBattleMoves[move].effect != EFFECT_FACADE && abilityAtk != ABILITY_GUTS) + && (gBattleMoves[move].effect != EFFECT_FACADE || B_BURN_FACADE_DMG < GEN_6) + && abilityAtk != ABILITY_GUTS) dmg = ApplyModifier(UQ_4_12(0.5), dmg); // check sunny/rain weather From 76e0b3896044572bcb063176eda30146add07bd5 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 12 Feb 2022 23:57:23 -0300 Subject: [PATCH 04/32] =?UTF-8?q?Config=20for=20Pok=C3=A9mon=20with=20Obli?= =?UTF-8?q?vious=20being=20affected=20by=20Taunt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/constants/battle_config.h | 1 + src/battle_script_commands.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index ab5a613d8..d989e746d 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -182,6 +182,7 @@ #define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if a Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. #define B_SYNCHRONIZE_TOXIC GEN_8 // In Gen5+, if a Pokémon with Synchronize is badly poisoned, the opponent will also become badly poisoned. Previously, the opponent would become regular poisoned. #define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. +#define B_OBLIVIOUS_TAUNT GEN_7 // In Gen6+, Pokémon with Oblivious can't be taunted. // Item settings #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e67eb917b..00be0d2f2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12297,13 +12297,16 @@ static void Cmd_jumpifnodamage(void) static void Cmd_settaunt(void) { +#if B_OBLIVIOUS_TAUNT >= GEN_6 if (GetBattlerAbility(gBattlerTarget) == ABILITY_OBLIVIOUS) { gBattlescriptCurrInstr = BattleScript_NotAffectedAbilityPopUp; gLastUsedAbility = ABILITY_OBLIVIOUS; RecordAbilityBattle(gBattlerTarget, ABILITY_OBLIVIOUS); } - else if (gDisableStructs[gBattlerTarget].tauntTimer == 0) + else +#endif + if (gDisableStructs[gBattlerTarget].tauntTimer == 0) { #if B_TAUNT_TURNS >= GEN_5 u8 turns = 4; From 748ce99de3aad3b6a588e82ba5cc659a613881e4 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 13 Feb 2022 00:17:37 -0300 Subject: [PATCH 05/32] Config for Ingrain grounding the user --- include/constants/battle_config.h | 1 + src/battle_util.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index d989e746d..9715e802f 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -170,6 +170,7 @@ #define B_BRICK_BREAK GEN_7 // In Gen4+, you can destroy your own side's screens. In Gen 5+, screens are not removed if the target is immune. #define B_WISH_HP_SOURCE GEN_7 // In Gen5+, Wish heals half of the user's max HP instead of the target's. #define B_RAMPAGE_CANCELLING GEN_7 // In Gen5+, a failed Thrash, etc, will cancel except on its last turn. +#define B_ROOTED_GROUNDING GEN_7 // In Gen4+, Ingrain causes the affected Pokémon to become grounded. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. diff --git a/src/battle_util.c b/src/battle_util.c index d9831f8f6..a6040eab1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7736,8 +7736,10 @@ bool32 IsBattlerGrounded(u8 battlerId) return TRUE; else if (gFieldStatuses & STATUS_FIELD_GRAVITY) return TRUE; +#if B_ROOTED_GROUNDING >= GEN_4 else if (gStatuses3[battlerId] & STATUS3_ROOTED) return TRUE; +#endif else if (gStatuses3[battlerId] & STATUS3_SMACKED_DOWN) return TRUE; From d73e6faab8ede9ba127806971d7944eacdd49f72 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 13 Feb 2022 00:30:37 -0300 Subject: [PATCH 06/32] Config for Growth being affected by sunlight --- data/battle_scripts_1.s | 4 ++++ include/constants/battle_config.h | 1 + 2 files changed, 5 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 624e911bc..c26d11950 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1907,7 +1907,9 @@ BattleScript_GrowthDoMoveAnim:: waitanimation setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_SPATK, 0 +.if B_GROWTH_UNDER_SUN >= GEN_5 jumpifweatheraffected BS_ATTACKER, B_WEATHER_SUN, BattleScript_GrowthAtk2 +.endif setstatchanger STAT_ATK, 1, FALSE goto BattleScript_GrowthAtk BattleScript_GrowthAtk2: @@ -1918,7 +1920,9 @@ BattleScript_GrowthAtk: printfromtable gStatUpStringIds waitmessage B_WAIT_TIME_LONG BattleScript_GrowthTrySpAtk:: +.if B_GROWTH_UNDER_SUN >= GEN_5 jumpifweatheraffected BS_ATTACKER, B_WEATHER_SUN, BattleScript_GrowthSpAtk2 +.endif setstatchanger STAT_SPATK, 1, FALSE goto BattleScript_GrowthSpAtk BattleScript_GrowthSpAtk2: diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 9715e802f..29ecf2135 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -171,6 +171,7 @@ #define B_WISH_HP_SOURCE GEN_7 // In Gen5+, Wish heals half of the user's max HP instead of the target's. #define B_RAMPAGE_CANCELLING GEN_7 // In Gen5+, a failed Thrash, etc, will cancel except on its last turn. #define B_ROOTED_GROUNDING GEN_7 // In Gen4+, Ingrain causes the affected Pokémon to become grounded. +#define B_GROWTH_UNDER_SUN GEN_7 // In Gen5+, Growth's effects are doubled when under the effects of the sun. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. From c849197a8890c8ddced5b35e84c01d32a20655f0 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 13 Feb 2022 00:45:35 -0300 Subject: [PATCH 07/32] Config for Minimize raising 2 stages --- data/battle_scripts_1.s | 4 ++++ include/constants/battle_config.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index c26d11950..cbdf1bef4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4341,7 +4341,11 @@ BattleScript_NightmareWorked:: BattleScript_EffectMinimize:: attackcanceler setminimize +.if B_MINIMIZE_EVASION >= GEN_5 + setstatchanger STAT_EVASION, 2, FALSE +.else setstatchanger STAT_EVASION, 1, FALSE +.endif goto BattleScript_EffectStatUpAfterAtkCanceler BattleScript_EffectCurse:: diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 29ecf2135..4aa4bebdd 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -152,6 +152,8 @@ #define B_SPEED_BUFFING_RAPID_SPIN GEN_8 // In Gen8, Rapid Spin raises the user's Speed by 1 stage. #define B_RECOIL_IF_MISS_DMG GEN_7 // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing. #define B_UPDATED_CONVERSION GEN_7 // In Gen6+, Conversion changes the user's type to match their first move's. Before, it would choose a move at random. +#define B_PP_REDUCED_BY_SPITE GEN_7 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. +#define B_MINIMIZE_EVASION GEN_7 // In Gen5+, Minimize raises evasion by 2 stages instead of 1. // Move accuracy settings #define B_TOXIC_NEVER_MISS GEN_7 // In Gen6+, if Toxic is used by a Poison-type Pokémon, it will never miss. @@ -161,7 +163,6 @@ // Other move settings #define B_SOUND_SUBSTITUTE GEN_7 // In Gen6+, sound moves bypass Substitute. #define B_INCINERATE_GEMS GEN_7 // In Gen6+, Incinerate can destroy Gems. -#define B_PP_REDUCED_BY_SPITE GEN_7 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. #define B_CAN_SPITE_FAIL GEN_7 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP. #define B_CRASH_IF_TARGET_IMMUNE GEN_7 // In Gen4+, The user of Jump Kick or High Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. #define B_MEMENTO_FAIL GEN_7 // In Gen4+, Memento fails if there is no target or if the target is protected or behind substitute. But not if Atk/Sp. Atk are at -6. From dde65d5cea2e8a89cdd91e24483bae5557ac4cfc Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 13 Feb 2022 01:07:42 -0300 Subject: [PATCH 08/32] =?UTF-8?q?Config=20for=20Sheer=20Cold=20being=20les?= =?UTF-8?q?s=20accurate=20when=20not=20used=20by=20Ice=20type=20Pok=C3=A9m?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/constants/battle_config.h | 1 + src/battle_script_commands.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 4aa4bebdd..ab70634a8 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -159,6 +159,7 @@ #define B_TOXIC_NEVER_MISS GEN_7 // In Gen6+, if Toxic is used by a Poison-type Pokémon, it will never miss. #define B_MINIMIZE_DMG_ACC GEN_7 // In Gen6+, moves that causes double damage to minimized Pokémon will also skip accuracy checks. #define B_BLIZZARD_HAIL GEN_7 // In Gen4+, Blizzard bypasses accuracy checks if it's hailing. +#define B_SHEER_COLD_ACC GEN_7 // In Gen7+, Sheer Cold's base chance of hitting is reduced to 20% if the user isn't Ice-typed. // Other move settings #define B_SOUND_SUBSTITUTE GEN_7 // In Gen6+, sound moves bypass Substitute. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 00be0d2f2..75357dbed 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10728,6 +10728,10 @@ static void Cmd_tryKO(void) else { u16 odds = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattlerAttacker].level - gBattleMons[gBattlerTarget].level); + #if B_SHEER_COLD_ACC >= GEN_7 + if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE)) + odds -= 10; + #endif if (Random() % 100 + 1 < odds && gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) lands = TRUE; } From 5e9767e06716c15ea9d3750f3abab203c8fdcbd2 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 13 Feb 2022 01:13:44 -0300 Subject: [PATCH 09/32] Fixed actually checking for Sheer Cold instead of affecting all OHKO moves --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 75357dbed..d3c1d4e21 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10729,7 +10729,7 @@ static void Cmd_tryKO(void) { u16 odds = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattlerAttacker].level - gBattleMons[gBattlerTarget].level); #if B_SHEER_COLD_ACC >= GEN_7 - if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE)) + if (gCurrentMove == MOVE_SHEER_COLD && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE)) odds -= 10; #endif if (Random() % 100 + 1 < odds && gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) From dafb5ca74ddd436008a171d908c123cbddd49983 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 3 Apr 2022 13:03:53 -0400 Subject: [PATCH 10/32] Fixed trapping moves not reflecting the configured turn config --- src/data/text/move_descriptions.h | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/data/text/move_descriptions.h b/src/data/text/move_descriptions.h index 4704af3fd..80c97a505 100644 --- a/src/data/text/move_descriptions.h +++ b/src/data/text/move_descriptions.h @@ -79,7 +79,11 @@ static const u8 sFlyDescription[] = _( static const u8 sBindDescription[] = _( "Binds and squeezes the foe\n" +#if B_BINDING_TURNS >= GEN_5 + "for 4 or 5 turns."); +#else "for 2 to 5 turns."); +#endif static const u8 sSlamDescription[] = _( "Slams the foe with a long\n" @@ -139,7 +143,11 @@ static const u8 sBodySlamDescription[] = _( static const u8 sWrapDescription[] = _( "Wraps and squeezes the foe\n" +#if B_BINDING_TURNS >= GEN_5 + "4 or 5 times with vines, etc."); +#else "2 to 5 times with vines, etc."); +#endif static const u8 sTakeDownDescription[] = _( "A reckless charge attack\n" @@ -331,7 +339,11 @@ static const u8 sDragonRageDescription[] = _( static const u8 sFireSpinDescription[] = _( "Traps the foe in a ring of\n" +#if B_BINDING_TURNS >= GEN_5 + "fire for 4 or 5 turns."); +#else "fire for 2 to 5 turns."); +#endif static const u8 sThunderShockDescription[] = _( "An electrical attack that\n" @@ -511,7 +523,11 @@ static const u8 sWaterfallDescription[] = _( static const u8 sClampDescription[] = _( "Traps and squeezes the\n" +#if B_BINDING_TURNS >= GEN_5 + "foe for 4 or 5 turns."); +#else "foe for 2 to 5 turns."); +#endif static const u8 sSwiftDescription[] = _( "Sprays star-shaped rays\n" @@ -999,7 +1015,11 @@ static const u8 sRockSmashDescription[] = _( static const u8 sWhirlpoolDescription[] = _( "Traps and hurts the foe in\n" +#if B_BINDING_TURNS >= GEN_5 + "a whirlpool for 4 or 5 turns."); +#else "a whirlpool for 2 to 5 turns."); +#endif static const u8 sBeatUpDescription[] = _( "Summons party Pokémon to\n" @@ -1311,7 +1331,11 @@ static const u8 sSkyUppercutDescription[] = _( static const u8 sSandTombDescription[] = _( "Traps and hurts the foe in\n" +#if B_BINDING_TURNS >= GEN_5 + "quicksand for 4 or 5 turns."); +#else "quicksand for 2 to 5 turns."); +#endif static const u8 sSheerColdDescription[] = _( "A chilling attack that\n" @@ -1815,7 +1839,11 @@ static const u8 sSpacialRendDescription[] = _( static const u8 sMagmaStormDescription[] = _( "Traps the foe in a vortex\n" +#if B_BINDING_TURNS >= GEN_5 + "of fire for 4 or 5 turns."); +#else "of fire for 2 to 5 turns."); +#endif static const u8 sDarkVoidDescription[] = _( "Drags the foe into total\n" @@ -2367,7 +2395,11 @@ static const u8 sNuzzleDescription[] = _( static const u8 sInfestationDescription[] = _( "The foe is infested and\n" +#if B_BINDING_TURNS >= GEN_5 + "attacked for 4 or 5 turns."); +#else "attacked for 2 to 5 turns."); +#endif static const u8 sPowerUpPunchDescription[] = _( "A hard punch that raises\n" @@ -2912,7 +2944,11 @@ static const u8 sSurgingStrikesDescription[] = _( static const u8 sThunderCageDescription[] = _( "Traps the foe in a cage of\n" +#if B_BINDING_TURNS >= GEN_5 + "electricity for 4 or 5 turns."); +#else "electricity for 2 to 5 turns."); +#endif static const u8 sDragonEnergyDescription[] = _( "The higher the user's HP\n" From 6235970722ad9eab298deaf3b66580f9a78dd2d9 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Thu, 5 May 2022 11:41:27 -0700 Subject: [PATCH 11/32] added special battle evo changes --- include/constants/pokemon.h | 2 ++ src/battle_main.c | 37 +++++++++++++++++++++++++++++++++--- src/battle_script_commands.c | 7 +++++++ src/pokemon.c | 13 +++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index c375bbdd1..a7f0e3e4e 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -379,6 +379,7 @@ #define EVO_SPECIFIC_MAP 32 // Pokémon levels up on specified map #define EVO_LEVEL_NATURE_AMPED 33 // Pokémon reaches the specified level, it has a Hardy, Brave, Adamant, Naughty, Docile, Impish, Lax, Hasty, Jolly, Naive, Rash, Sassy, or Quirky nature. #define EVO_LEVEL_NATURE_LOW_KEY 34 // Pokémon reaches the specified level, it has a Lonely, Bold, Relaxed, Timid, Serious, Modest, Mild, Quiet, Bashful, Calm, Gentle, or Careful nature. +#define EVO_CRITICAL_HITS 35 // Pokémon performs specified number of critical hits in one battle #define EVOS_PER_MON 10 @@ -387,6 +388,7 @@ #define EVO_MODE_TRADE 1 #define EVO_MODE_ITEM_USE 2 #define EVO_MODE_ITEM_CHECK 3 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve +#define EVO_MODE_BATTLE_SPECIAL 4 #define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8 diff --git a/src/battle_main.c b/src/battle_main.c index 479cafae6..ca59ff86e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -115,6 +115,7 @@ static void HandleEndTurn_MonFled(void); static void HandleEndTurn_FinishBattle(void); static void SpriteCB_UnusedBattleInit(struct Sprite* sprite); static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite); +static void TrySpecialEvolution(void); EWRAM_DATA u16 gBattle_BG0_X = 0; EWRAM_DATA u16 gBattle_BG0_Y = 0; @@ -237,6 +238,8 @@ EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u16 gLastThrownBall = 0; EWRAM_DATA bool8 gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky +EWRAM_DATA u8 gPartyCriticalHits[PARTY_SIZE] = {0}; +EWRAM_DATA static u8 sTriedEvolving = 0; void (*gPreBattleCallback1)(void); void (*gBattleMainFunc)(void); @@ -2999,6 +3002,7 @@ static void BattleStartClearSetData(void) gBattleStruct->usedHeldItems[i][0] = 0; gBattleStruct->usedHeldItems[i][1] = 0; gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + gPartyCriticalHits[i] = 0; } gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky @@ -5154,9 +5158,16 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) gIsFishingEncounter = FALSE; gIsSurfingEncounter = FALSE; ResetSpriteData(); - if (gLeveledUpInBattle && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT)) + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_RECORDED_LINK + | BATTLE_TYPE_FIRST_BATTLE + | BATTLE_TYPE_SAFARI + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_WALLY_TUTORIAL)) + && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT)) { - gBattleMainFunc = TryEvolvePokemon; + gBattleMainFunc = TrySpecialEvolution; } else { @@ -5174,6 +5185,26 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) } } +static void TrySpecialEvolution(void) // Attempts to perform non-level related battle evolutions (not the script command). +{ + s32 i; + + for (i = 0; i < PARTY_SIZE; i++) + { + u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, SPECIES_NONE); + if (species != SPECIES_NONE && !(sTriedEvolving & gBitTable[i])) + { + sTriedEvolving |= gBitTable[i]; + FreeAllWindowBuffers(); + gBattleMainFunc = WaitForEvoSceneToFinish; + EvolutionScene(&gPlayerParty[i], species, TRUE, i); + return; + } + } + sTriedEvolving = 0; + gBattleMainFunc = TryEvolvePokemon; +} + static void TryEvolvePokemon(void) { s32 i; @@ -5208,7 +5239,7 @@ static void TryEvolvePokemon(void) static void WaitForEvoSceneToFinish(void) { if (gMain.callback2 == BattleMainCB2) - gBattleMainFunc = TryEvolvePokemon; + gBattleMainFunc = TrySpecialEvolution; } static void ReturnFromBattleToOverworld(void) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d6edb0ab2..4ae67d1a2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1914,6 +1914,7 @@ s8 GetInverseCritChance(u8 battlerAtk, u8 battlerDef, u32 move) static void Cmd_critcalc(void) { + u16 partySlot; s32 critChance = CalcCritChanceStage(gBattlerAttacker, gBattlerTarget, gCurrentMove, TRUE); gPotentialItemEffectBattler = gBattlerAttacker; @@ -1928,6 +1929,12 @@ static void Cmd_critcalc(void) else gIsCriticalHit = FALSE; + // Counter for EVO_CRITICAL_HITS. + partySlot = gBattlerPartyIndexes[gBattlerAttacker]; + if (gIsCriticalHit && GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER + && !(gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gBattlerAttacker) == B_POSITION_PLAYER_LEFT)) + gPartyCriticalHits[partySlot]++; + gBattlescriptCurrInstr++; } diff --git a/src/pokemon.c b/src/pokemon.c index 71176d2eb..ff2dcbe51 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5394,6 +5394,19 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem) } } break; + // Battle evolution without leveling; party slot is being passed into the evolutionItem arg. + case EVO_MODE_BATTLE_SPECIAL: + for (i = 0; i < EVOS_PER_MON; i++) + { + switch (gEvolutionTable[species][i].method) + { + case EVO_CRITICAL_HITS: + if (gPartyCriticalHits[evolutionItem] >= gEvolutionTable[species][i].param) + targetSpecies = gEvolutionTable[species][i].targetSpecies; + break; + } + } + break; } return targetSpecies; From e343c73cd8cd3ad16bd045f9cf8b48b00f05f638 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Thu, 5 May 2022 15:17:31 -0700 Subject: [PATCH 12/32] fixed compile error + small tweaks --- src/battle_main.c | 6 +++++- src/pokemon.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/battle_main.c b/src/battle_main.c index ca59ff86e..ee6166062 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5191,7 +5191,11 @@ static void TrySpecialEvolution(void) // Attempts to perform non-level related b for (i = 0; i < PARTY_SIZE; i++) { - u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, SPECIES_NONE); + #ifndef POKEMON_EXPANSION + u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i); + #else + u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, SPECIES_NONE); + #endif if (species != SPECIES_NONE && !(sTriedEvolving & gBitTable[i])) { sTriedEvolving |= gBitTable[i]; diff --git a/src/pokemon.c b/src/pokemon.c index ff2dcbe51..fe2bcf9dd 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5394,6 +5394,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem) } } break; + #ifdef BATTLE_ENGINE // Battle evolution without leveling; party slot is being passed into the evolutionItem arg. case EVO_MODE_BATTLE_SPECIAL: for (i = 0; i < EVOS_PER_MON; i++) @@ -5407,6 +5408,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem) } } break; + #endif } return targetSpecies; From e730d64945b95aba49eaf924ef29c553abd2e433 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Thu, 5 May 2022 15:54:33 -0700 Subject: [PATCH 13/32] corrections --- include/battle.h | 1 + src/pokemon.c | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/include/battle.h b/include/battle.h index 4068454bf..fde4162c7 100644 --- a/include/battle.h +++ b/include/battle.h @@ -932,5 +932,6 @@ extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky +extern u8 gPartyCriticalHits[PARTY_SIZE]; #endif // GUARD_BATTLE_H diff --git a/src/pokemon.c b/src/pokemon.c index fe2bcf9dd..71176d2eb 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5394,21 +5394,6 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem) } } break; - #ifdef BATTLE_ENGINE - // Battle evolution without leveling; party slot is being passed into the evolutionItem arg. - case EVO_MODE_BATTLE_SPECIAL: - for (i = 0; i < EVOS_PER_MON; i++) - { - switch (gEvolutionTable[species][i].method) - { - case EVO_CRITICAL_HITS: - if (gPartyCriticalHits[evolutionItem] >= gEvolutionTable[species][i].param) - targetSpecies = gEvolutionTable[species][i].targetSpecies; - break; - } - } - break; - #endif } return targetSpecies; From 07579bd42bbf5087274af3504af9da3d92df558d Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 7 May 2022 09:56:32 -0400 Subject: [PATCH 14/32] prevent ally pollen puff selection under heal block. add some ai checks for heal block --- include/battle_util.h | 1 + src/battle_ai_main.c | 8 ++++++++ src/battle_controller_opponent.c | 11 ++++++++--- src/battle_controller_player.c | 6 ++++-- src/battle_util.c | 9 +++++++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index d2d7ac29f..dee85ef7f 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -171,6 +171,7 @@ void TryToApplyMimicry(u8 battlerId, bool8 various); void TryToRevertMimicry(void); void RestoreBattlerOriginalTypes(u8 battlerId); u32 GetBattlerMoveTargetType(u8 battlerId, u16 move); +bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move); // Ability checks bool32 IsRolePlayBannedAbilityAtk(u16 ability); bool32 IsRolePlayBannedAbility(u16 ability); diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 192b75d74..5c7d577c0 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -438,6 +438,9 @@ static u8 ChooseMoveOrAction_Doubles(void) { if (gBattleMons[sBattler_AI].moves[j] != 0) { + if (!CanTargetBattler(sBattler_AI, i, gBattleMons[sBattler_AI].moves[j])) + continue; + if (mostViableMovesScores[0] == AI_THINKING_STRUCT->score[j]) { mostViableMovesScores[mostViableMovesNo] = AI_THINKING_STRUCT->score[j]; @@ -2296,6 +2299,8 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) case EFFECT_HIT_ENEMY_HEAL_ALLY: // pollen puff if (IsTargetingPartner(battlerAtk, battlerDef)) { + if (gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK) + return 0; if (AtMaxHp(battlerDef)) score -= 10; else if (gBattleMons[battlerDef].hp > gBattleMons[battlerDef].maxHP / 2) @@ -4902,6 +4907,9 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) || (moveType == TYPE_ELECTRIC && AI_DATA->atkPartnerAbility == ABILITY_VOLT_ABSORB) || (moveType == TYPE_WATER && (AI_DATA->atkPartnerAbility == ABILITY_DRY_SKIN || AI_DATA->atkPartnerAbility == ABILITY_WATER_ABSORB))) { + if (gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK) + return 0; + if (CanTargetFaintAi(FOE(battlerAtk), AI_DATA->battlerAtkPartner) || (CanTargetFaintAi(BATTLE_PARTNER(FOE(battlerAtk)), AI_DATA->battlerAtkPartner))) score--; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 69e0de5af..35e774341 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1605,6 +1605,7 @@ static void OpponentHandleChooseMove(void) else // Wild pokemon - use random move { u16 move; + u8 target; do { chosenMoveId = Random() & 3; @@ -1615,6 +1616,10 @@ static void OpponentHandleChooseMove(void) BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gActiveBattler << 8)); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { + do { + target = GetBattlerAtPosition(Random() & 2); + } while (!CanTargetBattler(gActiveBattler, target, move)); + #if B_WILD_NATURAL_ENEMIES == TRUE // Don't bother to loop through table if the move can't attack ally if (!(gBattleMoves[move].target & MOVE_TARGET_BOTH)) @@ -1641,14 +1646,14 @@ static void OpponentHandleChooseMove(void) break; } } - if (isPartnerEnemy) + if (isPartnerEnemy && CanTargetBattler(gActiveBattler, target, move)) BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(gActiveBattler)) << 8)); else - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8)); } else #endif - BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); + BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8)); } else BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index bd6b3a023..0e01eb549 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -436,7 +436,8 @@ static void HandleInputChooseTarget(void) break; } - if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]) + if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor] + || !CanTargetBattler(gActiveBattler, gMultiUsePlayerCursor, move)) i = 0; } while (i == 0); } @@ -485,7 +486,8 @@ static void HandleInputChooseTarget(void) break; } - if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]) + if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor] + || !CanTargetBattler(gActiveBattler, gMultiUsePlayerCursor, move)) i = 0; } while (i == 0); } diff --git a/src/battle_util.c b/src/battle_util.c index 68c675c54..d17c9ce99 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10099,3 +10099,12 @@ u32 GetBattlerMoveTargetType(u8 battlerId, u16 move) else return gBattleMoves[move].target; } + +bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move) +{ + if (gBattleMoves[move].effect == EFFECT_HIT_ENEMY_HEAL_ALLY + && GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef) + && gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK) + return FALSE; + return TRUE; +} From 89816b62bad6fd4ba2f7626f11f3abc826be74f8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 7 May 2022 10:38:16 -0400 Subject: [PATCH 15/32] Added Sheer Cold accuracy change to ShouldTryOHKO --- src/battle_ai_util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index de4271bba..8ed6e0490 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -1499,6 +1499,10 @@ bool32 ShouldTryOHKO(u8 battlerAtk, u8 battlerDef, u16 atkAbility, u16 defAbilit else // test the odds { u16 odds = accuracy + (gBattleMons[battlerAtk].level - gBattleMons[battlerDef].level); + #if B_SHEER_COLD_ACC >= GEN_7 + if (gCurrentMove == MOVE_SHEER_COLD && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE)) + odds -= 10; + #endif if (Random() % 100 + 1 < odds && gBattleMons[battlerAtk].level >= gBattleMons[battlerDef].level) return TRUE; } From 096fe3c11d5e4d830d89b6d6892b0ae477d3b01b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 7 May 2022 10:56:31 -0400 Subject: [PATCH 16/32] Removed unecessary B_LEEK_ALWAYS_CRIT config --- include/constants/battle_config.h | 3 +-- src/battle_script_commands.c | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 047d7c1a6..fa181fb65 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -99,7 +99,7 @@ #endif // Calculation settings -#define B_CRIT_CHANCE GEN_7 // Chances of a critical hit landing. See CalcCritChanceStage. +#define B_CRIT_CHANCE GEN_7 // Chances of a critical hit landing. See CalcCritChanceStage. Gen6+ chances guarantee that Farfetch'd and Sirfetch'd always get critical hits while holding a Leek and using high-crit ratio moves. #define B_CRIT_MULTIPLIER GEN_7 // In Gen6+, critical hits multiply damage by 1.5 instead of 2. #define B_PARALYSIS_SPEED GEN_7 // In Gen7+, Speed is decreased by 50% instead of 75%. #define B_CONFUSION_SELF_DMG_CHANCE GEN_7 // In Gen7+, confusion has a 33.3% of self-damage, instead of 50%. @@ -209,7 +209,6 @@ #define B_HEAVY_BALL_MODIFIER GEN_7 // In Gen7+, Heavy Ball's ranges change. See Cmd_handleballthrow. #define B_DREAM_BALL_MODIFIER GEN_8 // In Gen8, Dream Ball's catch multiplier is x4 when the target is asleep or has the ability Comatose. #define B_SERENE_GRACE_BOOST GEN_7 // In Gen5+, Serene Grace boosts the added flinch chance of King's Rock and Razor Fang. -#define B_LEEK_ALWAYS_CRIT GEN_7 // In Gen6+, if a Farfetch'd or Sirfetch'd holding a Leek use a move with increased Critical Hit ratio, it will always result in a Critical Hit. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1d9009e6e..d0431c25e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1878,11 +1878,7 @@ s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbi else if (gStatuses3[battlerAtk] & STATUS3_LASER_FOCUS || gBattleMoves[move].effect == EFFECT_ALWAYS_CRIT || (abilityAtk == ABILITY_MERCILESS && gBattleMons[battlerDef].status1 & STATUS1_PSN_ANY) - || move == MOVE_SURGING_STRIKES - #if B_LEEK_ALWAYS_CRIT >= GEN_6 - || ((gBattleMoves[gCurrentMove].flags & FLAG_HIGH_CRIT) && BENEFITS_FROM_LEEK(battlerAtk, holdEffectAtk)) - #endif - ) + || move == MOVE_SURGING_STRIKES) { critChance = -2; } From 5456a87b83a7a86655c7a757a8bd6f1a8535da75 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 7 May 2022 11:27:32 -0400 Subject: [PATCH 17/32] fix pollen puff heal blocked battler in CanTargetBattler --- src/battle_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index d17c9ce99..f1a5bd883 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10104,7 +10104,7 @@ bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move) { if (gBattleMoves[move].effect == EFFECT_HIT_ENEMY_HEAL_ALLY && GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef) - && gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK) - return FALSE; + && gStatuses3[battlerAtk] & STATUS3_HEAL_BLOCK) + return FALSE; // Pokémon affected by Heal Block cannot target allies with Pollen Puff return TRUE; } From 017f44f5ac2ec86cc5d9182bfa6cedd02d8da489 Mon Sep 17 00:00:00 2001 From: AgustinGDLV <103095241+AgustinGDLV@users.noreply.github.com> Date: Sat, 7 May 2022 09:35:00 -0700 Subject: [PATCH 18/32] Apply suggestions from code review Co-authored-by: Eduardo Quezada D'Ottone --- include/constants/pokemon.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index a7f0e3e4e..b1aea3334 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -380,15 +380,20 @@ #define EVO_LEVEL_NATURE_AMPED 33 // Pokémon reaches the specified level, it has a Hardy, Brave, Adamant, Naughty, Docile, Impish, Lax, Hasty, Jolly, Naive, Rash, Sassy, or Quirky nature. #define EVO_LEVEL_NATURE_LOW_KEY 34 // Pokémon reaches the specified level, it has a Lonely, Bold, Relaxed, Timid, Serious, Modest, Mild, Quiet, Bashful, Calm, Gentle, or Careful nature. #define EVO_CRITICAL_HITS 35 // Pokémon performs specified number of critical hits in one battle +#define EVO_SCRIPT_TRIGGER_DMG 36 // Pokémon has specified HP below max, then player interacts trigger +#define EVO_DARK_SCROLL 37 // interacts with Scroll of Darkness +#define EVO_WATER_SCROLL 38 // interacts with Scroll of Waters #define EVOS_PER_MON 10 // Evolution 'modes,' for GetEvolutionTargetSpecies #define EVO_MODE_NORMAL 0 -#define EVO_MODE_TRADE 1 -#define EVO_MODE_ITEM_USE 2 -#define EVO_MODE_ITEM_CHECK 3 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve -#define EVO_MODE_BATTLE_SPECIAL 4 +#define EVO_MODE_NORMAL 0 +#define EVO_MODE_TRADE 1 +#define EVO_MODE_ITEM_USE 2 +#define EVO_MODE_ITEM_CHECK 3 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve +#define EVO_MODE_BATTLE_SPECIAL 4 +#define EVO_MODE_OVERWORLD_SPECIAL 5 #define NUM_MALE_LINK_FACILITY_CLASSES 8 #define NUM_FEMALE_LINK_FACILITY_CLASSES 8 From 4c8770fdc2a308ae2ac4155c931eb8c0559d732e Mon Sep 17 00:00:00 2001 From: sneed Date: Sat, 7 May 2022 21:57:50 +0300 Subject: [PATCH 19/32] Update battle_util.c --- src/battle_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 30df20f4f..114235f73 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6098,12 +6098,18 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) return FALSE; } +#if defined(ITEM_EXPANSION) && B_CONFUSE_BERRIES_HEAL >= GEN_7 + #define CONFUSE_BERRY_HP_FRACTION 4 +#else + #define CONFUSE_BERRY_HP_FRACTION 2 +#endif + static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2) { #if B_HEAL_BLOCKING >= GEN_5 - if (HasEnoughHpToEatBerry(battlerId, 2, itemId) && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) + if (HasEnoughHpToEatBerry(battlerId, CONFUSE_BERRY_HP_FRACTION, itemId) && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) #else - if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) + if (HasEnoughHpToEatBerry(battlerId, CONFUSE_BERRY_HP_FRACTION, itemId)) #endif { PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId); @@ -6140,6 +6146,8 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2) return 0; } +#undef CONFUSE_BERRY_HP_FRACTION + static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2) { if (CompareStat(battlerId, statId, MAX_STAT_STAGE, CMP_LESS_THAN) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId)) From c6b529ed50ec42f0d3e9f1e7eecef84bcb80b46f Mon Sep 17 00:00:00 2001 From: sneed Date: Sat, 7 May 2022 22:09:08 +0300 Subject: [PATCH 20/32] add missing constant --- include/constants/battle_config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fa181fb65..86d6582ba 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -194,6 +194,7 @@ // Item settings #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. #define B_BERRIES_INSTANT GEN_7 // In Gen4+, most berries activate on battle start/switch-in if applicable. In Gen3, they only activate either at the move end or turn end. +#define B_CONFUSE_BERRIES_HEAL GEN_8 // Before Gen7, Figy and similar berries restore 1/8th of HP and trigger at half HP. In Gen7 they restore half HP, triggering at 25% HP. In Gen8 they heal 1/3rd of HP. #define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. #define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable #define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items. From f83875cf0f06c28507f58b07477c67f6b327e786 Mon Sep 17 00:00:00 2001 From: sneed Date: Sat, 7 May 2022 23:34:38 +0300 Subject: [PATCH 21/32] remove item expansion check --- include/constants/battle_config.h | 1 + src/battle_util.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 86d6582ba..baecae018 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -195,6 +195,7 @@ #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. #define B_BERRIES_INSTANT GEN_7 // In Gen4+, most berries activate on battle start/switch-in if applicable. In Gen3, they only activate either at the move end or turn end. #define B_CONFUSE_BERRIES_HEAL GEN_8 // Before Gen7, Figy and similar berries restore 1/8th of HP and trigger at half HP. In Gen7 they restore half HP, triggering at 25% HP. In Gen8 they heal 1/3rd of HP. + // Requires using Item Expansion or manually editing the holdEffectParam of Figy, Wiki, Mago, Aguav and Iapapa berries. #define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. #define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable #define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items. diff --git a/src/battle_util.c b/src/battle_util.c index 114235f73..9681afbe2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6098,7 +6098,7 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) return FALSE; } -#if defined(ITEM_EXPANSION) && B_CONFUSE_BERRIES_HEAL >= GEN_7 +#if B_CONFUSE_BERRIES_HEAL >= GEN_7 #define CONFUSE_BERRY_HP_FRACTION 4 #else #define CONFUSE_BERRY_HP_FRACTION 2 From 07b0ce973766c16d9109ce4326c480e2f2b55e0a Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 8 May 2022 17:57:30 -0400 Subject: [PATCH 22/32] add inner focus ability popup msg --- data/battle_scripts_1.s | 7 +++++++ include/battle_scripts.h | 1 + src/battle_script_commands.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 89d2292cc..354dde4f0 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8498,6 +8498,13 @@ BattleScript_ObliviousPreventsAttraction:: waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd +BattleScript_FlinchPrevention:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_PKMNSXPREVENTSFLINCHING + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd + BattleScript_OwnTempoPrevents:: pause B_WAIT_TIME_SHORT call BattleScript_AbilityPopUp diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 5fd70159b..4134a87dc 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -169,6 +169,7 @@ extern const u8 BattleScript_BRNPrevention[]; extern const u8 BattleScript_PRLZPrevention[]; extern const u8 BattleScript_PSNPrevention[]; extern const u8 BattleScript_ObliviousPreventsAttraction[]; +extern const u8 BattleScript_FlinchPrevention[]; extern const u8 BattleScript_OwnTempoPrevents[]; extern const u8 BattleScript_SoundproofProtected[]; extern const u8 BattleScript_AbilityNoSpecificStatLoss[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ef8c5a764..f64b57d66 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2941,7 +2941,17 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_FLINCH: if (battlerAbility == ABILITY_INNER_FOCUS) { - gBattlescriptCurrInstr++; + if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN) + { + gLastUsedAbility = ABILITY_INNER_FOCUS; + gBattlerAbility = gEffectBattler; + RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); + gBattlescriptCurrInstr = BattleScript_FlinchPrevention; + } + else + { + gBattlescriptCurrInstr++; + } } else { From 277f4a37511495a567b2f671e9b0ac64eb69db70 Mon Sep 17 00:00:00 2001 From: AgustinGDLV <103095241+AgustinGDLV@users.noreply.github.com> Date: Sun, 8 May 2022 21:23:06 -0700 Subject: [PATCH 23/32] niceties Co-authored-by: Eduardo Quezada D'Ottone --- src/battle_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_main.c b/src/battle_main.c index ee6166062..fbe132eae 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5194,7 +5194,7 @@ static void TrySpecialEvolution(void) // Attempts to perform non-level related b #ifndef POKEMON_EXPANSION u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i); #else - u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, SPECIES_NONE); + u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL); #endif if (species != SPECIES_NONE && !(sTriedEvolving & gBitTable[i])) { From 9bb5db2275e42ace6bb34b384659e4f8136505c5 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sun, 8 May 2022 21:23:51 -0700 Subject: [PATCH 24/32] removed duplicate define --- include/constants/pokemon.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index b1aea3334..13db5644e 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -387,7 +387,6 @@ #define EVOS_PER_MON 10 // Evolution 'modes,' for GetEvolutionTargetSpecies -#define EVO_MODE_NORMAL 0 #define EVO_MODE_NORMAL 0 #define EVO_MODE_TRADE 1 #define EVO_MODE_ITEM_USE 2 From 709f583390f2889eba2f3ccd0df3a820c6b7fbeb Mon Sep 17 00:00:00 2001 From: sneed Date: Tue, 10 May 2022 02:58:24 +0300 Subject: [PATCH 25/32] Initial commit --- include/constants/battle_config.h | 1 + src/battle_main.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index baecae018..d968dbd2f 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -252,6 +252,7 @@ // Other settings #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. #define B_MULTI_BATTLE_WHITEOUT GEN_8 // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. +#define B_EVOLUTION_AFTER_WHITEOUT TRUE // If set to TRUE, Pokemon that qualify for evolution after battle will evolve even if the player loses. #define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) // Animation Settings diff --git a/src/battle_main.c b/src/battle_main.c index c376b227e..b2b205cbe 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5174,7 +5174,11 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_WALLY_TUTORIAL)) +#if !B_EVOLUTION_AFTER_WHITEOUT && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT)) +#else + ) +#endif { gBattleMainFunc = TrySpecialEvolution; } From bceccf54747f36aaba7a81637285af553e79943a Mon Sep 17 00:00:00 2001 From: sneed Date: Tue, 10 May 2022 08:17:31 +0300 Subject: [PATCH 26/32] changes --- include/constants/battle_config.h | 2 +- src/battle_main.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index d968dbd2f..74ac9e129 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -252,7 +252,7 @@ // Other settings #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. #define B_MULTI_BATTLE_WHITEOUT GEN_8 // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. -#define B_EVOLUTION_AFTER_WHITEOUT TRUE // If set to TRUE, Pokemon that qualify for evolution after battle will evolve even if the player loses. +#define B_EVOLUTION_AFTER_WHITEOUT GEN_6 // In Gen6+, Pokemon that qualify for evolution after battle will evolve even if the player loses. #define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) // Animation Settings diff --git a/src/battle_main.c b/src/battle_main.c index b2b205cbe..bf2853a7b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5174,11 +5174,7 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_WALLY_TUTORIAL)) -#if !B_EVOLUTION_AFTER_WHITEOUT - && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT)) -#else - ) -#endif + && (B_EVOLUTION_AFTER_WHITEOUT >= GEN_6 || gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT)) { gBattleMainFunc = TrySpecialEvolution; } From b5d98ec93eb1582bc4627de4b65458c9e67b6477 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 13 May 2022 20:05:52 -0400 Subject: [PATCH 27/32] prevent overwriting wild mon held items --- src/pokemon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pokemon.c b/src/pokemon.c index 71176d2eb..65aad6196 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6459,6 +6459,9 @@ void SetWildMonHeldItem(void) for (i = 0; i < count; i++) { + if (GetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM) != ITEM_NONE) + continue; // prevent ovewriting previously set item + rnd = Random() % 100; species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, 0); if (gMapHeader.mapLayoutId == LAYOUT_ALTERING_CAVE) From 7dd6988b2b525e3a2ed7f2191725889f3b777012 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 13 May 2022 20:32:03 -0400 Subject: [PATCH 28/32] fix args to GetMonData --- src/pokemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokemon.c b/src/pokemon.c index 65aad6196..26f12dca2 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6459,7 +6459,7 @@ void SetWildMonHeldItem(void) for (i = 0; i < count; i++) { - if (GetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM) != ITEM_NONE) + if (GetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, NULL) != ITEM_NONE) continue; // prevent ovewriting previously set item rnd = Random() % 100; From 0424e37252f048f3047fb5d6ff5ae690c21a892d Mon Sep 17 00:00:00 2001 From: sneed Date: Thu, 19 May 2022 14:20:34 +0300 Subject: [PATCH 29/32] Fix cherrim + castform interaction --- src/battle_gfx_sfx_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 9dbfa7771..aeed8ab81 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -914,6 +914,8 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo { StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg); paletteOffset = 0x100 + battlerAtk * 16; + lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue); + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]); LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); gBattleMonForms[battlerAtk] = gBattleSpritesDataPtr->animationData->animArg; if (gBattleSpritesDataPtr->battlerData[battlerAtk].transformSpecies != SPECIES_NONE) From 928d3c5a2855a0c85d7b3a6b87e8feeecf58b9ee Mon Sep 17 00:00:00 2001 From: sneed Date: Thu, 19 May 2022 15:08:03 +0300 Subject: [PATCH 30/32] change form on weather fade --- data/battle_scripts_1.s | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 354dde4f0..a9c15040d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6511,9 +6511,11 @@ BattleScript_LearnMoveReturn:: BattleScript_RainContinuesOrEnds:: printfromtable gRainContinuesStringIds waitmessage B_WAIT_TIME_LONG - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainContinuesOrEndsEnd + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_RAIN_STOPPED, BattleScript_RainEnds playanimation BS_ATTACKER, B_ANIM_RAIN_CONTINUES -BattleScript_RainContinuesOrEndsEnd:: + end2 +BattleScript_RainEnds:: + call BattleScript_WeatherFormChanges end2 BattleScript_DamagingWeatherContinues:: @@ -6552,6 +6554,7 @@ BattleScript_DamagingWeatherContinuesEnd:: BattleScript_SandStormHailEnds:: printfromtable gSandStormHailEndStringIds waitmessage B_WAIT_TIME_LONG + call BattleScript_WeatherFormChanges end2 BattleScript_SunlightContinues:: @@ -6563,6 +6566,7 @@ BattleScript_SunlightContinues:: BattleScript_SunlightFaded:: printstring STRINGID_SUNLIGHTFADED waitmessage B_WAIT_TIME_LONG + call BattleScript_WeatherFormChanges end2 BattleScript_OverworldWeatherStarts:: From 881e7e70ec7c14d27d30180e73981397975ef25c Mon Sep 17 00:00:00 2001 From: sneed Date: Thu, 19 May 2022 15:22:28 +0300 Subject: [PATCH 31/32] Generalize usage of castformPalette https://github.com/pret/pokeemerald/pull/1663 --- src/battle_gfx_sfx_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index aeed8ab81..2d441c7eb 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -915,7 +915,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg); paletteOffset = 0x100 + battlerAtk * 16; lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue); - LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]); + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette); LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); gBattleMonForms[battlerAtk] = gBattleSpritesDataPtr->animationData->animArg; if (gBattleSpritesDataPtr->battlerData[battlerAtk].transformSpecies != SPECIES_NONE) From d8d31b79722cb2543d99b8c200970c46e431fa34 Mon Sep 17 00:00:00 2001 From: sneed Date: Fri, 20 May 2022 04:57:32 +0300 Subject: [PATCH 32/32] disable last used ball in bpike --- src/battle_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index 6d98d794d..e0d3b7d61 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3309,7 +3309,7 @@ bool32 CanThrowLastUsedBall(void) #else if (!CanThrowBall()) return FALSE; - if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FRONTIER)) return FALSE; if (!CheckBagHasItem(gLastThrownBall, 1)) return FALSE;