GenerateFloor matched

This commit is contained in:
DizzyEggg 2024-11-18 17:16:24 +01:00
parent 378a00c510
commit 9c461115bb
9 changed files with 248 additions and 794 deletions

View File

@ -9,6 +9,26 @@
#define GENERATION_CONSTANT_NO_IMPERFECTIONS_CHANCE 60 // (0 to 100) probability that a room will not have imperfections, if it was already flagged for them
#define GENERATION_CONSTANT_SECONDARY_STRUCTURE_FLAG_CHANCE 80 // (0 to 100) probability that a room will be flagged to have a secondary structure.
enum FloorLayout {
LAYOUT_LARGE,
LAYOUT_SMALL,
LAYOUT_ONE_ROOM_MONSTER_HOUSE,
LAYOUT_OUTER_RING,
LAYOUT_CROSSROADS,
LAYOUT_TWO_ROOMS_WITH_MONSTER_HOUSE,
LAYOUT_LINE,
LAYOUT_CROSS,
LAYOUT_LARGE_0x8,
LAYOUT_BEETLE,
LAYOUT_OUTER_ROOMS,
LAYOUT_MEDIUM,
LAYOUT_UNUSED_0xC,
LAYOUT_UNUSED_0xD,
LAYOUT_UNUSED_0xE,
LAYOUT_UNUSED_0xF,
NUM_FLOOR_LAYOUTS
};
enum FloorSize {
FLOOR_SIZE_LARGE,
FLOOR_SIZE_SMALL,
@ -31,6 +51,7 @@ enum SecondaryStructureType {
SECONDARY_STRUCTURE_DIVIDER, // A "divider" of secondary terrain will split the room in half randomly either horizontally or vertically.
};
void GenerateFloor(void);
bool8 StairsAlwaysReachable(s32 stairsX, s32 stairsY, bool8 markUnreachable);
#endif

View File

@ -123,7 +123,7 @@ typedef struct UnkDungeonGlobal_unk181E8_sub
// Defines many of the key properties for dungeon generation, such as the type of layout, base number of rooms, and floor connectivity.
typedef struct FloorProperties
{
u8 unk0;
u8 layout;
s8 roomDensity;
u8 unk2;
u8 unk3;
@ -148,7 +148,7 @@ typedef struct FloorProperties
u8 unk16;
u8 unk17;
u8 unk18;
u8 unk19;
u8 itemlessMonsterHouseChance; // Chance that a monster house will be itemless
u8 unk1A;
} FloorProperties;
@ -371,7 +371,7 @@ typedef struct Dungeon
/* 0x3A0E */ s16 tileset;
/* 0x3A10 */ s16 unk3A10;
/* 0x3A12 */ s16 unk3A12;
/* 0x3A14 */ s16 fixedRoomId;
/* 0x3A14 */ s16 fixedRoomNumber;
/* 0x3A16 */ s16 unk3A16;
/* 0x3A18 */ Tile tiles[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
/* 0xEA18 */ DungeonPos playerSpawn;

View File

@ -311,7 +311,6 @@ extern void sub_803DF60(void);
extern void sub_803E02C(void);
extern void sub_8049840(void);
extern void sub_80847D4(void);
extern void sub_804AFAC(void);
extern void sub_8043D60(void);
extern void sub_806890C(void);
extern void sub_8068614(void);
@ -607,7 +606,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
gDungeon->weather.weather = 0;
gDungeon->tileset = gDungeon->unk1C574.unk2;
gDungeon->unk3A10 = gDungeon->unk1C574.unk3;
gDungeon->fixedRoomId = gDungeon->unk1C574.unk12;
gDungeon->fixedRoomNumber = gDungeon->unk1C574.unk12;
sub_807E5E4(0);
sub_80842F0();
}
@ -637,7 +636,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
ShowDungeonNameBanner();
if (!r6) {
sub_804AFAC();
GenerateFloor();
gDungeon->unk644.windTurns = GetTurnLimit(gDungeon->unk644.dungeonLocation.id);
gDungeon->unk644.unk36 = 0;
}

View File

@ -197,13 +197,13 @@ bool8 sub_806F660(Entity *pokemon,Entity *target)
targetInfo = target->info;
iVar8 = -1;
size = GetBodySize(targetInfo->apparentID);
if ((1 < ((u16)(gDungeon->fixedRoomId - 4))) && (gDungeon->fixedRoomId != 9) && (gDungeon->fixedRoomId != 0xf)) {
if ((u16)(gDungeon->fixedRoomId - 0x2cU) < 5) {
if ((1 < ((u16)(gDungeon->fixedRoomNumber - 4))) && (gDungeon->fixedRoomNumber != 9) && (gDungeon->fixedRoomNumber != 0xf)) {
if ((u16)(gDungeon->fixedRoomNumber - 0x2cU) < 5) {
if (gDungeon->unk644.unk18 == 0) {
return FALSE;
}
}
else if (gDungeon->fixedRoomId == 0x31) {
else if (gDungeon->fixedRoomNumber == 0x31) {
if (gDungeon->unk644.unk15 == 0) {
return FALSE;
}

View File

@ -20,18 +20,18 @@ void sub_8084854(struct unkData_8107234 *);
void sub_80847D4(void)
{
u32 fixedRoomId;
u32 fixedRoomNumber;
s32 index;
gDungeon->unk3A0D = 0;
gDungeon->unk1356C = 0;
sub_8040A84();
for(index = 0; index < 0x3e7 && gUnknown_8107234[index].unk0[0] != 0; index++) {
fixedRoomId = gDungeon->fixedRoomId;
if (fixedRoomId - 0x1c < 0x16) {
fixedRoomId = 0x1b;
fixedRoomNumber = gDungeon->fixedRoomNumber;
if (fixedRoomNumber - 0x1c < 0x16) {
fixedRoomNumber = 0x1b;
}
if (fixedRoomId == gUnknown_8107234[index].unk0[0])
if (fixedRoomNumber == gUnknown_8107234[index].unk0[0])
{
sub_8084854(&gUnknown_8107234[index]);
break;

View File

@ -34,7 +34,7 @@ static bool8 xxx_dungeon_80442D0(bool8);
bool8 IsBossFight()
{
if (gDungeon->fixedRoomId != 0 && gDungeon->fixedRoomId <= 0x31)
if (gDungeon->fixedRoomNumber != 0 && gDungeon->fixedRoomNumber <= 0x31)
{
return TRUE;
}

File diff suppressed because it is too large Load Diff

View File

@ -414,7 +414,7 @@ static void WriteDungeonFloor(DataSerializer *seri)
WriteS16(seri, gDungeon->tileset);
WriteS16(seri,gDungeon->unk3A10);
WriteS16(seri, gDungeon->unk3A12);
WriteS16(seri, gDungeon->fixedRoomId);
WriteS16(seri, gDungeon->fixedRoomNumber);
WriteS16(seri, gDungeon->unk3A16);
for (y = 0; y < DUNGEON_MAX_SIZE_Y; y++) {
@ -776,7 +776,7 @@ static void ReadDungeonFloor(DataSerializer *seri)
gDungeon->tileset = ReadS16(seri);
gDungeon->unk3A10 = ReadS16(seri);
gDungeon->unk3A12 = ReadS16(seri);
gDungeon->fixedRoomId = ReadS16(seri);
gDungeon->fixedRoomNumber = ReadS16(seri);
gDungeon->unk3A16 = ReadS16(seri);
for (y = 0; y < DUNGEON_MAX_SIZE_Y; y++) {

View File

@ -274,7 +274,7 @@ gUnknown_202EE76: /* 202EE76 (sub_804513C - sub_8082A08) */
.space 0x10
.include "src/dungeon_map_access.o"
.include "src/dungeon_generation.o"
.include "src/dungeon_generation.o"
.include "src/dungeon_message.o"
.include "src/dungeon_move.o"
.include "src/code_805D8C8_1.o"