WORKS, still needs work :D

This commit is contained in:
Pawkkie 2025-04-28 00:56:03 -04:00
parent 4970b3bd95
commit 38c90909eb
3 changed files with 13 additions and 8 deletions

View File

@ -326,8 +326,8 @@ void Ai_InitPartyStruct(void)
bool32 isOmniscient = (AI_THINKING_STRUCT->aiFlags[B_POSITION_OPPONENT_LEFT] & AI_FLAG_OMNISCIENT) || (AI_THINKING_STRUCT->aiFlags[B_POSITION_OPPONENT_RIGHT] & AI_FLAG_OMNISCIENT);
struct Pokemon *mon;
AI_PARTY->count[B_SIDE_PLAYER] = gPlayerPartyCount;
AI_PARTY->count[B_SIDE_OPPONENT] = gEnemyPartyCount;
AI_PARTY->count[B_SIDE_PLAYER] = CalculatePlayerPartyCount();
AI_PARTY->count[B_SIDE_OPPONENT] = CalculateEnemyPartyCount();
// Save first 2 or 4(in doubles) mons
CopyBattlerDataToAIParty(B_POSITION_PLAYER_LEFT, B_SIDE_PLAYER);
@ -558,6 +558,10 @@ u32 BattleAI_PredictMove(u32 battler, u32 opposingBattler)
}
}
}
DebugPrintf("Number of best moves: %d", numOfBestMoves);
DebugPrintf("Random best move: %d", consideredMoveArray[Random() % numOfBestMoves]);
DebugPrintf("Random best move: %d", consideredMoveArray[Random() % numOfBestMoves]);
DebugPrintf("Random best move: %d", consideredMoveArray[Random() % numOfBestMoves]);
return consideredMoveArray[Random() % numOfBestMoves];
}

View File

@ -459,7 +459,7 @@ static bool32 FindMonThatAbsorbsOpponentsMove(u32 battler)
if (!(AI_THINKING_STRUCT->aiFlags[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
if (gBattleStruct->prevTurnSpecies[battler] != gBattleMons[battler].species && !(AI_THINKING_STRUCT->aiFlags[battler] & AI_FLAG_PREDICT_MOVES)) // AI mon has changed, player's behaviour no longer reliable; note to override this if using AI_FLAG_PREDICT_MOVE
return FALSE;
if (HasSuperEffectiveMoveAgainstOpponents(battler, TRUE) && (RandomPercentage(RNG_AI_SWITCH_ABSORBING_STAY_IN, STAY_IN_ABSORBING_PERCENTAGE) || AI_DATA->aiSwitchPredictionInProgress))
return FALSE;

View File

@ -4151,6 +4151,12 @@ void SetupAISwitchingData(u32 battler, u32 opposingBattler, enum SwitchType swit
AI_DATA->predictingSwitch = RandomPercentage(RNG_AI_PREDICT_SWITCH, PREDICT_SWITCH_CHANCE);
}
if (AI_THINKING_STRUCT->aiFlags[battler] & AI_FLAG_PREDICT_MOVES)
{
AI_DATA->predictedMove[opposingBattler] = gBattleMons[opposingBattler].moves[BattleAI_PredictMove(battler, opposingBattler)];
DebugPrintf("Predicted move: %d", AI_DATA->predictedMove[opposingBattler]);
}
// AI's data
AI_DATA->mostSuitableMonId[battler] = GetMostSuitableMonToSwitchInto(battler, switchType);
if (ShouldSwitch(battler))
@ -4182,11 +4188,6 @@ static void HandleTurnActionSelectionState(void)
// Setup battler data
BattleAI_SetupAIData(0xF, battler);
if (AI_THINKING_STRUCT->aiFlags[battler] & AI_FLAG_PREDICT_MOVES)
{
AI_DATA->predictedMove[opposingBattler] = BattleAI_PredictMove(battler, opposingBattler);
DebugPrintf("Predicted move: %d", AI_DATA->predictedMove[opposingBattler]);
}
SetupAISwitchingData(battler, opposingBattler, switchType);