Skip to content

Instantly share code, notes, and snippets.

@sixsixnine
Created February 13, 2012 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixsixnine/1818568 to your computer and use it in GitHub Desktop.
Save sixsixnine/1818568 to your computer and use it in GitHub Desktop.
diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp
index 40684d1..f4d1a1e 100644
--- a/src/game/RandomMovementGenerator.cpp
+++ b/src/game/RandomMovementGenerator.cpp
@@ -40,8 +40,17 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
+ PathFinder path(&creature);
+ path.setPathLengthLimit(30.0f);
+ path.calculate(destX, destY, destZ);
+ if(path.getPathType() & PATHFIND_NOPATH)
+ {
+ i_nextMoveTime.Reset(urand(500, 1000));
+ return;
+ }
+
Movement::MoveSplineInit init(creature);
- init.MoveTo(destX, destY, destZ, true);
+ init.MovebyPath(path.getPath());
init.SetWalk(true);
init.Launch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment