From 0c0919f45a009f2e1a2644db383e39e35a58059d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 13 Sep 2023 16:12:02 -0400 Subject: [PATCH] v2.2.0: sad ghost now avoids heaps and level exit while wandering --- .../actors/mobs/npcs/Ghost.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java index 9e521a59a..cea061298 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java @@ -61,12 +61,25 @@ public class Ghost extends NPC { flying = true; + WANDERING = new Wandering(); state = WANDERING; //not actually large of course, but this makes the ghost stick to the exit room properties.add(Property.LARGE); } + protected class Wandering extends Mob.Wandering{ + @Override + protected int randomDestination() { + int pos = super.randomDestination(); + //cannot wander onto heaps or the level exit + if (Dungeon.level.heaps.get(pos) != null || pos == Dungeon.level.exit()){ + return -1; + } + return pos; + } + } + @Override protected boolean act() { if (Dungeon.hero.buff(AscensionChallenge.class) != null){