From b9be1a6a05b8df105c3ff8a96ab371e788223b35 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 27 Jul 2019 14:33:47 -0400 Subject: [PATCH] v0.7.4a: fixed respawn cells on special levels not checking for chars --- .../shatteredpixeldungeon/levels/CavesBossLevel.java | 6 +++--- .../shatteredpixeldungeon/levels/CityBossLevel.java | 6 +++--- .../shatteredpixeldungeon/levels/HallsBossLevel.java | 6 +++--- .../shatteredpixeldungeon/levels/LastLevel.java | 6 +++--- .../shatteredpixeldungeon/levels/LastShopLevel.java | 8 +++++++- .../shatteredpixeldungeon/levels/PrisonBossLevel.java | 7 ++++++- .../shatteredpixeldungeon/levels/SewerBossLevel.java | 2 +- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java index 79a7e888b..20071cf6a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java @@ -203,10 +203,10 @@ public class CavesBossLevel extends Level { @Override public int randomRespawnCell() { - int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)]; - while (!passable[cell]){ + int cell; + do { cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)]; - } + } while (!passable[cell] || Actor.findChar(cell) != null); return cell; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java index e22091032..6b37c0c73 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java @@ -174,10 +174,10 @@ public class CityBossLevel extends Level { @Override public int randomRespawnCell() { - int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)]; - while (!passable[cell]){ + int cell; + do { cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)]; - } + } while (!passable[cell] || Actor.findChar(cell) != null); return cell; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java index 189464ab2..bd844a802 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java @@ -164,10 +164,10 @@ public class HallsBossLevel extends Level { @Override public int randomRespawnCell() { int pos = entrance == -1 ? stairs : entrance; - int cell = pos + PathFinder.NEIGHBOURS8[Random.Int(8)]; - while (!passable[cell]){ + int cell; + do { cell = pos + PathFinder.NEIGHBOURS8[Random.Int(8)]; - } + } while (!passable[cell] || Actor.findChar(cell) != null); return cell; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java index 03c206b5b..fda9c246e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java @@ -131,10 +131,10 @@ public class LastLevel extends Level { @Override public int randomRespawnCell() { - int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)]; - while (!passable[cell]){ + int cell; + do { cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)]; - } + } while (!passable[cell] || Actor.findChar(cell) != null); return cell; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java index 1337b8591..d9fd42040 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java @@ -37,6 +37,8 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ImpShopRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.noosa.Group; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Random; import java.util.ArrayList; @@ -127,7 +129,11 @@ public class LastShopLevel extends RegularLevel { @Override public int randomRespawnCell() { - return pointToCell( roomEntrance.random() ); + int cell; + do { + cell = pointToCell( roomEntrance.random() ); + } while (!passable[cell] || Actor.findChar(cell) != null); + return cell; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java index 906669f90..cd531418e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java @@ -210,7 +210,12 @@ public class PrisonBossLevel extends Level { @Override public int randomRespawnCell() { - return 5+2*32 + PathFinder.NEIGHBOURS8[Random.Int(8)]; //random cell adjacent to the entrance. + int pos = 5+2*32; //random cell adjacent to the entrance. + int cell; + do { + cell = pos + PathFinder.NEIGHBOURS8[Random.Int(8)]; + } while (!passable[cell] || Actor.findChar(cell) != null); + return cell; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java index caf19b941..6888dee62 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java @@ -130,7 +130,7 @@ public class SewerBossLevel extends SewerLevel { int pos; do { pos = pointToCell(roomEntrance.random()); - } while (pos == entrance || solid[pos]); + } while (pos == entrance || !passable[pos] || Actor.findChar(pos) != null); return pos; }