From c3513b587019c5e51c0954419462fe1fe7ca8b82 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 17 Aug 2015 03:28:01 -0400 Subject: [PATCH] v0.3.1: adjusted how special floors handle random respawn cell logic. --- .../shatteredpixeldungeon/levels/CavesBossLevel.java | 6 +++++- .../shatteredpixeldungeon/levels/CityBossLevel.java | 6 +++++- .../shatteredpixeldungeon/levels/DeadEndLevel.java | 5 +++++ .../shatteredpixeldungeon/levels/HallsBossLevel.java | 6 +++++- .../shatteredpixeldungeon/levels/LastLevel.java | 11 ++++++++++- .../shatteredpixeldungeon/levels/LastShopLevel.java | 2 +- .../shatteredpixeldungeon/levels/PrisonBossLevel.java | 2 +- .../shatteredpixeldungeon/levels/SewerBossLevel.java | 2 +- 8 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java index 5c7b32f92..c982f2dd7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java @@ -215,7 +215,11 @@ public class CavesBossLevel extends Level { @Override public int randomRespawnCell() { - return -1; + int cell = entrance + NEIGHBOURS8[Random.Int(8)]; + while (!passable[cell]){ + cell = entrance + NEIGHBOURS8[Random.Int(8)]; + } + return cell; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java index fec797e40..162ca0415 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java @@ -169,7 +169,11 @@ public class CityBossLevel extends Level { @Override public int randomRespawnCell() { - return -1; + int cell = entrance + NEIGHBOURS8[Random.Int(8)]; + while (!passable[cell]){ + cell = entrance + NEIGHBOURS8[Random.Int(8)]; + } + return cell; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java index bf811d729..918894191 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/DeadEndLevel.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import java.util.Arrays; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.watabou.utils.Random; public class DeadEndLevel extends Level { @@ -88,6 +89,10 @@ public class DeadEndLevel extends Level { protected void createMobs() { } + public Actor respawner() { + return null; + } + @Override protected void createItems() { } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java index eabe614cf..e9847e937 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java @@ -159,7 +159,11 @@ public class HallsBossLevel extends Level { @Override public int randomRespawnCell() { - return -1; + int cell = entrance + NEIGHBOURS8[Random.Int(8)]; + while (!passable[cell]){ + cell = entrance + NEIGHBOURS8[Random.Int(8)]; + } + return cell; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java index e6db58bb5..08129a3a7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastLevel.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import java.util.Arrays; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.watabou.noosa.Scene; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; @@ -119,6 +120,10 @@ public class LastLevel extends Level { protected void createMobs() { } + public Actor respawner() { + return null; + } + @Override protected void createItems() { drop( new Amulet(), pedestal ); @@ -126,7 +131,11 @@ public class LastLevel extends Level { @Override public int randomRespawnCell() { - return -1; + int cell = entrance + NEIGHBOURS8[Random.Int(8)]; + while (!passable[cell]){ + cell = entrance + NEIGHBOURS8[Random.Int(8)]; + } + return cell; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java index 83482c596..e16099b1b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/LastShopLevel.java @@ -176,7 +176,7 @@ public class LastShopLevel extends RegularLevel { @Override public int randomRespawnCell() { - return -1; + return roomEntrance.random(); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java index 8f906b860..1a5c1b928 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java @@ -357,7 +357,7 @@ public class PrisonBossLevel extends RegularLevel { @Override public int randomRespawnCell() { - return -1; + return roomEntrance.random(); } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java index 3b00965ce..5eb2f3b62 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java @@ -237,7 +237,7 @@ public class SewerBossLevel extends RegularLevel { @Override public int randomRespawnCell() { - return -1; + return roomEntrance.random(); }