From ef159a8057cd93e7cad889469329d2f68f23aaa9 Mon Sep 17 00:00:00 2001 From: Nephrite Date: Wed, 24 Jan 2024 23:03:56 +0900 Subject: [PATCH] Applied review changes --- include/battle_ai_util.h | 2 +- src/battle_ai_main.c | 12 +++++----- src/battle_ai_util.c | 2 +- test/battle/move_effect/two_turn_moves.c | 30 ++++++++---------------- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index 95b5838b911b..a174e1e5dcd3 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -110,7 +110,7 @@ bool32 IsStatLoweringMoveEffect(u32 moveEffect); bool32 IsMoveRedirectionPrevented(u32 move, u32 atkAbility); bool32 IsMoveEncouragedToHit(u32 battlerAtk, u32 battlerDef, u32 move); bool32 IsHazardMoveEffect(u32 moveEffect); -bool32 IsChargingMove(u32 battlerAtk, u32 move); +bool32 IsTwoTurnNotSemiInvulnerableMove(u32 battlerAtk, u32 move); void ProtectChecks(u32 battlerAtk, u32 battlerDef, u32 move, u32 predictedMove, s32 *score); bool32 ShouldSetSandstorm(u32 battler, u32 ability, u32 holdEffect); bool32 ShouldSetHail(u32 battler, u32 ability, u32 holdEffect); diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 4ed8b0dea046..a302f9ed4c9c 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -803,7 +803,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) if (IsSemiInvulnerable(battlerDef, move) && moveEffect != EFFECT_SEMI_INVULNERABLE && AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) RETURN_SCORE_MINUS(20); // if target off screen and we go first, don't use move - if (IsChargingMove(battlerAtk, move) && CanTargetFaintAi(battlerDef, battlerAtk)) + if (IsTwoTurnNotSemiInvulnerableMove(battlerAtk, move) && CanTargetFaintAi(battlerDef, battlerAtk)) RETURN_SCORE_MINUS(10); // check if negates type @@ -3109,7 +3109,7 @@ static s32 AI_CompareDamagingMoves(u32 battlerAtk, u32 battlerDef, u32 currId) s32 score = 0; s32 leastHits = 1000; u16 *moves = GetMovesArray(battlerAtk); - bool8 isChargingMoveEffect[MAX_MON_MOVES]; + bool8 isTwoTurnNotSemiInvulnerableMove[MAX_MON_MOVES]; for (i = 0; i < MAX_MON_MOVES; i++) { @@ -3121,13 +3121,13 @@ static s32 AI_CompareDamagingMoves(u32 battlerAtk, u32 battlerDef, u32 currId) leastHits = noOfHits[i]; } viableMoveScores[i] = AI_SCORE_DEFAULT; - isChargingMoveEffect[i] = IsChargingMove(battlerAtk, moves[i]); + isTwoTurnNotSemiInvulnerableMove[i] = IsTwoTurnNotSemiInvulnerableMove(battlerAtk, moves[i]); } else { noOfHits[i] = -1; viableMoveScores[i] = 0; - isChargingMoveEffect[i] = FALSE; + isTwoTurnNotSemiInvulnerableMove[i] = FALSE; } /* MgbaPrintf_("%S: required hits: %d Dmg: %d", gMoveNames[moves[i]], noOfHits[i], AI_DATA->simulatedDmg[battlerAtk][battlerDef][i]); @@ -3151,9 +3151,9 @@ static s32 AI_CompareDamagingMoves(u32 battlerAtk, u32 battlerDef, u32 currId) { multipleBestMoves = TRUE; // We need to make sure it's the current move which is objectively better. - if (isChargingMoveEffect[i] && !isChargingMoveEffect[currId]) + if (isTwoTurnNotSemiInvulnerableMove[i] && !isTwoTurnNotSemiInvulnerableMove[currId]) viableMoveScores[i] -= 3; - else if (!isChargingMoveEffect[i] && isChargingMoveEffect[currId]) + else if (!isTwoTurnNotSemiInvulnerableMove[i] && isTwoTurnNotSemiInvulnerableMove[currId]) viableMoveScores[currId] -= 3; switch (CompareMoveAccuracies(battlerAtk, battlerDef, currId, i)) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index c67bd9191e8d..3ed88dd46b54 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -1980,7 +1980,7 @@ bool32 HasSnatchAffectedMove(u32 battler) CHECK_MOVE_FLAG(snatchAffected); } -bool32 IsChargingMove(u32 battlerAtk, u32 move) +bool32 IsTwoTurnNotSemiInvulnerableMove(u32 battlerAtk, u32 move) { switch (gBattleMoves[move].effect) { diff --git a/test/battle/move_effect/two_turn_moves.c b/test/battle/move_effect/two_turn_moves.c index 23e094e23c09..b3c5be0dab49 100644 --- a/test/battle/move_effect/two_turn_moves.c +++ b/test/battle/move_effect/two_turn_moves.c @@ -43,12 +43,10 @@ SINGLE_BATTLE_TEST("Razor Wind doesn't need to charge with Power Herb") } WHEN { TURN { MOVE(player, MOVE_RAZOR_WIND); } } SCENE { - if (B_UPDATED_MOVE_DATA >= GEN_5) - { + if (B_UPDATED_MOVE_DATA >= GEN_5) { NOT MESSAGE("Wobbuffet whipped up a whirlwind!"); MESSAGE("Wobbuffet used Razor Wind!"); - } - else + } else ANIMATION(ANIM_TYPE_MOVE, MOVE_RAZOR_WIND, player); if (B_UPDATED_MOVE_DATA < GEN_5) MESSAGE("Wobbuffet whipped up a whirlwind!"); @@ -74,12 +72,10 @@ SINGLE_BATTLE_TEST("Skull Bash needs a charging turn") TURN { SKIP_TURN(player); } } SCENE { // Charging turn - if (B_UPDATED_MOVE_DATA >= GEN_5) - { + if (B_UPDATED_MOVE_DATA >= GEN_5) { NOT MESSAGE("Wobbuffet lowered its head!"); MESSAGE("Wobbuffet used Skull Bash!"); - } - else + } else ANIMATION(ANIM_TYPE_MOVE, MOVE_SKULL_BASH, player); if (B_UPDATED_MOVE_DATA < GEN_5) MESSAGE("Wobbuffet lowered its head!"); @@ -102,12 +98,10 @@ SINGLE_BATTLE_TEST("Skull Bash doesn't need to charge with Power Herb") } WHEN { TURN { MOVE(player, MOVE_SKULL_BASH); } } SCENE { - if (B_UPDATED_MOVE_DATA >= GEN_5) - { + if (B_UPDATED_MOVE_DATA >= GEN_5) { NOT MESSAGE("Wobbuffet lowered its head!"); MESSAGE("Wobbuffet used Skull Bash!"); - } - else + } else ANIMATION(ANIM_TYPE_MOVE, MOVE_SKULL_BASH, player); if (B_UPDATED_MOVE_DATA < GEN_5) MESSAGE("Wobbuffet lowered its head!"); @@ -134,15 +128,13 @@ SINGLE_BATTLE_TEST("Sky Attack needs a charging turn") TURN { SKIP_TURN(player); } } SCENE { // Charging turn - if (B_UPDATED_MOVE_DATA >= GEN_5) - { + if (B_UPDATED_MOVE_DATA >= GEN_5) { NONE_OF { MESSAGE("Wobbuffet became cloaked in a harsh light!"); MESSAGE("Wobbuffet is glowing!"); } MESSAGE("Wobbuffet used Sky Attack!"); - } - else + } else ANIMATION(ANIM_TYPE_MOVE, MOVE_SKY_ATTACK, player); if (B_UPDATED_MOVE_DATA < GEN_4) MESSAGE("Wobbuffet is glowing!"); @@ -165,15 +157,13 @@ SINGLE_BATTLE_TEST("Sky Attack doesn't need to charge with Power Herb") } WHEN { TURN { MOVE(player, MOVE_SKY_ATTACK); } } SCENE { - if (B_UPDATED_MOVE_DATA >= GEN_5) - { + if (B_UPDATED_MOVE_DATA >= GEN_5) { NONE_OF { MESSAGE("Wobbuffet became cloaked in a harsh light!"); MESSAGE("Wobbuffet is glowing!"); } MESSAGE("Wobbuffet used Sky Attack!"); - } - else + } else ANIMATION(ANIM_TYPE_MOVE, MOVE_SKY_ATTACK, player); if (B_UPDATED_MOVE_DATA < GEN_4) MESSAGE("Wobbuffet is glowing!");