Document floorProps->enemyDensity bug

This commit is contained in:
darsh
2025-09-30 13:41:30 -04:00
parent 9201177a94
commit 9b3eff4847
2 changed files with 5 additions and 2 deletions

View File

@@ -120,12 +120,12 @@ typedef struct UnkDungeonGlobal_unk181E8_sub
typedef struct FloorProperties
{
u8 layout;
s8 roomDensity;
s8 roomDensity; // If positive, allow variance. If negative, use exact value of abs(roomDensity).
u8 tileset;
u8 bgMusic;
u8 weather; // Uses the weather constants in weather.h.
u8 floorConnectivity;
u8 enemyDensity;
u8 enemyDensity; // Game treats this as signed. See SpawnEnemies in src/dungeon_generation.asm for details.
u8 kecleonShopChance; // Percentage chance 0-100%
u8 monsterHouseChance; // Percentage chance 0-100%
u8 mazeRoomChance; // Percentage chance 0-100%

View File

@@ -4423,6 +4423,9 @@ static void SpawnEnemies(FloorProperties *floorProps, bool8 isEmptyMonsterHouse)
s32 numEnemies, numMonsterHouseEnemies;
s32 enemyDensity = floorProps->enemyDensity;
// BUG: Game assumes floorProps->enemyDensity is a signed byte, but in reality it's unsigned.
// Attempting to use a negative density will instead produce a very large positive density up to 255.
// This only matters for unused dungeons, as Deoxys has its own logic despite Meteor Cave having an effective enemy density of 255.
if (enemyDensity > 0) {
// Positive means value with variance
numEnemies = DungeonRandRange(enemyDensity / 2, enemyDensity);