Updated code and formatting

Scyrous 2024-08-04 12:28:03 +02:00
parent c5d9b7bf85
commit 7b488947a2
1 changed files with 70 additions and 49 deletions

@ -6,7 +6,7 @@ This feature lets us use any trainer for the elite four mugshot battle intro:
### 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
- Add `#include "constants/battle_transition.h"` to the top
- remove the following:
```
enum // TRANSITION_MUGSHOT
@ -52,8 +52,8 @@ Now you can use `MUGSHOT_##` in scripts. This will be relevant later.
### 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
B_TRANSITION_MUGSHOT
B_TRANSITION_COUNT
```
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.
@ -69,24 +69,44 @@ Inside `include/constants/vars.h`, replace an unused variable or add your own: `
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;
- Add the following code:
```diff
if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
return B_TRANSITION_CHAMPION;
+ if (gTrainers[gTrainerBattleOpponent_A].hasCustomTransition)
+ return gTrainers[gTrainerBattleOpponent_A].transition;
+
if (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR)
{
```
- 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)
- Add `static void Task_Mugshot(u8 taskId);` in the function declarations. For example, above `static void Task_Sidney(u8 taskId);`
- Add the new transition to `sTasks_Main` by adding `[B_TRANSITION_MUGSHOT] = Task_Mugshot,` to the array.
- Add our new function:
```diff
static void Task_Mugshot(u8 taskId)
// Sprite data for trainer sprites in mugshots
#define sState data[0]
#define sSlideSpeed data[1]
#define sSlideAccel data[2]
#define sDone data[6]
#define sSlideDir data[7]
+static void Task_Mugshot(u8 taskId)
+{
+ gTasks[taskId].tMugshotId = VarGet(VAR_MUGSHOT_ID);
+ DoMugshotTransition(taskId);
+}
+
static void Task_Sidney(u8 taskId)
{
gTasks[taskId].tMugshotId = VarGet(VAR_MUGSHOT_ID);
Phase2Task_MugShotTransition(taskId);
gTasks[taskId].tMugshotId = MUGSHOT_SIDNEY;
DoMugshotTransition(taskId);
}
```
@ -137,6 +157,7 @@ static const u16 *const sOpponentMugshotsPals[MUGSHOTS_COUNT] =
[MUGSHOT_CHAMPION] = sMugshotPal_Champion
};
```
In `sOpponentMugshotsPals`, we reuse Glacia's pink background palette, but you can change this as you see fit or create your own custom palette.
### Change Relevant Trainer Data
- Open [src/data/trainers.h](../blob/master/src/data/trainers.h)