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 240dd06e8..0ddcca56d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -763,8 +763,14 @@ public abstract class Level implements Bundlable { GameScene.updateMap( cell ); } - public int pitCell() { - return randomRespawnCell(); + public int fallCell( boolean fallIntoPit ) { + int result; + do { + result = randomRespawnCell(); + } while (traps.get(result) != null + || findMob(result) != null + || heaps.get(result) != null); + return result; } public void press( int cell, Char ch ) { 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 eaf48f0de..58c53da71 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -40,7 +40,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; 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.special.WeakFloorRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; @@ -53,7 +52,6 @@ import com.watabou.utils.Random; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; public abstract class RegularLevel extends Level { @@ -374,14 +372,21 @@ public abstract class RegularLevel extends Level { } @Override - public int pitCell() { - for (Room room : rooms) { - if (room instanceof PitRoom || room.legacyType.equals("PIT")) { - return pointToCell(room.random()); + public int fallCell( boolean fallIntoPit ) { + if (fallIntoPit) { + for (Room room : rooms) { + if (room instanceof PitRoom || room.legacyType.equals("PIT")) { + int result; + do { + result = pointToCell(room.random()); + } while (traps.get(result) != null + || findMob(result) != null + || heaps.get(result) != null); + } } } - return super.pitCell(); + return super.fallCell( false ); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java index 0000dd64b..3d1d9de72 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/InterlevelScene.java @@ -233,7 +233,7 @@ public class InterlevelScene extends PixelScene { Dungeon.depth++; level = Dungeon.loadLevel( Dungeon.hero.heroClass ); } - Dungeon.switchLevel( level, fallIntoPit ? level.pitCell() : level.randomRespawnCell() ); + Dungeon.switchLevel( level, level.fallCell( fallIntoPit )); } private void ascend() throws IOException {