Skip to content

Commit

Permalink
Fixes Triple Kick effect and Z move damage calc (#2983)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuffelSaft authored May 31, 2023
2 parents 837e2fb + 5a384f9 commit 2e08277
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
76 changes: 38 additions & 38 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,47 +822,47 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 *typeEffectiveness,
else
dmg = (critDmg + normalDmg * (critChance - 1)) / critChance;

// Handle dynamic move damage
switch (gBattleMoves[move].effect)
if (!gBattleStruct->zmove.active)
{
case EFFECT_LEVEL_DAMAGE:
case EFFECT_PSYWAVE:
dmg = gBattleMons[battlerAtk].level * (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_DRAGON_RAGE:
dmg = 40 * (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_SONICBOOM:
dmg = 20 * (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_MULTI_HIT:
dmg *= (AI_DATA->abilities[battlerAtk] == ABILITY_SKILL_LINK ? 5 : 3);
break;
case EFFECT_TRIPLE_KICK:
dmg *= (AI_DATA->abilities[battlerAtk] == ABILITY_SKILL_LINK ? 6 : 5);
break;
case EFFECT_ENDEAVOR:
// If target has less HP than user, Endeavor does no damage
dmg = max(0, gBattleMons[battlerDef].hp - gBattleMons[battlerAtk].hp);
break;
case EFFECT_SUPER_FANG:
dmg = (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND
? max(2, gBattleMons[battlerDef].hp * 3 / 4)
: max(1, gBattleMons[battlerDef].hp / 2));
break;
case EFFECT_FINAL_GAMBIT:
dmg = gBattleMons[battlerAtk].hp;
break;
}
// Handle dynamic move damage
switch (gBattleMoves[move].effect)
{
case EFFECT_LEVEL_DAMAGE:
case EFFECT_PSYWAVE:
dmg = gBattleMons[battlerAtk].level * (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_DRAGON_RAGE:
dmg = 40 * (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_SONICBOOM:
dmg = 20 * (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND ? 2 : 1);
break;
case EFFECT_MULTI_HIT:
dmg *= (AI_DATA->abilities[battlerAtk] == ABILITY_SKILL_LINK ? 5 : 3);
break;
case EFFECT_ENDEAVOR:
// If target has less HP than user, Endeavor does no damage
dmg = max(0, gBattleMons[battlerDef].hp - gBattleMons[battlerAtk].hp);
break;
case EFFECT_SUPER_FANG:
dmg = (AI_DATA->abilities[battlerAtk] == ABILITY_PARENTAL_BOND
? max(2, gBattleMons[battlerDef].hp * 3 / 4)
: max(1, gBattleMons[battlerDef].hp / 2));
break;
case EFFECT_FINAL_GAMBIT:
dmg = gBattleMons[battlerAtk].hp;
break;
}

// Handle other multi-strike moves
if (gBattleMoves[move].flags & FLAG_TWO_STRIKES)
dmg *= 2;
else if (gBattleMoves[move].flags & FLAG_THREE_STRIKES || (move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH))
dmg *= 3;
// Handle other multi-strike moves
if (gBattleMoves[move].flags & FLAG_TWO_STRIKES)
dmg *= 2;
else if (gBattleMoves[move].flags & FLAG_THREE_STRIKES || (move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH))
dmg *= 3;

if (dmg == 0)
dmg = 1;
if (dmg == 0)
dmg = 1;
}
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8499,7 +8499,10 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
basePower = gBattleStruct->presentBasePower;
break;
case EFFECT_TRIPLE_KICK:
basePower *= (4 - gMultiHitCounter);
if (gMultiHitCounter == 0) // Calc damage with max BP for move consideration
basePower *= 6;
else
basePower *= (4 - gMultiHitCounter);
break;
case EFFECT_SPIT_UP:
basePower = 100 * gDisableStructs[battlerAtk].stockpileCounter;
Expand Down

0 comments on commit 2e08277

Please sign in to comment.