diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Bomb.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Bomb.java index 31dd11ec4..fb0a425c9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Bomb.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Bomb.java @@ -39,6 +39,8 @@ import com.watabou.utils.Bundle; import com.watabou.utils.Random; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; public class Bomb extends Item { @@ -85,10 +87,11 @@ public class Bomb extends Item { Actor.addDelayed(fuse = new Fuse().ignite(this), 2); } if (Actor.findChar( cell ) != null && !(Actor.findChar( cell ) instanceof Hero) ){ - int newCell; - do { - newCell = cell + Level.NEIGHBOURS8[Random.Int( 8 )]; - } while (!Level.passable[newCell]); + ArrayList candidates = new ArrayList<>(); + for (int i : Level.NEIGHBOURS8) + if (Level.passable[cell + i]) + candidates.add(cell + i); + int newCell = candidates.isEmpty() ? cell : Random.element(candidates); Dungeon.level.drop( this, newCell ).sprite.drop( cell ); } else super.onThrow( cell );