Skip to content

Commit

Permalink
Shed tail rounds up, not down (#4913)
Browse files Browse the repository at this point in the history
* Shed tail rounds up, not down

* Label
  • Loading branch information
kleeenexfeu authored Jul 5, 2024
1 parent 13b8daf commit 8168dd7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -12608,9 +12608,14 @@ static void Cmd_setsubstitute(void)
CMD_ARGS();

u32 factor = gMovesInfo[gCurrentMove].effect == EFFECT_SHED_TAIL ? 2 : 4;
u32 hp = GetNonDynamaxMaxHP(gBattlerAttacker) / factor;
u32 hp;

if (GetNonDynamaxMaxHP(gBattlerAttacker) / factor == 0)
if (factor == 2)
hp = (GetNonDynamaxMaxHP(gBattlerAttacker)+1) / factor; // shed tail rounds up
else
hp = GetNonDynamaxMaxHP(gBattlerAttacker) / factor; // one bit value will only work for Pokémon which max hp can go to 1020(which is more than possible in games)

if (hp == 0)
hp = 1;

if (gBattleMons[gBattlerAttacker].hp <= hp)
Expand All @@ -12620,7 +12625,7 @@ static void Cmd_setsubstitute(void)
}
else
{
gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / factor; // one bit value will only work for Pokémon which max hp can go to 1020(which is more than possible in games)
gBattleMoveDamage = hp;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;

Expand Down

0 comments on commit 8168dd7

Please sign in to comment.