diff --git a/include/battle_ai_main.h b/include/battle_ai_main.h index ce92296b67..60028eb8cd 100644 --- a/include/battle_ai_main.h +++ b/include/battle_ai_main.h @@ -29,8 +29,9 @@ #define STAT_CHANGE_ACC 10 #define STAT_CHANGE_EVASION 11 -#define BEST_DAMAGE_MOVE 1 // Move with the most amount of hits with the best accuracy/effect -#define POWERFUL_STATUS_MOVE 10 // Moves with this score will be chosen over a move that faints target +#define BEST_DAMAGE_MOVE 1 // Move with the most amount of hits with the best accuracy/effect +#define POWERFUL_STATUS_MOVE 10 // Moves with this score will be chosen over a move that faints target +#define NO_DAMAGE_OR_FAILS -20 // Move fails or does no damage // Scores given in AI_CalcMoveEffectScore #define WEAK_EFFECT 1 @@ -64,6 +65,14 @@ score += val; \ } while (0) \ +#define ADJUST_AND_RETURN_SCORE(val) \ + do \ + { \ + TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, sBattler_AI, AI_THINKING_STRUCT->movesetIndex, val); \ + score += val; \ + return score; \ + } while (0) \ + #define ADJUST_SCORE_PTR(val) \ do \ { \ diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index a94926b3bf..43fdcb5ce9 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -4734,17 +4734,17 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score if (gMovesInfo[move].power) { if (GetNoOfHitsToKOBattler(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex) == 0) - ADJUST_SCORE(-20); + ADJUST_AND_RETURN_SCORE(NO_DAMAGE_OR_FAILS); // No point in checking the move further so return early else { if ((AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_RISKY) && GetBestDmgMoveFromBattler(battlerAtk, battlerDef) == move) - ADJUST_SCORE(1); + ADJUST_SCORE(BEST_DAMAGE_MOVE); else - score += AI_CompareDamagingMoves(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex); + ADJUST_SCORE(AI_CompareDamagingMoves(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex)); } } - score += AI_CalcMoveEffectScore(battlerAtk, battlerDef, move); + ADJUST_SCORE(AI_CalcMoveEffectScore(battlerAtk, battlerDef, move)); return score; } diff --git a/test/battle/move_effect/spicy_extract.c b/test/battle/move_effect/spicy_extract.c index 3642bf936c..8a66003ec7 100644 --- a/test/battle/move_effect/spicy_extract.c +++ b/test/battle/move_effect/spicy_extract.c @@ -170,7 +170,6 @@ AI_DOUBLE_BATTLE_TEST("Spicy Extract user will use it if partner holds Clear Amu PARAMETRIZE { move = MOVE_TACKLE; } PARAMETRIZE { move = MOVE_SWIFT;} - AI_LOG; GIVEN { AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); PLAYER(SPECIES_WOBBUFFET) { Speed(10); }