Skip to content

Custom Battle Mugshots

ghoulslash edited this page Sep 29, 2020 · 1 revision

Custom Battle Mugshots

This feature lets us use any trainer for the elite four mugshot battle intro:

First, lets move the mugshot IDs to a constants

enum // TRANSITION_MUGSHOT
{
    MUGSHOT_SIDNEY,
    MUGSHOT_PHOEBE,
    MUGSHOT_GLACIA,
    MUGSHOT_DRAKE,
    MUGSHOT_CHAMPION,
    MUGSHOTS_COUNT
};
  • create a new file, include/constants/battle_transition.h
#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

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)
#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

    u8 transition:7;
    u8 hasCustomTransition:1;
  • Open src/battle_setup.c. Find the function GetTrainerBattleTransition
  • Add the following code above Line 816: if (gTrainers[gTrainerBattleOpponent_A].trainerClass == TRAINER_CLASS_ELITE_FOUR)
    if (gTrainers[gTrainerBattleOpponent_A].hasCustomTransition)
        return gTrainers[gTrainerBattleOpponent_A].transition;
  • In 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
  • 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:
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:

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

        .hasCustomTransition = TRUE,
        .transition = B_TRANSITION_MUGSHOT,

Set the variable

We must define VAR_MUGSHOT_ID before our trainerbattle, and it should work!

For example:

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
Clone this wiki locally