Closed Karthik99999 closed 1 month ago
I was about to prepare my own PR until I found this. This is correct. My change would have use <= 4 instead of < 5 but I see no issue.
This code was taken from the emerald decomp
u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale)
{
u8 result = hp * scale / maxhp;
if (result == 0 && hp > 0)
return 1;
return result;
}
static void Cmd_remaininghptopower(void)
{
s32 i;
s32 hpFraction = GetScaledHPFraction(gBattleMons[gBattlerAttacker].hp, gBattleMons[gBattlerAttacker].maxHP, 48);
for (i = 0; i < (s32) sizeof(sFlailHpScaleToPowerTable); i += 2)
{
if (hpFraction <= sFlailHpScaleToPowerTable[i])
break;
}
gDynamicBasePower = sFlailHpScaleToPowerTable[i + 1];
gBattlescriptCurrInstr++;
}
static const u8 sFlailHpScaleToPowerTable[] =
{
1, 200,
4, 150,
9, 100,
16, 80,
32, 40,
48, 20
};
The code can be found here https://github.com/pret/pokeemerald/blob/18f84b78f2d1a8669753fa586836fca06036c790/src/battle_script_commands.c#L8246
Thanks Karthik!
https://www.smogon.com/forums/threads/gen-3-reversal-flail.3743660/