From 18a03c1d21a98acb65683474a989f9d1b613eca8 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 16 May 2025 17:40:31 -0400 Subject: [PATCH] v3.1.0: improved logic for fairly placing enemies near entrances --- .../levels/RegularLevel.java | 20 +++++++++++++++---- .../levels/rooms/standard/StandardRoom.java | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 550e6d0ef..804b6c098 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -231,12 +231,24 @@ public abstract class RegularLevel extends Level { Random.shuffle(stdRooms); Iterator stdRoomIter = stdRooms.iterator(); - //enemies cannot be within an 8-tile FOV of the entrance - // or a 6-tile open space distance from the entrance + //enemies cannot be within a 8-tile FOV or 8-tile open space walk from the entrance boolean[] entranceFOV = new boolean[length()]; Point c = cellToPoint(entrance()); - ShadowCaster.castShadow(c.x, c.y, width(), entranceFOV, losBlocking, 6); - PathFinder.buildDistanceMap(entrance(), BArray.not(solid, null), 8); + ShadowCaster.castShadow(c.x, c.y, width(), entranceFOV, losBlocking, 8); + + boolean[] entranceWalkable = BArray.not(solid, null); + + //doors within the entrance room are ignored for this walk, but doors on the edge are not + for (int y = roomEntrance.top+1; y < roomEntrance.bottom; y++){ + for (int x = roomEntrance.left+1; x < roomEntrance.right; x++){ + int cell = x + y*width(); + if (passable[cell]){ + entranceWalkable[cell] = true; + } + } + } + + PathFinder.buildDistanceMap(entrance(), entranceWalkable, 8); Mob mob = null; while (mobsToSpawn > 0) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index 55db55b27..b1783ce92 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -104,6 +104,9 @@ public abstract class StandardRoom extends Room { } public int mobSpawnWeight(){ + if (isEntrance()){ + return 1; //entrance rooms don't have higher mob spawns even if they're larger + } return sizeFactor(); }