From 0ec777dd24c09a1bb428e20ce632c56468a49a83 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sun, 21 Jan 2024 23:42:01 +0100 Subject: [PATCH] Fixes Mind Blown / Magic Guard interaction and renames Steel Beam effect (#4043) * Fixes Mind Blown / Magic Guard interaction and renames Steel Beam effect * review fixes --------- Co-authored-by: Bassoonian --- data/battle_scripts_1.s | 5 +-- include/constants/battle_move_effects.h | 2 +- src/battle_ai_util.c | 2 +- src/battle_tv.c | 2 +- src/data/battle_moves.h | 4 +-- test/battle/move_effect/max_hp_50_recoil.c | 39 ++++++++++++++++++++++ test/battle/move_effect/mind_blown.c | 13 ++++++++ 7 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 test/battle/move_effect/max_hp_50_recoil.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 2e2fd09e23e3..18d20ebc9417 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -406,7 +406,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHit @ EFFECT_RISING_VOLTAGE .4byte BattleScript_EffectHit @ EFFECT_BEAK_BLAST .4byte BattleScript_EffectCourtChange @ EFFECT_COURT_CHANGE - .4byte BattleScript_EffectSteelBeam @ EFFECT_STEEL_BEAM + .4byte BattleScript_EffectMaxHp50Recoil @ EFFECT_MAX_HP_50_RECOIL .4byte BattleScript_EffectExtremeEvoboost @ EFFECT_EXTREME_EVOBOOST .4byte BattleScript_EffectHitSetRemoveTerrain @ EFFECT_HIT_SET_REMOVE_TERRAIN .4byte BattleScript_EffectDarkVoid @ EFFECT_DARK_VOID @@ -927,7 +927,7 @@ BattleScript_EffectShellTrap:: waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd -BattleScript_EffectSteelBeam:: +BattleScript_EffectMaxHp50Recoil:: attackcanceler attackstring ppreduce @@ -3592,6 +3592,7 @@ BattleScript_MindBlownDamp: goto BattleScript_DampStopsExplosion BattleScript_EffectMindBlown_HpDown: setbyte sMULTIHIT_EFFECT, 1 @ Note to not faint the attacker + jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_EffectMindBlown_AnimDmgNoFaint dmg_1_2_attackerhp healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index beebe59462da..056f0ce4f7be 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -383,7 +383,7 @@ #define EFFECT_RISING_VOLTAGE 377 #define EFFECT_BEAK_BLAST 378 #define EFFECT_COURT_CHANGE 379 -#define EFFECT_STEEL_BEAM 380 +#define EFFECT_MAX_HP_50_RECOIL 380 #define EFFECT_EXTREME_EVOBOOST 381 #define EFFECT_HIT_SET_REMOVE_TERRAIN 382 // genesis supernova #define EFFECT_DARK_VOID 383 diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 1853ba22cf38..f675602fb968 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -972,7 +972,7 @@ static bool32 AI_IsMoveEffectInMinus(u32 battlerAtk, u32 battlerDef, u32 move, s case EFFECT_OVERHEAT: case EFFECT_MAKE_IT_RAIN: case EFFECT_MIND_BLOWN: - case EFFECT_STEEL_BEAM: + case EFFECT_MAX_HP_50_RECOIL: return TRUE; case EFFECT_RECOIL_25: case EFFECT_RECOIL_IF_MISS: diff --git a/src/battle_tv.c b/src/battle_tv.c index af485df70d27..f22b9f96e5b9 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -467,7 +467,7 @@ static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_RISING_VOLTAGE] = 0, // TODO: Assign points [EFFECT_BEAK_BLAST] = 0, // TODO: Assign points [EFFECT_COURT_CHANGE] = 0, // TODO: Assign points - [EFFECT_STEEL_BEAM] = 0, // TODO: Assign points + [EFFECT_MAX_HP_50_RECOIL] = 0, // TODO: Assign points [EFFECT_EXTREME_EVOBOOST] = 0, // TODO: Assign points [EFFECT_HIT_SET_REMOVE_TERRAIN] = 0, // TODO: Assign points [EFFECT_DARK_VOID] = 0, // TODO: Assign points diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 005415a956bb..1a2347f557db 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12606,7 +12606,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = [MOVE_STEEL_BEAM] = { - .effect = EFFECT_STEEL_BEAM, + .effect = EFFECT_MAX_HP_50_RECOIL, .power = 140, .type = TYPE_STEEL, .accuracy = 95, @@ -13259,7 +13259,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = #else .power = 120, #endif - .effect = EFFECT_STEEL_BEAM, + .effect = EFFECT_MAX_HP_50_RECOIL, .type = TYPE_GRASS, .accuracy = 95, .pp = 5, diff --git a/test/battle/move_effect/max_hp_50_recoil.c b/test/battle/move_effect/max_hp_50_recoil.c new file mode 100644 index 000000000000..b921e5a85f23 --- /dev/null +++ b/test/battle/move_effect/max_hp_50_recoil.c @@ -0,0 +1,39 @@ +#include "global.h" +#include "test/battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_STEEL_BEAM].effect == EFFECT_MAX_HP_50_RECOIL); +} + +SINGLE_BATTLE_TEST("Steel Beam causes the user to take damage equal to half of its maximum HP") +{ + s16 recoilDamage; + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STEEL_BEAM); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STEEL_BEAM, player); + HP_BAR(opponent); + HP_BAR(player, captureDamage: &recoilDamage); + } THEN { + EXPECT_EQ(player->maxHP / 2, recoilDamage); + } +} + +SINGLE_BATTLE_TEST("Steel Beam hp loss is prevented by Magic Guard") +{ + GIVEN { + PLAYER(SPECIES_CLEFAIRY) { Ability(ABILITY_MAGIC_GUARD); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STEEL_BEAM); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STEEL_BEAM, player); + HP_BAR(opponent); + NOT HP_BAR(player); + } +} diff --git a/test/battle/move_effect/mind_blown.c b/test/battle/move_effect/mind_blown.c index 485f2abd66e8..671491a8469d 100644 --- a/test/battle/move_effect/mind_blown.c +++ b/test/battle/move_effect/mind_blown.c @@ -105,3 +105,16 @@ DOUBLE_BATTLE_TEST("Mind Blown causes everyone to faint in a double battle") MESSAGE("Wobbuffet fainted!"); } } + +SINGLE_BATTLE_TEST("Mind Blown hp loss is prevented by Magic Guard") +{ + GIVEN { + PLAYER(SPECIES_CLEFAIRY) { Ability(ABILITY_MAGIC_GUARD); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_MIND_BLOWN); } + } SCENE { + NOT HP_BAR(player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_MIND_BLOWN, player); + } +}