summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.cpp
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-05-20 23:40:25 +0200
committerworktycho <work.tycho@gmail.com>2015-05-20 23:40:25 +0200
commit1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6 (patch)
tree68b959cc0ca2eaee66add4887fed70785e4ce283 /src/Mobs/Path.cpp
parentMerge pull request #2074 from SafwatHalaby/rmUnique (diff)
parentPath recalculation improvements (diff)
downloadcuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.tar
cuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.tar.gz
cuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.tar.bz2
cuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.tar.lz
cuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.tar.xz
cuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.tar.zst
cuberite-1bdd205eb8195c4e44d2072aa2e1ddb0a11745c6.zip
Diffstat (limited to 'src/Mobs/Path.cpp')
-rw-r--r--src/Mobs/Path.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index bf5e4ba5e..eba29be7e 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -6,6 +6,7 @@
#include "Path.h"
#include "../Chunk.h"
+
#define DISTANCE_MANHATTAN 0 // 1: More speed, a bit less accuracy 0: Max accuracy, less speed.
#define HEURISTICS_ONLY 0 // 1: Much more speed, much less accurate.
#define CALCULATIONS_PER_STEP 10 // Higher means more CPU load but faster path calculations.
@@ -178,11 +179,18 @@ bool cPath::Step_Internal()
// Calculation not finished yet.
// Check if we have a new NearestPoint.
- if (CurrentCell->m_H < m_NearestPointToTarget->m_H)
+
+ if ((m_Destination - CurrentCell->m_Location).Length() < 5)
+ {
+ if (m_Rand.NextInt(4) == 0)
+ {
+ m_NearestPointToTarget = CurrentCell;
+ }
+ }
+ else if (CurrentCell->m_H < m_NearestPointToTarget->m_H)
{
m_NearestPointToTarget = CurrentCell;
}
-
// process a currentCell by inspecting all neighbors.
// Check North, South, East, West on all 3 different heights.