mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
convert a few various to callnatives
This commit is contained in:
parent
7ab3d37a7c
commit
34ba9b4e0d
@ -1310,6 +1310,33 @@
|
||||
callnative BS_CalcMetalBurstDmg
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
.macro setzeffect
|
||||
callnative BS_SetZEffect
|
||||
.endm
|
||||
|
||||
@ Used by effects that may proc Symbiosis but do not call removeitem.
|
||||
.macro trysymbiosis
|
||||
callnative BS_TrySymbiosis
|
||||
.endm
|
||||
|
||||
@ returns TRUE or FALSE to gBattleCommunication[0]
|
||||
.macro canteleport battler:req
|
||||
callnative BS_CanTeleport
|
||||
.byte \battler
|
||||
.endm
|
||||
|
||||
@ returns B_SIDE_x to gBattleCommunication[0]
|
||||
.macro getbattlerside battler:req
|
||||
callnative BS_GetBattlerSide
|
||||
.byte \battler
|
||||
.endm
|
||||
|
||||
.macro checkparentalbondcounter counter:req, ptr:req
|
||||
callnative BS_CheckParentalBondCounter
|
||||
.byte \counter
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
@ various command changed to more readable macros
|
||||
.macro cancelmultiturnmoves battler:req
|
||||
@ -1791,10 +1818,6 @@
|
||||
various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH
|
||||
.endm
|
||||
|
||||
.macro setzeffect
|
||||
various BS_ATTACKER, VARIOUS_SET_Z_EFFECT
|
||||
.endm
|
||||
|
||||
.macro consumeberry battler:req, frombattler:req
|
||||
various \battler, VARIOUS_CONSUME_BERRY
|
||||
.byte \frombattler
|
||||
@ -1986,20 +2009,6 @@
|
||||
various BS_ATTACKER, VARIOUS_SWAP_SIDE_STATUSES
|
||||
.endm
|
||||
|
||||
.macro canteleport battler:req
|
||||
various \battler, VARIOUS_CAN_TELEPORT
|
||||
.endm
|
||||
|
||||
.macro getbattlerside battler:req
|
||||
various \battler, VARIOUS_GET_BATTLER_SIDE
|
||||
.endm
|
||||
|
||||
.macro checkparentalbondcounter counter:req, ptr:req
|
||||
various BS_ATTACKER, VARIOUS_CHECK_PARENTAL_BOND_COUNTER
|
||||
.byte \counter
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
@ helpful macros
|
||||
.macro setstatchanger stat:req, stages:req, down:req
|
||||
setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7
|
||||
@ -2152,8 +2161,3 @@
|
||||
.macro skydropyawn
|
||||
various 0, VARIOUS_SKY_DROP_YAWN
|
||||
.endm
|
||||
|
||||
@ Used by effects that may proc Symbiosis but do not call removeitem.
|
||||
.macro trysymbiosis
|
||||
various BS_ATTACKER, VARIOUS_TRY_SYMBIOSIS
|
||||
.endm
|
||||
|
@ -241,11 +241,6 @@
|
||||
#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 150
|
||||
#define VARIOUS_SET_BEAK_BLAST 151
|
||||
#define VARIOUS_SWAP_SIDE_STATUSES 152
|
||||
#define VARIOUS_SET_Z_EFFECT 153
|
||||
#define VARIOUS_TRY_SYMBIOSIS 154
|
||||
#define VARIOUS_CAN_TELEPORT 155
|
||||
#define VARIOUS_GET_BATTLER_SIDE 156
|
||||
#define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157
|
||||
|
||||
// Cmd_manipulatedamage
|
||||
#define DMG_CHANGE_SIGN 0
|
||||
|
@ -9434,9 +9434,6 @@ static void Cmd_various(void)
|
||||
gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe)
|
||||
}
|
||||
return;
|
||||
case VARIOUS_SET_Z_EFFECT:
|
||||
SetZEffect(); //handles battle script jumping internally
|
||||
return;
|
||||
case VARIOUS_MOVEEND_ITEM_EFFECTS:
|
||||
if (ItemBattleEffects(ITEMEFFECT_NORMAL, gActiveBattler, FALSE))
|
||||
return;
|
||||
@ -10035,39 +10032,6 @@ static void Cmd_various(void)
|
||||
case VARIOUS_SWAP_SIDE_STATUSES:
|
||||
CourtChangeSwapSideStatuses();
|
||||
break;
|
||||
case VARIOUS_TRY_SYMBIOSIS: //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem.
|
||||
if (SYMBIOSIS_CHECK(gActiveBattler, BATTLE_PARTNER(gActiveBattler)))
|
||||
{
|
||||
BestowItem(BATTLE_PARTNER(gActiveBattler), gActiveBattler);
|
||||
gLastUsedAbility = gBattleMons[BATTLE_PARTNER(gActiveBattler)].ability;
|
||||
gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(gActiveBattler);
|
||||
gBattlerAttacker = gActiveBattler;
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_SymbiosisActivates;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case VARIOUS_CAN_TELEPORT:
|
||||
gBattleCommunication[0] = CanTeleport(gActiveBattler);
|
||||
break;
|
||||
case VARIOUS_GET_BATTLER_SIDE:
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
gBattleCommunication[0] = B_SIDE_PLAYER;
|
||||
else
|
||||
gBattleCommunication[0] = B_SIDE_OPPONENT;
|
||||
break;
|
||||
case VARIOUS_CHECK_PARENTAL_BOND_COUNTER:
|
||||
{
|
||||
// Some effects should only happen on the first or second strike of Parental Bond,
|
||||
// so a way to check this in battle scripts is useful
|
||||
u8 counter = T1_READ_8(gBattlescriptCurrInstr + 3);
|
||||
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == counter && gBattleMons[gBattlerTarget].hp != 0)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4);
|
||||
else
|
||||
gBattlescriptCurrInstr += 8;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
} // End of switch (gBattlescriptCurrInstr[2])
|
||||
|
||||
gBattlescriptCurrInstr += 3;
|
||||
@ -14861,3 +14825,62 @@ static bool8 IsFinalStrikeEffect(u16 move)
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 10 bytes long (callnative(5) + counter(1) + ptr(4))
|
||||
void BS_CheckParentalBondCounter(void)
|
||||
{
|
||||
// Some effects should only happen on the first or second strike of Parental Bond,
|
||||
// so a way to check this in battle scripts is useful
|
||||
u8 counter = T1_READ_8(gBattlescriptCurrInstr + 5);
|
||||
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == counter && gBattleMons[gBattlerTarget].hp != 0)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 6);
|
||||
else
|
||||
gBattlescriptCurrInstr += 10;
|
||||
}
|
||||
|
||||
// 6 bytes long (callnative(5) + battler(1))
|
||||
void BS_GetBattlerSide(void)
|
||||
{
|
||||
u8 battler = gBattlescriptCurrInstr[5];
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
gBattleCommunication[0] = B_SIDE_PLAYER;
|
||||
else
|
||||
gBattleCommunication[0] = B_SIDE_OPPONENT;
|
||||
|
||||
gBattlescriptCurrInstr += 6;
|
||||
}
|
||||
|
||||
// 6 bytes long (callnative(5) + battler(1))
|
||||
void BS_CanTeleport(void)
|
||||
{
|
||||
u8 battler = gBattlescriptCurrInstr[5];
|
||||
gBattleCommunication[0] = CanTeleport(battler);
|
||||
gBattlescriptCurrInstr += 6;
|
||||
}
|
||||
|
||||
// 5 bytes long
|
||||
void BS_TrySymbiosis(void)
|
||||
{
|
||||
//called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem.
|
||||
gActiveBattler = gBattlerAttacker;
|
||||
if (SYMBIOSIS_CHECK(gBattlerAttacker, BATTLE_PARTNER(gActiveBattler)))
|
||||
{
|
||||
BestowItem(BATTLE_PARTNER(gActiveBattler), gActiveBattler);
|
||||
gLastUsedAbility = gBattleMons[BATTLE_PARTNER(gActiveBattler)].ability;
|
||||
gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(gActiveBattler);
|
||||
gBattlerAttacker = gActiveBattler;
|
||||
BattleScriptPushCursor(gBattlescriptCurrInstr + 5);
|
||||
gBattlescriptCurrInstr = BattleScript_SymbiosisActivates;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattlescriptCurrInstr += 5;
|
||||
}
|
||||
}
|
||||
|
||||
void BS_SetZEffect(void)
|
||||
{
|
||||
SetZEffect(); // Handles battle script jumping internally
|
||||
}
|
||||
|
||||
|
||||
|
@ -593,7 +593,7 @@ const u8 *GetZMoveName(u16 move)
|
||||
return gZMoveNames[0]; // Failsafe
|
||||
}
|
||||
|
||||
#define Z_EFFECT_BS_LENGTH 3
|
||||
#define Z_EFFECT_BS_LENGTH 5
|
||||
// This function kinda cheats by setting a return battle script to after the setzeffect various command
|
||||
// and then jumping to a z effect script
|
||||
void SetZEffect(void)
|
||||
@ -684,7 +684,7 @@ void SetZEffect(void)
|
||||
gBattlescriptCurrInstr = BattleScript_StatUpZMove;
|
||||
break;
|
||||
default:
|
||||
gBattlescriptCurrInstr += 3;
|
||||
gBattlescriptCurrInstr += Z_EFFECT_BS_LENGTH;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user