mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
Merge pull request #2416 from DizzyEggg/fix_palace
Fix battle palace bug
This commit is contained in:
commit
ebc9fc31d2
@ -1547,19 +1547,18 @@ static void OpponentHandleYesNoBox(void)
|
||||
}
|
||||
|
||||
static void OpponentHandleChooseMove(void)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 chosenMoveId;
|
||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
|
||||
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)
|
||||
|| IsWildMonSmart())
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
}
|
||||
else
|
||||
{
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||
@ -1598,6 +1597,7 @@ static void OpponentHandleChooseMove(void)
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
else // Wild pokemon - use random move
|
||||
@ -1659,7 +1659,6 @@ static void OpponentHandleChooseMove(void)
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void OpponentHandleChooseItem(void)
|
||||
{
|
||||
|
@ -164,6 +164,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
|
||||
{
|
||||
gBattleStruct->palaceFlags &= 0xF;
|
||||
gBattleStruct->palaceFlags |= (selectedMoves << 4);
|
||||
sBattler_AI = gActiveBattler;
|
||||
BattleAI_SetupAIData(selectedMoves);
|
||||
chosenMoveId = BattleAI_ChooseMoveOrAction();
|
||||
}
|
||||
@ -171,8 +172,9 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
|
||||
// If no moves matched the selected group, pick a new move from groups the pokemon has
|
||||
// In this case the AI is not checked again, so the choice may be worse
|
||||
// If a move is chosen this way, there's a 50% chance that it will be unable to use it anyway
|
||||
if (chosenMoveId == -1)
|
||||
if (chosenMoveId == -1 || chosenMoveId >= MAX_MON_MOVES)
|
||||
{
|
||||
chosenMoveId = -1;
|
||||
if (unusableMovesBits != 0xF)
|
||||
{
|
||||
validMoveFlags = 0, numValidMoveGroups = 0;
|
||||
|
@ -3973,7 +3973,8 @@ static void HandleTurnActionSelectionState(void)
|
||||
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
|
||||
|
||||
// Do AI score computations here so we can use them in AI_TrySwitchOrUseItem
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) && IsBattlerAIControlled(gActiveBattler)) {
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart())
|
||||
&& (IsBattlerAIControlled(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE))) {
|
||||
gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user