Pudge 24 Posted November 23, 2020 Share Posted November 23, 2020 Hello, I need a little help. How can I make this function to use pathfinder to find the first/nearest position in the list of vector3? Because it goes in a straight line at start, and only use pathfinder after getting stuck. I would like to make a search path for the required NPC in the override quest type, and then interact with it when it appears, but the bot goes to this path in a straight line through sea. var path = new List<Vector3>() { new Vector3(134.4189f, -4571.758f, 268.0376f, "None"), new Vector3(146.1211f, -4538.368f, 261.461f, "None"), new Vector3(150.3505f, -4503.114f, 256.2892f, "None"), new Vector3(146.0072f, -4467.485f, 253.9808f, "None"), new Vector3(139.8191f, -4433.039f, 254.3852f, "None"), new Vector3(140.4656f, -4397.381f, 255.7277f, "None"), new Vector3(151.0651f, -4363.204f, 256.8899f, "None"), new Vector3(163.2112f, -4330.521f, 257.0603f, "None"), new Vector3(180.1993f, -4299.34f, 251.8035f, "None"), new Vector3(207.5983f, -4277.318f, 248.4619f, "None"), new Vector3(240.8512f, -4264.621f, 249.7808f, "None"), new Vector3(268.6209f, -4242.891f, 251.4492f, "None"), new Vector3(289.0244f, -4213.805f, 253.3416f, "None"), new Vector3(309.0491f, -4184.992f, 257.0113f, "None"), new Vector3(336.7352f, -4162.454f, 259.8828f, "None"), new Vector3(369.5115f, -4150.962f, 256.6224f, "None"), new Vector3(404.9132f, -4145.873f, 253.9392f, "None"), new Vector3(438.0468f, -4133.036f, 250.3237f, "None"), new Vector3(467.8514f, -4115.109f, 247.1384f, "None"), new Vector3(495.5876f, -4100.673f, 245.6649f, "None"), }; MovementManager.Go(path); //MovementManager.GoLoop(path); Link to comment https://wrobot.eu/forums/topic/12686-movementmanagergo/ Share on other sites More sharing options...
Zer0 148 Posted November 23, 2020 Share Posted November 23, 2020 If you want to move to the first spot on the list, use GoToTask.ToPosition(path[0]); If you want to find nearest spot on the list, you can do it this way: using System.Linq; List<Vector3> closestSpots = path .OrderBy(spot => spot.Position.DistanceTo(ObjectManager.Me.Position)) .ToList(); Vector3 closestSpot = closestSpots[0]; I haven't tested it and there's probably a more efficient way to do it, but that should work. Pudge 1 Link to comment https://wrobot.eu/forums/topic/12686-movementmanagergo/#findComment-60621 Share on other sites More sharing options...
Pudge 24 Posted November 23, 2020 Author Share Posted November 23, 2020 Hmm, this is a good option, thanks for the tip. GoToTask.ToPosition(path[0]); MovementManager.Go(path); Should work like a loop to find npc. Link to comment https://wrobot.eu/forums/topic/12686-movementmanagergo/#findComment-60622 Share on other sites More sharing options...
TheSmokie 242 Posted November 23, 2020 Share Posted November 23, 2020 Hey @pudge, i did something like this a long time ago, I've found it to be be to long, and it would slow down quester because loading all the vectors then move too. idk could be because i had it very long or somewhat. but you wanna make the MovementManager.go into a while loop. so it keeps moving. Link to comment https://wrobot.eu/forums/topic/12686-movementmanagergo/#findComment-60623 Share on other sites More sharing options...
Pudge 24 Posted November 23, 2020 Author Share Posted November 23, 2020 44 minutes ago, TheSmokie said: Hey @pudge, i did something like this a long time ago, I've found it to be be to long, and it would slow down quester because loading all the vectors then move too. idk could be because i had it very long or somewhat. but you wanna make the MovementManager.go into a while loop. so it keeps moving. I don't know how it will be work, I haven't tested it yet, code looks like this: var anton = ObjectManager.GetObjectWoWUnit().FirstOrDefault(g => g.Entry == 24291); if (anton == null) { Lua.LuaDoString("print('searching for npc')"); wManager.Wow.Bot.Tasks.GoToTask.ToPosition(path[0]); MovementManager.Go(path); } if (anton != null) { if (Is.In path) // checking if it moves in "path" need to do { MovementManager.StopMove(); } Lua.LuaDoString("print('npc founded')"); if (wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithNpc(new Vector3(anton.Position), anton.Entry)) { wManager.Wow.Helpers.Vendor.BuyItem("Fresh Pound of Flesh", 1); Thread.Sleep(3000); } } As I understand it, I need to add another check that will check it is in the "path", and stop movement? How can i do this? if (Is.In path) { MovementManager.StopMove(); } Link to comment https://wrobot.eu/forums/topic/12686-movementmanagergo/#findComment-60625 Share on other sites More sharing options...
TheSmokie 242 Posted November 23, 2020 Share Posted November 23, 2020 Your using 2 go to spot, i think this will cause problems, use something like this pathToFollow = PathFinder.FindPath(new Vector3(-5814.899, 650.6406, 94.55161)); but set it to find the npc vectors. Link to comment https://wrobot.eu/forums/topic/12686-movementmanagergo/#findComment-60626 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now