v2.4.0: made enemy spawn logic near entrances a bit more strict

This commit is contained in:
Evan Debenham
2024-05-05 13:19:20 -04:00
parent 995d84e53a
commit cb18c1eee1

View File

@@ -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<Room> 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)