From 59e617b16d930ba3bd333b775d79e8623300c0a5 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 20 Oct 2024 16:44:28 -0300 Subject: [PATCH] Updated Wring Out effects to match Eruption effects (#5549) --- include/constants/battle_move_effects.h | 4 +-- src/battle_ai_main.c | 2 +- src/battle_dynamax.c | 2 +- src/battle_util.c | 6 ++-- src/data/battle_move_effects.h | 4 +-- src/data/moves_info.h | 21 ++++++------ test/battle/move.c | 2 +- .../move_effect/power_based_on_target_hp.c | 32 +++++++++++++++++++ .../move_effect/power_based_on_user_hp.c | 32 +++++++++++++++++++ 9 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 test/battle/move_effect/power_based_on_target_hp.c create mode 100644 test/battle/move_effect/power_based_on_user_hp.c diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 770e773f80..b1472d0280 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -157,7 +157,7 @@ enum { EFFECT_YAWN, EFFECT_KNOCK_OFF, EFFECT_ENDEAVOR, - EFFECT_ERUPTION, + EFFECT_POWER_BASED_ON_USER_HP, EFFECT_SKILL_SWAP, EFFECT_IMPRISON, EFFECT_REFRESH, @@ -177,7 +177,7 @@ enum { EFFECT_PLEDGE, EFFECT_FLING, EFFECT_NATURAL_GIFT, - EFFECT_VARY_POWER_BASED_ON_HP, + EFFECT_POWER_BASED_ON_TARGET_HP, EFFECT_ASSURANCE, EFFECT_TRUMP_CARD, EFFECT_ACROBATICS, diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 9099ffd5c0..f69a8640f8 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2518,7 +2518,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) else ADJUST_SCORE(-10); break; - case EFFECT_ERUPTION: + case EFFECT_POWER_BASED_ON_USER_HP: if (effectiveness <= AI_EFFECTIVENESS_x0_5) ADJUST_SCORE(-1); if (aiData->hpPercents[battlerDef] < 50) diff --git a/src/battle_dynamax.c b/src/battle_dynamax.c index 75ea78460c..fae0e8377a 100644 --- a/src/battle_dynamax.c +++ b/src/battle_dynamax.c @@ -415,7 +415,7 @@ static u8 GetMaxPowerTier(u32 move) case EFFECT_GYRO_BALL: return MAX_POWER_TIER_5; case EFFECT_MAGNITUDE: - case EFFECT_VARY_POWER_BASED_ON_HP: + case EFFECT_POWER_BASED_ON_TARGET_HP: return MAX_POWER_TIER_6; case EFFECT_FLAIL: case EFFECT_LOW_KICK: diff --git a/src/battle_util.c b/src/battle_util.c index bcc1d61c5e..ed5254c396 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8892,7 +8892,7 @@ static inline u32 CalcMoveBasePower(u32 move, u32 battlerAtk, u32 battlerDef, u3 case EFFECT_FLING: basePower = GetFlingPowerFromItemId(gBattleMons[battlerAtk].item); break; - case EFFECT_ERUPTION: + case EFFECT_POWER_BASED_ON_USER_HP: basePower = gBattleMons[battlerAtk].hp * basePower / gBattleMons[battlerAtk].maxHP; break; case EFFECT_FLAIL: @@ -8954,8 +8954,8 @@ static inline u32 CalcMoveBasePower(u32 move, u32 battlerAtk, u32 battlerDef, u3 basePower *= 2; } break; - case EFFECT_VARY_POWER_BASED_ON_HP: - basePower = gMovesInfo[move].argument * gBattleMons[battlerDef].hp / gBattleMons[battlerDef].maxHP; + case EFFECT_POWER_BASED_ON_TARGET_HP: + basePower = gBattleMons[battlerDef].hp * basePower / gBattleMons[battlerDef].maxHP; break; case EFFECT_ASSURANCE: if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg) diff --git a/src/data/battle_move_effects.h b/src/data/battle_move_effects.h index 776563bbec..956a2d0f23 100644 --- a/src/data/battle_move_effects.h +++ b/src/data/battle_move_effects.h @@ -1011,7 +1011,7 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] = .battleTvScore = 1, }, - [EFFECT_ERUPTION] = + [EFFECT_POWER_BASED_ON_USER_HP] = { .battleScript = BattleScript_EffectHit, .battleTvScore = 1, @@ -1144,7 +1144,7 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] = .encourageEncore = TRUE, }, - [EFFECT_VARY_POWER_BASED_ON_HP] = + [EFFECT_POWER_BASED_ON_TARGET_HP] = { .battleScript = BattleScript_EffectHit, .battleTvScore = 0, // TODO: Assign points diff --git a/src/data/moves_info.h b/src/data/moves_info.h index c273eda3b5..24508f59b0 100644 --- a/src/data/moves_info.h +++ b/src/data/moves_info.h @@ -7201,7 +7201,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "The higher the user's HP,\n" "the more damage caused."), - .effect = EFFECT_ERUPTION, + .effect = EFFECT_POWER_BASED_ON_USER_HP, .power = 150, .type = TYPE_FIRE, .accuracy = 100, @@ -8178,7 +8178,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Inflicts more damage if the\n" "user's HP is high."), - .effect = EFFECT_ERUPTION, + .effect = EFFECT_POWER_BASED_ON_USER_HP, .power = 150, .type = TYPE_WATER, .accuracy = 100, @@ -9498,15 +9498,14 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = { .name = COMPOUND_STRING("Wring Out"), .description = sWringOutDescription, - .effect = EFFECT_VARY_POWER_BASED_ON_HP, - .power = 1, + .effect = EFFECT_POWER_BASED_ON_TARGET_HP, + .power = 120, .type = TYPE_NORMAL, .accuracy = 100, .pp = 5, .target = MOVE_TARGET_SELECTED, .priority = 0, .category = DAMAGE_CATEGORY_SPECIAL, - .argument = 120, .makesContact = TRUE, .contestEffect = CONTEST_EFFECT_STARTLE_PREV_MON, .contestCategory = CONTEST_CATEGORY_SMART, @@ -11564,15 +11563,14 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = { .name = COMPOUND_STRING("Crush Grip"), .description = sWringOutDescription, - .effect = EFFECT_VARY_POWER_BASED_ON_HP, - .power = 1, + .effect = EFFECT_POWER_BASED_ON_TARGET_HP, + .power = 120, .type = TYPE_NORMAL, .accuracy = 100, .pp = 5, .target = MOVE_TARGET_SELECTED, .priority = 0, .category = DAMAGE_CATEGORY_PHYSICAL, - .argument = 120, .makesContact = TRUE, .contestEffect = CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON, .contestCategory = CONTEST_CATEGORY_TOUGH, @@ -18528,7 +18526,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "The higher the user's HP\n" "the more damage caused."), - .effect = EFFECT_ERUPTION, + .effect = EFFECT_POWER_BASED_ON_USER_HP, .power = 150, .type = TYPE_DRAGON, .accuracy = 100, @@ -20516,15 +20514,14 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = { .name = COMPOUND_STRING("Hard Press"), .description = sWringOutDescription, - .effect = EFFECT_VARY_POWER_BASED_ON_HP, - .power = 1, + .effect = EFFECT_POWER_BASED_ON_TARGET_HP, + .power = 100, .type = TYPE_STEEL, .accuracy = 100, .pp = 10, .target = MOVE_TARGET_SELECTED, .priority = 0, .category = DAMAGE_CATEGORY_PHYSICAL, - .argument = 100, .makesContact = TRUE, .battleAnimScript = gBattleAnimMove_HardPress, }, diff --git a/test/battle/move.c b/test/battle/move.c index ba928e433b..9ee37391ec 100644 --- a/test/battle/move.c +++ b/test/battle/move.c @@ -88,7 +88,7 @@ DOUBLE_BATTLE_TEST("Turn order is determined randomly if priority and Speed tie GIVEN { ASSUME(gMovesInfo[MOVE_ENDEAVOR].effect == EFFECT_ENDEAVOR); ASSUME(gMovesInfo[MOVE_LIFE_DEW].effect == EFFECT_JUNGLE_HEALING); - ASSUME(gMovesInfo[MOVE_CRUSH_GRIP].effect == EFFECT_VARY_POWER_BASED_ON_HP); + ASSUME(gMovesInfo[MOVE_CRUSH_GRIP].effect == EFFECT_POWER_BASED_ON_TARGET_HP); ASSUME(gMovesInfo[MOVE_SUPER_FANG].effect == EFFECT_SUPER_FANG); PLAYER(SPECIES_WOBBUFFET) { MaxHP(480); HP(360); Defense(100); Speed(1); } PLAYER(SPECIES_WYNAUT) { Speed(1); } diff --git a/test/battle/move_effect/power_based_on_target_hp.c b/test/battle/move_effect/power_based_on_target_hp.c new file mode 100644 index 0000000000..2cecf3ff7f --- /dev/null +++ b/test/battle/move_effect/power_based_on_target_hp.c @@ -0,0 +1,32 @@ +#include "global.h" +#include "test/battle.h" + +ASSUMPTIONS +{ + ASSUME(gMovesInfo[MOVE_CRUSH_GRIP].effect == EFFECT_POWER_BASED_ON_TARGET_HP); +} + +SINGLE_BATTLE_TEST("Crush Grip's damage is affected by the target's current HP", s16 damage) +{ + s16 hp, maxHp = 256; + + PARAMETRIZE { hp = maxHp; } + PARAMETRIZE { hp = maxHp / 2; } + PARAMETRIZE { hp = maxHp / 8; } + PARAMETRIZE { hp = 1; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { HP(hp); MaxHP(maxHp); } + } WHEN { + TURN { MOVE(player, MOVE_CRUSH_GRIP); } + } SCENE { + MESSAGE("Wobbuffet used Crush Grip!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CRUSH_GRIP, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.125), results[2].damage); + EXPECT_EQ(results[3].damage, 1); + } +} diff --git a/test/battle/move_effect/power_based_on_user_hp.c b/test/battle/move_effect/power_based_on_user_hp.c new file mode 100644 index 0000000000..1dfa70ddf9 --- /dev/null +++ b/test/battle/move_effect/power_based_on_user_hp.c @@ -0,0 +1,32 @@ +#include "global.h" +#include "test/battle.h" + +ASSUMPTIONS +{ + ASSUME(gMovesInfo[MOVE_ERUPTION].effect == EFFECT_POWER_BASED_ON_USER_HP); +} + +SINGLE_BATTLE_TEST("Eruption's damage is affected by the user's current HP", s16 damage) +{ + s16 hp, maxHp = 256; + + PARAMETRIZE { hp = maxHp; } + PARAMETRIZE { hp = maxHp / 2; } + PARAMETRIZE { hp = maxHp / 8; } + PARAMETRIZE { hp = 1; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { HP(hp); MaxHP(maxHp); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_ERUPTION); } + } SCENE { + MESSAGE("Wobbuffet used Eruption!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_ERUPTION, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.125), results[2].damage); + EXPECT_EQ(results[3].damage, 1); + } +}