Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes minor wrong order in AI_CalcDamage and adds Tera Blast/Tera Storm #5155

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,16 @@ 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;
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))
Expand All @@ -537,12 +541,25 @@ 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);
moveEffect = gMovesInfo[move].effect;
switch (moveEffect)
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
{
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;

Expand All @@ -559,7 +576,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)
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
{
case EFFECT_ROLLOUT:
n = gDisableStructs[battlerAtk].rolloutTimer - 1;
Expand Down Expand Up @@ -606,7 +623,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)
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
{
for (gMultiHitCounter = gMovesInfo[move].strikeCount; gMultiHitCounter > 0; gMultiHitCounter--) // The global is used to simulate actual damage done
{
Expand All @@ -630,7 +647,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)
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
{
case EFFECT_LEVEL_DAMAGE:
simDamage.expected = simDamage.minimum = gBattleMons[battlerAtk].level * (aiData->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
Expand Down
Loading