diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index ad3c52800..d437f5f7f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -260,7 +260,7 @@ public class Dungeon { QuickSlotButton.reset(); Toolbar.swappedQuickslots = false; - depth = 15; + depth = 1; branch = 0; generatedLevels.clear(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java index cc11d6581..1697c2623 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bombs/ShrapnelBomb.java @@ -49,7 +49,7 @@ public class ShrapnelBomb extends Bomb { boolean[] FOV = new boolean[Dungeon.level.length()]; Point c = Dungeon.level.cellToPoint(cell); - ShadowCaster.castShadow(c.x, c.y, FOV, Dungeon.level.losBlocking, 8); + ShadowCaster.castShadow(c.x, c.y, Dungeon.level.width(), FOV, Dungeon.level.losBlocking, 8); ArrayList affected = new ArrayList<>(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfChallenge.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfChallenge.java index 4c2f43a0d..558a75b0a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfChallenge.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfChallenge.java @@ -113,7 +113,7 @@ public class ScrollOfChallenge extends ExoticScroll { boolean[] visibleCells = new boolean[Dungeon.level.length()]; Point c = Dungeon.level.cellToPoint(pos); - ShadowCaster.castShadow(c.x, c.y, visibleCells, Dungeon.level.losBlocking, 8); + ShadowCaster.castShadow(c.x, c.y, Dungeon.level.width(), visibleCells, Dungeon.level.losBlocking, 8); int count=0; for (boolean b : visibleCells){ if (b) count++; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java index 1927b0c4e..a90ea7621 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java @@ -47,7 +47,7 @@ public class StoneOfDisarming extends Runestone { protected void activate(final int cell) { boolean[] FOV = new boolean[Dungeon.level.length()]; Point c = Dungeon.level.cellToPoint(cell); - ShadowCaster.castShadow(c.x, c.y, FOV, Dungeon.level.losBlocking, DIST); + ShadowCaster.castShadow(c.x, c.y, Dungeon.level.width(), FOV, Dungeon.level.losBlocking, DIST); int sX = Math.max(0, c.x - DIST); int eX = Math.min(Dungeon.level.width()-1, c.x + DIST); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 9e77ca432..c80bde435 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -1290,7 +1290,7 @@ public abstract class Level implements Bundlable { viewDist *= 1f + 0.25f*((Hero) c).pointsInTalent(Talent.FARSIGHT); } - ShadowCaster.castShadow( cx, cy, fieldOfView, blocking, viewDist ); + ShadowCaster.castShadow( cx, cy, width(), fieldOfView, blocking, viewDist ); } else { BArray.setFalse(fieldOfView); } 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 069c915b4..9241e1881 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -61,9 +61,9 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MagicalFire import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.entrance.EntranceRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit.ExitRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BlazingTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BurningTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap; @@ -73,6 +73,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap; 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.Bundle; import com.watabou.utils.Point; import com.watabou.utils.Random; @@ -213,7 +214,7 @@ public abstract class RegularLevel extends Level { ArrayList stdRooms = new ArrayList<>(); for (Room room : rooms) { - if (room instanceof StandardRoom && room != roomEntrance) { + if (room instanceof StandardRoom) { for (int i = 0; i < ((StandardRoom) room).mobSpawnWeight(); i++) { stdRooms.add(room); } @@ -222,6 +223,10 @@ public abstract class RegularLevel extends Level { Random.shuffle(stdRooms); Iterator stdRoomIter = stdRooms.iterator(); + boolean[] entranceFOV = new boolean[length()]; + Point c = cellToPoint(entrance()); + ShadowCaster.castShadow(c.x, c.y, width(), entranceFOV, losBlocking, 8); + while (mobsToSpawn > 0) { Mob mob = createMob(); Room roomToSpawn; @@ -236,6 +241,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) || !passable[mob.pos] || solid[mob.pos] || !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this) @@ -256,6 +262,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) || !passable[mob.pos] || solid[mob.pos] || !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java index 515b01dfc..554ed0777 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java @@ -30,18 +30,24 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap; import com.watabou.noosa.Image; import com.watabou.noosa.Tilemap; import com.watabou.utils.GameMath; +import com.watabou.utils.PathFinder; import com.watabou.utils.Point; import com.watabou.utils.Random; import java.util.ArrayList; -public class MineEntrance extends StandardRoom { +public class MineEntrance extends CaveRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{1, 0, 0}; + } @Override public int minWidth() { @@ -60,19 +66,24 @@ public class MineEntrance extends StandardRoom { @Override public void paint(Level level) { - Painter.fill( level, this, Terrain.WALL ); - Painter.fill( level, this, 1, Terrain.EMPTY ); - - for (Door door : connected.values()) { - door.set( Door.Type.REGULAR ); - } + super.paint(level); int entrance; + boolean valid = false; do { entrance = level.pointToCell(random(3)); - } while (level.findMob(entrance) != null || level.map[entrance] == Terrain.WALL); + for (int i : PathFinder.NEIGHBOURS9){ + if (level.map[entrance+i] != Terrain.WALL){ + valid = true; + } + } + } while (level.findMob(entrance) != null || !valid); Painter.set( level, entrance, Terrain.ENTRANCE ); + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, entrance+i, Terrain.EMPTY ); + } + QuestExit vis = new QuestExit(); Point e = level.cellToPoint(entrance); vis.pos(e.x - 1, e.y - 1); @@ -88,7 +99,8 @@ public class MineEntrance extends StandardRoom { if (Blacksmith.Quest.Type() == Blacksmith.Quest.CRYSTAL){ for (int i = 0; i < width()*height()/2; i ++){ Point r = random(1); - if (level.distance(level.pointToCell(r), entrance) > 1) { + if (level.distance(level.pointToCell(r), entrance) > 1 + && level.map[level.pointToCell(r)] != Terrain.WALL) { Painter.set(level, r, Terrain.MINE_CRYSTAL); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java index 33ffdc6c3..06d429b82 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java @@ -54,7 +54,11 @@ public class EntranceRoom extends StandardRoom { @Override public boolean canMerge(Level l, Point p, int mergeTerrain) { - return false; + if (Dungeon.depth <= 2) { + return false; + } else { + return super.canMerge(l, p, mergeTerrain); + } } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java index ab188734d..285b38177 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java @@ -40,7 +40,12 @@ public class ExitRoom extends StandardRoom { public int minHeight() { return Math.max(super.minHeight(), 5); } - + + @Override + public boolean isExit() { + return true; + } + public void paint(Level level) { Painter.fill( level, this, Terrain.WALL ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java index 2f52f3089..ce6f6341b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java @@ -21,7 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.mechanics; -import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.watabou.utils.BArray; @@ -46,7 +45,7 @@ public final class ShadowCaster { } } - public static void castShadow( int x, int y, boolean[] fieldOfView, boolean[] blocking, int distance ) { + public static void castShadow( int x, int y, int w, boolean[] fieldOfView, boolean[] blocking, int distance ) { if (distance >= MAX_DISTANCE){ distance = MAX_DISTANCE; @@ -55,18 +54,18 @@ public final class ShadowCaster { BArray.setFalse(fieldOfView); //set source cell to true - fieldOfView[y * Dungeon.level.width() + x] = true; + fieldOfView[y * w + x] = true; //scans octants, clockwise try { - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, -1, false); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, +1, true); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, +1, true); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, +1, false); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, +1, false); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, +1, -1, true); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, -1, true); - scanOctant(distance, fieldOfView, blocking, 1, x, y, 0.0, 1.0, -1, -1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, -1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, +1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, +1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, +1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, +1, false); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, +1, -1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, -1, true); + scanOctant(distance, fieldOfView, blocking, 1, x, y, w, 0.0, 1.0, -1, -1, false); } catch (Exception e){ ShatteredPixelDungeon.reportException(e); BArray.setFalse(fieldOfView); @@ -77,7 +76,7 @@ public final class ShadowCaster { //scans a single 45 degree octant of the FOV. //This can add up to a whole FOV by mirroring in X(mX), Y(mY), and X=Y(mXY) private static void scanOctant(int distance, boolean[] fov, boolean[] blocking, int row, - int x, int y, double lSlope, double rSlope, + int x, int y, int w, double lSlope, double rSlope, int mX, int mY, boolean mXY){ boolean inBlocking = false; @@ -112,11 +111,11 @@ public final class ShadowCaster { (int)Math.ceil((row + 0.5) * rSlope - 0.499)); //coordinates of source - int cell = x + y*Dungeon.level.width(); + int cell = x + y*w; //plus coordinates of current cell (including mirroring in x, y, and x=y) - if (mXY) cell += mX*start*Dungeon.level.width() + mY*row; - else cell += mX*start + mY*row*Dungeon.level.width(); + if (mXY) cell += mX*start*w + mY*row; + else cell += mX*start + mY*row*w; //for each column in this row, which for (col = start; col <= end; col++){ @@ -136,7 +135,7 @@ public final class ShadowCaster { //start a new scan, 1 row deeper, ending at the left side of current cell if (col != start){ - scanOctant(distance, fov, blocking, row+1, x, y, lSlope, + scanOctant(distance, fov, blocking, row+1, x, y, w, lSlope, //change in x over change in y (col - 0.5) / (row + 0.5), mX, mY, mXY); @@ -155,7 +154,7 @@ public final class ShadowCaster { } if (!mXY) cell += mX; - else cell += mX*Dungeon.level.width(); + else cell += mX*w; }