Merge pull request #2464 from ghoulslash/be/callnative

add callnative bs func, convert metal burst dmg calc
This commit is contained in:
Eduardo Quezada D'Ottone 2022-11-28 16:16:04 -03:00 committed by GitHub
commit 7ab3d37a7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 8 deletions

View File

@ -1299,9 +1299,15 @@
.byte 0xfe .byte 0xfe
.4byte \ptr .4byte \ptr
.endm .endm
.macro metalburstdamagecalculator ptr:req .macro callnative func:req
.byte 0xff .byte 0xff
.4byte \func
.endm
@ callnative macros
.macro metalburstdamagecalculator ptr:req
callnative BS_CalcMetalBurstDmg
.4byte \ptr .4byte \ptr
.endm .endm

View File

@ -574,7 +574,7 @@ static void Cmd_averagestats(void);
static void Cmd_jumpifoppositegenders(void); static void Cmd_jumpifoppositegenders(void);
static void Cmd_unused(void); static void Cmd_unused(void);
static void Cmd_tryworryseed(void); static void Cmd_tryworryseed(void);
static void Cmd_metalburstdamagecalculator(void); static void Cmd_callnative(void);
void (* const gBattleScriptingCommandsTable[])(void) = void (* const gBattleScriptingCommandsTable[])(void) =
{ {
@ -833,7 +833,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_jumpifoppositegenders, //0xFC Cmd_jumpifoppositegenders, //0xFC
Cmd_unused, //0xFD Cmd_unused, //0xFD
Cmd_tryworryseed, //0xFE Cmd_tryworryseed, //0xFE
Cmd_metalburstdamagecalculator, //0xFF Cmd_callnative, //0xFF
}; };
const struct StatFractions gAccuracyStageRatios[] = const struct StatFractions gAccuracyStageRatios[] =
@ -14743,7 +14743,14 @@ static void Cmd_tryworryseed(void)
} }
} }
static void Cmd_metalburstdamagecalculator(void) static void Cmd_callnative(void)
{
void (*func)() = (void *)T1_READ_PTR(gBattlescriptCurrInstr + 1);
func();
}
// Callnative Funcs
void BS_CalcMetalBurstDmg(void)
{ {
u8 sideAttacker = GetBattlerSide(gBattlerAttacker); u8 sideAttacker = GetBattlerSide(gBattlerAttacker);
u8 sideTarget = 0; u8 sideTarget = 0;
@ -14759,7 +14766,7 @@ static void Cmd_metalburstdamagecalculator(void)
else else
gBattlerTarget = gProtectStructs[gBattlerAttacker].physicalBattlerId; gBattlerTarget = gProtectStructs[gBattlerAttacker].physicalBattlerId;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 9;
} }
else if (gProtectStructs[gBattlerAttacker].specialDmg else if (gProtectStructs[gBattlerAttacker].specialDmg
&& sideAttacker != (sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].specialBattlerId)) && sideAttacker != (sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].specialBattlerId))
@ -14772,12 +14779,12 @@ static void Cmd_metalburstdamagecalculator(void)
else else
gBattlerTarget = gProtectStructs[gBattlerAttacker].specialBattlerId; gBattlerTarget = gProtectStructs[gBattlerAttacker].specialBattlerId;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 9;
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5);
} }
} }