From dd43d62a123ea8c43d54536f5ce32917a5ea9798 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Tue, 2 May 2023 21:06:21 +0200 Subject: [PATCH] Fixes Triple Dive effect (#2947) --- include/constants/pokemon.h | 5 +-- src/battle_ai_util.c | 2 +- src/battle_util.c | 2 +- src/data/battle_moves.h | 6 ++-- test/move_effect_triple_kick.c | 31 ++++++++++++++++++ test/move_flag_three_strikes.c | 57 ++++++++++++++++++++++++++++++++++ 6 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 test/move_effect_triple_kick.c create mode 100644 test/move_flag_three_strikes.c diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index ff2a44dc9c..504a94ea3d 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -242,8 +242,9 @@ #define FLAG_THAW_USER (1 << 25) #define FLAG_HIT_IN_SUBSTITUTE (1 << 26) // Hyperspace Fury #define FLAG_TWO_STRIKES (1 << 27) // A move with this flag will strike twice, and may apply its effect on each hit -#define FLAG_WIND_MOVE (1 << 28) -#define FLAG_SLICING_MOVE (1 << 29) +#define FLAG_THREE_STRIKES (1 << 28) // A move with this flag will strike thrice, and may apply its effect on each hit +#define FLAG_WIND_MOVE (1 << 29) +#define FLAG_SLICING_MOVE (1 << 30) // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 3adbd77ae2..e187a06a98 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -856,7 +856,7 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 *typeEffectiveness, // Handle other multi-strike moves if (gBattleMoves[move].flags & FLAG_TWO_STRIKES) dmg *= 2; - else if (move == MOVE_SURGING_STRIKES || (move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH)) + else if (gBattleMoves[move].flags & FLAG_THREE_STRIKES || (move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH)) dmg *= 3; if (dmg == 0) diff --git a/src/battle_util.c b/src/battle_util.c index 1c5a5d5d94..402af3544a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3779,7 +3779,7 @@ u8 AtkCanceller_UnableToUseMove(void) // TODO } } - else if (gBattleMoves[gCurrentMove].effect == EFFECT_TRIPLE_KICK || gCurrentMove == MOVE_SURGING_STRIKES) + else if (gBattleMoves[gCurrentMove].effect == EFFECT_TRIPLE_KICK || gBattleMoves[gCurrentMove].flags & FLAG_THREE_STRIKES) { gMultiHitCounter = 3; PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 9473bae71c..4d04c743fd 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12338,7 +12338,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST | FLAG_THREE_STRIKES, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, @@ -13106,7 +13106,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_TRIPLE_DIVE] = { - .effect = EFFECT_TRIPLE_KICK, + .effect = EFFECT_HIT, .power = 30, .type = TYPE_WATER, .accuracy = 95, @@ -13114,7 +13114,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_THREE_STRIKES, .split = SPLIT_PHYSICAL, .zMoveEffect = Z_EFFECT_NONE, }, diff --git a/test/move_effect_triple_kick.c b/test/move_effect_triple_kick.c new file mode 100644 index 0000000000..d3187aefec --- /dev/null +++ b/test/move_effect_triple_kick.c @@ -0,0 +1,31 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_TRIPLE_KICK].effect & EFFECT_TRIPLE_KICK); +} + +SINGLE_BATTLE_TEST("Triple Kick damage is increaased by its base damage for each hit") +{ + s16 firstHit; + s16 secondHit; + s16 thirdHit; + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_KICK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_KICK, player); + HP_BAR(opponent, captureDamage: &firstHit); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_KICK, player); + HP_BAR(opponent, captureDamage: &secondHit); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_KICK, player); + HP_BAR(opponent, captureDamage: &thirdHit); + } FINALLY { + EXPECT_EQ(secondHit, firstHit * 2); + EXPECT_EQ(thirdHit, firstHit * 3); + } +} diff --git a/test/move_flag_three_strikes.c b/test/move_flag_three_strikes.c new file mode 100644 index 0000000000..7ea7844c4f --- /dev/null +++ b/test/move_flag_three_strikes.c @@ -0,0 +1,57 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Three-strike flag turns a move into a 3-hit move") +{ + s16 firstHit; + s16 secondHit; + s16 thirdHit; + + GIVEN { + ASSUME(gBattleMoves[MOVE_TRIPLE_DIVE].flags & FLAG_THREE_STRIKES); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRIPLE_DIVE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_DIVE, player); + HP_BAR(opponent, captureDamage: &firstHit); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_DIVE, player); + HP_BAR(opponent, captureDamage: &secondHit); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_DIVE, player); + HP_BAR(opponent, captureDamage: &thirdHit); + } FINALLY { + EXPECT_EQ(firstHit, secondHit); + EXPECT_EQ(secondHit, thirdHit); + EXPECT_EQ(firstHit, thirdHit); + } +} + +SINGLE_BATTLE_TEST("Surging Strikes hits 3 times with each hit being a critical hit") +{ + s16 firstHit; + s16 secondHit; + s16 thirdHit; + + GIVEN { + ASSUME(gBattleMoves[MOVE_SURGING_STRIKES].flags & FLAG_THREE_STRIKES); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SURGING_STRIKES); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SURGING_STRIKES, player); + HP_BAR(opponent, captureDamage: &firstHit); + MESSAGE("A critical hit!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_SURGING_STRIKES, player); + HP_BAR(opponent, captureDamage: &secondHit); + MESSAGE("A critical hit!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_SURGING_STRIKES, player); + HP_BAR(opponent, captureDamage: &thirdHit); + MESSAGE("A critical hit!"); + } FINALLY { + EXPECT_EQ(firstHit, secondHit); + EXPECT_EQ(secondHit, thirdHit); + EXPECT_EQ(firstHit, thirdHit); + } +}