opponents properly revert Gigantamax + understand Max Guard

This commit is contained in:
AgustinGDLV 2023-03-25 19:26:55 -07:00
parent fff0f78c89
commit e1c819a863
4 changed files with 16 additions and 3 deletions

View file

@ -533,6 +533,7 @@ struct DynamaxData
u16 baseMove[MAX_BATTLERS_COUNT]; // base move of Max Move
u16 lastUsedBaseMove;
u16 levelUpHP;
u16 opponentBaseForm; // changedSpecies isn't used for opposing Pokemon
};
struct StolenItem

View file

@ -3080,6 +3080,10 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
// We only check for moves that have a 20% chance or more for their secondary effect to happen because moves with a smaller chance are rather worthless. We don't want the AI to use those.
bool32 sereneGraceBoost = (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && (gBattleMoves[move].secondaryEffectChance >= 20 && gBattleMoves[move].secondaryEffectChance < 100));
// The AI should understand that while Dynamaxed, status moves function like Protect.
if (IsDynamaxed(battlerAtk) && gBattleMoves[move].split == SPLIT_STATUS)
moveEffect = EFFECT_PROTECT;
// Targeting partner, check benefits of doing that instead
if (IsTargetingPartner(battlerAtk, battlerDef))
return score;

View file

@ -115,7 +115,7 @@ bool32 CanDynamax(u16 battlerId)
#if B_FLAG_DYNAMAX_BATTLE != 0
if (!FlagGet(B_FLAG_DYNAMAX_BATTLE))
#endif
return FALSE;
//return FALSE;
// Check if Player has a Dynamax Band.

View file

@ -10268,6 +10268,10 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method)
// Saves the original species on the first form change for the player.
if (side == B_SIDE_PLAYER && gBattleStruct->changedSpecies[monId] == SPECIES_NONE)
gBattleStruct->changedSpecies[monId] = gBattleMons[battlerId].species;
// Saves the original species for Gigantamax forms for the opponent.
if (side == B_SIDE_OPPONENT && gBattleStruct->dynamax.opponentBaseForm == SPECIES_NONE)
gBattleStruct->dynamax.opponentBaseForm = gBattleMons[battlerId].species;
TryToSetBattleFormChangeMoves(&party[monId], method);
SetMonData(&party[monId], MON_DATA_SPECIES, &targetSpecies);
@ -10275,7 +10279,8 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method)
RecalcBattlerStats(battlerId, &party[monId]);
return TRUE;
}
else if (gBattleStruct->changedSpecies[monId] != SPECIES_NONE)
else if (gBattleStruct->changedSpecies[monId] != SPECIES_NONE
|| gBattleStruct->dynamax.opponentBaseForm != SPECIES_NONE)
{
bool8 restoreSpecies = FALSE;
@ -10295,7 +10300,10 @@ bool32 TryBattleFormChange(u8 battlerId, u16 method)
{
// Reverts the original species
TryToSetBattleFormChangeMoves(&party[monId], method);
SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]);
if (side == B_SIDE_PLAYER)
SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->changedSpecies[monId]);
else
SetMonData(&party[monId], MON_DATA_SPECIES, &gBattleStruct->dynamax.opponentBaseForm);
RecalcBattlerStats(battlerId, &party[monId]);
return TRUE;
}