From 4adb7fb4b3aa9ded67e5b179554a685e19f51edd Mon Sep 17 00:00:00 2001
From: Evan Debenham <Evan.SHPX@gmail.com>
Date: Tue, 15 Aug 2017 00:37:20 -0400
Subject: [PATCH] v0.6.1: fixed the sad ghost getting stuck behind closing
 doors on bosses

---
 .../levels/CavesBossLevel.java                  |  9 +++++++++
 .../levels/CityBossLevel.java                   |  9 +++++++++
 .../levels/PrisonBossLevel.java                 | 17 ++++++++++++++---
 3 files changed, 32 insertions(+), 3 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 e32f33b76..da8045695 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java
@@ -225,6 +225,15 @@ public class CavesBossLevel extends Level {
 			enteredArena = true;
 			seal();
 			
+			for (Mob m : mobs){
+				//bring the first ally with you
+				if (m.ally){
+					m.pos = Dungeon.hero.pos + (Random.Int(2) == 0 ? +1 : -1);
+					m.sprite.place(m.pos);
+					break;
+				}
+			}
+			
 			DM300 boss = new DM300();
 			boss.state = boss.WANDERING;
 			do {
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 592a2b33f..0da456b56 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CityBossLevel.java
@@ -196,6 +196,15 @@ public class CityBossLevel extends Level {
 			enteredArena = true;
 			seal();
 			
+			for (Mob m : mobs){
+				//bring the first ally with you
+				if (m.ally){
+					m.pos = Dungeon.hero.pos + (Random.Int(2) == 0 ? +1 : -1);
+					m.sprite.place(m.pos);
+					break;
+				}
+			}
+			
 			King boss = new King();
 			boss.state = boss.WANDERING;
 			int count = 0;
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 3b7aeec3e..3be7069d5 100644
--- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java
+++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java
@@ -285,6 +285,15 @@ public class PrisonBossLevel extends Level {
 				set(5 + 25 * 32, Terrain.LOCKED_DOOR);
 				GameScene.updateMap(5 + 25 * 32);
 
+				for (Mob m : mobs){
+					//bring the first ally with you
+					if (m.ally){
+						m.pos = 5 + 25 * 32; //they should immediately walk out of the door
+						m.sprite.place(m.pos);
+						break;
+					}
+				}
+				
 				tengu.state = tengu.HUNTING;
 				tengu.pos = 5 + 28*32; //in the middle of the fight room
 				GameScene.add( tengu );
@@ -329,10 +338,12 @@ public class PrisonBossLevel extends Level {
 				changeMap(MAP_ARENA);
 				clearEntities( (Room) new Room().set(0, 0, 10, 4)); //clear all but the area right around the teleport spot
 				
-				//if any characters are left over, move them along the same way as the hero
+				//if any allies are left over, move them along the same way as the hero
 				for (Mob m : mobs){
-					m.pos += 9+3*32;
-					m.sprite().place(m.pos);
+					if (m.ally) {
+						m.pos += 9 + 3 * 32;
+						m.sprite().place(m.pos);
+					}
 				}
 
 				tengu.state = tengu.HUNTING;