Skip to content

Commit

Permalink
Fixes small ai bulldoze effect bug (#3872)
Browse files Browse the repository at this point in the history
Co-authored-by: DizzyEggg <jajkodizzy@wp.pl>
Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
  • Loading branch information
3 people authored Dec 30, 2023
1 parent 726c6f4 commit a3c2511
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ static bool32 AI_IsMoveEffectInPlus(u32 battlerAtk, u32 battlerDef, u32 move, s3
if (ShouldLowerStat(battlerDef, abilityDef, STAT_DEF) && noOfHitsToKo != 1)
return TRUE;
break;
case EFFECT_BULLDOZE:
case EFFECT_SPEED_DOWN_HIT:
if (ShouldLowerStat(battlerDef, abilityDef, STAT_SPEED) && noOfHitsToKo != 1)
return TRUE;
Expand Down
15 changes: 15 additions & 0 deletions test/battle/ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ AI_DOUBLE_BATTLE_TEST("AI without any flags chooses moves at random - doubles")
}
}

AI_SINGLE_BATTLE_TEST("AI will choose either Rock Tomb or Bulldoze if Stat drop effect will activate and they kill with the same number of hits")
{
GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
PLAYER(SPECIES_WOBBUFFET) { HP(46); Speed(20); }
PLAYER(SPECIES_WYNAUT) { Speed(20); }
OPPONENT(SPECIES_WOBBUFFET) { Speed(10); Moves(MOVE_BULLDOZE, MOVE_ROCK_TOMB); }
} WHEN {
TURN { EXPECT_MOVES(opponent, MOVE_BULLDOZE, MOVE_ROCK_TOMB); }
TURN { EXPECT_MOVES(opponent, MOVE_BULLDOZE, MOVE_ROCK_TOMB); SEND_OUT(player, 1); }
} SCENE {
MESSAGE("Wobbuffet fainted!");
}
}

AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_MON_CHOICES: AI will not switch in a Pokemon which is slower and gets 1HKOed after fainting")
{
bool32 alakazamFirst;
Expand Down

0 comments on commit a3c2511

Please sign in to comment.