Convert various to callnatives - Part 1 (#3269)

This commit is contained in:
ghoulslash 2023-09-11 09:19:56 -04:00 committed by GitHub
commit 582cfb0ae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 166 additions and 159 deletions

View File

@ -1388,6 +1388,51 @@
.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
.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
@ -1633,21 +1678,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
@ -2020,21 +2050,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
@ -2299,16 +2314,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

View File

@ -210,53 +210,46 @@
#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
#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_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_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
#define VARIOUS_HANDLE_ULTRA_BURST 168
#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_HOLD_EFFECT 140
#define VARIOUS_CURE_CERTAIN_STATUSES 141
#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 142
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 143
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 144
#define VARIOUS_SAVE_BATTLER_ITEM 145
#define VARIOUS_RESTORE_BATTLER_ITEM 146
#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 147
#define VARIOUS_SET_BEAK_BLAST 148
#define VARIOUS_SWAP_SIDE_STATUSES 149
#define VARIOUS_SWAP_STATS 150
#define VARIOUS_TEATIME_INVUL 151
#define VARIOUS_TEATIME_TARGETS 152
#define VARIOUS_TRY_WIND_RIDER_POWER 153
#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 154
#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 155
#define VARIOUS_STORE_HEALING_WISH 156
#define VARIOUS_HIT_SWITCH_TARGET_FAILED 157
#define VARIOUS_TRY_REVIVAL_BLESSING 158
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 159
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 160
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -8344,8 +8344,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;
@ -8361,8 +8361,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;
@ -8378,8 +8378,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;
@ -9528,27 +9528,6 @@ static void Cmd_various(void)
}
return;
}
case VARIOUS_HANDLE_MEGA_EVO:
{
VARIOUS_ARGS(u8 case_);
HandleScriptMegaPrimalBurst(cmd->case_, battler, HANDLE_TYPE_MEGA_EVOLUTION);
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
case VARIOUS_HANDLE_PRIMAL_REVERSION:
{
VARIOUS_ARGS(u8 case_);
HandleScriptMegaPrimalBurst(cmd->case_, battler, HANDLE_TYPE_PRIMAL_REVERSION);
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
case VARIOUS_HANDLE_ULTRA_BURST:
{
VARIOUS_ARGS(u8 case_);
HandleScriptMegaPrimalBurst(cmd->case_, battler, HANDLE_TYPE_ULTRA_BURST);
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
case VARIOUS_HANDLE_FORM_CHANGE:
{
VARIOUS_ARGS(u8 case_);
@ -10724,33 +10703,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);
@ -10783,15 +10735,6 @@ static void Cmd_various(void)
AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, 0, 0, 0);
return;
}
case VARIOUS_JUMP_IF_EMERGENCY_EXITED:
{
VARIOUS_ARGS(const u8 *jumpInstr);
if (gSpecialStatuses[battler].emergencyExited)
gBattlescriptCurrInstr = cmd->jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
case VARIOUS_STORE_HEALING_WISH:
{
VARIOUS_ARGS();
@ -10808,15 +10751,6 @@ static void Cmd_various(void)
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
case VARIOUS_JUMP_IF_SHELL_TRAP:
{
VARIOUS_ARGS(const u8 *jumpInstr);
if (gProtectStructs[battler].shellTrap)
gBattlescriptCurrInstr = cmd->jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
case VARIOUS_TRY_REVIVAL_BLESSING:
{
VARIOUS_ARGS(const u8 *failInstr);
@ -16308,3 +16242,78 @@ void BS_SetSnow(void)
}
gBattlescriptCurrInstr = cmd->nextInstr;
}
void BS_HandleMegaEvolution(void)
{
NATIVE_ARGS(u8 battler, u8 caseId);
u8 battler = GetBattlerForBattleScript(cmd->battler);
HandleScriptMegaPrimalBurst(cmd->caseId, battler, HANDLE_TYPE_MEGA_EVOLUTION);
gBattlescriptCurrInstr = cmd->nextInstr;
}
void BS_HandlePrimalReversion(void)
{
NATIVE_ARGS(u8 battler, u8 caseId);
u8 battler = GetBattlerForBattleScript(cmd->battler);
HandleScriptMegaPrimalBurst(cmd->caseId, battler, HANDLE_TYPE_PRIMAL_REVERSION);
gBattlescriptCurrInstr = cmd->nextInstr;
}
void BS_HandleUltraBurst(void)
{
NATIVE_ARGS(u8 battler, u8 caseId);
u8 battler = GetBattlerForBattleScript(cmd->battler);
HandleScriptMegaPrimalBurst(cmd->caseId, battler, HANDLE_TYPE_ULTRA_BURST);
gBattlescriptCurrInstr = cmd->nextInstr;
}
void BS_JumpIfShellTrap(void)
{
NATIVE_ARGS(u8 battler, const u8 *jumpInstr);
u8 battler = GetBattlerForBattleScript(cmd->battler);
if (gProtectStructs[battler].shellTrap)
gBattlescriptCurrInstr = cmd->jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
}
void BS_JumpIfEmergencyExited(void)
{
NATIVE_ARGS(u8 battler, const u8 *jumpInstr);
u8 battler = GetBattlerForBattleScript(cmd->battler);
if (gSpecialStatuses[battler].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;
}