diff options
author | ghoulslash <41651341+ghoulslash@users.noreply.github.com> | 2020-09-29 10:40:34 -0600 |
---|---|---|
committer | ghoulslash <41651341+ghoulslash@users.noreply.github.com> | 2020-09-29 10:40:34 -0600 |
commit | 640adfc24853b8ed647c9800b84cfad138ef4535 (patch) | |
tree | 9d5d7c6af40d1475b8e7f8da2ddd9c7fa9c180b3 | |
parent | 89967c2d7ec1ffdacb3a6f5403fcdfbd166d38f2 (diff) |
Created Custom Battle Mugshots (markdown)
-rw-r--r-- | Custom-Battle-Mugshots.md | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/Custom-Battle-Mugshots.md b/Custom-Battle-Mugshots.md new file mode 100644 index 0000000..e21c3a4 --- /dev/null +++ b/Custom-Battle-Mugshots.md @@ -0,0 +1,161 @@ +## Custom Battle Mugshots + +This feature lets us use any trainer for the elite four mugshot battle intro: + +<a href="https://imgur.com/T47I2js"><img src="https://i.imgur.com/T47I2js.gif" title="source: imgur.com" /></a> + +### First, lets move the mugshot IDs to a constants +- Open [include/battle_transition.h](../blob/master/include/battle_transitions.h) +- Add `#include "constants/battle_transition.h` to the top +- remove the following: +``` +enum // TRANSITION_MUGSHOT +{ + MUGSHOT_SIDNEY, + MUGSHOT_PHOEBE, + MUGSHOT_GLACIA, + MUGSHOT_DRAKE, + MUGSHOT_CHAMPION, + MUGSHOTS_COUNT +}; +``` +- create a new file, `include/constants/battle_transition.h` +```c +#ifndef GUARD_CONSTANTS_BATTLE_TRANSITION_H +#define GUARD_CONSTANTS_BATTLE_TRANSITION_H + +#define MUGSHOT_SIDNEY 0 +#define MUGSHOT_PHOEBE 1 +#define MUGSHOT_GLACIA 2 +#define MUGSHOT_DRAKE 3 +#define MUGSHOT_CHAMPION 4 + +#define MUGSHOTS_COUNT 5 + +#endif //GUARD_CONSTANTS_BATTLE_TRANSITION_H +``` + +### Allow scripts to recognize these constants +- Open [data/event_scripts.s](../blob/master/data/event_scripts.s) +- Add `#include "constants/battle_transition.h"` somewhere at the top + +Now you can use `MUGSHOT_##` in scripts. This will be relevant later. + +### Define a new mugshot Id +- Let's define a new mugshot for our trainer. I will use May as an example. +- Inside the new `constants/battle_transition.h`, define a new ID (and increase `MUGSHOT_COUNT`) +```c +#define MUGSHOT_MAY 5 +#define MUGSHOT_COUNT 6 +``` + +### Define a new mugshot type +At the bottom of `include/battle_transition.h`, replace `B_TRANSITION_COUNT` with: +``` +#define B_TRANSITION_MUGSHOT 42 +#define B_TRANSITION_COUNT 43 +``` + +Now we just need a way to load the appropriate mugshot for this transition type. We'll use a variable that we can set before battles. + +### Define a variable to load the mugshot ID +Inside `include/constants/vars.h`, replace an unused variable or add your own: `VAR_MUGSHOT_ID` + +### Allow trainers to have custom battle transitions +- Open [include/data.h](../blob/master/include/data.h) +- Add the following to `struct Trainer`: +```c + u8 transition:7; + u8 hasCustomTransition:1; +``` +- Open [src/battle_setup.c](../blob/master/src/battle_setup.c). Find the function `GetTrainerBattleTransition` +- Add the following code above Line 816: `if (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR)` +```c + if (gTrainers[gTrainerBattleOpponent_A].hasCustomTransition) + return gTrainers[gTrainerBattleOpponent_A].transition; +``` +- In [src/data.c](../blob/master/src/data.c), we need to add `#include "battle_transition.h"` to the top as well. + +### Lets add the actual mugshot loading code +- Open [src/battle_transition.c](../blob/master/src/battle_transition.c) +- Add `#include "event_data.h"` to the top. +- Add `static void Phase2Task_Mugshot(u8 taskId);` in the function declarations. For example, above `static void Phase2Task_Sidney(u8 taskId);` +- Add the new transition to `sPhase2_Tasks` by adding `[B_TRANSITION_MUGSHOT] = Phase2Task_Mugshot,` to the array. +- Somewhere in the file, add our new function: +```c +static void Phase2Task_Mugshot(u8 taskId) +{ + gTasks[taskId].tMugshotId = VarGet(VAR_MUGSHOT_ID); + Phase2Task_MugShotTransition(taskId); +} +``` + +### Add Mugshot Id graphics +For each mugshot we've added, we need to add an element to the following: +- `sMugshotsTrainerPicIDsTable` +- `sMugshotsOpponentRotationScales`: ({0x200, 0x200} should be fine, but dealer's choice) +- `sMugshotsOpponentCoords`: ({0, 0} should be fine, but again its case-dependent) +- `sOpponentMugshotsPals` + +For example: +```diff +static const u8 sMugshotsTrainerPicIDsTable[MUGSHOTS_COUNT] = +static const u8 sMugshotsTrainerPicIDsTable[MUGSHOTS_COUNT] = +{ ++ [MUGSHOT_MAY] = TRAINER_PIC_MAY, + [MUGSHOT_SIDNEY] = TRAINER_PIC_ELITE_FOUR_SIDNEY, + [MUGSHOT_PHOEBE] = TRAINER_PIC_ELITE_FOUR_PHOEBE, + [MUGSHOT_GLACIA] = TRAINER_PIC_ELITE_FOUR_GLACIA, + [MUGSHOT_DRAKE] = TRAINER_PIC_ELITE_FOUR_DRAKE, + [MUGSHOT_CHAMPION] = TRAINER_PIC_CHAMPION_WALLACE, +}; +static const s16 sMugshotsOpponentRotationScales[MUGSHOTS_COUNT][2] = +{ ++ [MUGSHOT_MAY] = {0x200, 0x200}, + [MUGSHOT_SIDNEY] = {0x200, 0x200}, + [MUGSHOT_PHOEBE] = {0x200, 0x200}, + [MUGSHOT_GLACIA] = {0x1B0, 0x1B0}, + [MUGSHOT_DRAKE] = {0x1A0, 0x1A0}, + [MUGSHOT_CHAMPION] = {0x188, 0x188}, +}; +static const s16 sMugshotsOpponentCoords[MUGSHOTS_COUNT][2] = +{ ++ [MUGSHOT_MAY] = {0, 0}, + [MUGSHOT_SIDNEY] = {0, 0}, + [MUGSHOT_PHOEBE] = {0, 0}, + [MUGSHOT_GLACIA] = {-4, 4}, + [MUGSHOT_DRAKE] = {0, 5}, + [MUGSHOT_CHAMPION] = {-8, 7}, +}; +static const u16 *const sOpponentMugshotsPals[MUGSHOTS_COUNT] = +{ ++ [MUGSHOT_MAY] = sMugshotPal_Glacia, + [MUGSHOT_SIDNEY] = sMugshotPal_Sidney, + [MUGSHOT_PHOEBE] = sMugshotPal_Phoebe, + [MUGSHOT_GLACIA] = sMugshotPal_Glacia, + [MUGSHOT_DRAKE] = sMugshotPal_Drake, + [MUGSHOT_CHAMPION] = sMugshotPal_Champion +}; +``` + +### Change Relevant Trainer Data +- Open [src/data/trainers.h](../blob/master/src/data/trainers.h) +- Add the following to any trainer you want to give a mugshot +```c + .hasCustomTransition = TRUE, + .transition = B_TRANSITION_MUGSHOT, +``` + +### Set the variable +We must define `VAR_MUGSHOT_ID` before our trainerbattle, and it should work! + +For example: +```c +EventScript_BattleMay:: + lockall + faceplayer + msgbox sText_SomeIntro, MSGBOX_DEFAULT + setvar VAR_MUGSHOT_ID, MUGSHOT_MAY + trainerbattle_no_intro TRAINER_MAY_ROUTE_103_TORCHIC, sText_MayLose +``` + |