From c0d8a456b325f9f89c7dae8cf6049f485ba3b409 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 4 Oct 2019 15:11:11 -0400 Subject: [PATCH] v0.7.5a: tweaked Tengu's spawn behaviour --- .../levels/NewPrisonBossLevel.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewPrisonBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewPrisonBossLevel.java index 9aadcbf5a..a1e6ea59a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewPrisonBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewPrisonBossLevel.java @@ -397,9 +397,23 @@ public class NewPrisonBossLevel extends Level { switch (state){ case START: - //if something is occupying Tengu's space, wait and do nothing. - if (Actor.findChar(pointToCell(tenguCellCenter)) != null){ - return; + int tenguPos = pointToCell(tenguCellCenter); + + //if something is occupying Tengu's space, try to put him in an adjacent cell + if (Actor.findChar(tenguPos) != null){ + ArrayList candidates = new ArrayList<>(); + for (int i : PathFinder.NEIGHBOURS8){ + if (Actor.findChar(tenguPos + i) == null){ + candidates.add(tenguPos + i); + } + } + + if (!candidates.isEmpty()){ + tenguPos = Random.element(candidates); + //if there are no adjacent cells, wait and do nothing + } else { + return; + } } seal(); @@ -416,7 +430,7 @@ public class NewPrisonBossLevel extends Level { } tengu.state = tengu.HUNTING; - tengu.pos = pointToCell(tenguCellCenter); //in the middle of the fight room + tengu.pos = tenguPos; GameScene.add( tengu ); tengu.notice();