diff --git a/include/battle.h b/include/battle.h index 49d7cbb0ab..71dbb19491 100755 --- a/include/battle.h +++ b/include/battle.h @@ -27,26 +27,6 @@ #include "random.h" // for rng_value_t #include "trainer_slide.h" -// Helper for accessing command arguments and advancing gBattlescriptCurrInstr. -// -// For example accuracycheck is defined as: -// -// .macro accuracycheck failInstr:req, move:req -// .byte 0x1 -// .4byte \failInstr -// .2byte \move -// .endm -// -// Which corresponds to: -// -// CMD_ARGS(const u8 *failInstr, u16 move); -// -// The arguments can be accessed as cmd->failInstr and cmd->move. -// gBattlescriptCurrInstr = cmd->nextInstr; advances to the next instruction. -#define CMD_ARGS(...) const struct __attribute__((packed)) { u8 opcode; RECURSIVELY(R_FOR_EACH(APPEND_SEMICOLON, __VA_ARGS__)) const u8 nextInstr[0]; } *const cmd UNUSED = (const void *)gBattlescriptCurrInstr -#define VARIOUS_ARGS(...) CMD_ARGS(u8 battler, u8 id, ##__VA_ARGS__) -#define NATIVE_ARGS(...) CMD_ARGS(void (*func)(void), ##__VA_ARGS__) - // Used to exclude moves learned temporarily by Transform or Mimic #define MOVE_IS_PERMANENT(battler, moveSlot) \ (!(gBattleMons[battler].volatiles.transformed) \ diff --git a/src/battle_dynamax.c b/src/battle_dynamax.c index d5edbc0e61..c907ae696f 100644 --- a/src/battle_dynamax.c +++ b/src/battle_dynamax.c @@ -457,43 +457,3 @@ void ChooseDamageNonTypesString(enum Type type) break; } } - -// Updates Dynamax HP multipliers and healthboxes. -void BS_UpdateDynamax(void) -{ - NATIVE_ARGS(); - u32 battler = gBattleScripting.battler; - struct Pokemon *mon = GetBattlerMon(battler); - - if (!IsGigantamaxed(battler)) // RecalcBattlerStats will get called on form change. - RecalcBattlerStats(battler, mon, GetActiveGimmick(battler) == GIMMICK_DYNAMAX); - - UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], mon, HEALTHBOX_ALL); - gBattlescriptCurrInstr = cmd->nextInstr; -} - -// Goes to the jump instruction if the target is Dynamaxed. -void BS_JumpIfDynamaxed(void) -{ - NATIVE_ARGS(const u8 *jumpInstr); - if ((GetActiveGimmick(gBattlerTarget) == GIMMICK_DYNAMAX)) - gBattlescriptCurrInstr = cmd->jumpInstr; - else - gBattlescriptCurrInstr = cmd->nextInstr; -} - -void BS_UndoDynamax(void) -{ - NATIVE_ARGS(u8 battler); - u32 battler = GetBattlerForBattleScript(cmd->battler); - - if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX) - { - UndoDynamax(battler); - gBattleScripting.battler = battler; - BattleScriptCall(BattleScript_DynamaxEnds_Ret); - return; - } - - gBattlescriptCurrInstr = cmd->nextInstr; -} diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 61c9f01ec2..97e324b25c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -72,6 +72,26 @@ #include "load_save.h" #include "test/test_runner_battle.h" +// Helper for accessing command arguments and advancing gBattlescriptCurrInstr. +// +// For example accuracycheck is defined as: +// +// .macro accuracycheck failInstr:req, move:req +// .byte 0x1 +// .4byte \failInstr +// .2byte \move +// .endm +// +// Which corresponds to: +// +// CMD_ARGS(const u8 *failInstr, u16 move); +// +// The arguments can be accessed as cmd->failInstr and cmd->move. +// gBattlescriptCurrInstr = cmd->nextInstr; advances to the next instruction. +#define CMD_ARGS(...) const struct __attribute__((packed)) { u8 opcode; RECURSIVELY(R_FOR_EACH(APPEND_SEMICOLON, __VA_ARGS__)) const u8 nextInstr[0]; } *const cmd UNUSED = (const void *)gBattlescriptCurrInstr +#define VARIOUS_ARGS(...) CMD_ARGS(u8 battler, u8 id, ##__VA_ARGS__) +#define NATIVE_ARGS(...) CMD_ARGS(void (*func)(void), ##__VA_ARGS__) + // table to avoid ugly powing on gba (courtesy of doesnt) // this returns (i^2.5)/4 // the quarters cancel so no need to re-quadruple them in actual calculation @@ -18081,3 +18101,43 @@ void BS_TryAbsorbToxicSpikesOnFaint(void) gBattlescriptCurrInstr = cmd->nextInstr; } + +// Updates Dynamax HP multipliers and healthboxes. +void BS_UpdateDynamax(void) +{ + NATIVE_ARGS(); + u32 battler = gBattleScripting.battler; + struct Pokemon *mon = GetBattlerMon(battler); + + if (!IsGigantamaxed(battler)) // RecalcBattlerStats will get called on form change. + RecalcBattlerStats(battler, mon, GetActiveGimmick(battler) == GIMMICK_DYNAMAX); + + UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], mon, HEALTHBOX_ALL); + gBattlescriptCurrInstr = cmd->nextInstr; +} + +// Goes to the jump instruction if the target is Dynamaxed. +void BS_JumpIfDynamaxed(void) +{ + NATIVE_ARGS(const u8 *jumpInstr); + if ((GetActiveGimmick(gBattlerTarget) == GIMMICK_DYNAMAX)) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_UndoDynamax(void) +{ + NATIVE_ARGS(u8 battler); + u32 battler = GetBattlerForBattleScript(cmd->battler); + + if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX) + { + UndoDynamax(battler); + gBattleScripting.battler = battler; + BattleScriptCall(BattleScript_DynamaxEnds_Ret); + return; + } + + gBattlescriptCurrInstr = cmd->nextInstr; +}