From 093c65380107f6bd42bfb96c4fd23978584f9231 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 1 Oct 2023 15:25:04 +0200 Subject: [PATCH] Fixed Berserk gene issue in double battles (#3363) * fix berserk gene issue + tests * Update test/battle/hold_effect/berserk_gene.c Co-authored-by: Eduardo Quezada D'Ottone * Update test/battle/hold_effect/berserk_gene.c Co-authored-by: Eduardo Quezada D'Ottone * berserk gene review changes --------- Co-authored-by: Eduardo Quezada D'Ottone --- data/battle_scripts_1.s | 3 + test/battle/hold_effect/berserk_gene.c | 99 +++++++++++++++++++++----- 2 files changed, 85 insertions(+), 17 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d03e37085..76987499b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -10340,6 +10340,8 @@ BattleScript_CouldntFullyProtect:: BattleScript_BerserkGeneRet:: BattleScript_BerserkGeneRet_Anim: + savetarget + copybyte gBattlerTarget, sBATTLER statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_BerserkGeneRet_TryConfuse setgraphicalstatchangevalues playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1 @@ -10362,6 +10364,7 @@ BattleScript_BerserkGeneRet_OwnTempoPrevents: printstring STRINGID_PKMNPREVENTSCONFUSIONWITH waitmessage B_WAIT_TIME_LONG BattleScript_BerserkGeneRet_End: + restoretarget removeitem BS_SCRIPTING end3 diff --git a/test/battle/hold_effect/berserk_gene.c b/test/battle/hold_effect/berserk_gene.c index 6fd0f8a85..8419eff3c 100644 --- a/test/battle/hold_effect/berserk_gene.c +++ b/test/battle/hold_effect/berserk_gene.c @@ -6,18 +6,18 @@ ASSUMPTIONS ASSUME(gItems[ITEM_BERSERK_GENE].holdEffect == HOLD_EFFECT_BERSERK_GENE); } -SINGLE_BATTLE_TEST("Berserk Gene sharply raises attack at the start of battle", s16 damage) +SINGLE_BATTLE_TEST("Berserk Gene sharply raises attack at the start of a single battle", s16 damage) { - u16 useItem; - PARAMETRIZE { useItem = FALSE; } - PARAMETRIZE { useItem = TRUE; } + u16 item; + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_BERSERK_GENE; } GIVEN { - PLAYER(SPECIES_WOBBUFFET) { if (useItem) Item(ITEM_BERSERK_GENE); } + PLAYER(SPECIES_WOBBUFFET) { Item(item); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_TACKLE, WITH_RNG(RNG_CONFUSION, FALSE)); } } SCENE { - if (useItem) + if (item == ITEM_BERSERK_GENE) { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); MESSAGE("Using Berserk Gene, the Attack of Wobbuffet sharply rose!"); @@ -30,20 +30,46 @@ SINGLE_BATTLE_TEST("Berserk Gene sharply raises attack at the start of battle", } } +DOUBLE_BATTLE_TEST("Berserk Gene sharply raises attack at the start of a double battle", s16 damage) +{ + u16 item; + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_BERSERK_GENE; } + GIVEN { + PLAYER(SPECIES_WYNAUT); + PLAYER(SPECIES_WOBBUFFET) { Item(item); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerRight, MOVE_TACKLE, target:opponentLeft, WITH_RNG(RNG_CONFUSION, FALSE)); } + } SCENE { + if (item == ITEM_BERSERK_GENE) + { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerRight); + MESSAGE("Using Berserk Gene, the Attack of Wobbuffet sharply rose!"); + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_CONFUSION, playerRight); + MESSAGE("Wobbuffet became confused!"); + } + HP_BAR(opponentLeft, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[1].damage); + } +} + SINGLE_BATTLE_TEST("Berserk Gene activates on switch in", s16 damage) { - u16 useItem; - PARAMETRIZE { useItem = FALSE; } - PARAMETRIZE { useItem = TRUE; } + u16 item; + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_BERSERK_GENE; } GIVEN { PLAYER(SPECIES_WYNAUT); - PLAYER(SPECIES_WOBBUFFET) { if (useItem) Item(ITEM_BERSERK_GENE); } + PLAYER(SPECIES_WOBBUFFET) { Item(item); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { SWITCH(player, 1); } TURN { MOVE(player, MOVE_TACKLE, WITH_RNG(RNG_CONFUSION, FALSE)); } } SCENE { - if (useItem) + if (item == ITEM_BERSERK_GENE) { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); MESSAGE("Using Berserk Gene, the Attack of Wobbuffet sharply rose!"); @@ -56,20 +82,20 @@ SINGLE_BATTLE_TEST("Berserk Gene activates on switch in", s16 damage) } } -SINGLE_BATTLE_TEST("Berserk Gene does not confuse a Pokemon with Own Tempo but still raises attack sharply", s16 damage) +SINGLE_BATTLE_TEST("Berserk Gene does not confuse a Pokemon with Own Tempo but still raises attack sharply in a single battle", s16 damage) { - u16 useItem; - PARAMETRIZE { useItem = FALSE; } - PARAMETRIZE { useItem = TRUE; } + u16 item; + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_BERSERK_GENE; } GIVEN { - PLAYER(SPECIES_SLOWBRO) { Ability(ABILITY_OWN_TEMPO); if (useItem) Item(ITEM_BERSERK_GENE); } + PLAYER(SPECIES_SLOWBRO) { Ability(ABILITY_OWN_TEMPO); Item(item); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_TACKLE); } } SCENE { - if (useItem) + if (item == ITEM_BERSERK_GENE) { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); MESSAGE("Using Berserk Gene, the Attack of Slowbro sharply rose!"); @@ -83,6 +109,45 @@ SINGLE_BATTLE_TEST("Berserk Gene does not confuse a Pokemon with Own Tempo but s } } +DOUBLE_BATTLE_TEST("Berserk Gene does not confuse a Pokemon with Own Tempo but still raises attack sharply in a double battle", s16 damage) +{ + u16 item; + bool8 positionLeft = FALSE; + + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_BERSERK_GENE; positionLeft = TRUE; } + PARAMETRIZE { item = ITEM_BERSERK_GENE; positionLeft = FALSE; } + GIVEN { + if (positionLeft) { + PLAYER(SPECIES_SLOWBRO) { Ability(ABILITY_OWN_TEMPO); Item(item); } + PLAYER(SPECIES_WOBBUFFET); + } else { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_SLOWBRO) { Ability(ABILITY_OWN_TEMPO); Item(item); } + } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { + MOVE((positionLeft != 0) ? playerLeft : playerRight, MOVE_TACKLE, target: opponentLeft); + } + } SCENE { + if (item == ITEM_BERSERK_GENE) + { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, (positionLeft != 0) ? playerLeft : playerRight); + MESSAGE("Using Berserk Gene, the Attack of Slowbro sharply rose!"); + ABILITY_POPUP((positionLeft != 0) ? playerLeft : playerRight, ABILITY_OWN_TEMPO); + MESSAGE("Slowbro's Own Tempo prevents confusion!"); + } + HP_BAR(opponentLeft, captureDamage: &results[i].damage); + NOT MESSAGE("Slowbro became confused!"); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[2].damage); + EXPECT_EQ(((positionLeft != 0) ? playerLeft : playerRight)->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 2); + } +} + SINGLE_BATTLE_TEST("Berserk Gene does not confuse on Misty Terrain but still raises attack sharply") { GIVEN {