diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java index fa5478473..ff52fabe4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/RockfallTrap.java @@ -58,9 +58,12 @@ public class RockfallTrap extends Trap { //determines if the trap is actually in the world, or if it is being spawned for its effect boolean onGround = Dungeon.level.traps.get(pos) == this; + Room r = null; + if (Dungeon.level instanceof RegularLevel){ + r = ((RegularLevel) Dungeon.level).room(pos); + } - if (onGround && Dungeon.level instanceof RegularLevel){ - Room r = ((RegularLevel) Dungeon.level).room(pos); + if (onGround && r != null){ int cell; for (Point p : r.getPoints()){ cell = Dungeon.level.pointToCell(p); @@ -69,7 +72,7 @@ public class RockfallTrap extends Trap { } } - //if we don't have rooms, then just do 5x5 + //if we don't have a room, then just do 5x5 } else { PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 ); for (int i = 0; i < PathFinder.distance.length; i++) {