Added class-based Poké Balls for trainers

Thanks to Ghoulslash for helping me optimizing things.
This commit is contained in:
LOuroboros 2022-10-13 12:18:20 -03:00
parent 839d7063fe
commit 90f79999bb
3 changed files with 34 additions and 0 deletions

View File

@ -175,6 +175,7 @@
#define B_EVOLUTION_AFTER_WHITEOUT GEN_LATEST // In Gen6+, Pokemon that qualify for evolution after battle will evolve even if the player loses.
#define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper)
#define B_AFFECTION_MECHANICS FALSE // In Gen6+, there's a stat called affection that can trigger different effects in battle. From LGPE onwards, those effects use friendship instead.
#define B_TRAINER_CLASS_POKE_BALLS GEN_LATEST // In Gen7+, trainers will use certain types of Poké Balls depending on their trainer class.
// Animation Settings
#define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle.

View File

@ -352,6 +352,7 @@
#define TRAINER_CLASS_PIKE_QUEEN 0x3f
#define TRAINER_CLASS_PYRAMID_KING 0x40
#define TRAINER_CLASS_RS_PROTAG 0x41
#define TRAINER_CLASS_COUNT 0x42
#define TRAINER_ENCOUNTER_MUSIC_MALE 0 // standard male encounter music
#define TRAINER_ENCOUNTER_MUSIC_FEMALE 1 // standard female encounter music

View File

@ -392,6 +392,32 @@ const struct TrainerMoney gTrainerMoneyTable[] =
{0xFF, 5}, // Any trainer class not listed above uses this
};
#if B_TRAINER_CLASS_POKE_BALLS >= GEN_7
static const u16 sTrainerBallTable[TRAINER_CLASS_COUNT] =
{
#if B_TRAINER_CLASS_POKE_BALLS == GEN_7
[TRAINER_CLASS_PKMN_BREEDER] = ITEM_FRIEND_BALL,
#elif B_TRAINER_CLASS_POKE_BALLS == GEN_8
[TRAINER_CLASS_PKMN_BREEDER] = ITEM_HEAL_BALL,
#endif
[TRAINER_CLASS_COOLTRAINER] = ITEM_ULTRA_BALL,
[TRAINER_CLASS_COLLECTOR] = ITEM_PREMIER_BALL,
[TRAINER_CLASS_SWIMMER_M] = ITEM_DIVE_BALL,
[TRAINER_CLASS_BLACK_BELT] = ITEM_ULTRA_BALL,
[TRAINER_CLASS_AQUA_LEADER] = ITEM_MASTER_BALL,
[TRAINER_CLASS_GENTLEMAN] = ITEM_LUXURY_BALL,
[TRAINER_CLASS_ELITE_FOUR] = ITEM_ULTRA_BALL,
#if B_TRAINER_CLASS_POKE_BALLS == GEN_7
[TRAINER_CLASS_FISHERMAN] = ITEM_LURE_BALL,
#elif B_TRAINER_CLASS_POKE_BALLS == GEN_8
[TRAINER_CLASS_FISHERMAN] = ITEM_DIVE_BALL,
#endif
[TRAINER_CLASS_SWIMMER_F] = ITEM_DIVE_BALL,
[TRAINER_CLASS_COOLTRAINER_2] = ITEM_ULTRA_BALL,
[TRAINER_CLASS_MAGMA_LEADER] = ITEM_MASTER_BALL,
};
#endif
#include "data/text/abilities.h"
static void (* const sTurnActionsFuncsTable[])(void) =
@ -1847,6 +1873,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
u8 fixedIV;
s32 i, j;
u8 monsCount;
u16 ball;
if (trainerNum == TRAINER_SECRET_BASE)
return 0;
@ -1950,6 +1977,11 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
break;
}
}
#if B_TRAINER_CLASS_POKE_BALLS >= GEN_7
ball = (sTrainerBallTable[gTrainers[trainerNum].trainerClass]) ? sTrainerBallTable[gTrainers[trainerNum].trainerClass] : ITEM_POKE_BALL;
SetMonData(&party[i], MON_DATA_POKEBALL, &ball);
#endif
}
gBattleTypeFlags |= gTrainers[trainerNum].doubleBattle;