From 4ac61ad15ff1f83d6df589a8c8493741d21edd3f Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 31 Aug 2023 22:24:58 -0400 Subject: [PATCH 1/3] handleultraburst, handleprimalreversion, handlemegaevo --- asm/macros/battle_script.inc | 33 ++++++++------- include/constants/battle_script_commands.h | 2 - src/battle_script_commands.c | 48 ++++++++++++---------- 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 25898a7d8f41..e43929c8dc3c 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1382,6 +1382,24 @@ .4byte \ptr .endm + .macro handlemegaevo battler:req, case:req + callnative BS_HandleMegaEvolution + .byte \battler + .byte \case + .endm + + .macro handleprimalreversion battler:req, case:req + callnative BS_HandlePrimalReversion + .byte \battler + .byte \case + .endm + + .macro handleultraburst battler:req, case:req + callnative BS_HandleUltraBurst + .byte \battler + .byte \case + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES @@ -1627,21 +1645,6 @@ .4byte \failInstr .endm - .macro handlemegaevo battler:req, case:req - various \battler, VARIOUS_HANDLE_MEGA_EVO - .byte \case - .endm - - .macro handleprimalreversion battler:req, case:req - various \battler, VARIOUS_HANDLE_PRIMAL_REVERSION - .byte \case - .endm - - .macro handleultraburst battler:req, case:req - various \battler, VARIOUS_HANDLE_ULTRA_BURST - .byte \case - .endm - .macro handleformchange battler:req, case:req various \battler, VARIOUS_HANDLE_FORM_CHANGE .byte \case diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 20e6d7e45e46..b6ed845611d3 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -210,7 +210,6 @@ #define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 #define VARIOUS_CONSUME_BERRY 119 #define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 120 -#define VARIOUS_HANDLE_PRIMAL_REVERSION 121 #define VARIOUS_APPLY_PLASMA_FISTS 122 #define VARIOUS_JUMP_IF_SPECIES 123 #define VARIOUS_UPDATE_ABILITY_POPUP 124 @@ -257,7 +256,6 @@ #define VARIOUS_TRY_REVIVAL_BLESSING 165 #define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 166 #define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 167 -#define VARIOUS_HANDLE_ULTRA_BURST 168 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5627f0d385d2..45f4972011d4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9626,27 +9626,6 @@ static void Cmd_various(void) } return; } - case VARIOUS_HANDLE_MEGA_EVO: - { - VARIOUS_ARGS(u8 case_); - HandleScriptMegaPrimalBurst(cmd->case_, gActiveBattler, HANDLE_TYPE_MEGA_EVOLUTION); - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } - case VARIOUS_HANDLE_PRIMAL_REVERSION: - { - VARIOUS_ARGS(u8 case_); - HandleScriptMegaPrimalBurst(cmd->case_, gActiveBattler, HANDLE_TYPE_PRIMAL_REVERSION); - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } - case VARIOUS_HANDLE_ULTRA_BURST: - { - VARIOUS_ARGS(u8 case_); - HandleScriptMegaPrimalBurst(cmd->case_, gActiveBattler, HANDLE_TYPE_ULTRA_BURST); - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } case VARIOUS_HANDLE_FORM_CHANGE: { VARIOUS_ARGS(u8 case_); @@ -16383,3 +16362,30 @@ void BS_SetSnow(void) } gBattlescriptCurrInstr = cmd->nextInstr; } + +void BS_HandleMegaEvolution(void) +{ + NATIVE_ARGS(u8 battler, u8 caseId); + + gActiveBattler = GetBattlerForBattleScript(cmd->battler); + HandleScriptMegaPrimalBurst(cmd->caseId, gActiveBattler, HANDLE_TYPE_MEGA_EVOLUTION); + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_HandlePrimalReversion(void) +{ + NATIVE_ARGS(u8 battler, u8 caseId); + + gActiveBattler = GetBattlerForBattleScript(cmd->battler); + HandleScriptMegaPrimalBurst(cmd->caseId, gActiveBattler, HANDLE_TYPE_PRIMAL_REVERSION); + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_HandleUltraBurst(void) +{ + NATIVE_ARGS(u8 battler, u8 caseId); + + gActiveBattler = GetBattlerForBattleScript(cmd->battler); + HandleScriptMegaPrimalBurst(cmd->caseId, gActiveBattler, HANDLE_TYPE_ULTRA_BURST); + gBattlescriptCurrInstr = cmd->nextInstr; +} From c4553c71aa0ac7fa164acb3942d061416e091a13 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 31 Aug 2023 23:43:48 -0400 Subject: [PATCH 2/3] 5 more callnatives - jumpifshelltrap - jumpifemergencyexited - jumpifrodaffected - jumpifabsorbaffected - jumpifmotoraffected --- asm/macros/battle_script.inc | 52 +++++----- include/constants/battle_script_commands.h | 5 - src/battle_script_commands.c | 105 +++++++++++---------- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index e43929c8dc3c..4374482d6fc5 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1400,6 +1400,33 @@ .byte \case .endm + .macro jumpifshelltrap battler:req, jumpInstr:req + callnative BS_JumpIfShellTrap + .byte \battler + .4byte \jumpInstr + .endm + + .macro jumpifemergencyexited battler:req, jumpInstr:req + callnative BS_JumpIfEmergencyExited + .byte \battler + .4byte \jumpInstr + .endm + + .macro jumpifrodaffected battler:req, jumpInstr:req + callnative BS_JumpIfRod + .4byte \jumpInstr + .endm + + .macro jumpifabsorbaffected battler:req, jumpInstr:req + callnative BS_JumpIfAbsorb + .4byte \jumpInstr + .endm + + .macro jumpifmotoraffected battler:req, jumpInstr:req + callnative BS_JumpIfMotor + .4byte \jumpInstr + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES @@ -2017,21 +2044,6 @@ various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK .endm - .macro jumpifrodaffected battler:req, jumpInstr:req - various \battler, VARIOUS_JUMP_IF_ROD - .4byte \jumpInstr - .endm - - .macro jumpifabsorbaffected battler:req, jumpInstr:req - various \battler, VARIOUS_JUMP_IF_ABSORB - .4byte \jumpInstr - .endm - - .macro jumpifmotoraffected battler:req, jumpInstr:req - various \battler, VARIOUS_JUMP_IF_MOTOR - .4byte \jumpInstr - .endm - .macro jumpifteanoberry jumpInstr:req various BS_ATTACKER, VARIOUS_TEATIME_TARGETS .4byte \jumpInstr @@ -2301,16 +2313,6 @@ waitmessage B_WAIT_TIME_LONG .endm - .macro jumpifemergencyexited battler:req, jumpInstr:req - various \battler, VARIOUS_JUMP_IF_EMERGENCY_EXITED - .4byte \jumpInstr - .endm - - .macro jumpifshelltrap battler:req, ptr:req - various \battler, VARIOUS_JUMP_IF_SHELL_TRAP - .4byte \ptr - .endm - .macro hitswitchtargetfailed various 0, VARIOUS_HIT_SWITCH_TARGET_FAILED .endm diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index b6ed845611d3..f004d7ff1b6e 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -241,18 +241,13 @@ #define VARIOUS_SET_BEAK_BLAST 150 #define VARIOUS_SWAP_SIDE_STATUSES 151 #define VARIOUS_SWAP_STATS 152 -#define VARIOUS_JUMP_IF_ROD 153 -#define VARIOUS_JUMP_IF_ABSORB 154 -#define VARIOUS_JUMP_IF_MOTOR 155 #define VARIOUS_TEATIME_INVUL 156 #define VARIOUS_TEATIME_TARGETS 157 #define VARIOUS_TRY_WIND_RIDER_POWER 158 #define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 159 #define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 160 -#define VARIOUS_JUMP_IF_EMERGENCY_EXITED 161 #define VARIOUS_STORE_HEALING_WISH 162 #define VARIOUS_HIT_SWITCH_TARGET_FAILED 163 -#define VARIOUS_JUMP_IF_SHELL_TRAP 164 #define VARIOUS_TRY_REVIVAL_BLESSING 165 #define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 166 #define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 167 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 45f4972011d4..e0c7d1c20961 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8452,8 +8452,8 @@ static bool32 IsAbilityRodAffected(void) if (gBattleStruct->dynamicMoveType == 0) moveType = gBattleMoves[gCurrentMove].type; - else if (!(gBattleStruct->dynamicMoveType & 0x40)) - moveType = gBattleStruct->dynamicMoveType & 0x3F; + else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_1)) + moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; else moveType = gBattleMoves[gCurrentMove].type; @@ -8469,8 +8469,8 @@ static bool32 IsAbilityMotorAffected(void) if (gBattleStruct->dynamicMoveType == 0) moveType = gBattleMoves[gCurrentMove].type; - else if (!(gBattleStruct->dynamicMoveType & 0x40)) - moveType = gBattleStruct->dynamicMoveType & 0x3F; + else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_1)) + moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; else moveType = gBattleMoves[gCurrentMove].type; @@ -8486,8 +8486,8 @@ static bool32 IsAbilityAbsorbAffected(void) if (gBattleStruct->dynamicMoveType == 0) moveType = gBattleMoves[gCurrentMove].type; - else if (!(gBattleStruct->dynamicMoveType & 0x40)) - moveType = gBattleStruct->dynamicMoveType & 0x3F; + else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_1)) + moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; else moveType = gBattleMoves[gCurrentMove].type; @@ -10810,33 +10810,6 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->jumpInstr; return; } - case VARIOUS_JUMP_IF_ROD: - { - VARIOUS_ARGS(const u8 *jumpInstr); - if (IsAbilityRodAffected()) - gBattlescriptCurrInstr = cmd->jumpInstr; - else - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } - case VARIOUS_JUMP_IF_MOTOR: - { - VARIOUS_ARGS(const u8 *jumpInstr); - if (IsAbilityMotorAffected()) - gBattlescriptCurrInstr = cmd->jumpInstr; - else - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } - case VARIOUS_JUMP_IF_ABSORB: - { - VARIOUS_ARGS(const u8 *jumpInstr); - if (IsAbilityAbsorbAffected()) - gBattlescriptCurrInstr = cmd->jumpInstr; - else - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } case VARIOUS_TRY_WIND_RIDER_POWER: { VARIOUS_ARGS(const u8 *failInstr); @@ -10869,15 +10842,6 @@ static void Cmd_various(void) AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, gActiveBattler, 0, 0, 0); return; } - case VARIOUS_JUMP_IF_EMERGENCY_EXITED: - { - VARIOUS_ARGS(const u8 *jumpInstr); - if (gSpecialStatuses[gActiveBattler].emergencyExited) - gBattlescriptCurrInstr = cmd->jumpInstr; - else - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } case VARIOUS_STORE_HEALING_WISH: { VARIOUS_ARGS(); @@ -10894,15 +10858,6 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->nextInstr; return; } - case VARIOUS_JUMP_IF_SHELL_TRAP: - { - VARIOUS_ARGS(const u8 *jumpInstr); - if (gProtectStructs[gActiveBattler].shellTrap) - gBattlescriptCurrInstr = cmd->jumpInstr; - else - gBattlescriptCurrInstr = cmd->nextInstr; - return; - } case VARIOUS_TRY_REVIVAL_BLESSING: { VARIOUS_ARGS(const u8 *failInstr); @@ -16389,3 +16344,51 @@ void BS_HandleUltraBurst(void) HandleScriptMegaPrimalBurst(cmd->caseId, gActiveBattler, HANDLE_TYPE_ULTRA_BURST); gBattlescriptCurrInstr = cmd->nextInstr; } + +void BS_JumpIfShellTrap(void) +{ + NATIVE_ARGS(u8 battler, const u8 *jumpInstr); + + gActiveBattler = GetBattlerForBattleScript(cmd->battler); + if (gProtectStructs[gActiveBattler].shellTrap) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_JumpIfEmergencyExited(void) +{ + NATIVE_ARGS(u8 battler, const u8 *jumpInstr); + gActiveBattler = GetBattlerForBattleScript(cmd->battler); + if (gSpecialStatuses[gActiveBattler].emergencyExited) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_JumpIfRod(void) +{ + NATIVE_ARGS(const u8 *jumpInstr); + if (IsAbilityRodAffected()) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_JumpIfAbsorb(void) +{ + NATIVE_ARGS(const u8 *jumpInstr); + if (IsAbilityAbsorbAffected()) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_JumpIfMotor(void) +{ + NATIVE_ARGS(const u8 *jumpInstr); + if (IsAbilityMotorAffected()) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} From 66710ac22ae132cdf1cf5c9b5356f0a987cc6ffd Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 31 Aug 2023 23:54:11 -0400 Subject: [PATCH 3/3] Updated various defines --- include/constants/battle_script_commands.h | 82 +++++++++++----------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index f004d7ff1b6e..c7e62a1f7287 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -210,47 +210,47 @@ #define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 #define VARIOUS_CONSUME_BERRY 119 #define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 120 -#define VARIOUS_APPLY_PLASMA_FISTS 122 -#define VARIOUS_JUMP_IF_SPECIES 123 -#define VARIOUS_UPDATE_ABILITY_POPUP 124 -#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 -#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 -#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 -#define VARIOUS_PHOTON_GEYSER_CHECK 128 -#define VARIOUS_SHELL_SIDE_ARM_CHECK 129 -#define VARIOUS_TRY_NO_RETREAT 130 -#define VARIOUS_TRY_TAR_SHOT 131 -#define VARIOUS_CAN_TAR_SHOT_WORK 132 -#define VARIOUS_CHECK_POLTERGEIST 133 -#define VARIOUS_SET_OCTOLOCK 134 -#define VARIOUS_CUT_1_3_HP_RAISE_STATS 135 -#define VARIOUS_TRY_END_NEUTRALIZING_GAS 136 -#define VARIOUS_JUMP_IF_UNDER_200 137 -#define VARIOUS_SET_SKY_DROP 138 -#define VARIOUS_CLEAR_SKY_DROP 139 -#define VARIOUS_SKY_DROP_YAWN 140 -#define VARIOUS_JUMP_IF_CANT_FLING 141 -#define VARIOUS_JUMP_IF_HOLD_EFFECT 142 -#define VARIOUS_CURE_CERTAIN_STATUSES 143 -#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 144 -#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 145 -#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 146 -#define VARIOUS_SAVE_BATTLER_ITEM 147 -#define VARIOUS_RESTORE_BATTLER_ITEM 148 -#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 149 -#define VARIOUS_SET_BEAK_BLAST 150 -#define VARIOUS_SWAP_SIDE_STATUSES 151 -#define VARIOUS_SWAP_STATS 152 -#define VARIOUS_TEATIME_INVUL 156 -#define VARIOUS_TEATIME_TARGETS 157 -#define VARIOUS_TRY_WIND_RIDER_POWER 158 -#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 159 -#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 160 -#define VARIOUS_STORE_HEALING_WISH 162 -#define VARIOUS_HIT_SWITCH_TARGET_FAILED 163 -#define VARIOUS_TRY_REVIVAL_BLESSING 165 -#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 166 -#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 167 +#define VARIOUS_APPLY_PLASMA_FISTS 121 +#define VARIOUS_JUMP_IF_SPECIES 122 +#define VARIOUS_UPDATE_ABILITY_POPUP 123 +#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 124 +#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 125 +#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 126 +#define VARIOUS_PHOTON_GEYSER_CHECK 127 +#define VARIOUS_SHELL_SIDE_ARM_CHECK 128 +#define VARIOUS_TRY_NO_RETREAT 129 +#define VARIOUS_TRY_TAR_SHOT 130 +#define VARIOUS_CAN_TAR_SHOT_WORK 131 +#define VARIOUS_CHECK_POLTERGEIST 132 +#define VARIOUS_SET_OCTOLOCK 133 +#define VARIOUS_CUT_1_3_HP_RAISE_STATS 134 +#define VARIOUS_TRY_END_NEUTRALIZING_GAS 135 +#define VARIOUS_JUMP_IF_UNDER_200 136 +#define VARIOUS_SET_SKY_DROP 137 +#define VARIOUS_CLEAR_SKY_DROP 138 +#define VARIOUS_SKY_DROP_YAWN 139 +#define VARIOUS_JUMP_IF_CANT_FLING 140 +#define VARIOUS_JUMP_IF_HOLD_EFFECT 141 +#define VARIOUS_CURE_CERTAIN_STATUSES 142 +#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 143 +#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 144 +#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 145 +#define VARIOUS_SAVE_BATTLER_ITEM 146 +#define VARIOUS_RESTORE_BATTLER_ITEM 147 +#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 148 +#define VARIOUS_SET_BEAK_BLAST 149 +#define VARIOUS_SWAP_SIDE_STATUSES 150 +#define VARIOUS_SWAP_STATS 151 +#define VARIOUS_TEATIME_INVUL 152 +#define VARIOUS_TEATIME_TARGETS 153 +#define VARIOUS_TRY_WIND_RIDER_POWER 154 +#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 155 +#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 156 +#define VARIOUS_STORE_HEALING_WISH 157 +#define VARIOUS_HIT_SWITCH_TARGET_FAILED 158 +#define VARIOUS_TRY_REVIVAL_BLESSING 159 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 160 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 161 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0