From 7e3c7f44cdcd8fd85226b09ac9c3b68265b5eb7d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 2 Sep 2016 01:07:26 -0400 Subject: [PATCH] v0.4.2: fixed bugs and corrected logic to pathfinder --- .../shatteredpixeldungeon/actors/hero/Hero.java | 2 +- .../shatteredpixeldungeon/actors/mobs/Mob.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 3ae9c9159..a649f0afd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -1045,7 +1045,7 @@ public class Hero extends Char { } else { boolean newPath = false; - if (path == null || path.isEmpty()) + if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst())) newPath = true; else if (path.getLast() != target) newPath = true; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index dd6a32d54..9cd7d8bb4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -307,12 +307,13 @@ public abstract class Mob extends Char { } else { boolean newPath = false; - if (path == null || path.isEmpty()) + if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst())) newPath = true; else if (path.getLast() != target) { //if the new target is adjacent to the end of the path, adjust for that - //rather than scrapping the whole path - if (Dungeon.level.adjacent(target, path.getLast())) { + //rather than scrapping the whole path. Unless the path is very long, + //in which case re-checking will likely result in a much better path + if (Dungeon.level.adjacent(target, path.getLast()) && path.size() < viewDistance) { int last = path.removeLast(); if (path.isEmpty()) {