diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4f11fc78b..6c985e3cd 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1322,6 +1322,11 @@ .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES .endm + + @ Stores Healing Wish effect. + .macro storehealingwish battler:req + various \battler, VARIOUS_STORE_HEALING_WISH + .endm .macro setmagiccoattarget battler:req various \battler, VARIOUS_SET_MAGIC_COAT_TARGET diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ae92aba7c..6fa0cd7ad 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2697,6 +2697,8 @@ BattleScript_EffectHealingWish: instanthpdrop BS_ATTACKER setatkhptozero tryfaintmon BS_ATTACKER + storehealingwish BS_ATTACKER +.if B_HEALING_WISH_SWITCH <= GEN_4 openpartyscreen BS_ATTACKER, BattleScript_EffectHealingWishEnd switchoutabilities BS_ATTACKER waitstate @@ -2711,11 +2713,19 @@ BattleScript_EffectHealingWish: printstring STRINGID_SWITCHINMON switchinanim BS_ATTACKER, TRUE waitstate + switchineffects BS_ATTACKER +.endif +BattleScript_EffectHealingWishEnd: + moveendall + end + +BattleScript_HealingWishActivates:: setbyte cMULTISTRING_CHOOSER, 0 - jumpifnotchosenmove MOVE_LUNAR_DANCE, BattleScript_EffectHealingWishNewMon + goto BattleScript_EffectHealingWishRestore +BattleScript_LunarDanceActivates:: setbyte cMULTISTRING_CHOOSER, 1 restorepp BS_ATTACKER -BattleScript_EffectHealingWishNewMon: +BattleScript_EffectHealingWishRestore: printfromtable gHealingWishStringIds waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_WISH_HEAL @@ -2730,10 +2740,7 @@ BattleScript_EffectHealingWishNewMon: waitstate printstring STRINGID_HEALINGWISHHEALED waitmessage B_WAIT_TIME_LONG - switchineffects BS_ATTACKER -BattleScript_EffectHealingWishEnd: - moveendall - end + return BattleScript_EffectWorrySeed: attackcanceler diff --git a/include/battle.h b/include/battle.h index 8be922384..2c16887bf 100644 --- a/include/battle.h +++ b/include/battle.h @@ -655,6 +655,8 @@ struct BattleStruct u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) bool8 allowedToChangeFormInWeather[PARTY_SIZE][2]; // For each party member and side, used by Ice Face. u8 battleBondTransformed[NUM_BATTLE_SIDES]; // Bitfield for each party. + u8 storedHealingWish:4; // Each battler as a bit. + u8 storedLunarDance:4; // Each battler as a bit. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 18c1911e5..70d398e2a 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -452,6 +452,8 @@ extern const u8 BattleScript_MimicryActivates_End3[]; extern const u8 BattleScript_IceFaceNullsDamage[]; extern const u8 BattleScript_BattlerFormChangeWithStringEnd3[]; extern const u8 BattleScript_DampPreventsAftermath[]; +extern const u8 BattleScript_HealingWishActivates[]; +extern const u8 BattleScript_LunarDanceActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/config/battle.h b/include/config/battle.h index 6dea72b40..a8f4a3e8b 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -95,6 +95,8 @@ #define B_BEAT_UP GEN_LATEST // In Gen5+, Beat Up uses a different formula to calculate its damage, and deals Dark-type damage. Prior to Gen 5, each hit also announces the party member's name. #define B_DARK_VOID_FAIL GEN_LATEST // In Gen7+, only Darkrai can use Dark Void. #define B_BURN_HIT_THAW GEN_LATEST // In Gen6+, damaging moves with a chance of burn will thaw the target, regardless if they're fire-type moves or not. +#define B_HEALING_WISH_SWITCH GEN_LATEST // In Gen5+, the mon receiving Healing Wish is sent out at the end of the turn. + // Additionally, in gen8+ the Healing Wish's effect will be stored until the user switches into a statused or hurt mon. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 68e927d75..9f18455a8 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -257,6 +257,7 @@ #define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 165 #define VARIOUS_JUMP_IF_NO_VALID_TARGETS 166 #define VARIOUS_JUMP_IF_EMERGENCY_EXITED 167 +#define VARIOUS_STORE_HEALING_WISH 168 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8b8d4f1e9..48d23cf76 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6924,6 +6924,24 @@ static void Cmd_switchineffects(void) BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SwitchInAbilityMsgRet; } + // Healing Wish activates before hazards. + // Starting from Gen8 - it heals only pokemon which can be healed. In gens 5,6,7 the effect activates anyways. + else if (((gBattleStruct->storedHealingWish & gBitTable[gActiveBattler]) || (gBattleStruct->storedLunarDance & gBitTable[gActiveBattler])) + && (gBattleMons[gActiveBattler].hp != gBattleMons[gActiveBattler].maxHP || gBattleMons[gActiveBattler].status1 != 0 || B_HEALING_WISH_SWITCH < GEN_8)) + { + if (gBattleStruct->storedHealingWish & gBitTable[gActiveBattler]) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_HealingWishActivates; + gBattleStruct->storedHealingWish &= ~(gBitTable[gActiveBattler]); + } + else // Lunar Dance + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_LunarDanceActivates; + gBattleStruct->storedLunarDance &= ~(gBitTable[gActiveBattler]); + } + } else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED) && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES) && GetBattlerAbility(gActiveBattler) != ABILITY_MAGIC_GUARD @@ -11040,6 +11058,15 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->nextInstr; return; } + case VARIOUS_STORE_HEALING_WISH: + { + VARIOUS_ARGS(); + if (gCurrentMove == MOVE_LUNAR_DANCE) + gBattleStruct->storedLunarDance |= gBitTable[gActiveBattler]; + else + gBattleStruct->storedHealingWish |= gBitTable[gActiveBattler]; + break; + } } // End of switch (cmd->id) gBattlescriptCurrInstr = cmd->nextInstr; diff --git a/test/move_effect_healing_wish.c b/test/move_effect_healing_wish.c new file mode 100644 index 000000000..98e8730b3 --- /dev/null +++ b/test/move_effect_healing_wish.c @@ -0,0 +1,80 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_HEALING_WISH].effect == EFFECT_HEALING_WISH); + ASSUME(gBattleMoves[MOVE_LUNAR_DANCE].effect == EFFECT_HEALING_WISH); +} + +#define TEST_MAX_HP (100) + +SINGLE_BATTLE_TEST("Healing Wish causes the user to faint and fully heals the replacement") +{ + GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_5); + PLAYER(SPECIES_GARDEVOIR); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(TEST_MAX_HP); Status1(STATUS1_POISON); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_HEALING_WISH); SEND_OUT(player, 1); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_HEALING_WISH, player); + HP_BAR(player, hp: 0); + MESSAGE("Gardevoir fainted!"); + MESSAGE("The healing wish came true for Wynaut!"); + HP_BAR(player, hp: TEST_MAX_HP); + STATUS_ICON(player, none: TRUE); + MESSAGE("Wynaut regained health!"); + } +} + +DOUBLE_BATTLE_TEST("Lunar Dance causes the user to faint and fully heals the replacement in a double battle") +{ + GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_5); + PLAYER(SPECIES_GARDEVOIR) { Speed(300); } + PLAYER(SPECIES_WOBBUFFET) { Speed(50); } + PLAYER(SPECIES_WYNAUT) { HP(TEST_MAX_HP - 1); MaxHP(TEST_MAX_HP); Status1(STATUS1_BURN); Speed(50); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(50); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(50); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_LUNAR_DANCE); SEND_OUT(playerLeft, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_LUNAR_DANCE, playerLeft); + HP_BAR(playerLeft, hp: 0); + MESSAGE("Gardevoir fainted!"); + MESSAGE("Wynaut became cloaked in mystical moonlight!"); + HP_BAR(playerLeft, hp: TEST_MAX_HP); + STATUS_ICON(playerLeft, none: TRUE); + MESSAGE("Wynaut regained health!"); + } +} + +SINGLE_BATTLE_TEST("Healing Wish effect activates only if the switched pokemon can be healed") +{ + GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_8); + PLAYER(SPECIES_GARDEVOIR) { Speed(300); } + PLAYER(SPECIES_NINJASK) { Speed(400); } + PLAYER(SPECIES_WYNAUT) { HP(TEST_MAX_HP / 2); MaxHP(TEST_MAX_HP); Status1(STATUS1_PARALYSIS); Speed(50); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(50); } + } WHEN { + TURN { MOVE(player, MOVE_HEALING_WISH); SEND_OUT(player, 1); } + TURN { MOVE(player, MOVE_U_TURN); SEND_OUT(player, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_HEALING_WISH, player); + HP_BAR(player, hp: 0); + MESSAGE("Gardevoir fainted!"); + NONE_OF { + MESSAGE("The healing wish came true for Wynaut!"); + MESSAGE("Wynaut regained health!"); + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_U_TURN, player); + MESSAGE("Do it! Wynaut!"); + MESSAGE("The healing wish came true for Wynaut!"); + HP_BAR(player, hp: TEST_MAX_HP); + STATUS_ICON(player, none: TRUE); + MESSAGE("Wynaut regained health!"); + } +} diff --git a/test/move_effect_recoil_if_miss.c b/test/move_effect_recoil_if_miss.c index 5c1f1a61a..8a80309d7 100644 --- a/test/move_effect_recoil_if_miss.c +++ b/test/move_effect_recoil_if_miss.c @@ -42,8 +42,8 @@ SINGLE_BATTLE_TEST("Jump Kick has 50% recoil on protect") SINGLE_BATTLE_TEST("Jump Kick has no recoil if no target") { - KNOWN_FAILING; // #2596. GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WYNAUT);