v0.2.4c: fixed a crash with bombs choosing adjacent tiles
This commit is contained in:
parent
471aa3ca7d
commit
ec1a4823b6
|
@ -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<Integer> 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 );
|
||||
|
|
Loading…
Reference in New Issue
Block a user