v1.4.0: added checks for a few extra cases of respawn cell being -1

This commit is contained in:
Evan Debenham
2022-09-09 14:28:00 -04:00
parent 80a1bbe865
commit 20ed6ab62d
2 changed files with 11 additions and 5 deletions
@@ -427,14 +427,15 @@ public class GameScene extends PixelScene {
if (dropped != null) {
for (Item item : dropped) {
int pos = Dungeon.level.randomRespawnCell( null );
if (pos == -1) pos = Dungeon.level.entrance();
if (item instanceof Potion) {
((Potion)item).shatter( pos );
((Potion) item).shatter(pos);
} else if (item instanceof Plant.Seed && !Dungeon.isChallenged(Challenges.NO_HERBALISM)) {
Dungeon.level.plant( (Plant.Seed)item, pos );
Dungeon.level.plant((Plant.Seed) item, pos);
} else if (item instanceof Honeypot) {
Dungeon.level.drop(((Honeypot) item).shatter(null, pos), pos);
} else {
Dungeon.level.drop( item, pos );
Dungeon.level.drop(item, pos);
}
}
Dungeon.droppedItems.remove( Dungeon.depth );
@@ -469,11 +469,16 @@ public class InterlevelScene extends PixelScene {
Dungeon.hero.resurrect();
level = Dungeon.newLevel();
Dungeon.hero.pos = level.randomRespawnCell(Dungeon.hero);
if (Dungeon.hero.pos == -1) Dungeon.hero.pos = level.entrance();
for (Item i : preservedItems){
level.drop(i, level.randomRespawnCell(null));
int pos = level.randomRespawnCell(null);
if (pos == -1) pos = level.entrance();
level.drop(i, pos);
}
level.drop(new LostBackpack(), level.randomRespawnCell(null));
int pos = level.randomRespawnCell(null);
if (pos == -1) pos = level.entrance();
level.drop(new LostBackpack(), pos);
} else {
level = Dungeon.level;