Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Belch AI Scoring Fix #4616

Merged
merged 7 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ u8 GetBattleMoveCategory(u32 moveId);
bool32 CanFling(u32 battler);
bool32 IsTelekinesisBannedSpecies(u16 species);
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
bool32 IsBelchPreventingMove(u32 battler, u32 move);
bool32 HasEnoughHpToEatBerry(u32 battler, u32 hpFraction, u32 itemId);
bool32 IsPartnerMonFromSameTrainer(u32 battler);
u8 GetCategoryBasedOnStats(u32 battler);
Expand Down
2 changes: 1 addition & 1 deletion src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ bool32 IsDamageMoveUnusable(u32 move, u32 battlerAtk, u32 battlerDef)
return TRUE;
break;
case EFFECT_BELCH:
if (ItemId_GetPocket(GetUsedHeldItem(battlerAtk)) != POCKET_BERRIES)
if (IsBelchPreventingMove(battlerAtk, move))
return TRUE;
break;
case EFFECT_LAST_RESORT:
Expand Down
2 changes: 2 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,7 @@ static void Cmd_multihitresultmessage(void)
if (gSpecialStatuses[gBattlerTarget].berryReduced
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
gBattleStruct->ateBerry[gBattlerTarget & BIT_SIDE] |= gBitTable[gBattlerPartyIndexes[gBattlerTarget]];
gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
Expand Down Expand Up @@ -2646,6 +2647,7 @@ static void Cmd_resultmessage(void)
if (gSpecialStatuses[gBattlerTarget].berryReduced
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
gBattleStruct->ateBerry[gBattlerTarget & BIT_SIDE] |= gBitTable[gBattlerPartyIndexes[gBattlerTarget]];
gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
Expand Down
2 changes: 1 addition & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move)
return gMovesInfo[move].healingMove;
}

static bool32 IsBelchPreventingMove(u32 battler, u32 move)
bool32 IsBelchPreventingMove(u32 battler, u32 move)
{
if (gMovesInfo[move].effect != EFFECT_BELCH)
return FALSE;
Expand Down
52 changes: 52 additions & 0 deletions test/battle/move_effect/belch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gMovesInfo[MOVE_BELCH].effect == EFFECT_BELCH);
ASSUME(gMovesInfo[MOVE_MUD_SHOT].type == TYPE_GROUND);
ASSUME(gItemsInfo[ITEM_SHUCA_BERRY].holdEffect == HOLD_EFFECT_RESIST_BERRY);
ASSUME(gItemsInfo[ITEM_SHUCA_BERRY].holdEffectParam == TYPE_GROUND);
ASSUME(gItemsInfo[ITEM_SHUCA_BERRY].pocket == POCKET_BERRIES);
ASSUME(gItemsInfo[ITEM_ORAN_BERRY].pocket == POCKET_BERRIES);
}

AI_SINGLE_BATTLE_TEST("AI: Belch has nonzero score after eating a berry")
{
GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
PLAYER(SPECIES_BAYLEEF) { Level(18); Moves(MOVE_MUD_SHOT, MOVE_TACKLE); }
OPPONENT(SPECIES_PIKACHU) { Level(15); Item(ITEM_SHUCA_BERRY); Moves(MOVE_BELCH, MOVE_TACKLE); }
} WHEN {
TURN { MOVE(player, MOVE_MUD_SHOT); EXPECT_MOVE(opponent, MOVE_TACKLE); }
TURN { MOVE(player, MOVE_TACKLE); EXPECT_MOVE(opponent, MOVE_BELCH);}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_BELCH, opponent);
}
}

SINGLE_BATTLE_TEST("Belch cannot be used if the user has not eaten a berry")
{
u16 item = 0;
PARAMETRIZE { item = ITEM_NONE; }
PARAMETRIZE { item = ITEM_ORAN_BERRY; }
GIVEN {
PLAYER(SPECIES_SKWOVET) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
if (item == ITEM_NONE)
TURN { MOVE(player, MOVE_BELCH, allowed: FALSE); MOVE(player, MOVE_CELEBRATE); }
else {
TURN { MOVE(player, MOVE_STUFF_CHEEKS); }
TURN { MOVE(player, MOVE_BELCH); }
}
} SCENE {
if (item == ITEM_NONE) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
}
else {
ANIMATION(ANIM_TYPE_MOVE, MOVE_STUFF_CHEEKS, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_BELCH, player);
}
}
}
26 changes: 0 additions & 26 deletions test/battle/move_effect/stuff_cheeks.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,29 +103,3 @@ SINGLE_BATTLE_TEST("Stuff Cheeks fails if the user's berry is removed before the
MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Belch cannot be used if the user has not eaten a berry")
{
u16 item = 0;
PARAMETRIZE { item = ITEM_NONE; }
PARAMETRIZE { item = ITEM_ORAN_BERRY; }
GIVEN {
PLAYER(SPECIES_SKWOVET) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
if (item == ITEM_NONE)
TURN { MOVE(player, MOVE_BELCH, allowed: FALSE); MOVE(player, MOVE_CELEBRATE); }
else {
TURN { MOVE(player, MOVE_STUFF_CHEEKS); }
TURN { MOVE(player, MOVE_BELCH); }
}
} SCENE {
if (item == ITEM_NONE) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, player);
}
else {
ANIMATION(ANIM_TYPE_MOVE, MOVE_STUFF_CHEEKS, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_BELCH, player);
}
}
}
Loading