From afac1bada7c2790f67f3fc54f753a021cfb2ecc1 Mon Sep 17 00:00:00 2001 From: Pawkkie Date: Thu, 16 May 2024 16:31:15 -0400 Subject: [PATCH] Fixes Cud Chuw #4379 --- data/battle_scripts_1.s | 5 +-- src/battle_util.c | 8 +++-- test/battle/move_effect/cud_chuw.c | 49 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 test/battle/move_effect/cud_chuw.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d793c54ac915..becadbe231de 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7966,10 +7966,7 @@ BattleScript_CudChewActivates:: pause B_WAIT_TIME_SHORTEST call BattleScript_AbilityPopUp setbyte sBERRY_OVERRIDE, 1 @ override the requirements for eating berries - consumeberry BS_TARGET, FALSE - orword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE - healthbarupdate BS_ATTACKER - datahpupdate BS_ATTACKER + consumeberry BS_SCRIPTING, FALSE setbyte sBERRY_OVERRIDE, 0 end3 diff --git a/src/battle_util.c b/src/battle_util.c index 96e46569600d..d0376d8ef2be 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5101,10 +5101,12 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 } break; case ABILITY_CUD_CHEW: - if (ItemId_GetPocket(GetUsedHeldItem(battler)) == POCKET_BERRIES && gDisableStructs[battler].cudChew == TRUE) + if (gDisableStructs[battler].cudChew == TRUE) { - gLastUsedItem = gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)]; - gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)] = ITEM_NONE; + gBattleScripting.battler = battler; + gDisableStructs[battler].cudChew = FALSE; + gLastUsedItem = gBattleStruct->usedHeldItems[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)]; + gBattleStruct->usedHeldItems[gBattlerPartyIndexes[battler]][GetBattlerSide(battler)] = ITEM_NONE; BattleScriptPushCursorAndCallback(BattleScript_CudChewActivates); effect++; } diff --git a/test/battle/move_effect/cud_chuw.c b/test/battle/move_effect/cud_chuw.c new file mode 100644 index 000000000000..4cf048ae1a98 --- /dev/null +++ b/test/battle/move_effect/cud_chuw.c @@ -0,0 +1,49 @@ +#include "global.h" +#include "test/battle.h" + +SINGLE_BATTLE_TEST("Cud Chuw will activate Kee Berry effect again on the next turn") +{ + GIVEN { + ASSUME(gItems[ITEM_KEE_BERRY].holdEffect == HOLD_EFFECT_KEE_BERRY); + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_SPECIAL); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_TAUROS_PALDEAN_COMBAT_BREED) { Ability(ABILITY_CUD_CHEW); Item(ITEM_KEE_BERRY); } + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + TURN { MOVE(player, MOVE_CELEBRATE);} + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + HP_BAR(opponent); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player); + ABILITY_POPUP(opponent, ABILITY_CUD_CHEW); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + } THEN { + EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE + 2); + } +} + +SINGLE_BATTLE_TEST("Cud Chuw will activate Oran Berry effect again on the next turn") +{ + GIVEN { + ASSUME(gItems[ITEM_ORAN_BERRY].holdEffect == HOLD_EFFECT_RESTORE_HP); + ASSUME(gItems[ITEM_ORAN_BERRY].holdEffectParam == 10); + ASSUME(gBattleMoves[MOVE_DRAGON_RAGE].effect == EFFECT_DRAGON_RAGE); + // ASSUME(gBattleMoves[MOVE_DRAGON_RAGE].argument == 40); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_TAUROS_PALDEAN_COMBAT_BREED) { MaxHP(60); HP(60); Ability(ABILITY_CUD_CHEW); Item(ITEM_ORAN_BERRY); } + } WHEN { + TURN { MOVE(player, MOVE_DRAGON_RAGE); } + TURN { MOVE(player, MOVE_CELEBRATE);} + TURN {} + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_RAGE, player); + HP_BAR(opponent); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player); + ABILITY_POPUP(opponent, ABILITY_CUD_CHEW); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + } THEN { + EXPECT_EQ(opponent->hp, 40); + } +} \ No newline at end of file