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

Fixed Steam Roller AI check affecting Terrain setting effects #4498

Merged
merged 5 commits into from
May 5, 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
6 changes: 3 additions & 3 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ bool32 IsDamageMoveUnusable(u32 move, u32 battlerAtk, u32 battlerDef)
return TRUE;
break;
case EFFECT_HIT_SET_REMOVE_TERRAIN:
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_ANY))
return TRUE;
break;
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_ANY) && gMovesInfo[move].argument == ARG_TRY_REMOVE_TERRAIN_FAIL)
return TRUE;
break;
}

return FALSE;
Expand Down
42 changes: 42 additions & 0 deletions test/battle/move_effect/hit_set_remove_terrain.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,45 @@ SINGLE_BATTLE_TEST("Ice Spinner doesn't fail if there is no terrain on the field
NOT MESSAGE("But it failed!");
}
}

AI_SINGLE_BATTLE_TEST("Steel Roller will not be chosen by the AI if it might fail")
{
u32 move;

PARAMETRIZE { move = MOVE_ELECTRIC_TERRAIN; }
PARAMETRIZE { move = MOVE_NONE; }

GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_STEEL_ROLLER, MOVE_ICE_SHARD); }
} WHEN {
if (move == MOVE_ELECTRIC_TERRAIN) {
TURN { MOVE(player, MOVE_ELECTRIC_TERRAIN); EXPECT_MOVE(opponent, MOVE_ICE_SHARD); }
TURN { EXPECT_MOVE(opponent, MOVE_STEEL_ROLLER); }
} else {
TURN { EXPECT_MOVE(opponent, MOVE_ICE_SHARD); }
}
}
}

AI_SINGLE_BATTLE_TEST("Ice Spinner can be chosen by the AI regardless if there is a terrain or not")
{
u32 move;

PARAMETRIZE { move = MOVE_ELECTRIC_TERRAIN; }
PARAMETRIZE { move = MOVE_NONE; }

GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_ICE_SPINNER, MOVE_ICE_SHARD); }
} WHEN {
if (move == MOVE_ELECTRIC_TERRAIN) {
TURN { MOVE(player, MOVE_ELECTRIC_TERRAIN); EXPECT_MOVE(opponent, MOVE_ICE_SPINNER); }
TURN { EXPECT_MOVE(opponent, MOVE_ICE_SPINNER); }
} else {
TURN { EXPECT_MOVE(opponent, MOVE_ICE_SPINNER); }
}
}
}
Loading