Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant AI score increases #3504

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_SMELLINGSALT
.4byte BattleScript_EffectSmellingsalt @ EFFECT_SMELLING_SALTS
.4byte BattleScript_EffectFollowMe @ EFFECT_FOLLOW_ME
.4byte BattleScript_EffectNaturePower @ EFFECT_NATURE_POWER
.4byte BattleScript_EffectCharge @ EFFECT_CHARGE
Expand Down
1 change: 0 additions & 1 deletion include/battle_ai_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ 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_SMELLINGSALT 166
#define EFFECT_SMELLING_SALTS 166
#define EFFECT_FOLLOW_ME 167
#define EFFECT_NATURE_POWER 168
#define EFFECT_CHARGE 169
Expand Down
123 changes: 8 additions & 115 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,10 +1684,6 @@ 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 @@ -3295,63 +3291,16 @@ 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)
score += (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) ? 20 : 10;
ADJUST_SCORE(10);

// check burn
if (gBattleMons[battlerAtk].status1 & STATUS1_BURN)
// check burn / frostbite
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING && AI_DATA->abilities[battlerAtk] == ABILITY_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_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;
}
if ((gBattleMons[battlerAtk].status1 & STATUS1_BURN && HasOnlyMovesWithSplit(battlerAtk, SPLIT_PHYSICAL, TRUE))
|| (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE && HasOnlyMovesWithSplit(battlerAtk, SPLIT_SPECIAL, TRUE)))
score = 90; // Force switch if all your attacking moves are physical and you have Natural Cure.
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
}

// check frostbite
if (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE)
{
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 @@ -3362,12 +3311,6 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
if (AI_RandLessThan(128))
IncreaseSleepScore(battlerAtk, battlerDef, move, &score);
break;
case EFFECT_ABSORB:
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -3581,11 +3524,6 @@ 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 @@ -3734,20 +3672,12 @@ 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 @@ -4243,14 +4173,6 @@ 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 @@ -4745,11 +4667,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
ADJUST_SCORE(2);
break;
case EFFECT_PLEDGE:
if (isDoubleBattle)
{
if (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE))
ADJUST_SCORE(3); // Partner might use pledge move
}
if (isDoubleBattle && 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 @@ -4952,26 +4871,13 @@ 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 @@ -4981,19 +4887,6 @@ 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: 0 additions & 1 deletion src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ 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 @@ -979,7 +979,7 @@ static const u16 sFinalStrikeOnlyEffects[] =
EFFECT_SECRET_POWER,
EFFECT_SMACK_DOWN,
EFFECT_SPARKLING_ARIA,
EFFECT_SMELLINGSALT,
EFFECT_SMELLING_SALTS,
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_SMELLINGSALT] = 1,
[EFFECT_SMELLING_SALTS] = 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 @@ -8555,7 +8555,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_SMELLINGSALT:
case EFFECT_SMELLING_SALTS:
if (gBattleMons[battlerDef].status1 & STATUS1_PARALYSIS)
basePower *= 2;
break;
Expand Down
Loading
Loading