Skip to content

Commit

Permalink
Revert "Remove redundant AI score increases (rh-hideout#3504)"
Browse files Browse the repository at this point in the history
This reverts commit 8ed5460.
  • Loading branch information
Kasenn committed Dec 29, 2023
1 parent 3df5e1a commit 21d90d0
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 1,540 deletions.
2 changes: 1 addition & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectMemento @ EFFECT_MEMENTO
.4byte BattleScript_EffectHit @ EFFECT_FACADE
.4byte BattleScript_EffectFocusPunch @ EFFECT_FOCUS_PUNCH
.4byte BattleScript_EffectSmellingsalt @ EFFECT_SMELLING_SALTS
.4byte BattleScript_EffectSmellingsalt @ EFFECT_SMELLINGSALT
.4byte BattleScript_EffectFollowMe @ EFFECT_FOLLOW_ME
.4byte BattleScript_EffectNaturePower @ EFFECT_NATURE_POWER
.4byte BattleScript_EffectCharge @ EFFECT_CHARGE
Expand Down
1 change: 1 addition & 0 deletions include/battle_ai_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ bool32 ShouldFakeOut(u32 battlerAtk, u32 battlerDef, u32 move);
bool32 HasThawingMove(u32 battler);
bool32 IsStatRaisingEffect(u32 effect);
bool32 IsStatLoweringEffect(u32 effect);
bool32 IsStatRaisingEffect(u32 effect);
bool32 IsAttackBoostMoveEffect(u32 effect);
bool32 IsUngroundingEffect(u32 effect);
bool32 IsSemiInvulnerable(u32 battlerDef, u32 move);
Expand Down
2 changes: 1 addition & 1 deletion include/constants/battle_move_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
#define EFFECT_MEMENTO 163
#define EFFECT_FACADE 164
#define EFFECT_FOCUS_PUNCH 165
#define EFFECT_SMELLING_SALTS 166
#define EFFECT_SMELLINGSALT 166
#define EFFECT_FOLLOW_ME 167
#define EFFECT_NATURE_POWER 168
#define EFFECT_CHARGE 169
Expand Down
124 changes: 114 additions & 10 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,10 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
if (gDisableStructs[battlerAtk].stockpileCounter >= 3)
ADJUST_SCORE(-10);
break;
case EFFECT_SPIT_UP:
if (gDisableStructs[battlerAtk].stockpileCounter <= 1)
ADJUST_SCORE(-10);
break;
case EFFECT_SWALLOW:
if (gDisableStructs[battlerAtk].stockpileCounter == 0)
{
Expand Down Expand Up @@ -3309,16 +3313,63 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score

// check thawing moves
if ((gBattleMons[battlerAtk].status1 & (STATUS1_FREEZE | STATUS1_FROSTBITE)) && gBattleMoves[move].thawsUser)
ADJUST_SCORE(10);
score += (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) ? 20 : 10;

// check burn
if (gBattleMons[battlerAtk].status1 & STATUS1_BURN)
{
switch (aiData->abilities[battlerAtk])
{
case ABILITY_GUTS:
break;
case ABILITY_NATURAL_CURE:
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING
&& HasOnlyMovesWithSplit(battlerAtk, SPLIT_PHYSICAL, TRUE))
score = 90; // Force switch if all your attacking moves are physical and you have Natural Cure.
break;
default:
if (IS_MOVE_PHYSICAL(move) && gBattleMoves[move].effect != EFFECT_FACADE)
ADJUST_SCORE(-2);
break;
}
}

// check burn / frostbite
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING && AI_DATA->abilities[battlerAtk] == ABILITY_NATURAL_CURE)
// check frostbite
if (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE)
{
if ((gBattleMons[battlerAtk].status1 & STATUS1_BURN && HasOnlyMovesWithSplit(battlerAtk, SPLIT_PHYSICAL, TRUE))
|| (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE && HasOnlyMovesWithSplit(battlerAtk, SPLIT_SPECIAL, TRUE)))
ADJUST_SCORE(-20); // Force switch if all your attacking moves are physical and you have Natural Cure.
switch (aiData->abilities[battlerAtk])
{
case ABILITY_GUTS:
break;
case ABILITY_NATURAL_CURE:
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING
&& HasOnlyMovesWithSplit(battlerAtk, SPLIT_SPECIAL, TRUE))
score = 90; // Force switch if all your attacking moves are special and you have Natural Cure.
break;
default:
if (IS_MOVE_SPECIAL(move) && gBattleMoves[move].effect != EFFECT_FACADE)
ADJUST_SCORE(-2);
break;
}
}

// attacker ability checks
switch (aiData->abilities[battlerAtk])
{
case ABILITY_MOXIE:
case ABILITY_BEAST_BOOST:
case ABILITY_CHILLING_NEIGH:
case ABILITY_GRIM_NEIGH:
case ABILITY_AS_ONE_ICE_RIDER:
case ABILITY_AS_ONE_SHADOW_RIDER:
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // Attacker should go first
{
if (CanIndexMoveFaintTarget(battlerAtk, battlerDef, movesetIndex, 0))
ADJUST_SCORE(8); // prioritize killing target for stat boost
}
break;
} // ability checks

// move effect checks
switch (moveEffect)
{
Expand All @@ -3330,8 +3381,11 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
IncreaseSleepScore(battlerAtk, battlerDef, move, &score);
break;
case EFFECT_ABSORB:
if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_BIG_ROOT && effectiveness >= AI_EFFECTIVENESS_x1)
ADJUST_SCORE(2);
if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_BIG_ROOT)
ADJUST_SCORE(1);
if (effectiveness <= AI_EFFECTIVENESS_x0_5 && AI_RandLessThan(50))
ADJUST_SCORE(-3);
break;
case EFFECT_EXPLOSION:
case EFFECT_MEMENTO:
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_WILL_SUICIDE && gBattleMons[battlerDef].statStages[STAT_EVASION] < 7)
Expand Down Expand Up @@ -3545,6 +3599,11 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
if (aiData->hpPercents[battlerAtk] < 90)
ADJUST_SCORE(-2);
break;
case EFFECT_DREAM_EATER:
if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP))
break;
ADJUST_SCORE(1); // if target is asleep, dream eater is a pretty good move even without draining
// fallthrough
case EFFECT_ACUPRESSURE:
break;
case EFFECT_ATTACK_ACCURACY_UP: // hone claws
Expand Down Expand Up @@ -3693,12 +3752,20 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
|| HasHighCritRatioMove(battlerAtk))
ADJUST_SCORE(2);
break;
case EFFECT_CONFUSE_HIT:
if (sereneGraceBoost)
ADJUST_SCORE(1);
//fallthrough
case EFFECT_CONFUSE:
IncreaseConfusionScore(battlerAtk, battlerDef, move, &score);
break;
case EFFECT_PARALYZE:
IncreaseParalyzeScore(battlerAtk, battlerDef, move, &score);
break;
case EFFECT_GRAV_APPLE:
if (gFieldStatuses & STATUS_FIELD_GRAVITY)
ADJUST_SCORE(2);
// fall through
case EFFECT_ATTACK_DOWN_HIT:
case EFFECT_DEFENSE_DOWN_HIT:
case EFFECT_SPECIAL_ATTACK_DOWN_HIT:
Expand Down Expand Up @@ -4201,6 +4268,14 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_DEF, &score);
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score);
break;
case EFFECT_SPIT_UP:
if (gDisableStructs[battlerAtk].stockpileCounter >= 2)
ADJUST_SCORE(1);
break;
case EFFECT_ROLLOUT:
if (gBattleMons[battlerAtk].status2 & STATUS2_DEFENSE_CURL)
ADJUST_SCORE(8);
break;
case EFFECT_SWAGGER:
if (HasMoveEffect(battlerAtk, EFFECT_FOUL_PLAY)
|| HasMoveEffect(battlerAtk, EFFECT_PSYCH_UP)
Expand Down Expand Up @@ -4696,8 +4771,11 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
ADJUST_SCORE(2);
break;
case EFFECT_PLEDGE:
if (isDoubleBattle && HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE))
ADJUST_SCORE(3); // Partner might use pledge move
if (isDoubleBattle)
{
if (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE))
ADJUST_SCORE(3); // Partner might use pledge move
}
break;
case EFFECT_TRICK_ROOM:
if (!(gFieldStatuses & STATUS_FIELD_TRICK_ROOM) && GetBattlerSideSpeedAverage(battlerAtk) < GetBattlerSideSpeedAverage(battlerDef))
Expand Down Expand Up @@ -4900,13 +4978,26 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
ADJUST_SCORE(3);
}
break;
case EFFECT_FLAIL:
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // Ai goes first
{
if (aiData->hpPercents[battlerAtk] < 20)
ADJUST_SCORE(1);
else if (aiData->hpPercents[battlerAtk] < 8)
ADJUST_SCORE(2);
}
break;
case EFFECT_SHORE_UP:
if ((AI_GetWeather(aiData) & B_WEATHER_SANDSTORM)
&& ShouldRecover(battlerAtk, battlerDef, move, 67))
ADJUST_SCORE(3);
else if (ShouldRecover(battlerAtk, battlerDef, move, 50))
ADJUST_SCORE(2);
break;
case EFFECT_FACADE:
if (gBattleMons[battlerAtk].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE))
ADJUST_SCORE(1);
break;
case EFFECT_FOCUS_PUNCH:
if (!isDoubleBattle && effectiveness > AI_EFFECTIVENESS_x0_5)
{
Expand All @@ -4916,6 +5007,19 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
ADJUST_SCORE(1);
}
break;
case EFFECT_SMELLINGSALT:
if (gBattleMons[battlerDef].status1 & STATUS1_PARALYSIS)
ADJUST_SCORE(2);
break;
case EFFECT_WAKE_UP_SLAP:
if (gBattleMons[battlerDef].status1 & STATUS1_SLEEP)
ADJUST_SCORE(2);
break;
case EFFECT_REVENGE:
if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP)
&& !(gBattleMons[battlerDef].status2 & (STATUS2_INFATUATION | STATUS2_CONFUSION)))
ADJUST_SCORE(2);
break;
case EFFECT_ENDEAVOR:
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_SLOWER) // Opponent faster
{
Expand Down
1 change: 1 addition & 0 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ static const u16 sIgnoredPowerfulMoveEffects[] =
EFFECT_RECHARGE,
EFFECT_SKULL_BASH,
EFFECT_SOLAR_BEAM,
EFFECT_SPIT_UP,
EFFECT_FOCUS_PUNCH,
EFFECT_SUPERPOWER,
EFFECT_ERUPTION,
Expand Down
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ static const u16 sFinalStrikeOnlyEffects[] =
EFFECT_SECRET_POWER,
EFFECT_SMACK_DOWN,
EFFECT_SPARKLING_ARIA,
EFFECT_SMELLING_SALTS,
EFFECT_SMELLINGSALT,
EFFECT_WAKE_UP_SLAP,
EFFECT_HIT_ESCAPE,
EFFECT_RECOIL_HP_25,
Expand Down
2 changes: 1 addition & 1 deletion src/battle_tv.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] =
[EFFECT_MEMENTO] = 7,
[EFFECT_FACADE] = 1,
[EFFECT_FOCUS_PUNCH] = 7,
[EFFECT_SMELLING_SALTS] = 1,
[EFFECT_SMELLINGSALT] = 1,
[EFFECT_FOLLOW_ME] = 5,
[EFFECT_NATURE_POWER] = 0,
[EFFECT_CHARGE] = 4,
Expand Down
2 changes: 1 addition & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8625,7 +8625,7 @@ static inline u32 CalcMoveBasePower(u32 move, u32 battlerAtk, u32 battlerDef, u3
if (gBattleMons[battlerDef].status1 & STATUS1_SLEEP || abilityDef == ABILITY_COMATOSE)
basePower *= 2;
break;
case EFFECT_SMELLING_SALTS:
case EFFECT_SMELLINGSALT:
if (gBattleMons[battlerDef].status1 & STATUS1_PARALYSIS)
basePower *= 2;
break;
Expand Down
Loading

0 comments on commit 21d90d0

Please sign in to comment.