From 8a6f855987a3c223135c9d7c50beb4c036b6f9d0 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 12 Apr 2024 10:42:53 +0200 Subject: [PATCH 1/2] Fixes Cud Chuw --- data/battle_scripts_1.s | 6 +--- src/battle_util.c | 8 +++-- test/battle/move_effect/cud_chuw.c | 49 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 8 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 6415dee69cad..167f2a4386b1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7055,11 +7055,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 - setbyte sBERRY_OVERRIDE, 0 + consumeberry BS_SCRIPTING, FALSE end3 BattleScript_TargetFormChangeNoPopup: diff --git a/src/battle_util.c b/src/battle_util.c index 5a9e8e842abc..e27049cba536 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4942,10 +4942,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..ba59d355a48b --- /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(gItemsInfo[ITEM_KEE_BERRY].holdEffect == HOLD_EFFECT_KEE_BERRY); + ASSUME(gMovesInfo[MOVE_TACKLE].category == DAMAGE_CATEGORY_PHYSICAL); + 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(gItemsInfo[ITEM_ORAN_BERRY].holdEffect == HOLD_EFFECT_RESTORE_HP); + ASSUME(gItemsInfo[ITEM_ORAN_BERRY].holdEffectParam == 10); + ASSUME(gMovesInfo[MOVE_DRAGON_RAGE].effect == EFFECT_FIXED_DAMAGE_ARG); + ASSUME(gMovesInfo[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); + } +} From 6879f796f40a0152346a3b70487a40ad76e36765 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 12 Apr 2024 11:12:15 +0200 Subject: [PATCH 2/2] small correction --- data/battle_scripts_1.s | 1 + 1 file changed, 1 insertion(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 167f2a4386b1..2e22c0df0897 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7056,6 +7056,7 @@ BattleScript_CudChewActivates:: call BattleScript_AbilityPopUp setbyte sBERRY_OVERRIDE, 1 @ override the requirements for eating berries consumeberry BS_SCRIPTING, FALSE + setbyte sBERRY_OVERRIDE, 0 end3 BattleScript_TargetFormChangeNoPopup: