Jump to content

Recommended Posts

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);


image.thumb.png.274a302f40e55f6e4a9a6dd4ba708757.png

 

Link to post
Share on other sites

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.

Link to post
Share on other sites
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...