From b869b836cca7bd427070c292b189ee4b9c756729 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 28 Nov 2022 10:34:27 -0500 Subject: [PATCH] add callnative bs func, convert metal burst dmg calc --- asm/macros/battle_script.inc | 11 ++++++++--- src/battle_script_commands.c | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 1a6641e76..d7b55762c 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1299,13 +1299,18 @@ .byte 0xfe .4byte \ptr .endm - - .macro metalburstdamagecalculator ptr:req + + .macro callnative func:req .byte 0xff - .4byte \ptr + .4byte \func .endm @ various command changed to more readable macros + .macro metalburstdamagecalculator ptr:req + callnative BS_CalcMetalBurstDmg + .4byte \ptr + .endm + .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES .endm diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e0e803ecd..b7551ab9e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -574,7 +574,7 @@ static void Cmd_averagestats(void); static void Cmd_jumpifoppositegenders(void); static void Cmd_unused(void); static void Cmd_tryworryseed(void); -static void Cmd_metalburstdamagecalculator(void); +static void Cmd_callnative(void); void (* const gBattleScriptingCommandsTable[])(void) = { @@ -833,7 +833,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_jumpifoppositegenders, //0xFC Cmd_unused, //0xFD Cmd_tryworryseed, //0xFE - Cmd_metalburstdamagecalculator, //0xFF + Cmd_callnative, //0xFF }; 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 sideTarget = 0; @@ -14759,7 +14766,7 @@ static void Cmd_metalburstdamagecalculator(void) else gBattlerTarget = gProtectStructs[gBattlerAttacker].physicalBattlerId; - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr += 9; } else if (gProtectStructs[gBattlerAttacker].specialDmg && sideAttacker != (sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].specialBattlerId)) @@ -14772,12 +14779,12 @@ static void Cmd_metalburstdamagecalculator(void) else gBattlerTarget = gProtectStructs[gBattlerAttacker].specialBattlerId; - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr += 9; } else { gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); } }