From 3122d744f535194e4e9747a6c0be8e457764f98b Mon Sep 17 00:00:00 2001 From: kaboissonneault Date: Thu, 2 Nov 2023 09:48:13 -0400 Subject: [PATCH 1/2] Added BUGFIX for "dual non-immunity" glitch. In certain AI script commands, the call to TypeCalc does not assign effectiveness flags properly, resulting in the check for immunity always failing --- src/battle_ai_script_commands.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 9a63031dd2..8bb76705ec 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1484,7 +1484,13 @@ static void Cmd_get_highest_type_effectiveness(void) if (gCurrentMove != MOVE_NONE) { + // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // This makes the check for gMoveResultFlags below always fail +#ifdef BUGFIX + gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#else TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#endif if (gBattleMoveDamage == 120) // Super effective STAB. gBattleMoveDamage = AI_EFFECTIVENESS_x2; @@ -1519,7 +1525,16 @@ static void Cmd_if_type_effectiveness(void) gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; + // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // This makes the check for gMoveResultFlags below always fail + // This is how you get the "dual non-immunity" glitch, where AI + // will use ineffective moves on immune pokémon if the second type + // has a non-neutral, non-immune effectiveness +#ifdef BUGFIX + gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#else TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); +#endif if (gBattleMoveDamage == 120) // Super effective STAB. gBattleMoveDamage = AI_EFFECTIVENESS_x2; From 5ddf3e2ee514cfd9250e68772c8a19ee2e8fb21d Mon Sep 17 00:00:00 2001 From: kaboissonneault Date: Thu, 2 Nov 2023 11:17:57 -0400 Subject: [PATCH 2/2] Fixed casing in comment on "dual non-immunity" glitch --- src/battle_ai_script_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 8bb76705ec..d8a9760ff2 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -1484,7 +1484,7 @@ static void Cmd_get_highest_type_effectiveness(void) if (gCurrentMove != MOVE_NONE) { - // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does // This makes the check for gMoveResultFlags below always fail #ifdef BUGFIX gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); @@ -1525,7 +1525,7 @@ static void Cmd_if_type_effectiveness(void) gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - // TypeCalc does not assign to gMoveResultFlags, Cmd_TypeCalc does + // TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does // This makes the check for gMoveResultFlags below always fail // This is how you get the "dual non-immunity" glitch, where AI // will use ineffective moves on immune pokémon if the second type