Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated trainer pic tutorial #6049

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 0 additions & 178 deletions docs/tutorials/how_to_trainer_class.md

This file was deleted.

98 changes: 98 additions & 0 deletions docs/tutorials/how_to_trainer_pic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# How to add a new trainer pic

## Content
* [Quick Summary](#quick-summary)
* [The Graphics](#the-graphics)
* [1. Edit the sprites](#2-edit-the-sprites)
* [2. Register the sprites](#2-register-the-sprites)
* [3. Connecting pictures to the data](#2-connecting-pictures-to-the-data)
* [The Data](#the-data)
* [4. Defining the trainer pic](#2-defining-the-trainer-pic)
* [Usage](#usage)

## Quick Summary
If you've done this before and just need a quick lookup, here's what files you need:
1. GFX into [graphics/trainers/front_pics](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/graphics/trainers/front_pics)
2. Palette into [graphics/trainers/palettes](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/graphics/trainers/palettes)
3. Point game to where graphic files are found: [src/data/graphics/trainers](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/graphics/trainers.h)
4. Add trainer to [include/constants/trainers.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/constants/trainers.h)

## The Graphics

### 1. Edit the sprites
We will start with a graphic that we want to use for our new trainer pic. Unlike with adding Pokémon, the trainer sprites aren't sorted in individual folders, but rather in one folder:
[graphics/trainers/front_pics](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/graphics/trainers/front_pics)

**Remember to limit yourself to 16 colors including transparency in the first slot!**

Export the pallette and place into the same folder.
fdeblasio marked this conversation as resolved.
Show resolved Hide resolved

### 2. Register the sprites
Sadly, just putting the image files into the graphics folder is not enough. To use the sprites we have to register them by linking the graphic files.
[src/data/graphics/trainers](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/graphics/trainers.h):
```diff
const u32 gTrainerPalette_RubySapphireBrendan[] = INCBIN_U32("graphics/trainers/palettes/ruby_sapphire_brendan.gbapal.lz");

const u32 gTrainerFrontPic_RubySapphireMay[] = INCBIN_U32("graphics/trainers/front_pics/ruby_sapphire.4bpp.lz");
const u32 gTrainerPalette_RubySapphireMay[] = INCBIN_U32("graphics/trainers/palettes/ruby_sapphire_may.gbapal.lz");

+ const u32 gTrainerFrontPic_myTrainerClass[] = INCBIN_U32("graphics/trainers/front_pics/myTrainerClass.4bpp.lz");
+ const u32 gTrainerPalette_myTrainerClass[] = INCBIN_U32("graphics/trainers/palettes/myTrainerClass.gbapal.lz");

const u8 gTrainerBackPic_Brendan[] = INCBIN_U8("graphics/trainers/back_pics/brendan.4bpp");
```

### 3. Connecting the Pictures to the Data
The last few things we have to do is prepare the graphics for usage. In [src/data/graphics/trainers.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/graphics/trainers.h) you'll find the gTrainerSprites struct, we need to add the trainer to this. You can just copy the last trainer type defined and edit it, but this is what it does: Connects the trainer type with the image we defined earlier.

So, finally, it needs to look like this:
```diff
define TRAINER_SPRITE(trainerPic, picFile, paletteFile, ...) \
[trainerPic] = \
{ \
.frontPic = {picFile, TRAINER_PIC_SIZE, trainerPic}, \
.palette = {paletteFile, trainerPic}, \
.mugshotCoords = {DEFAULT(0, __VA_ARGS__), DEFAULT_2(0, __VA_ARGS__)}, \
.mugshotRotation = DEFAULT_3(0x200, __VA_ARGS__), \
}

const struct TrainerSprite gTrainerSprites[] =
{
TRAINER_SPRITE(TRAINER_PIC_HIKER, gTrainerFrontPic_Hiker, gTrainerPalette_Hiker),
TRAINER_SPRITE(TRAINER_PIC_AQUA_GRUNT_M, gTrainerFrontPic_AquaGruntM, gTrainerPalette_AquaGruntM),
...
TRAINER_SPRITE(TRAINER_PIC_RS_MAY, gTrainerFrontPic_RubySapphireMay, gTrainerPalette_RubySapphireMay),
TRAINER_SPRITE(TRAINER_PIC_MY_TRAINER_CLASS, gTrainerFrontPic_myTrainerClass, gTrainerPalette_myTrainerClass)
};
```
### The Data
#### 4. Defining the trainer pic
Finally, let's bring it all together by defining our new trainer pic in [include/constants/trainers.h](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/include/constants/trainers.h):

```diff
#define TRAINER_PIC_RS_MAY 92
+ #define TRAINER_PIC_MY_TRAINER_CLASS 93

#define TRAINER_BACK_PIC_BRENDAN 0
#define TRAINER_BACK_PIC_MAY 1
```
Remember to count the number next to the trainer pic up by one!

## Usage
You can test your trainer type by going to [src/data/trainers](https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/data/trainers.h) and changing a trainer type. For example:
```diff
[TRAINER_BRENDAN_PLACEHOLDER] =
{
.partyFlags = 0,
.trainerClass = TRAINER_CLASS_RS_PROTAG,
.encounterMusic_gender = TRAINER_ENCOUNTER_MUSIC_MALE,
- .trainerPic = TRAINER_PIC_RS_BRENDAN,
+ .trainerPic = TRAINER_PIC_MY_TRAINER_CLASS,
.trainerName = _("BRENDAN"),
.items = {},
.doubleBattle = FALSE,
.aiFlags = 0,
.partySize = ARRAY_COUNT(sParty_BrendanLinkPlaceholder),
.party = {.NoItemDefaultMoves = sParty_BrendanLinkPlaceholder},
},
```
2 changes: 1 addition & 1 deletion include/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ extern const union AffineAnimCmd *const gAffineAnims_BattleSpriteContest[];
extern const union AnimCmd sAnim_GeneralFrame0[];
extern const union AnimCmd sAnim_GeneralFrame3[];
extern const union AnimCmd *const gAnims_MonPic[];
extern const union AnimCmd *const sAnims_Trainer[];
extern const union AnimCmd *const gAnims_Trainer[];
extern const struct TrainerSprite gTrainerSprites[];
extern const struct TrainerBacksprite gTrainerBacksprites[];

Expand Down
2 changes: 1 addition & 1 deletion src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const union AnimCmd *const gAnims_MonPic[MAX_MON_PIC_FRAMES] =
sAnim_MonPic_1,
};

const union AnimCmd *const sAnims_Trainer[] ={
const union AnimCmd *const gAnims_Trainer[] ={
sAnim_GeneralFrame0,
sAnim_GeneralFrame0,
};
Expand Down
4 changes: 2 additions & 2 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerPicId, u8 battlerPosition
gMultiuseSpriteTemplate = gMonSpritesGfxPtr->templates[battlerPosition];
else
gMultiuseSpriteTemplate = gBattlerSpriteTemplates[battlerPosition];
gMultiuseSpriteTemplate.anims = sAnims_Trainer;
gMultiuseSpriteTemplate.anims = gAnims_Trainer;
}
}

Expand All @@ -2232,7 +2232,7 @@ void SetMultiuseSpriteTemplateToTrainerFront(u16 trainerPicId, u8 battlerPositio
gMultiuseSpriteTemplate = gBattlerSpriteTemplates[battlerPosition];

gMultiuseSpriteTemplate.paletteTag = trainerPicId;
gMultiuseSpriteTemplate.anims = sAnims_Trainer;
gMultiuseSpriteTemplate.anims = gAnims_Trainer;
}

static void EncryptBoxMon(struct BoxPokemon *boxMon)
Expand Down
2 changes: 1 addition & 1 deletion src/trainer_pokemon_sprites.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void AssignSpriteAnimsTable(bool8 isTrainer)
if (!isTrainer)
sCreatingSpriteTemplate.anims = gAnims_MonPic;
else
sCreatingSpriteTemplate.anims = sAnims_Trainer;
sCreatingSpriteTemplate.anims = gAnims_Trainer;
}

static u16 CreatePicSprite(u16 species, bool8 isShiny, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 isTrainer)
Expand Down
Loading