Created Changing the Battle Music Depending on the Opponent (markdown)

smithk200 2023-11-09 15:33:51 -06:00
parent 879d358a53
commit bcabc5f7ca
1 changed files with 26 additions and 0 deletions

@ -0,0 +1,26 @@
Goal: To make different trainers use different battle themes. This could be really useful for giving each Gym Leader or Elite Four member a different theme, or something.
For this tutorial, I'm going to replace Sidney of the Elite Four's battle with the Gym Leader theme. Note that the other Elite Four members will use the Elite Four battle theme.
Open src/pokemon.c.
Search for `u16 GetBattleBGM(void)`.
In the `switch (trainerClass)` statement, add a statement like this:
```diff
case TRAINER_CLASS_ELITE_FOUR:
+ if (gTrainerBattleOpponent_A == TRAINER_SIDNEY)
+ return MUS_VS_GYM_LEADER;
return MUS_VS_ELITE_FOUR;
```
And that's it!
## Copy and paste the code (optional)
Here's the statement so you can copy-and-paste it (I always found it annoying to delete the pluses when I wanted to copy-and-paste statements written in a diff format)
```
case TRAINER_CLASS_ELITE_FOUR:
+ if (gTrainerBattleOpponent_A == TRAINER_SIDNEY)
+ return MUS_VS_GYM_LEADER;
return MUS_VS_ELITE_FOUR;
```