Skip to content

Commit

Permalink
AI PR 4036 follow up (rh-hideout#4199)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Feb 16, 2024
1 parent fcc2839 commit d102467
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3846,7 +3846,7 @@ static u32 AI_CalcMoveScore(u32 battlerAtk, u32 battlerDef, u32 move)
case EFFECT_FIRST_TURN_ONLY:
if (ShouldFakeOut(battlerAtk, battlerDef, move))
ADJUST_SCORE(GOOD_EFFECT);
else if (gMovesInfo[move].priority >= 1 && gDisableStructs[battlerAtk].isFirstTurn && GetBestDmgMoveFromBattler(battlerAtk, battlerDef) == move)
else if (gMovesInfo[move].argument == MOVE_FIRST_IMPRESSION && gDisableStructs[battlerAtk].isFirstTurn && GetBestDmgMoveFromBattler(battlerAtk, battlerDef) == move)
ADJUST_SCORE(BEST_EFFECT);
break;
case EFFECT_STOCKPILE:
Expand Down
36 changes: 28 additions & 8 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3297,7 +3297,7 @@ void IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, u32 statId, s32 *score)
return;

// Don't set up if AI is dead to residual damage from weather
if (BattlerWillFaintFromWeather(battlerAtk, AI_DATA->abilities[battlerAtk]))
if (GetBattlerSecondaryDamage(battlerAtk) >= gBattleMons[battlerAtk].hp)
return;

// Don't increase stats if opposing battler has Opportunist
Expand All @@ -3312,10 +3312,15 @@ void IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, u32 statId, s32 *score)
break;
case STAT_CHANGE_DEF:
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL))
ADJUST_SCORE_PTR(DECENT_EFFECT);
{
if (AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_STALL)
ADJUST_SCORE_PTR(DECENT_EFFECT);
else
ADJUST_SCORE_PTR(WEAK_EFFECT);
}
break;
case STAT_CHANGE_SPEED:
if ((noOfHitsToFaint >= 3 && !aiIsFaster) || noOfHitsToFaint == 0)
if ((noOfHitsToFaint >= 3 && !aiIsFaster) || noOfHitsToFaint == UNKNOWN_NO_OF_HITS)
ADJUST_SCORE_PTR(DECENT_EFFECT);
break;
case STAT_CHANGE_SPATK:
Expand All @@ -3324,18 +3329,28 @@ void IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, u32 statId, s32 *score)
break;
case STAT_CHANGE_SPDEF:
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL))
ADJUST_SCORE_PTR(DECENT_EFFECT);
{
if (AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_STALL)
ADJUST_SCORE_PTR(DECENT_EFFECT);
else
ADJUST_SCORE_PTR(WEAK_EFFECT);
}
break;
case STAT_CHANGE_ATK_2:
if (HasMoveWithCategory(battlerAtk, DAMAGE_CATEGORY_PHYSICAL) && shouldSetUp)
ADJUST_SCORE_PTR(GOOD_EFFECT);
break;
case STAT_CHANGE_DEF_2:
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL))
ADJUST_SCORE_PTR(GOOD_EFFECT);
{
if (AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_STALL)
ADJUST_SCORE_PTR(GOOD_EFFECT);
else
ADJUST_SCORE_PTR(DECENT_EFFECT);
}
break;
case STAT_CHANGE_SPEED_2:
if ((noOfHitsToFaint >= 3 && !aiIsFaster) || noOfHitsToFaint == 0)
if ((noOfHitsToFaint >= 3 && !aiIsFaster) || noOfHitsToFaint == UNKNOWN_NO_OF_HITS)
ADJUST_SCORE_PTR(GOOD_EFFECT);
break;
case STAT_CHANGE_SPATK_2:
Expand All @@ -3344,14 +3359,19 @@ void IncreaseStatUpScore(u32 battlerAtk, u32 battlerDef, u32 statId, s32 *score)
break;
case STAT_CHANGE_SPDEF_2:
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL))
ADJUST_SCORE_PTR(GOOD_EFFECT);
{
if (AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_STALL)
ADJUST_SCORE_PTR(GOOD_EFFECT);
else
ADJUST_SCORE_PTR(DECENT_EFFECT);
}
break;
case STAT_CHANGE_ACC:
if (gBattleMons[battlerAtk].statStages[STAT_ACC] <= 3) // Increase only if necessary
ADJUST_SCORE_PTR(DECENT_EFFECT);
break;
case STAT_CHANGE_EVASION:
if (GetBattlerSecondaryDamage(battlerAtk) && ((noOfHitsToFaint > 3) || noOfHitsToFaint == 0))
if (noOfHitsToFaint > 3 || noOfHitsToFaint == UNKNOWN_NO_OF_HITS)
ADJUST_SCORE_PTR(GOOD_EFFECT);
else
ADJUST_SCORE_PTR(DECENT_EFFECT);
Expand Down
1 change: 1 addition & 0 deletions src/data/moves_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -15027,6 +15027,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] =
.target = MOVE_TARGET_SELECTED,
.priority = 2,
.category = DAMAGE_CATEGORY_PHYSICAL,
.argument = MOVE_FIRST_IMPRESSION,
.makesContact = TRUE,
.contestEffect = CONTEST_EFFECT_BETTER_IF_FIRST,
.contestCategory = CONTEST_CATEGORY_COOL,
Expand Down

0 comments on commit d102467

Please sign in to comment.