mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
Fix battle tent again
This commit is contained in:
parent
215604f5f7
commit
ea43b7732c
@ -234,18 +234,8 @@ u8 BattleAI_ChooseMoveOrAction(void)
|
||||
// damages/other info computed in GetAIDataAndCalcDmg
|
||||
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);
|
||||
return BattleAI_ChooseMoveOrAction();
|
||||
}
|
||||
BattleAI_SetupAIData(0xF);
|
||||
return BattleAI_ChooseMoveOrAction();
|
||||
}
|
||||
|
||||
static void CopyBattlerDataToAIParty(u32 bPosition, u32 side)
|
||||
|
@ -1554,42 +1554,49 @@ static void OpponentHandleChooseMove(void)
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)
|
||||
|| IsWildMonSmart())
|
||||
{
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||
switch (chosenMoveId)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
case AI_CHOICE_WATCH:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
|
||||
break;
|
||||
case AI_CHOICE_FLEE:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0);
|
||||
break;
|
||||
case AI_CHOICE_SWITCH:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
|
||||
break;
|
||||
case 6:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget);
|
||||
break;
|
||||
default:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
}
|
||||
else
|
||||
{
|
||||
chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||
switch (chosenMoveId)
|
||||
{
|
||||
u16 chosenMove = moveInfo->moves[chosenMoveId];
|
||||
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
gBattlerTarget = gActiveBattler;
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH)
|
||||
case AI_CHOICE_WATCH:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
|
||||
break;
|
||||
case AI_CHOICE_FLEE:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0);
|
||||
break;
|
||||
case AI_CHOICE_SWITCH:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
|
||||
break;
|
||||
case 6:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
u16 chosenMove = moveInfo->moves[chosenMoveId];
|
||||
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
gBattlerTarget = gActiveBattler;
|
||||
if (GetBattlerMoveTargetType(gActiveBattler, chosenMove) & MOVE_TARGET_BOTH)
|
||||
{
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
|
||||
gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
}
|
||||
if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove))
|
||||
QueueZMove(gActiveBattler, chosenMove);
|
||||
if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it.
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
}
|
||||
if (ShouldUseZMove(gActiveBattler, gBattlerTarget, chosenMove))
|
||||
QueueZMove(gActiveBattler, chosenMove);
|
||||
if (CanMegaEvolve(gActiveBattler)) // If opponent can mega evolve, do it.
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
|
@ -2843,10 +2843,8 @@ static void PlayerChooseMoveInBattlePalace(void)
|
||||
{
|
||||
if (--*(gBattleStruct->arenaMindPoints + gActiveBattler) == 0)
|
||||
{
|
||||
u32 chosenMoveId = gBattleStruct->aiMoveOrAction[gActiveBattler];
|
||||
gBattlerTarget = gBattleStruct->aiChosenTarget[gActiveBattler];
|
||||
gBattlePalaceMoveSelectionRngValue = gRngValue;
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
PlayerBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
@ -164,6 +164,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
|
||||
{
|
||||
gBattleStruct->palaceFlags &= 0xF;
|
||||
gBattleStruct->palaceFlags |= (selectedMoves << 4);
|
||||
sBattler_AI = gActiveBattler;
|
||||
BattleAI_SetupAIData(selectedMoves);
|
||||
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 (chosenMoveId == -1 || chosenMoveId >= MAX_MON_MOVES)
|
||||
{
|
||||
chosenMoveId = -1;
|
||||
if (unusableMovesBits != 0xF)
|
||||
{
|
||||
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
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart())
|
||||
&& (IsBattlerAIControlled(gActiveBattler) || gBattleTypeFlags & BATTLE_TYPE_PALACE)) {
|
||||
&& (IsBattlerAIControlled(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE))) {
|
||||
gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user