Add shouldDynamax & shouldTerastal bits to TrainerMon (#4169)

This commit is contained in:
Nopinou 2024-02-11 21:36:35 +01:00 committed by GitHub
parent d1b3d1c2c3
commit de0f94406a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -71,6 +71,8 @@ struct TrainerMon
bool8 isShiny : 1;
u8 dynamaxLevel : 4;
bool8 gigantamaxFactor : 1;
bool8 shouldDynamax : 1;
bool8 shouldTerastal : 1;
};
#define TRAINER_PARTY(partyArray) partyArray, .partySize = ARRAY_COUNT(partyArray)

View file

@ -547,6 +547,9 @@ static void OpponentHandleChooseMove(u32 battler)
default:
{
u16 chosenMove = moveInfo->moves[chosenMoveId];
bool32 isSecondTrainer = (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT) && (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT;
u16 trainerId = isSecondTrainer ? gTrainerBattleOpponent_B : gTrainerBattleOpponent_A;
const struct TrainerMon *party = gTrainers[trainerId].party;
if (GetBattlerMoveTargetType(battler, chosenMove) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
gBattlerTarget = battler;
@ -564,8 +567,8 @@ static void OpponentHandleChooseMove(u32 battler)
// If opponent can Ultra Burst, do it.
else if (CanUltraBurst(battler))
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_ULTRA_BURST) | (gBattlerTarget << 8));
// If opponent can Dynamax and is on final Pokemon, do it.
else if (CanDynamax(battler) && CountAIAliveNonEggMonsExcept(gBattlerPartyIndexes[battler]) == 0)
// If opponent can Dynamax and is allowed in the partydata, do it.
else if (CanDynamax(battler) && party[isSecondTrainer ? gBattlerPartyIndexes[battler] - MULTI_PARTY_SIZE : gBattlerPartyIndexes[battler]].shouldDynamax)
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_DYNAMAX) | (gBattlerTarget << 8));
else
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));