From 422288d8573cc930b426086352a790848cf914c7 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 17 Aug 2020 10:14:53 -0400 Subject: [PATCH] v0.8.2b: fixed crashes caused by new respawn behaviour and questgivers --- .../shatteredpixeldungeon/levels/Level.java | 12 ++++++++++-- .../levels/RegularLevel.java | 19 ++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) 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 7cfd17cec..7c9e02dae 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -534,17 +534,25 @@ public abstract class Level implements Bundlable { if (count < Dungeon.level.nMobs()) { + PathFinder.buildDistanceMap(Dungeon.hero.pos, BArray.or(Dungeon.level.passable, Dungeon.level.avoid, null)); + Mob mob = Dungeon.level.createMob(); mob.state = mob.WANDERING; mob.pos = Dungeon.level.randomRespawnCell( mob ); - if (Dungeon.hero.isAlive() && mob.pos != -1) { + if (Dungeon.hero.isAlive() && mob.pos != -1 && PathFinder.distance[mob.pos] >= 12) { GameScene.add( mob ); if (Statistics.amuletObtained) { mob.beckon( Dungeon.hero.pos ); } + spend(Dungeon.level.respawnCooldown()); + } else { + //try again in 1 turn + spend(TICK); } + } else { + spend(Dungeon.level.respawnCooldown()); } - spend(Dungeon.level.respawnCooldown()); + return true; } } 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 4386eab59..1d3eae7de 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -55,9 +55,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap; -import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.watabou.utils.Bundle; -import com.watabou.utils.PathFinder; import com.watabou.utils.Random; import java.util.ArrayList; @@ -232,38 +230,33 @@ public abstract class RegularLevel extends Level { } } - + @Override public int randomRespawnCell( Char ch ) { int count = 0; int cell = -1; - PathFinder.buildDistanceMap(Dungeon.hero.pos, BArray.or(passable, avoid, null)); - while (true) { - + if (++count > 30) { return -1; } - + Room room = randomRoom( StandardRoom.class ); if (room == null || room == roomEntrance) { continue; } cell = pointToCell(room.random(1)); - if (Actor.findChar( cell ) == null + if (!heroFOV[cell] + && Actor.findChar( cell ) == null && passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell]) && room.canPlaceCharacter(cellToPoint(cell), this) && cell != exit) { - - if (heroFOV[cell] || PathFinder.distance[cell] < 12){ - continue; - } return cell; } - + } }