diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index dec096e6e..4b0b341dd 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1346,7 +1346,7 @@ callnative BS_ItemRestorePP .endm - .macro trytorevertweatherform + .macro tryrevertweatherform callnative BS_TryRevertWeatherForm .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 26f30ef3f..89e69b50c 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1580,7 +1580,7 @@ BattleScript_MoveEffectCoreEnforcer:: printstring STRINGID_PKMNSABILITYSUPPRESSED waitmessage B_WAIT_TIME_LONG trytoclearprimalweather - trytorevertweatherform + tryrevertweatherform printstring STRINGID_EMPTYSTRING3 waitmessage 1 BattleScript_CoreEnforcerRet: @@ -2729,7 +2729,7 @@ BattleScript_EffectSimpleBeam: printstring STRINGID_PKMNACQUIREDSIMPLE waitmessage B_WAIT_TIME_LONG trytoclearprimalweather - trytorevertweatherform + tryrevertweatherform printstring STRINGID_EMPTYSTRING3 waitmessage 1 tryendneutralizinggas BS_TARGET @@ -2829,7 +2829,7 @@ BattleScript_EffectWorrySeed: printstring STRINGID_PKMNACQUIREDABILITY waitmessage B_WAIT_TIME_LONG trytoclearprimalweather - trytorevertweatherform + tryrevertweatherform printstring STRINGID_EMPTYSTRING3 waitmessage 1 goto BattleScript_MoveEnd @@ -2961,7 +2961,7 @@ BattleScript_EffectGastroAcid: printstring STRINGID_PKMNSABILITYSUPPRESSED waitmessage B_WAIT_TIME_LONG trytoclearprimalweather - trytorevertweatherform + tryrevertweatherform printstring STRINGID_EMPTYSTRING3 waitmessage 1 tryendneutralizinggas BS_TARGET @@ -8003,9 +8003,7 @@ BattleScript_CudChewActivates:: setbyte sBERRY_OVERRIDE, 0 end3 -BattleScript_TargetFormChange:: - pause 5 - call BattleScript_AbilityPopUpTarget +BattleScript_TargetFormChangeNoPopup: printstring STRINGID_EMPTYSTRING3 waitmessage 1 handleformchange BS_TARGET, 0 @@ -8015,32 +8013,25 @@ BattleScript_TargetFormChange:: handleformchange BS_TARGET, 2 return +BattleScript_TargetFormChange:: + pause 5 + call BattleScript_AbilityPopUpTarget + call BattleScript_TargetFormChangeNoPopup + return + BattleScript_TargetFormChangeWithString:: pause 5 call BattleScript_AbilityPopUpTarget - printstring STRINGID_EMPTYSTRING3 - waitmessage 1 - handleformchange BS_TARGET, 0 - handleformchange BS_TARGET, 1 - playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL - waitanimation - handleformchange BS_TARGET, 2 + call BattleScript_TargetFormChangeNoPopup printstring STRINGID_PKMNTRANSFORMED waitmessage B_WAIT_TIME_LONG return -BattleScript_TargetFormChangeWithStringNoPopupEnd3:: - pause 5 - printstring STRINGID_EMPTYSTRING3 - waitmessage 1 - handleformchange BS_TARGET, 0 - handleformchange BS_TARGET, 1 - playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL - waitanimation - handleformchange BS_TARGET, 2 +BattleScript_TargetFormChangeWithStringNoPopup:: + call BattleScript_TargetFormChangeNoPopup printstring STRINGID_PKMNTRANSFORMED waitmessage B_WAIT_TIME_LONG - end3 + return BattleScript_BattlerFormChangeWithStringEnd3:: pause 5 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 4a0057275..c5b844b99 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -465,7 +465,7 @@ extern const u8 BattleScript_MoveEffectStockpileWoreOff[]; extern const u8 BattleScript_StealthRockActivates[]; extern const u8 BattleScript_SpikesActivates[]; extern const u8 BattleScript_BerserkGeneRet[]; -extern const u8 BattleScript_TargetFormChangeWithStringNoPopupEnd3[]; +extern const u8 BattleScript_TargetFormChangeWithStringNoPopup[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/form_change_types.h b/include/constants/form_change_types.h index 651bcf788..81d1b045b 100644 --- a/include/constants/form_change_types.h +++ b/include/constants/form_change_types.h @@ -89,6 +89,7 @@ // Form change that activates when a specific weather is set during battle. // param1: weather to check +// param2: (optional) revert if specified ability is lost #define FORM_CHANGE_BATTLE_WEATHER 14 // Form change that activates automatically when the turn ends. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b21197a67..dd198f512 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16567,13 +16567,12 @@ void BS_ItemRestorePP(void) void BS_TryRevertWeatherForm(void) { NATIVE_ARGS(); - u16 ability = gBattleMons[gBattlerTarget].ability; if (B_WEATHER_FORM_SUPPRESS >= GEN_5 - && (ability == ABILITY_FORECAST || ability == ABILITY_FLOWER_GIFT) - && TryBattleFormChange(gBattlerTarget, FORM_CHANGE_BATTLE_SWITCH)) // revert form + && TryBattleFormChange(gBattlerTarget, FORM_CHANGE_BATTLE_WEATHER)) { gBattleScripting.battler = gBattlerTarget; - BattleScriptPushCursorAndCallback(BattleScript_TargetFormChangeWithStringNoPopupEnd3); + BattleScriptPush(cmd->nextInstr); + gBattlescriptCurrInstr = BattleScript_TargetFormChangeWithStringNoPopup; return; } gBattlescriptCurrInstr = cmd->nextInstr; diff --git a/src/battle_util.c b/src/battle_util.c index 67270469e..602dd5c74 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6013,8 +6013,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move #else TRY_WEATHER_FORM: #endif - if ((IsBattlerWeatherAffected(battler, gBattleWeather) || gBattleWeather == B_WEATHER_NONE) - && TryBattleFormChange(battler, FORM_CHANGE_BATTLE_WEATHER)) + if ((IsBattlerWeatherAffected(battler, gBattleWeather) + || gBattleWeather == B_WEATHER_NONE + || !WEATHER_HAS_EFFECT) // Air Lock active + && TryBattleFormChange(battler, FORM_CHANGE_BATTLE_WEATHER)) { BattleScriptPushCursorAndCallback(BattleScript_BattlerFormChangeWithStringEnd3); effect++; @@ -10101,9 +10103,26 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method) } break; case FORM_CHANGE_BATTLE_WEATHER: - if (gBattleWeather & formChanges[i].param1 - || (gBattleWeather == B_WEATHER_NONE && formChanges[i].param1 == B_WEATHER_NONE)) + // Check if there is a required ability and if the battler's ability does not match it + // or is suppressed. If so, revert to the no weather form. + if (formChanges[i].param2 + && (gBattleMons[battlerId].ability != formChanges[i].param2 + || (gStatuses3[gBattlerTarget] & STATUS3_GASTRO_ACID)) + && formChanges[i].param1 == B_WEATHER_NONE) + { targetSpecies = formChanges[i].targetSpecies; + } + // We need to revert the weather form if the field is under Air Lock, too. + if (!WEATHER_HAS_EFFECT && formChanges[i].param1 == B_WEATHER_NONE) + { + targetSpecies = formChanges[i].targetSpecies; + } + // Otherwise, just check for a match between the weather and the form change table. + else if (gBattleWeather & formChanges[i].param1 + || (gBattleWeather == B_WEATHER_NONE && formChanges[i].param1 == B_WEATHER_NONE)) + { + targetSpecies = formChanges[i].targetSpecies; + } break; case FORM_CHANGE_BATTLE_TURN_END: if (formChanges[i].param1 == GetBattlerAbility(battlerId)) diff --git a/src/data/pokemon/form_change_tables.h b/src/data/pokemon/form_change_tables.h index c4ade7b9a..4137c9ba3 100644 --- a/src/data/pokemon/form_change_tables.h +++ b/src/data/pokemon/form_change_tables.h @@ -156,11 +156,11 @@ static const struct FormChange sAbsolFormChangeTable[] = { }; static const struct FormChange sCastformFormChangeTable[] = { - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_SUNNY, B_WEATHER_SUN}, - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_RAINY, B_WEATHER_RAIN}, - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_SNOWY, B_WEATHER_HAIL}, - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM, ~(B_WEATHER_SUN | B_WEATHER_RAIN | B_WEATHER_HAIL)}, - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM, B_WEATHER_NONE}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_SUNNY, B_WEATHER_SUN, ABILITY_FORECAST}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_RAINY, B_WEATHER_RAIN, ABILITY_FORECAST}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM_SNOWY, B_WEATHER_HAIL, ABILITY_FORECAST}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM, ~(B_WEATHER_SUN | B_WEATHER_RAIN | B_WEATHER_HAIL), ABILITY_FORECAST}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CASTFORM, B_WEATHER_NONE, ABILITY_FORECAST}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CASTFORM}, {FORM_CHANGE_FAINT, SPECIES_CASTFORM}, {FORM_CHANGE_END_BATTLE, SPECIES_CASTFORM}, @@ -231,9 +231,9 @@ static const struct FormChange sBurmyFormChangeTable[] = { }; static const struct FormChange sCherrimFormChangeTable[] = { - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM_SUNSHINE, B_WEATHER_SUN}, - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM, ~B_WEATHER_SUN}, - {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM, B_WEATHER_NONE}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM_SUNSHINE, B_WEATHER_SUN, ABILITY_FLOWER_GIFT}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM, ~B_WEATHER_SUN, ABILITY_FLOWER_GIFT}, + {FORM_CHANGE_BATTLE_WEATHER, SPECIES_CHERRIM, B_WEATHER_NONE, ABILITY_FLOWER_GIFT}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_CHERRIM}, {FORM_CHANGE_FAINT, SPECIES_CHERRIM}, {FORM_CHANGE_END_BATTLE, SPECIES_CHERRIM}, diff --git a/test/ability_flower_gift.c b/test/ability_flower_gift.c index 2f2b98d1e..1967b874d 100644 --- a/test/ability_flower_gift.c +++ b/test/ability_flower_gift.c @@ -54,7 +54,7 @@ SINGLE_BATTLE_TEST("Flower Gift transforms Cherrim back to normal when its abili } } -DOUBLE_BATTLE_TEST("Flower Gift increases the attack of Cherrim's ally by 1.5x", s16 damage) +DOUBLE_BATTLE_TEST("Flower Gift increases the attack of Cherrim and its allies by 1.5x", s16 damageL, s16 damageR) { bool32 sunny; PARAMETRIZE { sunny = FALSE; } @@ -67,19 +67,55 @@ DOUBLE_BATTLE_TEST("Flower Gift increases the attack of Cherrim's ally by 1.5x", } WHEN { if (sunny) TURN { MOVE(playerLeft, MOVE_SUNNY_DAY); } - TURN { MOVE(playerRight, MOVE_TACKLE, target: opponentLeft); } + TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); + MOVE(playerRight, MOVE_TACKLE, target: opponentLeft); } } SCENE { - // Sun activates + // sun activates if (sunny) { ABILITY_POPUP(playerLeft, ABILITY_FLOWER_GIFT); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, playerLeft); MESSAGE("Cherrim transformed!"); } - // Partner uses Tackle + // player uses Tackle + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerLeft); + HP_BAR(opponentLeft, captureDamage: &results[i].damageL); + // partner uses Tackle ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerRight); - HP_BAR(opponentLeft, captureDamage: &results[i].damage); + HP_BAR(opponentLeft, captureDamage: &results[i].damageR); } FINALLY { - EXPECT_MUL_EQ(results[0].damage, UQ_4_12(1.5), results[1].damage); + EXPECT_MUL_EQ(results[0].damageL, UQ_4_12(1.5), results[1].damageL); + EXPECT_MUL_EQ(results[0].damageR, UQ_4_12(1.5), results[1].damageR); + } +} + +DOUBLE_BATTLE_TEST("Flower Gift increases the Sp. Def of Cherrim and its allies by 1.5x", s16 damageL, s16 damageR) +{ + bool32 sunny; + PARAMETRIZE { sunny = FALSE; } + PARAMETRIZE { sunny = TRUE; } + GIVEN { + PLAYER(SPECIES_CHERRIM) { Ability(ABILITY_FLOWER_GIFT); }; + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (sunny) + TURN { MOVE(playerLeft, MOVE_SUNNY_DAY); } + TURN { MOVE(opponentLeft, MOVE_HYPER_VOICE, target: playerLeft); } + } SCENE { + // sun activates + if (sunny) { + ABILITY_POPUP(playerLeft, ABILITY_FLOWER_GIFT); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, playerLeft); + MESSAGE("Cherrim transformed!"); + } + // opponentLeft uses Hyper Voice + ANIMATION(ANIM_TYPE_MOVE, MOVE_HYPER_VOICE, opponentLeft); + HP_BAR(playerLeft, captureDamage: &results[i].damageL); + HP_BAR(playerRight, captureDamage: &results[i].damageR); + } FINALLY { + EXPECT_MUL_EQ(results[1].damageL, UQ_4_12(1.5), results[0].damageL); + EXPECT_MUL_EQ(results[1].damageR, UQ_4_12(1.5), results[0].damageR); } } diff --git a/test/ability_forecast.c b/test/ability_forecast.c index dba09992d..826ba0e99 100644 --- a/test/ability_forecast.c +++ b/test/ability_forecast.c @@ -7,6 +7,7 @@ SINGLE_BATTLE_TEST("Forecast transforms Castform in weather from an opponent's m PARAMETRIZE { move = MOVE_SUNNY_DAY; } PARAMETRIZE { move = MOVE_RAIN_DANCE; } PARAMETRIZE { move = MOVE_HAIL; } + PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; OPPONENT(SPECIES_WOBBUFFET); @@ -25,6 +26,7 @@ SINGLE_BATTLE_TEST("Forecast transforms Castform in weather from its own move") PARAMETRIZE { move = MOVE_SUNNY_DAY; } PARAMETRIZE { move = MOVE_RAIN_DANCE; } PARAMETRIZE { move = MOVE_HAIL; } + PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; OPPONENT(SPECIES_WOBBUFFET); @@ -43,6 +45,7 @@ DOUBLE_BATTLE_TEST("Forecast transforms Castform in weather from a partner's mov PARAMETRIZE { move = MOVE_SUNNY_DAY; } PARAMETRIZE { move = MOVE_RAIN_DANCE; } PARAMETRIZE { move = MOVE_HAIL; } + PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; PLAYER(SPECIES_WOBBUFFET); @@ -63,6 +66,7 @@ DOUBLE_BATTLE_TEST("Forecast transforms all Castforms present in weather") PARAMETRIZE { move = MOVE_SUNNY_DAY; } PARAMETRIZE { move = MOVE_RAIN_DANCE; } PARAMETRIZE { move = MOVE_HAIL; } + PARAMETRIZE { move = MOVE_SNOWSCAPE; } GIVEN { PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; @@ -88,10 +92,14 @@ DOUBLE_BATTLE_TEST("Forecast transforms all Castforms present in weather") SINGLE_BATTLE_TEST("Forecast transforms Castform in weather from an ability") { + u32 species, ability; + PARAMETRIZE { species = SPECIES_KYOGRE; ability = ABILITY_DRIZZLE; } + PARAMETRIZE { species = SPECIES_GROUDON; ability = ABILITY_DROUGHT; } + PARAMETRIZE { species = SPECIES_ABOMASNOW; ability = ABILITY_SNOW_WARNING; } GIVEN { PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; OPPONENT(SPECIES_WOBBUFFET); - OPPONENT(SPECIES_KYOGRE) { Ability(ABILITY_DRIZZLE); }; + OPPONENT(species) { Ability(ability); }; } WHEN { TURN { SWITCH(opponent, 1); } } SCENE { @@ -103,14 +111,17 @@ SINGLE_BATTLE_TEST("Forecast transforms Castform in weather from an ability") SINGLE_BATTLE_TEST("Forecast transforms Castform in primal weather") { + u32 species, item, ability; + PARAMETRIZE { species = SPECIES_KYOGRE; ability = ABILITY_PRIMORDIAL_SEA; item = ITEM_BLUE_ORB; } + PARAMETRIZE { species = SPECIES_GROUDON; ability = ABILITY_DESOLATE_LAND; item = ITEM_RED_ORB; } GIVEN { PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; OPPONENT(SPECIES_WOBBUFFET); - OPPONENT(SPECIES_KYOGRE) { Ability(ABILITY_DRIZZLE); Item(ITEM_BLUE_ORB); }; + OPPONENT(species) { Item(item); }; } WHEN { TURN { SWITCH(opponent, 1); } } SCENE { - ABILITY_POPUP(opponent, ABILITY_PRIMORDIAL_SEA); + ABILITY_POPUP(opponent, ability); ABILITY_POPUP(player, ABILITY_FORECAST); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); MESSAGE("Castform transformed!"); @@ -161,6 +172,29 @@ SINGLE_BATTLE_TEST("Forecast transforms Castform back to normal when Sandstorm i } } +SINGLE_BATTLE_TEST("Forecast transforms Castform back to normal under Air Lock") +{ + GIVEN { + PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_RAYQUAZA); + } WHEN { + TURN { MOVE(player, MOVE_RAIN_DANCE); } + TURN { SWITCH(opponent, 1); } + TURN { MOVE(opponent, MOVE_CELEBRATE, megaEvolve: TRUE); } + } SCENE { + // transforms + ABILITY_POPUP(player, ABILITY_FORECAST); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Castform transformed!"); + // back to normal + ABILITY_POPUP(opponent, ABILITY_AIR_LOCK); + ABILITY_POPUP(player, ABILITY_FORECAST); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Castform transformed!"); + } +} + SINGLE_BATTLE_TEST("Forecast transforms Castform on switch-in") { GIVEN { @@ -199,3 +233,22 @@ SINGLE_BATTLE_TEST("Forecast transforms Castform when weather changes") MESSAGE("Castform transformed!"); } } + +SINGLE_BATTLE_TEST("Forecast transforms Castform back to normal when its ability is suppressed") +{ + GIVEN { + PLAYER(SPECIES_CASTFORM) { Ability(ABILITY_FORECAST); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_SUNNY_DAY); } + TURN { MOVE(opponent, MOVE_GASTRO_ACID); } + } SCENE { + // transforms in sun + ABILITY_POPUP(player, ABILITY_FORECAST); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Castform transformed!"); + // back to normal + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FORM_CHANGE, player); + MESSAGE("Castform transformed!"); + } +}