From cb18c1eee19caa3195ae609101e9fdc3ad9a25d9 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 5 May 2024 13:19:20 -0400 Subject: [PATCH] v2.4.0: made enemy spawn logic near entrances a bit more strict --- .../shatteredpixeldungeon/levels/RegularLevel.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 03e6da364..50e48ded9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -77,7 +77,9 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PitfallTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap; import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster; +import com.watabou.utils.BArray; import com.watabou.utils.Bundle; +import com.watabou.utils.PathFinder; import com.watabou.utils.Point; import com.watabou.utils.Random; @@ -226,9 +228,12 @@ 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 boolean[] entranceFOV = new boolean[length()]; Point c = cellToPoint(entrance()); - ShadowCaster.castShadow(c.x, c.y, width(), entranceFOV, losBlocking, 8); + ShadowCaster.castShadow(c.x, c.y, width(), entranceFOV, losBlocking, 6); + PathFinder.buildDistanceMap(entrance(), BArray.not(solid, null), 8); while (mobsToSpawn > 0) { Mob mob = createMob(); @@ -244,7 +249,7 @@ public abstract class RegularLevel extends Level { mob.pos = pointToCell(roomToSpawn.random()); tries--; } while (tries >= 0 && (findMob(mob.pos) != null - || entranceFOV[mob.pos] || (roomToSpawn.isEntrance() && distance(entrance(), mob.pos) <= 5) + || entranceFOV[mob.pos] || PathFinder.distance[mob.pos] != Integer.MAX_VALUE || !passable[mob.pos] || solid[mob.pos] || !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this) @@ -265,7 +270,7 @@ public abstract class RegularLevel extends Level { mob.pos = pointToCell(roomToSpawn.random()); tries--; } while (tries >= 0 && (findMob(mob.pos) != null - || entranceFOV[mob.pos] || (roomToSpawn.isEntrance() && distance(entrance(), mob.pos) <= 5) + || entranceFOV[mob.pos] || PathFinder.distance[mob.pos] != Integer.MAX_VALUE || !passable[mob.pos] || solid[mob.pos] || !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this)