mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-28 12:44:18 +01:00
fix battle palace bug
This commit is contained in:
parent
93dd8786ee
commit
215604f5f7
@ -235,9 +235,18 @@ u8 BattleAI_ChooseMoveOrAction(void)
|
|||||||
u8 ComputeBattleAiScores(u8 battler)
|
u8 ComputeBattleAiScores(u8 battler)
|
||||||
{
|
{
|
||||||
sBattler_AI = battler;
|
sBattler_AI = battler;
|
||||||
|
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||||
|
{
|
||||||
|
u16 retVal = ChooseMoveAndTargetInBattlePalace(); // first byte is moveId, secondId is target
|
||||||
|
gBattleStruct->aiChosenTarget[sBattler_AI] = (retVal >> 8) & 0xFF;
|
||||||
|
return (retVal & 0xFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
BattleAI_SetupAIData(0xF);
|
BattleAI_SetupAIData(0xF);
|
||||||
return BattleAI_ChooseMoveOrAction();
|
return BattleAI_ChooseMoveOrAction();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void CopyBattlerDataToAIParty(u32 bPosition, u32 side)
|
static void CopyBattlerDataToAIParty(u32 bPosition, u32 side)
|
||||||
{
|
{
|
||||||
|
@ -1547,13 +1547,6 @@ static void OpponentHandleYesNoBox(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void OpponentHandleChooseMove(void)
|
static void OpponentHandleChooseMove(void)
|
||||||
{
|
|
||||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
|
||||||
{
|
|
||||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
|
||||||
OpponentBufferExecCompleted();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
u8 chosenMoveId;
|
u8 chosenMoveId;
|
||||||
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
|
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
|
||||||
@ -1659,7 +1652,6 @@ static void OpponentHandleChooseMove(void)
|
|||||||
OpponentBufferExecCompleted();
|
OpponentBufferExecCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void OpponentHandleChooseItem(void)
|
static void OpponentHandleChooseItem(void)
|
||||||
{
|
{
|
||||||
|
@ -2843,8 +2843,10 @@ static void PlayerChooseMoveInBattlePalace(void)
|
|||||||
{
|
{
|
||||||
if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0)
|
if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0)
|
||||||
{
|
{
|
||||||
|
u32 chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||||
|
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||||
gBattlePalaceMoveSelectionRngValue = gRngValue;
|
gBattlePalaceMoveSelectionRngValue = gRngValue;
|
||||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||||
PlayerBufferExecCompleted();
|
PlayerBufferExecCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
|
|||||||
// If no moves matched the selected group, pick a new move from groups the pokemon has
|
// 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
|
// 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 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)
|
||||||
{
|
{
|
||||||
if (unusableMovesBits != 0xF)
|
if (unusableMovesBits != 0xF)
|
||||||
{
|
{
|
||||||
|
@ -3973,7 +3973,8 @@ static void HandleTurnActionSelectionState(void)
|
|||||||
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
|
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
|
||||||
|
|
||||||
// Do AI score computations here so we can use them in AI_TrySwitchOrUseItem
|
// 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);
|
gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user