mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-28 06:13:59 +01:00
Fix battle tent again
This commit is contained in:
parent
215604f5f7
commit
ea43b7732c
@ -233,20 +233,10 @@ u8 BattleAI_ChooseMoveOrAction(void)
|
|||||||
|
|
||||||
// damages/other info computed in GetAIDataAndCalcDmg
|
// damages/other info computed in GetAIDataAndCalcDmg
|
||||||
u8 ComputeBattleAiScores(u8 battler)
|
u8 ComputeBattleAiScores(u8 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)
|
||||||
{
|
{
|
||||||
|
@ -1553,6 +1553,12 @@ static void OpponentHandleChooseMove(void)
|
|||||||
|
|
||||||
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)
|
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)
|
||||||
|| IsWildMonSmart())
|
|| IsWildMonSmart())
|
||||||
|
{
|
||||||
|
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||||
|
{
|
||||||
|
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||||
@ -1591,6 +1597,7 @@ static void OpponentHandleChooseMove(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
OpponentBufferExecCompleted();
|
OpponentBufferExecCompleted();
|
||||||
}
|
}
|
||||||
else // Wild pokemon - use random move
|
else // Wild pokemon - use random move
|
||||||
|
@ -2843,10 +2843,8 @@ 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, (chosenMoveId) | (gBattlerTarget << 8));
|
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||||
PlayerBufferExecCompleted();
|
PlayerBufferExecCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
|
|||||||
{
|
{
|
||||||
gBattleStruct->palaceFlags &= 0xF;
|
gBattleStruct->palaceFlags &= 0xF;
|
||||||
gBattleStruct->palaceFlags |= (selectedMoves << 4);
|
gBattleStruct->palaceFlags |= (selectedMoves << 4);
|
||||||
|
sBattler_AI = gActiveBattler;
|
||||||
BattleAI_SetupAIData(selectedMoves);
|
BattleAI_SetupAIData(selectedMoves);
|
||||||
chosenMoveId = BattleAI_ChooseMoveOrAction();
|
chosenMoveId = BattleAI_ChooseMoveOrAction();
|
||||||
}
|
}
|
||||||
@ -173,6 +174,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
|
|||||||
// 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 || chosenMoveId >= MAX_MON_MOVES)
|
if (chosenMoveId == -1 || chosenMoveId >= MAX_MON_MOVES)
|
||||||
{
|
{
|
||||||
|
chosenMoveId = -1;
|
||||||
if (unusableMovesBits != 0xF)
|
if (unusableMovesBits != 0xF)
|
||||||
{
|
{
|
||||||
validMoveFlags = 0, numValidMoveGroups = 0;
|
validMoveFlags = 0, numValidMoveGroups = 0;
|
||||||
|
@ -3974,7 +3974,7 @@ static void HandleTurnActionSelectionState(void)
|
|||||||
|
|
||||||
// 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())
|
if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart())
|
||||||
&& (IsBattlerAIControlled(gActiveBattler) || gBattleTypeFlags & BATTLE_TYPE_PALACE)) {
|
&& (IsBattlerAIControlled(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE))) {
|
||||||
gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler);
|
gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user