From 5eef092e0a2d05605ef267864a7afc875ff3e594 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 20 Aug 2022 23:56:46 -0400 Subject: [PATCH] v1.4.0: fixed Yog potentially spawning on an existing char --- .../levels/HallsBossLevel.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 29302052a..fcd6d6bdf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java @@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.YogDzewa; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; +import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; @@ -240,6 +241,24 @@ public class HallsBossLevel extends Level { YogDzewa boss = new YogDzewa(); boss.pos = exit() + width*3; + + //push any char that is already here away + if (Actor.findChar(boss.pos) != null){ + ArrayList candidates = new ArrayList<>(); + for (int i : PathFinder.NEIGHBOURS8){ + if (Actor.findChar(boss.pos + i) == null){ + candidates.add(boss.pos + i); + } + } + Char ch = Actor.findChar(boss.pos); + if (!candidates.isEmpty()){ + ch.pos = Random.element(candidates); + } else { + ch.pos = boss.pos+2*width; + } + Actor.add(new Pushing(ch, boss.pos, ch.pos)); + } + GameScene.add( boss ); }