1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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
```
|