removed aiFlags prefix
This commit is contained in:
parent
057c0f5480
commit
9a14bb2dd3
@ -354,7 +354,7 @@ struct AiThinkingStruct
|
||||
u16 moveConsidered;
|
||||
s32 score[MAX_MON_MOVES];
|
||||
u32 funcResult;
|
||||
u32 aiFlags[MAX_BATTLERS_COUNT];
|
||||
u32 flags[MAX_BATTLERS_COUNT];
|
||||
u8 aiAction;
|
||||
u8 aiLogicId;
|
||||
struct AI_SavedBattleMon saved[MAX_BATTLERS_COUNT];
|
||||
|
||||
@ -196,43 +196,43 @@ static u32 GetAiFlags(u16 trainerId)
|
||||
void BattleAI_SetupFlags(void)
|
||||
{
|
||||
if (IsAiVsAiBattle())
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_PLAYER_LEFT] = GetAiFlags(gPartnerTrainerId);
|
||||
gAiThinkingStruct->flags[B_POSITION_PLAYER_LEFT] = GetAiFlags(gPartnerTrainerId);
|
||||
else
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_PLAYER_LEFT] = 0; // player has no AI
|
||||
gAiThinkingStruct->flags[B_POSITION_PLAYER_LEFT] = 0; // player has no AI
|
||||
|
||||
if (DEBUG_OVERWORLD_MENU && gIsDebugBattle)
|
||||
{
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] = gDebugAIFlags;
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] = gDebugAIFlags;
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] = gDebugAIFlags;
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] = gDebugAIFlags;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsWildMonSmart() && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER)))
|
||||
{
|
||||
// smart wild AI
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] = GetAiFlags(0xFFFF);
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] = GetAiFlags(0xFFFF);
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] = GetAiFlags(0xFFFF);
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] = GetAiFlags(0xFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] = GetAiFlags(TRAINER_BATTLE_PARAM.opponentA);
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] = GetAiFlags(TRAINER_BATTLE_PARAM.opponentA);
|
||||
if (TRAINER_BATTLE_PARAM.opponentB != 0)
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] = GetAiFlags(TRAINER_BATTLE_PARAM.opponentB);
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] = GetAiFlags(TRAINER_BATTLE_PARAM.opponentB);
|
||||
else
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] = gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT];
|
||||
gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] = gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT];
|
||||
}
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|
||||
{
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_PLAYER_RIGHT] = GetAiFlags(gPartnerTrainerId - TRAINER_PARTNER(PARTNER_NONE));
|
||||
gAiThinkingStruct->flags[B_POSITION_PLAYER_RIGHT] = GetAiFlags(gPartnerTrainerId - TRAINER_PARTNER(PARTNER_NONE));
|
||||
}
|
||||
else if (IsDoubleBattle() && IsAiVsAiBattle())
|
||||
{
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_PLAYER_RIGHT] = gAiThinkingStruct->aiFlags[B_POSITION_PLAYER_LEFT];
|
||||
gAiThinkingStruct->flags[B_POSITION_PLAYER_RIGHT] = gAiThinkingStruct->flags[B_POSITION_PLAYER_LEFT];
|
||||
}
|
||||
else
|
||||
{
|
||||
gAiThinkingStruct->aiFlags[B_POSITION_PLAYER_RIGHT] = 0; // player
|
||||
gAiThinkingStruct->flags[B_POSITION_PLAYER_RIGHT] = 0; // player
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,9 +242,9 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler)
|
||||
u32 flags[MAX_BATTLERS_COUNT];
|
||||
|
||||
// Clear AI data but preserve the flags.
|
||||
memcpy(&flags[0], &gAiThinkingStruct->aiFlags[0], sizeof(u32) * MAX_BATTLERS_COUNT);
|
||||
memcpy(&flags[0], &gAiThinkingStruct->flags[0], sizeof(u32) * MAX_BATTLERS_COUNT);
|
||||
memset(gAiThinkingStruct, 0, sizeof(struct AiThinkingStruct));
|
||||
memcpy(&gAiThinkingStruct->aiFlags[0], &flags[0], sizeof(u32) * MAX_BATTLERS_COUNT);
|
||||
memcpy(&gAiThinkingStruct->flags[0], &flags[0], sizeof(u32) * MAX_BATTLERS_COUNT);
|
||||
|
||||
moveLimitations = gAiLogicData->moveLimitations[battler];
|
||||
|
||||
@ -287,7 +287,7 @@ void SetupAISwitchingData(u32 battler, enum SwitchType switchType)
|
||||
s32 opposingBattler = GetOppositeBattler(battler);
|
||||
|
||||
// AI's predicting data
|
||||
if ((gAiThinkingStruct->aiFlags[battler] & AI_FLAG_PREDICT_SWITCH))
|
||||
if ((gAiThinkingStruct->flags[battler] & AI_FLAG_PREDICT_SWITCH))
|
||||
{
|
||||
gAiLogicData->aiSwitchPredictionInProgress = TRUE;
|
||||
gAiLogicData->battlerDoingPrediction = battler;
|
||||
@ -319,7 +319,7 @@ void ComputeBattlerDecisions(u32 battler)
|
||||
return;
|
||||
|
||||
// Risky AI switches aggressively even mid battle
|
||||
enum SwitchType switchType = (gAiThinkingStruct->aiFlags[battler] & AI_FLAG_RISKY) ? SWITCH_AFTER_KO : SWITCH_MID_BATTLE;
|
||||
enum SwitchType switchType = (gAiThinkingStruct->flags[battler] & AI_FLAG_RISKY) ? SWITCH_AFTER_KO : SWITCH_MID_BATTLE;
|
||||
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
BattleAI_SetupAIData(0xF, battler);
|
||||
@ -366,7 +366,7 @@ static void CopyBattlerDataToAIParty(u32 bPosition, u32 side)
|
||||
void Ai_InitPartyStruct(void)
|
||||
{
|
||||
u32 i;
|
||||
bool32 isOmniscient = (gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_OMNISCIENT) || (gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_OMNISCIENT);
|
||||
bool32 isOmniscient = (gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_OMNISCIENT) || (gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_OMNISCIENT);
|
||||
struct Pokemon *mon;
|
||||
|
||||
gAiPartyData->count[B_SIDE_PLAYER] = CalculatePlayerPartyCount();
|
||||
@ -560,14 +560,14 @@ static u32 ChooseMoveOrAction_Singles(u32 battlerAi)
|
||||
u8 consideredMoveArray[MAX_MON_MOVES];
|
||||
u32 numOfBestMoves;
|
||||
s32 i;
|
||||
u32 flags = gAiThinkingStruct->aiFlags[battlerAi];
|
||||
u32 flags = gAiThinkingStruct->flags[battlerAi];
|
||||
|
||||
gAiLogicData->partnerMove = 0; // no ally
|
||||
while (flags != 0)
|
||||
{
|
||||
if (flags & 1)
|
||||
{
|
||||
if (IsBattlerPredictedToSwitch(gBattlerTarget) && (gAiThinkingStruct->aiFlags[battlerAi] & AI_FLAG_PREDICT_INCOMING_MON))
|
||||
if (IsBattlerPredictedToSwitch(gBattlerTarget) && (gAiThinkingStruct->flags[battlerAi] & AI_FLAG_PREDICT_INCOMING_MON))
|
||||
BattleAI_DoAIProcessing_PredictedSwitchin(gAiThinkingStruct, gAiLogicData, battlerAi, gBattlerTarget);
|
||||
else
|
||||
BattleAI_DoAIProcessing(gAiThinkingStruct, battlerAi, gBattlerTarget);
|
||||
@ -638,13 +638,13 @@ static u32 ChooseMoveOrAction_Doubles(u32 battlerAi)
|
||||
gAiLogicData->partnerMove = GetAllyChosenMove(battlerAi);
|
||||
gAiThinkingStruct->aiLogicId = 0;
|
||||
gAiThinkingStruct->movesetIndex = 0;
|
||||
flags = gAiThinkingStruct->aiFlags[battlerAi];
|
||||
flags = gAiThinkingStruct->flags[battlerAi];
|
||||
|
||||
while (flags != 0)
|
||||
{
|
||||
if (flags & 1)
|
||||
{
|
||||
if (IsBattlerPredictedToSwitch(gBattlerTarget) && (gAiThinkingStruct->aiFlags[battlerAi] & AI_FLAG_PREDICT_INCOMING_MON))
|
||||
if (IsBattlerPredictedToSwitch(gBattlerTarget) && (gAiThinkingStruct->flags[battlerAi] & AI_FLAG_PREDICT_INCOMING_MON))
|
||||
BattleAI_DoAIProcessing_PredictedSwitchin(gAiThinkingStruct, gAiLogicData, battlerAi, gBattlerTarget);
|
||||
else
|
||||
BattleAI_DoAIProcessing(gAiThinkingStruct, battlerAi, gBattlerTarget);
|
||||
@ -1151,7 +1151,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
ADJUST_SCORE(-20);
|
||||
break;
|
||||
case EFFECT_EXPLOSION:
|
||||
if (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_WILL_SUICIDE))
|
||||
if (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_WILL_SUICIDE))
|
||||
ADJUST_SCORE(-2);
|
||||
|
||||
if (effectiveness == UQ_4_12(0.0))
|
||||
@ -1501,7 +1501,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
ADJUST_SCORE(-1);
|
||||
if ((predictedMove == MOVE_NONE || GetBattleMoveCategory(predictedMove) == DAMAGE_CATEGORY_STATUS
|
||||
|| DoesSubstituteBlockMove(battlerAtk, BATTLE_PARTNER(battlerDef), predictedMove))
|
||||
&& !(predictedMove == MOVE_NONE && (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY))) // Let Risky AI predict blindly based on stats
|
||||
&& !(predictedMove == MOVE_NONE && (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY))) // Let Risky AI predict blindly based on stats
|
||||
ADJUST_SCORE(-10);
|
||||
break;
|
||||
|
||||
@ -2007,7 +2007,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
break;
|
||||
case EFFECT_RECOIL_IF_MISS:
|
||||
if (aiData->abilities[battlerAtk] != ABILITY_MAGIC_GUARD && gAiLogicData->moveAccuracy[battlerAtk][battlerDef][gAiThinkingStruct->movesetIndex] < 75
|
||||
&& !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY))
|
||||
&& !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY))
|
||||
ADJUST_SCORE(-6);
|
||||
break;
|
||||
case EFFECT_TRANSFORM:
|
||||
@ -2122,7 +2122,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
}
|
||||
}
|
||||
|
||||
/*if (gAiThinkingStruct->aiFlags[battlerAtk] == AI_SCRIPT_CHECK_BAD_MOVE //Only basic AI
|
||||
/*if (gAiThinkingStruct->flags[battlerAtk] == AI_SCRIPT_CHECK_BAD_MOVE //Only basic AI
|
||||
&& IsDoubleBattle()) //Make the regular AI know how to use Protect minimally in Doubles
|
||||
{
|
||||
u8 shouldProtect = ShouldProtect(battlerAtk, battlerDef, move);
|
||||
@ -2436,7 +2436,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
{
|
||||
ADJUST_SCORE(-10);
|
||||
}
|
||||
else if (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_POWERFUL_STATUS))
|
||||
else if (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_POWERFUL_STATUS))
|
||||
{
|
||||
if (gFieldStatuses & STATUS_FIELD_TRICK_ROOM) // Trick Room Up
|
||||
{
|
||||
@ -2955,7 +2955,7 @@ static s32 AI_DoubleBattle(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
}
|
||||
break;
|
||||
case ABILITY_VOLT_ABSORB:
|
||||
if (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_HP_AWARE))
|
||||
if (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_HP_AWARE))
|
||||
{
|
||||
RETURN_SCORE_MINUS(10);
|
||||
}
|
||||
@ -2978,7 +2978,7 @@ static s32 AI_DoubleBattle(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
case ABILITY_WATER_ABSORB:
|
||||
case ABILITY_DRY_SKIN:
|
||||
case ABILITY_EARTH_EATER:
|
||||
if (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_HP_AWARE))
|
||||
if (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_HP_AWARE))
|
||||
{
|
||||
RETURN_SCORE_MINUS(10);
|
||||
}
|
||||
@ -3397,7 +3397,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
moveEffect = EFFECT_PROTECT;
|
||||
|
||||
// check status move preference
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_PREFER_STATUS_MOVES && IsBattleMoveStatus(move) && effectiveness != UQ_4_12(0.0))
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_PREFER_STATUS_MOVES && IsBattleMoveStatus(move) && effectiveness != UQ_4_12(0.0))
|
||||
ADJUST_SCORE(10);
|
||||
|
||||
// check thawing moves
|
||||
@ -3405,7 +3405,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
ADJUST_SCORE(10);
|
||||
|
||||
// check burn / frostbite
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_SMART_SWITCHING && gAiLogicData->abilities[battlerAtk] == ABILITY_NATURAL_CURE)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_SMART_SWITCHING && gAiLogicData->abilities[battlerAtk] == ABILITY_NATURAL_CURE)
|
||||
{
|
||||
if ((gBattleMons[battlerAtk].status1 & STATUS1_BURN && HasOnlyMovesWithCategory(battlerAtk, DAMAGE_CATEGORY_PHYSICAL, TRUE))
|
||||
|| (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE && HasOnlyMovesWithCategory(battlerAtk, DAMAGE_CATEGORY_SPECIAL, TRUE)))
|
||||
@ -3431,14 +3431,14 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
break;
|
||||
case EFFECT_EXPLOSION:
|
||||
case EFFECT_MEMENTO:
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_WILL_SUICIDE && gBattleMons[battlerDef].statStages[STAT_EVASION] < 7)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_WILL_SUICIDE && gBattleMons[battlerDef].statStages[STAT_EVASION] < 7)
|
||||
{
|
||||
if (aiData->hpPercents[battlerAtk] < 50 && AI_RandLessThan(128))
|
||||
ADJUST_SCORE(DECENT_EFFECT);
|
||||
}
|
||||
break;
|
||||
case EFFECT_FINAL_GAMBIT:
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_WILL_SUICIDE)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_WILL_SUICIDE)
|
||||
ADJUST_SCORE(DECENT_EFFECT);
|
||||
break;
|
||||
case EFFECT_MIRROR_MOVE:
|
||||
@ -4451,7 +4451,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move
|
||||
break;
|
||||
case EFFECT_TRICK_ROOM:
|
||||
if (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_POWERFUL_STATUS))
|
||||
if (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_POWERFUL_STATUS))
|
||||
{
|
||||
if (!(gFieldStatuses & STATUS_FIELD_TRICK_ROOM) && GetBattlerSideSpeedAverage(battlerAtk) < GetBattlerSideSpeedAverage(battlerDef))
|
||||
ADJUST_SCORE(GOOD_EFFECT);
|
||||
@ -4913,7 +4913,7 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
|
||||
ADJUST_AND_RETURN_SCORE(NO_DAMAGE_OR_FAILS); // No point in checking the move further so return early
|
||||
else
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & (AI_FLAG_RISKY | AI_FLAG_PREFER_HIGHEST_DAMAGE_MOVE)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & (AI_FLAG_RISKY | AI_FLAG_PREFER_HIGHEST_DAMAGE_MOVE)
|
||||
&& GetBestDmgMoveFromBattler(battlerAtk, battlerDef, AI_ATTACKING) == move)
|
||||
ADJUST_SCORE(BEST_DAMAGE_MOVE);
|
||||
else
|
||||
@ -4935,7 +4935,7 @@ static s32 AI_ForceSetupFirstTurn(u32 battlerAtk, u32 battlerDef, u32 move, s32
|
||||
|| gBattleResults.battleTurnCounter != 0)
|
||||
return score;
|
||||
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_SMART_SWITCHING
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_SMART_SWITCHING
|
||||
&& AI_IsSlower(battlerAtk, battlerDef, move)
|
||||
&& CanTargetFaintAi(battlerDef, battlerAtk)
|
||||
&& GetBattleMovePriority(battlerAtk, gAiLogicData->abilities[battlerAtk], move) == 0)
|
||||
@ -5512,7 +5512,7 @@ static s32 AI_PredictSwitch(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
|
||||
case EFFECT_FOCUS_PUNCH:
|
||||
ADJUST_SCORE(DECENT_EFFECT);
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CHECK_BAD_MOVE)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CHECK_BAD_MOVE)
|
||||
{
|
||||
if (aiData->abilities[battlerDef] == ABILITY_WONDER_GUARD && effectiveness < UQ_4_12(2.0))
|
||||
ADJUST_SCORE(10);
|
||||
|
||||
@ -115,11 +115,11 @@ u32 GetThinkingBattler(u32 battler)
|
||||
|
||||
static bool32 IsAceMon(u32 battler, u32 monPartyId)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_ACE_POKEMON
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_ACE_POKEMON
|
||||
&& !gBattleStruct->battlerState[battler].forcedSwitch
|
||||
&& monPartyId == CalculateEnemyPartyCountInSide(battler)-1)
|
||||
return TRUE;
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_DOUBLE_ACE_POKEMON
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_DOUBLE_ACE_POKEMON
|
||||
&& !gBattleStruct->battlerState[battler].forcedSwitch
|
||||
&& (monPartyId == CalculateEnemyPartyCount()-1 || monPartyId == CalculateEnemyPartyCount()-2))
|
||||
return TRUE;
|
||||
@ -187,7 +187,7 @@ static bool32 ShouldSwitchIfHasBadOdds(u32 battler)
|
||||
enum BattleMoveEffects aiMoveEffect;
|
||||
|
||||
// Only use this if AI_FLAG_SMART_SWITCHING is set for the trainer
|
||||
if (!(gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
if (!(gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
|
||||
// Double Battles aren't included in AI_FLAG_SMART_MON_CHOICE. Defaults to regular switch in logic
|
||||
@ -461,7 +461,7 @@ static bool32 FindMonThatAbsorbsOpponentsMove(u32 battler)
|
||||
bool32 isOpposingBattlerChargingOrInvulnerable = (IsSemiInvulnerable(opposingBattler, incomingMove) || IsTwoTurnNotSemiInvulnerableMove(opposingBattler, incomingMove));
|
||||
s32 i, j;
|
||||
|
||||
if (!(gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
if (!(gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
if (gBattleStruct->prevTurnSpecies[battler] != gBattleMons[battler].species) // AI mon has changed, player's behaviour no longer reliable; note to override this if using AI_FLAG_PREDICT_MOVE
|
||||
return FALSE;
|
||||
@ -584,7 +584,7 @@ static bool32 ShouldSwitchIfOpponentChargingOrInvulnerable(u32 battler)
|
||||
u32 incomingMove = gAiLogicData->lastUsedMove[opposingBattler];
|
||||
bool32 isOpposingBattlerChargingOrInvulnerable = (IsSemiInvulnerable(opposingBattler, incomingMove) || IsTwoTurnNotSemiInvulnerableMove(opposingBattler, incomingMove));
|
||||
|
||||
if (IsDoubleBattle() || !(gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
if (IsDoubleBattle() || !(gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
|
||||
if (isOpposingBattlerChargingOrInvulnerable && gAiLogicData->mostSuitableMonId[battler] != PARTY_SIZE && RandomPercentage(RNG_AI_SWITCH_FREE_TURN, GetSwitchChance(SHOULD_SWITCH_FREE_TURN)))
|
||||
@ -603,7 +603,7 @@ static bool32 ShouldSwitchIfTrapperInParty(u32 battler)
|
||||
s32 opposingBattler = GetOppositeBattler(battler);
|
||||
|
||||
// Only use this if AI_FLAG_SMART_SWITCHING is set for the trainer
|
||||
if (!(gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
if (!(gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
|
||||
// Check if current mon has an ability that traps opponent
|
||||
@ -647,7 +647,7 @@ static bool32 ShouldSwitchIfBadlyStatused(u32 battler)
|
||||
&& RandomPercentage(RNG_AI_SWITCH_PERISH_SONG, GetSwitchChance(SHOULD_SWITCH_PERISH_SONG)))
|
||||
return SetSwitchinAndSwitch(battler, PARTY_SIZE);
|
||||
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING)
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING)
|
||||
{
|
||||
//Yawn
|
||||
if (gStatuses3[battler] & STATUS3_YAWN
|
||||
@ -836,7 +836,7 @@ static bool32 FindMonWithFlagsAndSuperEffective(u32 battler, u16 flags, u32 perc
|
||||
u16 move;
|
||||
|
||||
// Similar functionality handled more thoroughly by ShouldSwitchIfHasBadOdds
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING)
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING)
|
||||
return FALSE;
|
||||
|
||||
if (gLastLandedMoves[battler] == MOVE_NONE)
|
||||
@ -974,7 +974,7 @@ static bool32 ShouldSwitchIfEncored(u32 battler)
|
||||
u32 opposingBattler = GetOppositeBattler(battler);
|
||||
|
||||
// Only use this if AI_FLAG_SMART_SWITCHING is set for the trainer
|
||||
if (!(gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
if (!(gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
|
||||
// If not Encore'd don't switch
|
||||
@ -1024,7 +1024,7 @@ static bool32 ShouldSwitchIfAttackingStatsLowered(u32 battler)
|
||||
s8 spAttackingStage = gBattleMons[battler].statStages[STAT_SPATK];
|
||||
|
||||
// Only use this if AI_FLAG_SMART_SWITCHING is set for the trainer
|
||||
if (!(gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
if (!(gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING))
|
||||
return FALSE;
|
||||
|
||||
// Physical attacker
|
||||
@ -1100,7 +1100,7 @@ bool32 ShouldSwitch(u32 battler)
|
||||
return FALSE;
|
||||
|
||||
// Sequence Switching AI never switches mid-battle
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SEQUENCE_SWITCHING)
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SEQUENCE_SWITCHING)
|
||||
return FALSE;
|
||||
|
||||
availableToSwitch = 0;
|
||||
@ -1152,7 +1152,7 @@ bool32 ShouldSwitch(u32 battler)
|
||||
|
||||
if (ShouldSwitchIfWonderGuard(battler))
|
||||
return TRUE;
|
||||
if ((gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING) && (CanMonSurviveHazardSwitchin(battler) == FALSE))
|
||||
if ((gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING) && (CanMonSurviveHazardSwitchin(battler) == FALSE))
|
||||
return FALSE;
|
||||
if (HasGoodSubstituteMove(battler))
|
||||
return FALSE;
|
||||
@ -1182,7 +1182,7 @@ bool32 ShouldSwitch(u32 battler)
|
||||
// Removing switch capabilites under specific conditions
|
||||
// These Functions prevent the "FindMonWithFlagsAndSuperEffective" from getting out of hand.
|
||||
// We don't use FindMonWithFlagsAndSuperEffective with AI_FLAG_SMART_SWITCHING, so we can bail early.
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING)
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_SWITCHING)
|
||||
return FALSE;
|
||||
if (HasSuperEffectiveMoveAgainstOpponents(battler, FALSE))
|
||||
return FALSE;
|
||||
@ -2166,14 +2166,14 @@ u32 GetMostSuitableMonToSwitchInto(u32 battler, enum SwitchType switchType)
|
||||
GetAIPartyIndexes(battler, &firstId, &lastId);
|
||||
party = GetBattlerParty(battler);
|
||||
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SEQUENCE_SWITCHING)
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SEQUENCE_SWITCHING)
|
||||
{
|
||||
bestMonId = GetNextMonInParty(party, firstId, lastId, battlerIn1, battlerIn2);
|
||||
return bestMonId;
|
||||
}
|
||||
|
||||
// Only use better mon selection if AI_FLAG_SMART_MON_CHOICES is set for the trainer.
|
||||
if (gAiThinkingStruct->aiFlags[GetThinkingBattler(battler)] & AI_FLAG_SMART_MON_CHOICES && !IsDoubleBattle()) // Double Battles aren't included in AI_FLAG_SMART_MON_CHOICE. Defaults to regular switch in logic
|
||||
if (gAiThinkingStruct->flags[GetThinkingBattler(battler)] & AI_FLAG_SMART_MON_CHOICES && !IsDoubleBattle()) // Double Battles aren't included in AI_FLAG_SMART_MON_CHOICE. Defaults to regular switch in logic
|
||||
{
|
||||
bestMonId = GetBestMonIntegrated(party, firstId, lastId, battler, opposingBattler, battlerIn1, battlerIn2, switchType);
|
||||
return bestMonId;
|
||||
|
||||
@ -55,17 +55,17 @@ u32 AI_GetDamage(u32 battlerAtk, u32 battlerDef, u32 moveIndex, enum DamageCalcC
|
||||
if (calcContext == AI_ATTACKING && BattlerHasAi(battlerAtk))
|
||||
{
|
||||
|
||||
if ((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY) && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE)) // Risky assumes it deals max damage
|
||||
if ((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY) && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE)) // Risky assumes it deals max damage
|
||||
return aiData->simulatedDmg[battlerAtk][battlerDef][moveIndex].maximum;
|
||||
if ((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE) && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY)) // Conservative assumes it deals min damage
|
||||
if ((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE) && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY)) // Conservative assumes it deals min damage
|
||||
return aiData->simulatedDmg[battlerAtk][battlerDef][moveIndex].minimum;
|
||||
return aiData->simulatedDmg[battlerAtk][battlerDef][moveIndex].median; // Default assumes it deals median damage
|
||||
}
|
||||
else if (calcContext == AI_DEFENDING && BattlerHasAi(battlerDef))
|
||||
{
|
||||
if ((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY) && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE)) // Risky assumes it takes min damage
|
||||
if ((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY) && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE)) // Risky assumes it takes min damage
|
||||
return aiData->simulatedDmg[battlerAtk][battlerDef][moveIndex].minimum;
|
||||
if ((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE) && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY)) // Conservative assumes it takes max damage
|
||||
if ((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE) && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY)) // Conservative assumes it takes max damage
|
||||
return aiData->simulatedDmg[battlerAtk][battlerDef][moveIndex].maximum;
|
||||
return aiData->simulatedDmg[battlerAtk][battlerDef][moveIndex].median; // Default assumes it takes median damage
|
||||
}
|
||||
@ -125,8 +125,8 @@ bool32 BattlerHasAi(u32 battlerId)
|
||||
|
||||
bool32 IsAiBattlerAware(u32 battlerId)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_OMNISCIENT
|
||||
|| gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_OMNISCIENT)
|
||||
if (gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_OMNISCIENT
|
||||
|| gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_OMNISCIENT)
|
||||
return TRUE;
|
||||
|
||||
return BattlerHasAi(battlerId);
|
||||
@ -134,8 +134,8 @@ bool32 IsAiBattlerAware(u32 battlerId)
|
||||
|
||||
bool32 IsAiBattlerPredictingAbility(u32 battlerId)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_WEIGH_ABILITY_PREDICTION
|
||||
|| gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_WEIGH_ABILITY_PREDICTION)
|
||||
if (gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_WEIGH_ABILITY_PREDICTION
|
||||
|| gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_WEIGH_ABILITY_PREDICTION)
|
||||
return TRUE;
|
||||
|
||||
return BattlerHasAi(battlerId);
|
||||
@ -144,8 +144,8 @@ bool32 IsAiBattlerPredictingAbility(u32 battlerId)
|
||||
bool32 IsBattlerPredictedToSwitch(u32 battler)
|
||||
{
|
||||
// Check for prediction flag on AI, whether they're using those predictions this turn, and whether the AI thinks the player should switch
|
||||
if (gAiThinkingStruct->aiFlags[gAiLogicData->battlerDoingPrediction] & AI_FLAG_PREDICT_SWITCH
|
||||
|| gAiThinkingStruct->aiFlags[gAiLogicData->battlerDoingPrediction] & AI_FLAG_PREDICT_SWITCH)
|
||||
if (gAiThinkingStruct->flags[gAiLogicData->battlerDoingPrediction] & AI_FLAG_PREDICT_SWITCH
|
||||
|| gAiThinkingStruct->flags[gAiLogicData->battlerDoingPrediction] & AI_FLAG_PREDICT_SWITCH)
|
||||
{
|
||||
if (gAiLogicData->predictingSwitch && gAiLogicData->shouldSwitch & (1u << battler))
|
||||
return TRUE;
|
||||
@ -677,11 +677,11 @@ static inline bool32 ShouldCalcCritDamage(u32 battlerAtk, u32 battlerDef, u32 mo
|
||||
if (critChanceIndex == CRITICAL_HIT_ALWAYS)
|
||||
return TRUE;
|
||||
if (critChanceIndex >= RISKY_AI_CRIT_STAGE_THRESHOLD // Not guaranteed but above Risky threshold
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY)
|
||||
&& GetGenConfig(GEN_CONFIG_CRIT_CHANCE) != GEN_1)
|
||||
return TRUE;
|
||||
if (critChanceIndex >= RISKY_AI_CRIT_THRESHOLD_GEN_1 // Not guaranteed but above Risky threshold
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY)
|
||||
&& GetGenConfig(GEN_CONFIG_CRIT_CHANCE) == GEN_1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
@ -1439,7 +1439,7 @@ enum ItemHoldEffect AI_DecideHoldEffectForTurn(u32 battlerId)
|
||||
else
|
||||
holdEffect = GetBattlerHoldEffect(battlerId, FALSE);
|
||||
|
||||
if (gAiThinkingStruct->aiFlags[battlerId] & AI_FLAG_NEGATE_UNAWARE)
|
||||
if (gAiThinkingStruct->flags[battlerId] & AI_FLAG_NEGATE_UNAWARE)
|
||||
return holdEffect;
|
||||
|
||||
if (gStatuses3[battlerId] & STATUS3_EMBARGO)
|
||||
@ -1454,7 +1454,7 @@ enum ItemHoldEffect AI_DecideHoldEffectForTurn(u32 battlerId)
|
||||
|
||||
bool32 DoesBattlerIgnoreAbilityChecks(u32 battlerAtk, u32 atkAbility, u32 move)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_NEGATE_UNAWARE)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_NEGATE_UNAWARE)
|
||||
return FALSE; // AI handicap flag: doesn't understand ability suppression concept
|
||||
|
||||
if (IsMoldBreakerTypeAbility(battlerAtk, atkAbility) || MoveIgnoresTargetAbility(move))
|
||||
@ -1465,8 +1465,8 @@ bool32 DoesBattlerIgnoreAbilityChecks(u32 battlerAtk, u32 atkAbility, u32 move)
|
||||
|
||||
static inline bool32 AI_WeatherHasEffect(void)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_NEGATE_UNAWARE
|
||||
|| gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_NEGATE_UNAWARE)
|
||||
if (gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_NEGATE_UNAWARE
|
||||
|| gAiThinkingStruct->flags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_NEGATE_UNAWARE)
|
||||
return TRUE; // AI doesn't understand weather supression (handicap)
|
||||
|
||||
return gAiLogicData->weatherHasEffect; // weather damping abilities are announced
|
||||
@ -1583,7 +1583,7 @@ bool32 IsHazardClearingMove(u32 move)
|
||||
|
||||
bool32 IsMoveRedirectionPrevented(u32 battlerAtk, u32 move, u32 atkAbility)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_NEGATE_UNAWARE)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_NEGATE_UNAWARE)
|
||||
return FALSE;
|
||||
|
||||
enum BattleMoveEffects effect = GetMoveEffect(move);
|
||||
@ -1938,7 +1938,7 @@ u32 CountNegativeStatStages(u32 battlerId)
|
||||
bool32 ShouldLowerAttack(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
{
|
||||
if (AI_IsFaster(battlerAtk, battlerDef, gAiThinkingStruct->moveConsidered)
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return FALSE; // Don't bother lowering stats if can kill enemy.
|
||||
|
||||
@ -1957,7 +1957,7 @@ bool32 ShouldLowerAttack(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
bool32 ShouldLowerDefense(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
{
|
||||
if (AI_IsFaster(battlerAtk, battlerDef, gAiThinkingStruct->moveConsidered)
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return FALSE; // Don't bother lowering stats if can kill enemy.
|
||||
|
||||
@ -1988,7 +1988,7 @@ bool32 ShouldLowerSpeed(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
bool32 ShouldLowerSpAtk(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
{
|
||||
if (AI_IsFaster(battlerAtk, battlerDef, gAiThinkingStruct->moveConsidered)
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return FALSE; // Don't bother lowering stats if can kill enemy.
|
||||
|
||||
@ -2006,7 +2006,7 @@ bool32 ShouldLowerSpAtk(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
bool32 ShouldLowerSpDef(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
{
|
||||
if (AI_IsFaster(battlerAtk, battlerDef, gAiThinkingStruct->moveConsidered)
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return FALSE; // Don't bother lowering stats if can kill enemy.
|
||||
|
||||
@ -2024,7 +2024,7 @@ bool32 ShouldLowerSpDef(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
bool32 ShouldLowerAccuracy(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
{
|
||||
if (AI_IsFaster(battlerAtk, battlerDef, gAiThinkingStruct->moveConsidered)
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return FALSE; // Don't bother lowering stats if can kill enemy.
|
||||
|
||||
@ -2043,7 +2043,7 @@ bool32 ShouldLowerAccuracy(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
bool32 ShouldLowerEvasion(u32 battlerAtk, u32 battlerDef, u32 defAbility)
|
||||
{
|
||||
if (AI_IsFaster(battlerAtk, battlerDef, gAiThinkingStruct->moveConsidered)
|
||||
&& (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT)
|
||||
&& CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return FALSE; // Don't bother lowering stats if can kill enemy.
|
||||
|
||||
@ -3330,7 +3330,7 @@ bool32 ShouldTrap(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
if (BattlerWillFaintFromSecondaryDamage(battlerDef, gAiLogicData->abilities[battlerDef]))
|
||||
return TRUE; // battler is taking secondary damage with low HP
|
||||
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL)
|
||||
{
|
||||
if (!CanTargetFaintAi(battlerDef, battlerAtk))
|
||||
return TRUE; // attacker goes first and opponent can't kill us
|
||||
@ -3794,9 +3794,9 @@ s32 AI_CalcPartyMonDamage(u32 move, u32 battlerAtk, u32 battlerDef, struct Battl
|
||||
if (calcContext == AI_ATTACKING)
|
||||
{
|
||||
SetBattlerAiData(battlerAtk, gAiLogicData);
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE))
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE))
|
||||
return dmg.maximum;
|
||||
else if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY))
|
||||
else if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY))
|
||||
return dmg.minimum;
|
||||
else
|
||||
return dmg.median;
|
||||
@ -3805,9 +3805,9 @@ s32 AI_CalcPartyMonDamage(u32 move, u32 battlerAtk, u32 battlerDef, struct Battl
|
||||
else if (calcContext == AI_DEFENDING)
|
||||
{
|
||||
SetBattlerAiData(battlerDef, gAiLogicData);
|
||||
if (gAiThinkingStruct->aiFlags[battlerDef] & AI_FLAG_RISKY && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_CONSERVATIVE))
|
||||
if (gAiThinkingStruct->flags[battlerDef] & AI_FLAG_RISKY && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_CONSERVATIVE))
|
||||
return dmg.minimum;
|
||||
else if (gAiThinkingStruct->aiFlags[battlerDef] & AI_FLAG_CONSERVATIVE && !(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_RISKY))
|
||||
else if (gAiThinkingStruct->flags[battlerDef] & AI_FLAG_CONSERVATIVE && !(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_RISKY))
|
||||
return dmg.maximum;
|
||||
else
|
||||
return dmg.median;
|
||||
@ -4070,7 +4070,7 @@ static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef,
|
||||
case STAT_CHANGE_DEF:
|
||||
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL))
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL)
|
||||
tempScore += DECENT_EFFECT;
|
||||
else
|
||||
tempScore += WEAK_EFFECT;
|
||||
@ -4087,7 +4087,7 @@ static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef,
|
||||
case STAT_CHANGE_SPDEF:
|
||||
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL))
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL)
|
||||
tempScore += DECENT_EFFECT;
|
||||
else
|
||||
tempScore += WEAK_EFFECT;
|
||||
@ -4100,7 +4100,7 @@ static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef,
|
||||
case STAT_CHANGE_DEF_2:
|
||||
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL))
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL)
|
||||
tempScore += GOOD_EFFECT;
|
||||
else
|
||||
tempScore += DECENT_EFFECT;
|
||||
@ -4117,7 +4117,7 @@ static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef,
|
||||
case STAT_CHANGE_SPDEF_2:
|
||||
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL) || !HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL))
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL)
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL)
|
||||
tempScore += GOOD_EFFECT;
|
||||
else
|
||||
tempScore += DECENT_EFFECT;
|
||||
@ -4150,7 +4150,7 @@ u32 IncreaseStatUpScoreContrary(u32 battlerAtk, u32 battlerDef, enum StatChange
|
||||
|
||||
void IncreasePoisonScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
{
|
||||
if (((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
if (((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
|| gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_PSN || gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_STATUS)
|
||||
return;
|
||||
|
||||
@ -4159,7 +4159,7 @@ void IncreasePoisonScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
if (!HasDamagingMove(battlerDef))
|
||||
ADJUST_SCORE_PTR(DECENT_EFFECT);
|
||||
|
||||
if (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL && HasMoveEffect(battlerAtk, EFFECT_PROTECT))
|
||||
if (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL && HasMoveEffect(battlerAtk, EFFECT_PROTECT))
|
||||
ADJUST_SCORE_PTR(WEAK_EFFECT); // stall tactic
|
||||
|
||||
if (IsPowerBasedOnStatus(battlerAtk, EFFECT_DOUBLE_POWER_ON_ARG_STATUS, STATUS1_PSN_ANY)
|
||||
@ -4173,14 +4173,14 @@ void IncreasePoisonScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
|
||||
void IncreaseBurnScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
{
|
||||
if (((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
if (((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
|| gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_BRN || gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_STATUS)
|
||||
return;
|
||||
|
||||
if (AI_CanBurn(battlerAtk, battlerDef, gAiLogicData->abilities[battlerDef], BATTLE_PARTNER(battlerAtk), move, gAiLogicData->partnerMove))
|
||||
{
|
||||
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_PHYSICAL)
|
||||
|| (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_OMNISCIENT) // Not Omniscient but expects physical attacker
|
||||
|| (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_OMNISCIENT) // Not Omniscient but expects physical attacker
|
||||
&& gSpeciesInfo[gBattleMons[battlerDef].species].baseAttack >= gSpeciesInfo[gBattleMons[battlerDef].species].baseSpAttack + 10))
|
||||
{
|
||||
if (GetMoveCategory(GetBestDmgMoveFromBattler(battlerDef, battlerAtk, AI_DEFENDING)) == DAMAGE_CATEGORY_PHYSICAL)
|
||||
@ -4197,7 +4197,7 @@ void IncreaseBurnScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
|
||||
void IncreaseParalyzeScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
{
|
||||
if (((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
if (((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
|| gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_PAR || gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_STATUS)
|
||||
return;
|
||||
|
||||
@ -4219,7 +4219,7 @@ void IncreaseParalyzeScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
|
||||
void IncreaseSleepScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
{
|
||||
if (((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0) && GetMoveEffect(GetBestDmgMoveFromBattler(battlerAtk, battlerDef, AI_ATTACKING)) != EFFECT_FOCUS_PUNCH)
|
||||
if (((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0) && GetMoveEffect(GetBestDmgMoveFromBattler(battlerAtk, battlerDef, AI_ATTACKING)) != EFFECT_FOCUS_PUNCH)
|
||||
|| gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_SLP || gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_STATUS)
|
||||
return;
|
||||
|
||||
@ -4239,7 +4239,7 @@ void IncreaseSleepScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
|
||||
void IncreaseConfusionScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
{
|
||||
if (((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
if (((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
|| gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_CONFUSION || gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_CURE_STATUS)
|
||||
return;
|
||||
|
||||
@ -4258,13 +4258,13 @@ void IncreaseConfusionScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score
|
||||
|
||||
void IncreaseFrostbiteScore(u32 battlerAtk, u32 battlerDef, u32 move, s32 *score)
|
||||
{
|
||||
if ((gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
if ((gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_TRY_TO_FAINT) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
|
||||
return;
|
||||
|
||||
if (AI_CanGiveFrostbite(battlerAtk, battlerDef, gAiLogicData->abilities[battlerDef], BATTLE_PARTNER(battlerAtk), move, gAiLogicData->partnerMove))
|
||||
{
|
||||
if (HasMoveWithCategory(battlerDef, DAMAGE_CATEGORY_SPECIAL)
|
||||
|| (!(gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_OMNISCIENT) // Not Omniscient but expects special attacker
|
||||
|| (!(gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_OMNISCIENT) // Not Omniscient but expects special attacker
|
||||
&& gSpeciesInfo[gBattleMons[battlerDef].species].baseSpAttack >= gSpeciesInfo[gBattleMons[battlerDef].species].baseAttack + 10))
|
||||
{
|
||||
if (GetMoveCategory(GetBestDmgMoveFromBattler(battlerDef, battlerAtk, AI_DEFENDING)) == DAMAGE_CATEGORY_SPECIAL)
|
||||
@ -4362,7 +4362,7 @@ bool32 AI_ShouldCopyStatChanges(u32 battlerAtk, u32 battlerDef)
|
||||
return TRUE;
|
||||
case STAT_DEF:
|
||||
case STAT_SPDEF:
|
||||
return (gAiThinkingStruct->aiFlags[battlerAtk] & AI_FLAG_STALL);
|
||||
return (gAiThinkingStruct->flags[battlerAtk] & AI_FLAG_STALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4498,7 +4498,7 @@ bool32 HasLowAccuracyMove(u32 battlerAtk, u32 battlerDef)
|
||||
|
||||
bool32 IsBattlerItemEnabled(u32 battler)
|
||||
{
|
||||
if (gAiThinkingStruct->aiFlags[battler] & AI_FLAG_NEGATE_UNAWARE)
|
||||
if (gAiThinkingStruct->flags[battler] & AI_FLAG_NEGATE_UNAWARE)
|
||||
return TRUE;
|
||||
if (gFieldStatuses & STATUS_FIELD_MAGIC_ROOM)
|
||||
return FALSE;
|
||||
|
||||
@ -650,14 +650,14 @@ static void OpponentHandleChooseItem(u32 battler)
|
||||
|
||||
static inline bool32 IsAcePokemon(u32 chosenMonId, u32 pokemonInBattle, u32 battler)
|
||||
{
|
||||
return gAiThinkingStruct->aiFlags[battler] & AI_FLAG_ACE_POKEMON
|
||||
return gAiThinkingStruct->flags[battler] & AI_FLAG_ACE_POKEMON
|
||||
&& (chosenMonId == CalculateEnemyPartyCountInSide(battler) - 1)
|
||||
&& CountAIAliveNonEggMonsExcept(PARTY_SIZE) != pokemonInBattle;
|
||||
}
|
||||
|
||||
static inline bool32 IsDoubleAcePokemon(u32 chosenMonId, u32 pokemonInBattle, u32 battler)
|
||||
{
|
||||
return gAiThinkingStruct->aiFlags[battler] & AI_FLAG_DOUBLE_ACE_POKEMON
|
||||
return gAiThinkingStruct->flags[battler] & AI_FLAG_DOUBLE_ACE_POKEMON
|
||||
&& (chosenMonId == CalculateEnemyPartyCountInSide(battler) - 1)
|
||||
&& (chosenMonId == CalculateEnemyPartyCountInSide(battler) - 2)
|
||||
&& CountAIAliveNonEggMonsExcept(PARTY_SIZE) != pokemonInBattle
|
||||
|
||||
@ -2199,8 +2199,8 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data)
|
||||
data->modifyArrows.typeOfVal = VAL_BITFIELD_32;
|
||||
goto CASE_ITEM_STATUS;
|
||||
case LIST_ITEM_AI:
|
||||
data->modifyArrows.modifiedValPtr = &gAiThinkingStruct->aiFlags[data->battlerId];
|
||||
data->modifyArrows.currValue = GetBitfieldValue(gAiThinkingStruct->aiFlags[data->battlerId], data->bitfield[data->currentSecondaryListItemId].currBit, data->bitfield[data->currentSecondaryListItemId].bitsCount);
|
||||
data->modifyArrows.modifiedValPtr = &gAiThinkingStruct->flags[data->battlerId];
|
||||
data->modifyArrows.currValue = GetBitfieldValue(gAiThinkingStruct->flags[data->battlerId], data->bitfield[data->currentSecondaryListItemId].currBit, data->bitfield[data->currentSecondaryListItemId].bitsCount);
|
||||
data->modifyArrows.typeOfVal = VAL_BITFIELD_32;
|
||||
goto CASE_ITEM_STATUS;
|
||||
CASE_ITEM_STATUS:
|
||||
|
||||
@ -120,7 +120,7 @@ enum TimeMenuTimeOfDay
|
||||
DEBUG_TIME_MENU_ITEM_MORNING,
|
||||
DEBUG_TIME_MENU_ITEM_DAY,
|
||||
DEBUG_TIME_MENU_ITEM_EVENING,
|
||||
DEBUG_TIME_MENU_ITEM_NIGHT,
|
||||
DEBUG_TIME_MENU_ITEM_NIGHT,
|
||||
};
|
||||
|
||||
enum TimeMenuWeekdays
|
||||
@ -3776,7 +3776,7 @@ static void DebugAction_Give_DayCareEgg(u8 taskId)
|
||||
static void DebugAction_TimeMenu_ChangeTimeOfDay(u8 taskId)
|
||||
{
|
||||
u32 input = ListMenu_ProcessInput(gTasks[taskId].tMenuTaskId);
|
||||
|
||||
|
||||
DebugAction_DestroyExtraWindow(taskId);
|
||||
switch (input)
|
||||
{
|
||||
@ -3808,7 +3808,7 @@ static void DebugAction_TimeMenu_ChangeWeekdays(u8 taskId)
|
||||
{
|
||||
case DEBUG_TIME_MENU_ITEM_SUNDAY:
|
||||
daysToAdd = ((WEEKDAY_SUN - rtc->dayOfWeek) + WEEKDAY_COUNT) % WEEKDAY_COUNT;
|
||||
FakeRtc_AdvanceTimeBy(daysToAdd, 0, 0, 0);
|
||||
FakeRtc_AdvanceTimeBy(daysToAdd, 0, 0, 0);
|
||||
break;
|
||||
case DEBUG_TIME_MENU_ITEM_MONDAY:
|
||||
daysToAdd = ((WEEKDAY_MON - rtc->dayOfWeek) + WEEKDAY_COUNT) % WEEKDAY_COUNT;
|
||||
|
||||
@ -87,7 +87,7 @@ void RecordedBattle_Init(u8 mode)
|
||||
for (j = 0; j < BATTLER_RECORD_SIZE; j++)
|
||||
sBattleRecords[i][j] = 0xFF;
|
||||
sBattleFlags = gBattleTypeFlags;
|
||||
sAI_Scripts = gAiThinkingStruct->aiFlags[B_POSITION_OPPONENT_LEFT];
|
||||
sAI_Scripts = gAiThinkingStruct->flags[B_POSITION_OPPONENT_LEFT];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user