From 24017a521ecbd151f4c8c83abc20e40cccbe7cad Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Tue, 13 Aug 2024 15:11:17 +0200 Subject: [PATCH 1/3] Fixes minor wrong order in AI_CalcDamage and adds Tera Blast/Tera Storm --- src/battle_ai_util.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index a094dfd694a5..dcdea1aac0f9 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -520,11 +520,15 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u struct SimulatedDamage simDamage; s32 moveType; uq4_12_t effectivenessMultiplier; + u32 moveEffect = gMovesInfo[move].effect; bool32 isDamageMoveUnusable = FALSE; bool32 toggledGimmick = FALSE; struct AiLogicData *aiData = AI_DATA; gBattleStruct->aiCalcInProgress = TRUE; + if (moveEffect == EFFECT_NATURE_POWER) + move = GetNaturePowerMove(battlerAtk); + // Temporarily enable gimmicks for damage calcs if planned if (gBattleStruct->gimmick.usableGimmick[battlerAtk] && GetActiveGimmick(battlerAtk) == GIMMICK_NONE && !(gBattleStruct->gimmick.usableGimmick[battlerAtk] == GIMMICK_Z_MOVE && !considerZPower)) @@ -537,12 +541,24 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u SetActiveGimmick(battlerAtk, gBattleStruct->gimmick.usableGimmick[battlerAtk]); } - if (gMovesInfo[move].effect == EFFECT_PHOTON_GEYSER) - gBattleStruct->swapDamageCategory = (GetCategoryBasedOnStats(gBattlerAttacker) != gMovesInfo[gCurrentMove].category); - else if (gMovesInfo[move].effect == EFFECT_SHELL_SIDE_ARM) - gBattleStruct->swapDamageCategory = (gBattleStruct->shellSideArmCategory[battlerAtk][battlerDef] != gMovesInfo[gCurrentMove].category); - else if (gMovesInfo[move].effect == EFFECT_NATURE_POWER) - move = GetNaturePowerMove(battlerAtk); + switch (moveEffect) + { + case EFFECT_PHOTON_GEYSER: + gBattleStruct->swapDamageCategory = (GetCategoryBasedOnStats(battlerAtk) == DAMAGE_CATEGORY_PHYSICAL); + break; + case EFFECT_SHELL_SIDE_ARM: + if (gBattleStruct->shellSideArmCategory[battlerAtk][battlerDef] == DAMAGE_CATEGORY_PHYSICAL) + gBattleStruct->swapDamageCategory = TRUE; + break; + case EFFECT_TERA_BLAST: + if (GetActiveGimmick(battlerAtk) == GIMMICK_TERA) + gBattleStruct->swapDamageCategory = GetCategoryBasedOnStats(battlerAtk) == DAMAGE_CATEGORY_PHYSICAL; + break; + case EFFECT_TERA_STARSTORM: + if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_TERA && gBattleMons[gBattlerAttacker].species == SPECIES_TERAPAGOS_STELLAR) + gBattleStruct->swapDamageCategory = GetCategoryBasedOnStats(battlerAtk) == DAMAGE_CATEGORY_PHYSICAL; + break; + } gBattleStruct->dynamicMoveType = 0; @@ -559,7 +575,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u ProteanTryChangeType(battlerAtk, aiData->abilities[battlerAtk], move, moveType); // Certain moves like Rollout calculate damage based on values which change during the move execution, but before calling dmg calc. - switch (gMovesInfo[move].effect) + switch (moveEffect) { case EFFECT_ROLLOUT: n = gDisableStructs[battlerAtk].rolloutTimer - 1; @@ -606,7 +622,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u else { s32 nonCritDmg = 0; - if (gMovesInfo[move].effect == EFFECT_TRIPLE_KICK) + if (moveEffect == EFFECT_TRIPLE_KICK) { for (gMultiHitCounter = gMovesInfo[move].strikeCount; gMultiHitCounter > 0; gMultiHitCounter--) // The global is used to simulate actual damage done { @@ -630,7 +646,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u if (GetActiveGimmick(battlerAtk) != GIMMICK_Z_MOVE) { // Handle dynamic move damage - switch (gMovesInfo[move].effect) + switch (moveEffect) { case EFFECT_LEVEL_DAMAGE: simDamage.expected = simDamage.minimum = gBattleMons[battlerAtk].level * (aiData->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1); From 3e920745210cba9ae419de29c7ea51d96620a391 Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Sat, 17 Aug 2024 12:17:37 +0200 Subject: [PATCH 2/3] update moveEffect --- src/battle_ai_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index dcdea1aac0f9..fe040e061446 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -520,7 +520,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u struct SimulatedDamage simDamage; s32 moveType; uq4_12_t effectivenessMultiplier; - u32 moveEffect = gMovesInfo[move].effect; + u32 moveEffect; bool32 isDamageMoveUnusable = FALSE; bool32 toggledGimmick = FALSE; struct AiLogicData *aiData = AI_DATA; @@ -541,6 +541,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u SetActiveGimmick(battlerAtk, gBattleStruct->gimmick.usableGimmick[battlerAtk]); } + moveEffect = gMovesInfo[move].effect; switch (moveEffect) { case EFFECT_PHOTON_GEYSER: From fee27fc072211a07ef4a0f87a7d01732281057ff Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Sun, 18 Aug 2024 01:17:38 +0200 Subject: [PATCH 3/3] fix compile --- src/battle_ai_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index fe040e061446..47750cf11ef6 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -519,8 +519,8 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u { struct SimulatedDamage simDamage; s32 moveType; + u32 moveEffect = gMovesInfo[move].effect; uq4_12_t effectivenessMultiplier; - u32 moveEffect; bool32 isDamageMoveUnusable = FALSE; bool32 toggledGimmick = FALSE; struct AiLogicData *aiData = AI_DATA;