- 853
- Posts
- 4
- Years
- Seen Nov 9, 2023
can I get some help on figuring out the hidden power calculation, pretty much how it decides the type of the move. this is the current function,
and the values for the types are 0x0-0x11. (fixed typo, type wasn't 0x13 that was number of types in my rom)
any new types would have to be added at 0x17 on.
I think the most important part is here, but I don't know bitwise, to try calculating the outcomes.
gBattleStruct->dynamicMoveType = (15 * typeBits) / 63 + 1;
if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY)
++gBattleStruct->dynamicMoveType;
gBattleStruct->dynamicMoveType |= 0xC0;
and the values for the types are 0x0-0x11. (fixed typo, type wasn't 0x13 that was number of types in my rom)
any new types would have to be added at 0x17 on.
Code:
[SPOILER]static void atkC1_hiddenpowercalc(void)
{
s32 powerBits, typeBits;
powerBits = ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1)
| ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0)
| ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1)
| ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2)
| ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3)
| ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4);
typeBits = ((gBattleMons[gBattlerAttacker].hpIV & 1) << 0)
| ((gBattleMons[gBattlerAttacker].attackIV & 1) << 1)
| ((gBattleMons[gBattlerAttacker].defenseIV & 1) << 2)
| ((gBattleMons[gBattlerAttacker].speedIV & 1) << 3)
| ((gBattleMons[gBattlerAttacker].spAttackIV & 1) << 4)
| ((gBattleMons[gBattlerAttacker].spDefenseIV & 1) << 5);
gDynamicBasePower = (40 * powerBits) / 63 + 30;
gBattleStruct->dynamicMoveType = (15 * typeBits) / 63 + 1;
if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY)
++gBattleStruct->dynamicMoveType;
gBattleStruct->dynamicMoveType |= 0xC0;
++gBattlescriptCurrInstr;[/SPOILER]
gBattleStruct->dynamicMoveType = (15 * typeBits) / 63 + 1;
if (gBattleStruct->dynamicMoveType >= TYPE_MYSTERY)
++gBattleStruct->dynamicMoveType;
gBattleStruct->dynamicMoveType |= 0xC0;
Last edited: