Shed tail rounds up, not down (#4913)

* Shed tail rounds up, not down

* Label
This commit is contained in:
kleeenexfeu 2024-07-05 19:21:30 +02:00 committed by GitHub
parent 13b8daf36b
commit 8168dd7be9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
@ -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;