Fix names and constant usage for union room classes

This commit is contained in:
GriffinR 2022-08-23 12:39:24 -04:00
parent 8a8ba92f21
commit 3771abbe08
7 changed files with 26 additions and 20 deletions

View File

@ -247,9 +247,6 @@
#define EVO_MODE_ITEM_USE 2
#define EVO_MODE_ITEM_CHECK 3 // If an Everstone is being held, still want to show that the stone *could* be used on that Pokémon to evolve
#define NUM_MALE_LINK_FACILITY_CLASSES 8
#define NUM_FEMALE_LINK_FACILITY_CLASSES 8
#define MON_PIC_WIDTH 64
#define MON_PIC_HEIGHT 64
#define MON_PIC_SIZE (MON_PIC_WIDTH * MON_PIC_HEIGHT / 2)

View File

@ -13,6 +13,10 @@
#define UNION_ROOM_MAX_LEVEL 30
// The number of possible trainer classes for a trainer of a given gender in the Union Room.
// This value is necessarily a power of 2 because of the way it's treated in GetUnionRoomTrainerPic / GetUnionRoomTrainerClass
#define NUM_UNION_ROOM_CLASSES (1 << 3) // 8
#define ACTIVITY_NONE 0
#define ACTIVITY_BATTLE_SINGLE 1
#define ACTIVITY_BATTLE_DOUBLE 2

View File

@ -382,7 +382,7 @@ extern const u8 gPPUpGetMask[];
extern const u8 gPPUpClearMask[];
extern const u8 gPPUpAddValues[];
extern const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2];
extern const u16 gLinkPlayerFacilityClasses[];
extern const u16 gUnionRoomFacilityClasses[];
extern const struct SpriteTemplate gBattlerSpriteTemplates[];
extern const s8 gNatureStatTable[][5];

View File

@ -54,7 +54,7 @@ struct TrainerCard
/*0x4C*/ bool8 shouldDrawStickers; // FRLG only
/*0x4D*/ u8 unused;
/*0x4E*/ u8 monIconTint; // FRLG only
/*0x4F*/ u8 facilityClass;
/*0x4F*/ u8 unionRoomClass;
/*0x50*/ u8 stickers[TRAINER_CARD_STICKER_TYPES]; // FRLG only
/*0x54*/ u16 monSpecies[PARTY_SIZE]; // FRLG only
// Note: Link players use linkHasAllFrontierSymbols, not the field below,

View File

@ -46,6 +46,7 @@
#include "constants/moves.h"
#include "constants/songs.h"
#include "constants/trainers.h"
#include "constants/union_room.h"
struct SpeciesItem
{
@ -1884,7 +1885,9 @@ static const u16 sDeoxysBaseStats[] =
[STAT_SPDEF] = 90,
};
const u16 gLinkPlayerFacilityClasses[NUM_MALE_LINK_FACILITY_CLASSES + NUM_FEMALE_LINK_FACILITY_CLASSES] =
// The classes used by other players in the Union Room.
// These should correspond with the overworld graphics in sUnionRoomObjGfxIds
const u16 gUnionRoomFacilityClasses[NUM_UNION_ROOM_CLASSES * GENDER_COUNT] =
{
// Male classes
FACILITY_CLASS_COOLTRAINER_M,
@ -1895,7 +1898,7 @@ const u16 gLinkPlayerFacilityClasses[NUM_MALE_LINK_FACILITY_CLASSES + NUM_FEMALE
FACILITY_CLASS_BUG_CATCHER,
FACILITY_CLASS_PKMN_BREEDER_M,
FACILITY_CLASS_GUITARIST,
// Female Classes
// Female classes
FACILITY_CLASS_COOLTRAINER_F,
FACILITY_CLASS_HEX_MANIAC,
FACILITY_CLASS_PICNICKER,
@ -2740,9 +2743,9 @@ u16 GetUnionRoomTrainerPic(void)
else
linkId = GetMultiplayerId() ^ 1;
arrId = gLinkPlayers[linkId].trainerId & 7;
arrId |= gLinkPlayers[linkId].gender << 3;
return FacilityClassToPicIndex(gLinkPlayerFacilityClasses[arrId]);
arrId = gLinkPlayers[linkId].trainerId % NUM_UNION_ROOM_CLASSES;
arrId |= gLinkPlayers[linkId].gender * NUM_UNION_ROOM_CLASSES;
return FacilityClassToPicIndex(gUnionRoomFacilityClasses[arrId]);
}
u16 GetUnionRoomTrainerClass(void)
@ -2755,9 +2758,9 @@ u16 GetUnionRoomTrainerClass(void)
else
linkId = GetMultiplayerId() ^ 1;
arrId = gLinkPlayers[linkId].trainerId & 7;
arrId |= gLinkPlayers[linkId].gender << 3;
return gFacilityClassToTrainerClass[gLinkPlayerFacilityClasses[arrId]];
arrId = gLinkPlayers[linkId].trainerId % NUM_UNION_ROOM_CLASSES;
arrId |= gLinkPlayers[linkId].gender * NUM_UNION_ROOM_CLASSES;
return gFacilityClassToTrainerClass[gUnionRoomFacilityClasses[arrId]];
}
void CreateEventLegalEnemyMon(void)

View File

@ -31,6 +31,7 @@
#include "constants/battle_frontier.h"
#include "constants/rgb.h"
#include "constants/trainers.h"
#include "constants/union_room.h"
struct TrainerCardData
{
@ -761,9 +762,9 @@ static void TrainerCard_GenerateCardForPlayer(struct TrainerCard *trainerCard)
trainerCard->stars++;
if (trainerCard->gender == FEMALE)
trainerCard->facilityClass = gLinkPlayerFacilityClasses[(trainerCard->trainerId % NUM_FEMALE_LINK_FACILITY_CLASSES) + NUM_MALE_LINK_FACILITY_CLASSES];
trainerCard->unionRoomClass = gUnionRoomFacilityClasses[(trainerCard->trainerId % NUM_UNION_ROOM_CLASSES) + NUM_UNION_ROOM_CLASSES];
else
trainerCard->facilityClass = gLinkPlayerFacilityClasses[trainerCard->trainerId % NUM_MALE_LINK_FACILITY_CLASSES];
trainerCard->unionRoomClass = gUnionRoomFacilityClasses[trainerCard->trainerId % NUM_UNION_ROOM_CLASSES];
}
void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard *trainerCard)
@ -777,9 +778,9 @@ void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard *trainerCard)
trainerCard->stars++;
if (trainerCard->gender == FEMALE)
trainerCard->facilityClass = gLinkPlayerFacilityClasses[(trainerCard->trainerId % NUM_FEMALE_LINK_FACILITY_CLASSES) + NUM_MALE_LINK_FACILITY_CLASSES];
trainerCard->unionRoomClass = gUnionRoomFacilityClasses[(trainerCard->trainerId % NUM_UNION_ROOM_CLASSES) + NUM_UNION_ROOM_CLASSES];
else
trainerCard->facilityClass = gLinkPlayerFacilityClasses[trainerCard->trainerId % NUM_MALE_LINK_FACILITY_CLASSES];
trainerCard->unionRoomClass = gUnionRoomFacilityClasses[trainerCard->trainerId % NUM_UNION_ROOM_CLASSES];
}
void CopyTrainerCardData(struct TrainerCard *dst, struct TrainerCard *src, u8 gameVersion)
@ -1876,7 +1877,7 @@ static void CreateTrainerCardTrainerPic(void)
{
if (InUnionRoom() == TRUE && gReceivedRemoteLinkPlayers == 1)
{
CreateTrainerCardTrainerPicSprite(FacilityClassToPicIndex(sData->trainerCard.facilityClass),
CreateTrainerCardTrainerPicSprite(FacilityClassToPicIndex(sData->trainerCard.unionRoomClass),
TRUE,
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0],
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1],

View File

@ -24,7 +24,8 @@ static u32 IsUnionRoomPlayerInvisible(u32, u32);
static void SetUnionRoomObjectFacingDirection(s32, s32, u8);
// + 2 is just to match, those elements are empty and never read
static const u8 sUnionRoomObjGfxIds[GENDER_COUNT][MAX_UNION_ROOM_LEADERS + 2] = {
// Graphics ids should correspond with the classes in gUnionRoomFacilityClasses
static const u8 sUnionRoomObjGfxIds[GENDER_COUNT][NUM_UNION_ROOM_CLASSES + 2] = {
[MALE] = {
OBJ_EVENT_GFX_MAN_3,
OBJ_EVENT_GFX_BLACK_BELT,
@ -132,7 +133,7 @@ static bool32 IsPlayerStandingStill(void)
// Gender and trainer id are used to determine which sprite a player appears as
static u8 GetUnionRoomPlayerGraphicsId(u32 gender, u32 id)
{
return sUnionRoomObjGfxIds[gender][id % MAX_UNION_ROOM_LEADERS];
return sUnionRoomObjGfxIds[gender][id % NUM_UNION_ROOM_CLASSES];
}
static void GetUnionRoomPlayerCoords(u32 leaderId, u32 memberId, s32 * x, s32 * y)