Skip to content

Commit

Permalink
Dynamax messages (rh-hideout#3581)
Browse files Browse the repository at this point in the history
* Dynamax messages

* Convert various to callnative

* Remove battler argument from callnatives

* Rename i variable

* Fix missing else
  • Loading branch information
Bassoonian authored and PCG06 committed Nov 21, 2023
1 parent a3e1137 commit 586a8e9
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 66 deletions.
20 changes: 12 additions & 8 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,18 @@
.4byte \ptr
.endm

.macro trytrainerslidezmovemsg
callnative BS_TryTrainerSlideZMoveMsg
.endm

.macro trytrainerslidemegaevolutionmsg
callnative BS_TryTrainerSlideMegaEvolutionMsg
.endm

.macro trytrainerslidedynamaxmsg
callnative BS_TryTrainerSlideDynamaxMsg
.endm

@ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
Expand Down Expand Up @@ -2188,14 +2200,6 @@
various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES
.endm

.macro trytrainerslidezmovemsg battler:req
various \battler, VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE
.endm

.macro trytrainerslidemegaevolutionmsg battler:req
various \battler, VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION
.endm

@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7
Expand Down
11 changes: 6 additions & 5 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -7835,7 +7835,7 @@ BattleScript_FocusPunchSetUp::

BattleScript_MegaEvolution::
flushtextbox
trytrainerslidemegaevolutionmsg BS_ATTACKER
trytrainerslidemegaevolutionmsg
printstring STRINGID_MEGAEVOREACTING
BattleScript_MegaEvolutionAfterString:
waitmessage B_WAIT_TIME_LONG
Expand All @@ -7851,7 +7851,7 @@ BattleScript_MegaEvolutionAfterString:

BattleScript_WishMegaEvolution::
flushtextbox
trytrainerslidemegaevolutionmsg BS_ATTACKER
trytrainerslidemegaevolutionmsg
printstring STRINGID_FERVENTWISHREACHED
goto BattleScript_MegaEvolutionAfterString

Expand Down Expand Up @@ -7879,7 +7879,7 @@ BattleScript_PrimalReversionRet::

BattleScript_UltraBurst::
flushtextbox
trytrainerslidezmovemsg BS_ATTACKER
trytrainerslidezmovemsg
printstring STRINGID_ULTRABURSTREACTING
waitmessage B_WAIT_TIME_LONG
setbyte gIsCriticalHit, 0
Expand Down Expand Up @@ -10098,7 +10098,7 @@ BattleScript_JabocaRowapBerryActivate_Dmg:
@ z moves / effects
BattleScript_ZMoveActivateDamaging::
flushtextbox
trytrainerslidezmovemsg BS_ATTACKER
trytrainerslidezmovemsg
printstring STRINGID_ZPOWERSURROUNDS
playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL
printstring STRINGID_ZMOVEUNLEASHED
Expand All @@ -10107,7 +10107,7 @@ BattleScript_ZMoveActivateDamaging::

BattleScript_ZMoveActivateStatus::
flushtextbox
trytrainerslidezmovemsg BS_ATTACKER
trytrainerslidezmovemsg
savetarget
printstring STRINGID_ZPOWERSURROUNDS
playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL
Expand Down Expand Up @@ -10698,6 +10698,7 @@ BattleScript_EffectSteelsurge::

BattleScript_DynamaxBegins::
flushtextbox
trytrainerslidedynamaxmsg
returnatktoball
pause B_WAIT_TIME_SHORT
returntoball BS_SCRIPTING
Expand Down
1 change: 1 addition & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ struct BattleStruct
bool8 trainerSlideMegaEvolutionMsgDone;
bool8 trainerSlideZMoveMsgDone;
bool8 trainerSlideBeforeFirstTurnMsgDone;
bool8 trainerSlideDynamaxMsgDone;
u32 aiDelayTimer; // Counts number of frames AI takes to choose an action.
u32 aiDelayFrames; // Number of frames it took to choose an action.
bool8 transformZeroToHero[PARTY_SIZE][NUM_BATTLE_SIDES];
Expand Down
1 change: 1 addition & 0 deletions include/battle_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ enum
TRAINER_SLIDE_MEGA_EVOLUTION,
TRAINER_SLIDE_Z_MOVE,
TRAINER_SLIDE_BEFORE_FIRST_TURN,
TRAINER_SLIDE_DYNAMAX,
};

void BufferStringBattle(u16 stringID, u32 battler);
Expand Down
4 changes: 1 addition & 3 deletions include/constants/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@
#define VARIOUS_STORE_HEALING_WISH 152
#define VARIOUS_HIT_SWITCH_TARGET_FAILED 153
#define VARIOUS_TRY_REVIVAL_BLESSING 154
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 155
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 156
#define VARIOUS_GIVE_DROPPED_ITEMS 157
#define VARIOUS_GIVE_DROPPED_ITEMS 155

// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0
Expand Down
10 changes: 10 additions & 0 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -4091,6 +4091,7 @@ struct TrainerSlide
const u8 *msgMegaEvolution;
const u8 *msgZMove;
const u8 *msgBeforeFirstTurn;
const u8 *msgDynamax;
};

static const struct TrainerSlide sTrainerSlides[] =
Expand All @@ -4111,6 +4112,7 @@ static const struct TrainerSlide sTrainerSlides[] =
.msgMegaEvolution = sText_PowderExplodes,
.msgZMove = sText_Electromagnetism,
.msgBeforeFirstTurn = sText_GravityIntensified,
.msgDynamax = sText_TargetWokeUp,
},
*/
};
Expand Down Expand Up @@ -4296,6 +4298,14 @@ u32 ShouldDoTrainerSlide(u32 battler, u32 which)
return TRUE;
}
break;
case TRAINER_SLIDE_DYNAMAX:
if (sTrainerSlides[i].msgDynamax != NULL && !gBattleStruct->trainerSlideDynamaxMsgDone)
{
gBattleStruct->trainerSlideDynamaxMsgDone = TRUE;
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgDynamax;
return TRUE;
}
break;
}
break;
}
Expand Down
95 changes: 45 additions & 50 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -10671,55 +10671,6 @@ static void Cmd_various(void)
}
return;
}
case VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE:
{
VARIOUS_ARGS();
if ((i = ShouldDoTrainerSlide(battler, TRAINER_SLIDE_Z_MOVE)))
{
gBattleScripting.battler = battler;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
return;
}
break;
}
case VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION:
{
VARIOUS_ARGS();
if ((i = ShouldDoTrainerSlide(battler, TRAINER_SLIDE_MEGA_EVOLUTION)))
{
gBattleScripting.battler = battler;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
return;
}
break;
case VARIOUS_GIVE_DROPPED_ITEMS:
{
u8 i;
u8 battlers[] = {GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT),
GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)};
for (i = 0; i < 1 + IsDoubleBattle(); i++)
{
gLastUsedItem = gBattleResources->battleHistory->heldItems[battlers[i]];
gBattleResources->battleHistory->heldItems[battlers[i]] = ITEM_NONE;
if (gLastUsedItem && !(gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_WALLY_TUTORIAL)))
{
if(AddBagItem(gLastUsedItem, 1))
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ITEM_DROPPED;
else
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BAG_IS_FULL;
if (IsDoubleBattle())
BattleScriptPushCursor();
else
BattleScriptPush(gBattlescriptCurrInstr + 3);
gBattlescriptCurrInstr = BattleScript_ItemDropped;
return;
}
}
break;
}
}
} // End of switch (cmd->id)

gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down Expand Up @@ -16371,7 +16322,6 @@ void BS_TryRelicSong(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}


void BS_SetPledge(void)
{
NATIVE_ARGS(const u8 *jumpInstr);
Expand Down Expand Up @@ -16482,3 +16432,48 @@ void BS_SetPledgeStatus(void)
else
gBattlescriptCurrInstr = BattleScript_MoveEnd;
}

void BS_TryTrainerSlideZMoveMsg(void)
{
NATIVE_ARGS();
s32 shouldSlide;

if ((shouldSlide = ShouldDoTrainerSlide(gBattlerAttacker, TRAINER_SLIDE_Z_MOVE)))
{
gBattleScripting.battler = gBattlerAttacker;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = (shouldSlide == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
}
else
gBattlescriptCurrInstr = cmd->nextInstr;
}

void BS_TryTrainerSlideMegaEvolutionMsg(void)
{
NATIVE_ARGS();
s32 shouldSlide;

if ((shouldSlide = ShouldDoTrainerSlide(gBattlerAttacker, TRAINER_SLIDE_MEGA_EVOLUTION)))
{
gBattleScripting.battler = gBattlerAttacker;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = (shouldSlide == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
}
else
gBattlescriptCurrInstr = cmd->nextInstr;
}

void BS_TryTrainerSlideDynamaxMsg(void)
{
NATIVE_ARGS();
s32 shouldSlide;

if ((shouldSlide = ShouldDoTrainerSlide(gBattlerAttacker, TRAINER_SLIDE_DYNAMAX)))
{
gBattleScripting.battler = gBattlerAttacker;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = (shouldSlide == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
}
else
gBattlescriptCurrInstr = cmd->nextInstr;
}

0 comments on commit 586a8e9

Please sign in to comment.