Skip to content

Commit

Permalink
Fixes Cud Chuw (#4379)
Browse files Browse the repository at this point in the history
* Fixes Cud Chuw

* small correction
  • Loading branch information
AlexOn1ine authored Apr 12, 2024
1 parent ee3a577 commit 35e04b8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
5 changes: 1 addition & 4 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -7055,10 +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
consumeberry BS_SCRIPTING, FALSE
setbyte sBERRY_OVERRIDE, 0
end3

Expand Down
8 changes: 5 additions & 3 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
49 changes: 49 additions & 0 deletions test/battle/move_effect/cud_chuw.c
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 35e04b8

Please sign in to comment.