diff --git a/include/battle.h b/include/battle.h index 15e8d26366..7b08c25b09 100644 --- a/include/battle.h +++ b/include/battle.h @@ -718,6 +718,7 @@ struct BattleStruct } multiBuffer; u8 wishPerishSongState; u8 wishPerishSongBattlerId; + u8 aiCalcInProgress:1; u8 overworldWeatherDone:1; u8 startingStatusDone:1; u8 isAtkCancelerForCalledMove:1; // Certain cases in atk canceler should only be checked once, when the original move is called, however others need to be checked the twice. diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 3ab39ab337..162649d4b1 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -500,6 +500,7 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes bool32 toggledDynamax = FALSE; bool32 toggledTera = FALSE; struct AiLogicData *aiData = AI_DATA; + gBattleStruct->aiCalcInProgress = TRUE; // Temporarily enable Z-Moves for damage calcs if (considerZPower && IsViableZMove(battlerAtk, move)) @@ -650,6 +651,7 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes // convert multiper to AI_EFFECTIVENESS_xX *typeEffectiveness = AI_GetEffectiveness(effectivenessMultiplier); + gBattleStruct->aiCalcInProgress = FALSE; gBattleStruct->swapDamageCategory = FALSE; gBattleStruct->zmove.active = FALSE; gBattleStruct->zmove.baseMoves[battlerAtk] = MOVE_NONE; diff --git a/src/battle_util.c b/src/battle_util.c index 8695455347..5d40b4508b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10172,7 +10172,7 @@ static inline void MulByTypeEffectiveness(uq4_12_t *modifier, u32 move, u32 move mod = UQ_4_12(1.0); } - if (gBattleStruct->distortedTypeMatchups & gBitTable[battlerDef]) + if (gBattleStruct->distortedTypeMatchups & gBitTable[battlerDef] || (gBattleStruct->aiCalcInProgress && ShouldTeraShellDistortTypeMatchups(move, battlerDef))) { mod = UQ_4_12(0.5); if (recordAbilities)