Battle BGM changes upon last switch in (Outdated) - Pawkkie/Team-Aquas-Asset-Repo GitHub Wiki
Amend
There is an easier version to do what's explained below!
Kasen pointed out that you can change the music by doing {PLAY_BGM MUS_NAME_OF_SONG} in the actual string of the last switch in slide in message.
Made using pokeemerald_expansion 1.9.2
https://github.com/user-attachments/assets/dcad0b5a-ae1d-44fa-9332-8334112d9b64
Battle BGM changes upon last switch in
redtruth (mako)
These edits reuse the call for the TRAINER_SLIDE_LAST_SWITCHIN message to also do a BGM shift, useful to implement the "Victory Lies Ahead Of You!" BGM Gen 5 features. By default this will play for every trainer that has a slide in message for the last switch in. I plan on editing this in the future to take a couple more arguments to switch to different BGMs (or not switch at all) based on the trainer ID or class. TBD.
Implementing the function
The project uses the src/battle_gfx_sfx_util.c
file to handle BGM and SEs for the battles, so I thought it'd be appropriate to put this function here. Replace MUS_LAST_POKEMON
accordingly.
+ void TryLastMonBGM(void)
+ {
+ ResetMapMusic();
+ m4aMPlayAllStop();
+ PlayBGM(MUS_LAST_POKEMON);
+ }
Also include the prototype of this function in the header file include/battle_gfx_sfx_util.h
+ void TryLastMonBGM(void)
This is more of an attempt of having functions where they make more sense and to make sure that everything is referenced in the file it fits for where it should be. Therefore, I implemented it this way:
In src/battle_controllers.c
, edit in:
+ void SetLastPokemonMusic (void)
+ {
+ TryLastMonBGM();
+ }
and insert its prototype in include/battle_controllers.h
+ void SetLastPokemonMusic (void);
Finally, go to src/battle_script_commands.c
and add this in:
case VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON:
{
VARIOUS_ARGS();
if ((i = ShouldDoTrainerSlide(battler, TRAINER_SLIDE_LAST_SWITCHIN)))
{
gBattleScripting.battler = battler;
BattleScriptPush(cmd->nextInstr);
gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
+ SetLastPokemonMusic();
return;
}
There is a way to add the battle_gfx_sfx_util as an include guard in src/battle_script_commands.c
to cut one step, but I thought this way made it neater.
That's all the changes necessary. Easy peazy.
If you'd like to use my implementation of Victory Lies Before Your Eyes!, you have to be aware that I'm using the NDS Music Expansion
feature branch, which does a few changes, but mostly it adds the voice samples and voice groups I reference in the song's voice group.
The midi file is HERE.
The voice group is HERE.