hi all! any ideas on the best way to pathfind? Im working on an npc scanner type thing, and some of the npc's I need to find are in houses. This is what i have so far, and im getting 0's for the co-ordinates.
static void moveToNpc(PlayerMobile P, Mobile target, ushort locX, ushort locY, sbyte locZ)
{
//Stealth.Client.newMoveXY(locX, locY, true, 0, true);
//Stealth.Client.MoveXYZ(locX, locY, locZ, 1, 1, true);
//P.Movement.MoveXYZ(locX, locY, locZ, 1, 1, true);
MovingHelper moveToTarg = MovingHelper.GetMovingHelper();
moveToTarg.AutoOpenDoors = true;
List<MyPoint> path = moveToTarg.GetPathArray(locX, locY, true, 2);
foreach(MyPoint point in path)
{
P.Movement.MoveXYZ(point.X, point.Y, (sbyte)point.Z, 0, 0, true);
}
}
Post Merge: June 10, 2016, 09:05:15 PM
updated my code
static void moveToNpc(PlayerMobile P, Mobile target, ushort locX, ushort locY, sbyte locZ)
{
MovingHelper moveToTarg = MovingHelper.GetMovingHelper();
moveToTarg.AutoOpenDoors = true;
List<MyPoint> path = moveToTarg.GetPathArray(locX, locY, true, 1);
if (path.Count() < 1)
ErrorExit("no path has been created to npc");
foreach(MyPoint point in path)
{
Console.WriteLine("pointX: " + point.X + " " + "pointY: " + point.Y);
if (point.X == 0 || point.Y == 0)
{
moveToTarg.SetBadLocation(point.X, point.Y);
break;
}
moveToTarg.MoveXYZ(point.X, point.Y, (sbyte)point.Z, 0, 0, true);
}
}
still not working, but I added the console.writeline so i could see what kind of points I was getting. The points in path are valid, except for the last Y location is 0. So that messes it up somewhere. Also my character wont move... Im not sure if im doing something wrong...