diff --git a/docs/tutorials/how_to_testing_system.md b/docs/tutorials/how_to_testing_system.md index c2b9912898..70ee6c4033 100644 --- a/docs/tutorials/how_to_testing_system.md +++ b/docs/tutorials/how_to_testing_system.md @@ -497,10 +497,10 @@ Causes the test to fail if the `SCENE` command succeeds before the following com ``` Causes the test to fail unless one of the `SCENE` commands succeeds. ``` - ONE_OF { - MESSAGE("Wobbuffet used Celebrate!"); - MESSAGE("Wobbuffet couldn't move because it's paralyzed!"); - } + ONE_OF { + MESSAGE("Wobbuffet used Celebrate!"); + MESSAGE("Wobbuffet couldn't move because it's paralyzed!"); + } ``` ### `NONE_OF` @@ -511,12 +511,12 @@ Causes the test to fail unless one of the `SCENE` commands succeeds. ``` Causes the test to fail if one of the `SCENE` commands succeeds before the command after the `NONE_OF` succeeds. ``` - // Our Wobbuffet does not move before the foe's. - NONE_OF { - MESSAGE("Wobbuffet used Celebrate!"); - MESSAGE("Wobbuffet couldn't move because it's paralyzed!"); - } - MESSAGE("The opposing Wobbuffet used Celebrate!"); + // Our Wobbuffet does not move before the foe's. + NONE_OF { + MESSAGE("Wobbuffet used Celebrate!"); + MESSAGE("Wobbuffet couldn't move because it's paralyzed!"); + } + MESSAGE("The opposing Wobbuffet used Celebrate!"); ``` ### `PLAYER_PARTY` diff --git a/include/constants/generational_changes.h b/include/constants/generational_changes.h index a7a77c944e..ecbdd8a95e 100644 --- a/include/constants/generational_changes.h +++ b/include/constants/generational_changes.h @@ -66,7 +66,7 @@ F(RECOIL_IF_MISS_DMG, recoilIfMissDmg, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ F(KLUTZ_FLING_INTERACTION, klutzFlingInteraction, (u32, GEN_COUNT - 1)) \ F(UPDATED_CONVERSION, updatedConversion, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ - F(UPDATED_CONVERSION_2, updatedConversion2, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ + F(UPDATED_CONVERSION_2, updatedConversion2, (u32, GEN_COUNT - 1)) \ F(PP_REDUCED_BY_SPITE, ppReducedBySpite, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ F(EXTRAPOLATED_MOVE_FLAGS, extrapolatedMoveFlags, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ /* Ability data settings */ \ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5ba9c2bac5..516e817be5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11526,120 +11526,75 @@ static void Cmd_settypetorandomresistance(void) // Before Gen 5 Conversion 2 only worked on a move the attacker was actually hit by. // This changed later to the last move used by the selected target. - if (B_UPDATED_CONVERSION_2 < GEN_5) + u32 moveToCheck; + u32 typeToCheck; + + if (GetConfig(CONFIG_UPDATED_CONVERSION_2) < GEN_5) { - if (gLastLandedMoves[gBattlerAttacker] == MOVE_NONE - || gLastLandedMoves[gBattlerAttacker] == MOVE_UNAVAILABLE) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else if (gBattleMoveEffects[GetMoveEffect(gLastLandedMoves[gBattlerAttacker])].twoTurnEffect - && gBattleMons[gLastHitBy[gBattlerAttacker]].volatiles.multipleTurns) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_TERA) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else if (gLastHitByType[gBattlerAttacker] == TYPE_STELLAR || gLastHitByType[gBattlerAttacker] == TYPE_MYSTERY) - { - gBattlescriptCurrInstr = cmd->failInstr; - } + moveToCheck = gLastLandedMoves[gBattlerAttacker]; + if (GetMoveEffect(moveToCheck) == EFFECT_STRUGGLE) + typeToCheck = TYPE_NORMAL; else - { - u32 i, resistTypes = 0; - u32 hitByType = gLastHitByType[gBattlerAttacker]; - - for (i = 0; i < NUMBER_OF_MON_TYPES; i++) // Find all types that resist. - { - switch (GetTypeModifier(hitByType, i)) - { - case UQ_4_12(0): - case UQ_4_12(0.5): - resistTypes |= 1u << i; - break; - } - } - - while (resistTypes != 0) - { - i = Random() % NUMBER_OF_MON_TYPES; - if (resistTypes & 1u << i) - { - if (IS_BATTLER_OF_TYPE(gBattlerAttacker, i)) - { - resistTypes &= ~(1u << i); // Type resists, but the user is already of this type. - } - else - { - SET_BATTLER_TYPE(gBattlerAttacker, i); - PREPARE_TYPE_BUFFER(gBattleTextBuff1, i); - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } - } - } - - gBattlescriptCurrInstr = cmd->failInstr; - } + typeToCheck = gLastHitByType[gBattlerAttacker]; } else { - if (gLastResultingMoves[gBattlerTarget] == MOVE_NONE - || gLastResultingMoves[gBattlerTarget] == MOVE_UNAVAILABLE - || gLastResultingMoves[gBattlerTarget] == MOVE_STRUGGLE) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else if (!BreaksThroughSemiInvulnerablity(gBattlerTarget, gCurrentMove)) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else if (gLastUsedMoveType[gBattlerTarget] == TYPE_NONE || gLastUsedMoveType[gBattlerTarget] == TYPE_STELLAR || gLastUsedMoveType[gBattlerTarget] == TYPE_MYSTERY) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_TERA) - { - gBattlescriptCurrInstr = cmd->failInstr; - } - else - { - u32 i, resistTypes = 0; + moveToCheck = gLastResultingMoves[gBattlerTarget]; + typeToCheck = gLastUsedMoveType[gBattlerTarget]; + } - for (i = 0; i < NUMBER_OF_MON_TYPES; i++) // Find all types that resist. + if (moveToCheck == MOVE_NONE + || moveToCheck == MOVE_UNAVAILABLE) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else if (!BreaksThroughSemiInvulnerablity(gBattlerTarget, moveToCheck)) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_TERA) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else if (typeToCheck == TYPE_NONE || typeToCheck == TYPE_STELLAR || typeToCheck == TYPE_MYSTERY) + { + gBattlescriptCurrInstr = cmd->failInstr; + } + else + { + u32 i, resistTypes = 0; + + for (i = 0; i < NUMBER_OF_MON_TYPES; i++) // Find all types that resist. + { + switch (GetTypeModifier(typeToCheck, i)) { - switch (GetTypeModifier(gLastUsedMoveType[gBattlerTarget], i)) + case UQ_4_12(0): + case UQ_4_12(0.5): + resistTypes |= 1u << i; + break; + } + } + + while (resistTypes != 0) + { + i = Random() % NUMBER_OF_MON_TYPES; + if (resistTypes & 1u << i) + { + if (IS_BATTLER_OF_TYPE(gBattlerAttacker, i)) { - case UQ_4_12(0): - case UQ_4_12(0.5): - resistTypes |= 1u << i; - break; + resistTypes &= ~(1u << i); // Type resists, but the user is already of this type. + } + else + { + SET_BATTLER_TYPE(gBattlerAttacker, i); + PREPARE_TYPE_BUFFER(gBattleTextBuff1, i); + gBattlescriptCurrInstr = cmd->nextInstr; + return; } } - - while (resistTypes != 0) - { - i = Random() % NUMBER_OF_MON_TYPES; - if (resistTypes & 1u << i) - { - if (IS_BATTLER_OF_TYPE(gBattlerAttacker, i)) - { - resistTypes &= ~(1u << i); // Type resists, but the user is already of this type. - } - else - { - SET_BATTLER_TYPE(gBattlerAttacker, i); - PREPARE_TYPE_BUFFER(gBattleTextBuff1, i); - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } - } - } - - gBattlescriptCurrInstr = cmd->failInstr; } + + gBattlescriptCurrInstr = cmd->failInstr; } } diff --git a/test/battle/gimmick/terastal.c b/test/battle/gimmick/terastal.c index d78a68dc53..2379df58dc 100644 --- a/test/battle/gimmick/terastal.c +++ b/test/battle/gimmick/terastal.c @@ -327,33 +327,6 @@ SINGLE_BATTLE_TEST("(TERA) Reflect Type fails if used by a Terastallized Pokemon } } -SINGLE_BATTLE_TEST("(TERA) Conversion fails if used by a Terastallized Pokemon") -{ - GIVEN { - PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_PSYCHIC); } - OPPONENT(SPECIES_WOBBUFFET); - } WHEN { - TURN { MOVE(player, MOVE_CONVERSION, gimmick: GIMMICK_TERA); } - } SCENE { - MESSAGE("Wobbuffet used Conversion!"); - MESSAGE("But it failed!"); - } -} - -SINGLE_BATTLE_TEST("(TERA) Conversion2 fails if used by a Terastallized Pokemon") -{ - GIVEN { - PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_PSYCHIC); } - OPPONENT(SPECIES_WOBBUFFET); - } WHEN { - TURN { MOVE(opponent, MOVE_SCRATCH); } - TURN { MOVE(player, MOVE_CONVERSION_2, gimmick: GIMMICK_TERA); } - } SCENE { - MESSAGE("Wobbuffet used Conversion 2!"); - MESSAGE("But it failed!"); - } -} - SINGLE_BATTLE_TEST("(TERA) Reflect Type copies a Terastallized Pokemon's Tera Type") { GIVEN { @@ -506,26 +479,6 @@ SINGLE_BATTLE_TEST("(TERA) Revelation Dance uses a Stellar-type Pokemon's base t } } -#if B_UPDATED_CONVERSION_2 < GEN_5 -SINGLE_BATTLE_TEST("(TERA) Conversion2 fails if last hit by a Stellar-type move") -{ - GIVEN { - PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_STELLAR); } - OPPONENT(SPECIES_WOBBUFFET); - } WHEN { - TURN { MOVE(player, MOVE_TERA_BLAST, gimmick: GIMMICK_TERA); } - TURN { MOVE(opponent, MOVE_CONVERSION_2); } - } SCENE { - // turn 1 - MESSAGE("Wobbuffet used Tera Blast!"); - ANIMATION(ANIM_TYPE_MOVE, MOVE_TERA_BLAST, player); - // turn 2 - MESSAGE("The opposing Wobbuffet used Conversion 2!"); - MESSAGE("But it failed!"); - } -} -#endif - SINGLE_BATTLE_TEST("(TERA) Roost does not remove Flying-type ground immunity when Terastallized into the Stellar type") { GIVEN { diff --git a/test/battle/move_effect/conversion.c b/test/battle/move_effect/conversion.c index ac863cf2b2..165d274a50 100644 --- a/test/battle/move_effect/conversion.c +++ b/test/battle/move_effect/conversion.c @@ -8,3 +8,16 @@ TO_DO_BATTLE_TEST("Conversion fails if all the user's moves share types with the TO_DO_BATTLE_TEST("Conversion changes the user's types to the one in the user's first slot (Gen 6+)"); TO_DO_BATTLE_TEST("Conversion can read the user's first move slot even if that move cannot be selected (Gen 6+)"); //Eg. Disable TO_DO_BATTLE_TEST("Conversion can change the user's types to Conversion's type"); + +SINGLE_BATTLE_TEST("(TERA) Conversion fails if used by a Terastallized Pokemon") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_PSYCHIC); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_CONVERSION, gimmick: GIMMICK_TERA); } + } SCENE { + MESSAGE("Wobbuffet used Conversion!"); + MESSAGE("But it failed!"); + } +} diff --git a/test/battle/move_effect/conversion_2.c b/test/battle/move_effect/conversion_2.c index acd21125c3..169243019b 100644 --- a/test/battle/move_effect/conversion_2.c +++ b/test/battle/move_effect/conversion_2.c @@ -3,10 +3,10 @@ TO_DO_BATTLE_TEST("Conversion 2's type change considers Inverse Battles"); -#if B_UPDATED_CONVERSION_2 < GEN_5 -SINGLE_BATTLE_TEST("Conversion 2 randomly changes the type of the user to a type that resists the last move that hit the user (Gen 3-4)") +SINGLE_BATTLE_TEST("Conversion 2 randomly changes the type of the user to a type that resists the last move that hit the user (Gen 1-4)") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_4); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -16,15 +16,16 @@ SINGLE_BATTLE_TEST("Conversion 2 randomly changes the type of the user to a type MESSAGE("Wobbuffet used Ominous Wind!"); // turn 1 ONE_OF { - MESSAGE("The opposing Wobbuffet transformed into the Normal type!"); - MESSAGE("The opposing Wobbuffet transformed into the Dark type!"); + MESSAGE("The opposing Wobbuffet transformed into the Normal type!"); + MESSAGE("The opposing Wobbuffet transformed into the Dark type!"); } } } -SINGLE_BATTLE_TEST("Conversion 2's type change considers Struggle to be Normal type (Gen 3-4)") +SINGLE_BATTLE_TEST("Conversion 2's type change considers Struggle to be Normal type (Gen 1-4)") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_4); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -35,18 +36,17 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers Struggle to be Normal t MESSAGE("The opposing Wobbuffet used Struggle!"); // turn 2 ONE_OF { - MESSAGE("Wobbuffet transformed into the Steel type!"); - MESSAGE("Wobbuffet transformed into the Rock type!"); - MESSAGE("Wobbuffet transformed into the Ghost type!"); + MESSAGE("Wobbuffet transformed into the Steel type!"); + MESSAGE("Wobbuffet transformed into the Rock type!"); + MESSAGE("Wobbuffet transformed into the Ghost type!"); } } } -#endif -#if B_UPDATED_CONVERSION_2 >= GEN_5 SINGLE_BATTLE_TEST("Conversion 2 randomly changes the type of the user to a type that resists the last used target's move (Gen 5+)") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -56,8 +56,8 @@ SINGLE_BATTLE_TEST("Conversion 2 randomly changes the type of the user to a type MESSAGE("Wobbuffet used Ominous Wind!"); // turn 1 ONE_OF { - MESSAGE("The opposing Wobbuffet transformed into the Normal type!"); - MESSAGE("The opposing Wobbuffet transformed into the Dark type!"); + MESSAGE("The opposing Wobbuffet transformed into the Normal type!"); + MESSAGE("The opposing Wobbuffet transformed into the Dark type!"); } } } @@ -65,6 +65,7 @@ SINGLE_BATTLE_TEST("Conversion 2 randomly changes the type of the user to a type SINGLE_BATTLE_TEST("Conversion 2's type change considers status moves (Gen 5+)") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -75,8 +76,8 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers status moves (Gen 5+)") MESSAGE("The opposing Wobbuffet used Curse!"); // turn 2 ONE_OF { - MESSAGE("Wobbuffet transformed into the Normal type!"); - MESSAGE("Wobbuffet transformed into the Dark type!"); + MESSAGE("Wobbuffet transformed into the Normal type!"); + MESSAGE("Wobbuffet transformed into the Dark type!"); } } } @@ -84,6 +85,7 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers status moves (Gen 5+)") SINGLE_BATTLE_TEST("Conversion 2's type change considers the type of moves called by other moves") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -94,8 +96,8 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers the type of moves calle MESSAGE("The opposing Wobbuffet used Mirror Move!"); // turn 2 ONE_OF { - MESSAGE("Wobbuffet transformed into the Normal type!"); - MESSAGE("Wobbuffet transformed into the Dark type!"); + MESSAGE("Wobbuffet transformed into the Normal type!"); + MESSAGE("Wobbuffet transformed into the Dark type!"); } } } @@ -103,6 +105,7 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers the type of moves calle SINGLE_BATTLE_TEST("Conversion 2's type change considers dynamic type moves") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -113,10 +116,10 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers dynamic type moves") MESSAGE("The opposing Wobbuffet used Weather Ball!"); // turn 2 ONE_OF { - MESSAGE("Wobbuffet transformed into the Steel type!"); - MESSAGE("Wobbuffet transformed into the Fire type!"); - MESSAGE("Wobbuffet transformed into the Water type!"); - MESSAGE("Wobbuffet transformed into the Ice type!"); + MESSAGE("Wobbuffet transformed into the Steel type!"); + MESSAGE("Wobbuffet transformed into the Fire type!"); + MESSAGE("Wobbuffet transformed into the Water type!"); + MESSAGE("Wobbuffet transformed into the Ice type!"); } } } @@ -124,6 +127,7 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers dynamic type moves") SINGLE_BATTLE_TEST("Conversion 2's type change considers move types changed by Normalize and Electrify") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_NORMALIZE); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -136,17 +140,17 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers move types changed by N MESSAGE("The opposing Wobbuffet used Pound!"); // turn 2 ONE_OF { - MESSAGE("Wobbuffet transformed into the Ground type!"); - MESSAGE("Wobbuffet transformed into the Dragon type!"); - MESSAGE("Wobbuffet transformed into the Grass type!"); - MESSAGE("Wobbuffet transformed into the Electric type!"); + MESSAGE("Wobbuffet transformed into the Ground type!"); + MESSAGE("Wobbuffet transformed into the Dragon type!"); + MESSAGE("Wobbuffet transformed into the Grass type!"); + MESSAGE("Wobbuffet transformed into the Electric type!"); } // turn 3 MESSAGE("Wobbuffet used Water Gun!"); ONE_OF { - MESSAGE("The opposing Wobbuffet transformed into the Steel type!"); - MESSAGE("The opposing Wobbuffet transformed into the Rock type!"); - MESSAGE("The opposing Wobbuffet transformed into the Ghost type!"); + MESSAGE("The opposing Wobbuffet transformed into the Steel type!"); + MESSAGE("The opposing Wobbuffet transformed into the Rock type!"); + MESSAGE("The opposing Wobbuffet transformed into the Ghost type!"); } } } @@ -154,6 +158,7 @@ SINGLE_BATTLE_TEST("Conversion 2's type change considers move types changed by N SINGLE_BATTLE_TEST("Conversion 2's type change fails targeting Struggle (Gen 5+)") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -171,6 +176,7 @@ SINGLE_BATTLE_TEST("Conversion 2's type change fails targeting Struggle (Gen 5+) SINGLE_BATTLE_TEST("Conversion 2 fails if the move used is of typeless damage (Gen 5+)") { GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_ENTEI); } WHEN { @@ -187,7 +193,6 @@ SINGLE_BATTLE_TEST("Conversion 2 fails if the move used is of typeless damage (G MESSAGE("But it failed!"); } } -#endif SINGLE_BATTLE_TEST("Conversion 2 fails if the targeted move is Stellar Type") { @@ -205,3 +210,35 @@ SINGLE_BATTLE_TEST("Conversion 2 fails if the targeted move is Stellar Type") MESSAGE("But it failed!"); } } + +SINGLE_BATTLE_TEST("Conversion 2 fails if used by a Terastallized Pokemon") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_PSYCHIC); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); } + TURN { MOVE(player, MOVE_CONVERSION_2, gimmick: GIMMICK_TERA); } + } SCENE { + MESSAGE("Wobbuffet used Conversion 2!"); + MESSAGE("But it failed!"); + } +} + +SINGLE_BATTLE_TEST("Conversion 2 fails if last hit by a Stellar-type move (Gen 1-4)") +{ + GIVEN { + WITH_CONFIG(CONFIG_UPDATED_CONVERSION_2, GEN_4); + PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_STELLAR); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TERA_BLAST, gimmick: GIMMICK_TERA); MOVE(opponent, MOVE_CONVERSION_2); } + } SCENE { + // turn 1 + MESSAGE("Wobbuffet used Tera Blast!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TERA_BLAST, player); + // turn 2 + MESSAGE("The opposing Wobbuffet used Conversion 2!"); + MESSAGE("But it failed!"); + } +}