What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Flightor.MoveTo()

jim87

New Member
Joined
Aug 26, 2011
Messages
445
Reaction score
7
Hello!

I've got an action which theoretically should move me from hotspot to hotspot, but effectively it stops at each step from hotspot to hotspot for, let's say, 1 second or less, making it look a lot bottish. How can I avoid this? Thanks!

Also: does ProfileManager.CurrentProfile.HotspotManager.GetNextHotspot() get the nearest hotspot, or just "first or default"? And is my action faulty in something? It doesn't seem to follow the path indeed... weird!

PHP:
    class ActionFollowPath : Action
    {
        protected override RunStatus Run(object context)
        {
            SharedData shared = SharedData.Instance;
            FishingBuddySettings settings = FishingBuddySettings.Instance;

            // I've not initialized the path yet
            if (shared.nextPathIndex == -1)
            {
                // Get the index of the nearest hotspot
                shared.nextPathIndex = ProfileManager.CurrentProfile.HotspotManager.Hotspots.IndexOf(
                        ProfileManager.CurrentProfile.HotspotManager.GetNextHotspot()
                    );
                int totalHotspots = ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count;
                // There are less hotspots forward than backwards
                // And I've got a bounce behavior
                if (!settings.circlePathing)
                {
                    if ((totalHotspots - shared.nextPathIndex) < (totalHotspots / 2))
                        shared.inversePath = false;
                    else
                        shared.inversePath = true;
                }
                // Circle behavior
                else
                    shared.inversePath = false;

                return RunStatus.Running;
            }
            else
            {
                // Mount if not mounted
                if (!ObjectManager.Me.Mounted && Flightor.MountHelper.CanMount)
                    Flightor.MountHelper.MountUp();

                Utils.changeStatusText("Moving to next hotspot");

                // Start of the path
                if (shared.nextPathIndex == 0)
                    shared.inversePath = false;

                // End of the path
                if (shared.nextPathIndex == (ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count - 1))
                {
                    if (settings.circlePathing)
                        shared.inversePath = false;
                    else
                        shared.inversePath = true;
                }

                // Move to next hotspot
                Flightor.MoveTo(ProfileManager.CurrentProfile.HotspotManager.Hotspots.ElementAt(shared.nextPathIndex));

                if (shared.inversePath)
                    shared.nextPathIndex--;
                else
                    shared.nextPathIndex++;
            }
            return RunStatus.Success;
        }
    }

P.S.
The decorator doesn't let the action run if the "next hotspot" is too far from the current position.
 
Last edited:
you need to be able to check distance. so if distance between current hotspot and the next hotspot.
If(currentHotspot.Distance < 4)
Hotspot incriment++

does that make sense? you need to you gotta send the next one before you actually reach the one your getting too.
heres some code for Mr.LunarFestival GetNextNode() just increments the list location, but as you can see i im checking if im less then 10 yards from the point, to move to the next one.
Code:
   if ((lastcount == -1 || profile[lastcount].Distance(StyxWoW.Me.Location) <= 10) && fullcount != lastcount)
            {
                Logging.Write("Moving to Wavepoint #{0}", lastcount.ToString());
                WoWMovement.ClickToMove(profile[GetNextNode()]);
                Thread.Sleep(1000);
            }
 
Last edited:
This should already be done, as I specified this code runs every time the decorator allows it to run, and the decorator returns false if the distance is more than 5.0F, true otherwise. At this point the action should move to the next hotspot, as it first calls MoveTo, then it increments or decrements the index.

BTW I'm gonna do some further tests, but is this code acceptable from a logic/bot point of view?
 
This should already be done, as I specified this code runs every time the decorator allows it to run, and the decorator returns false if the distance is more than 5.0F, true otherwise. At this point the action should move to the next hotspot, as it first calls MoveTo, then it increments or decrements the index.

BTW I'm gonna do some further tests, but is this code acceptable from a logic/bot point of view?
yea,

for me when i was writing that botbase, it took a a while figure out the distance is the problem
try bumping it up to 10 and see if it gets better.
 
This seems to work flawlessy :)

PHP:
    class ActionFollowPath : Action
    {
        protected override RunStatus Run(object context)
        {
            SharedData shared = SharedData.Instance;
            FishingBuddySettings settings = FishingBuddySettings.Instance;

            LocalPlayer Me = ObjectManager.Me;

            // I've not initialized the path yet
            if (shared.nextPathIndex == -1)
            {
                // No hotspots found, stop the bot
                if (ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count == 0)
                {
                    Utils.changeStatusText("No hotspots found in current profile!");
                    TreeRoot.Stop();
                }

                // Get the index of the nearest hotspot
                shared.nextPathIndex = ProfileManager.CurrentProfile.HotspotManager.Hotspots.IndexOf(
                        ProfileManager.CurrentProfile.HotspotManager.GetNextHotspot()
                    );
                int totalHotspots = ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count;
                // There are less hotspots forward than backwards
                // And I've got a bounce behavior
                if (!settings.circlePathing)
                {
                    if ((totalHotspots - shared.nextPathIndex) < (totalHotspots / 2))
                        shared.inversePath = false;
                    else
                        shared.inversePath = true;
                }
                // Circle behavior
                else
                    shared.inversePath = false;

                return RunStatus.Running;
            }
            else
            {
                // Mount if not mounted
                if (!ObjectManager.Me.Mounted && Flightor.MountHelper.CanMount)
                    Flightor.MountHelper.MountUp();

                // Start of the path
                if (shared.nextPathIndex == 0)
                    shared.inversePath = false;

                // End of the path
                if (shared.nextPathIndex == (ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count - 1))
                {
                    if (settings.circlePathing)
                        shared.inversePath = false;
                    else
                        shared.inversePath = true;
                }

                // Move to next hotspot
                WoWPoint nextPoint = ProfileManager.CurrentProfile.HotspotManager.Hotspots.ElementAt(shared.nextPathIndex);
                // Next hotspot is too far, continue running
                if (nextPoint.Distance(Me.Location) > 10.0F)
                {
                    Flightor.MoveTo(ProfileManager.CurrentProfile.HotspotManager.Hotspots.ElementAt(shared.nextPathIndex));
                    return RunStatus.Success;
                }

                if (shared.inversePath)
                    shared.nextPathIndex--;
                else
                    shared.nextPathIndex++;

                Flightor.MoveTo(nextPoint);
                Utils.changeStatusText(String.Format("Moving to hotspot at {0}", nextPoint));

                return RunStatus.Success;
            }
        }
    }
 
You're having too much fun with your project. :D

Code:
if (nextPoint.Distance(Me.Location) > 10.0F)

Rather than hardcoding the 10.0F, I'd try using PathPrecision. PathPrecision is supposed to scale based on your traversal speed. For instance, if you are walking, PathPrecision should be 1.0-ish, if you are running, perhaps 3.0. If you are flying, its probably up around 10.0.

Here's the code, should you choose to give it a try...
Code:
if (nextPoint.Distance(Me.Location) > Navigator.PathPrecision)

I'd love to know your findings, if you do.


cheers,
chinajade
 
Eheh, yes the project is near the open beta stage, I only need to optimize some decorators and implement the combat routine - thanks for the tip about path precision ^^... BTW if I don't use the Navigator class, I could be wrong, but couldn't I just set this variable wherever I want? And last but not least, using this variable only once, is that bad to leave the simple float floating around there? ^^
 
Eheh, yes the project is near the open beta stage, I only need to optimize some decorators and implement the combat routine - thanks for the tip about path precision ^^... BTW if I don't use the Navigator class, I could be wrong, but couldn't I just set this variable wherever I want? And last but not least, using this variable only once, is that bad to leave the simple float floating around there? ^^

The Navigator is always present, whether you are using it or not. Even Flightor will use Navigator when it needs. Your interest in PathPrecision would be in a read-only capacity.

I believe the HBcore keeps the PathPrecision updated (almost every tick/pulse) based on the toon's current movement speed. This idea was originally taken from a plugin written by Highvoltz (a true master, but he doesn't post a whole lot. :D), and built into Honorbuddy 4620.


cheers,
chinajade
 
Thanks for the precisation :)

I tried to use PathPrecision, but even if I add 5.0F it still waits for a fraction of second (just a micro "stop'n'go")... here is the updated code:
PHP:
    class ActionFollowPath : Action
    {
        protected override RunStatus Run(object context)
        {
            SharedData shared = SharedData.Instance;
            FishingBuddySettings settings = FishingBuddySettings.Instance;

            LocalPlayer Me = ObjectManager.Me;

            // I've not initialized the path yet
            if (shared.nextPathIndex == -1)
            {
                // No hotspots found, stop the bot
                if (ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count == 0)
                {
                    Utils.changeStatusText("No hotspots found in current profile!");
                    TreeRoot.Stop();
                }

                // Get the index of the nearest hotspot
                shared.nextPathIndex = Utils.findNearestHotspotIndex();
                int totalHotspots = ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count;
                // There are less hotspots forward than backwards
                // And I've got a bounce behavior
                if (!settings.circlePathing)
                {
                    if ((totalHotspots - shared.nextPathIndex) < (totalHotspots / 2))
                        shared.inversePath = false;
                    else
                        shared.inversePath = true;
                }
                // Circle behavior
                else
                    shared.inversePath = false;

                return RunStatus.Running;
            }
            else
            {
                // Mount if not mounted
                // and recalculate nearest hotspot
                if (!ObjectManager.Me.Mounted && Flightor.MountHelper.CanMount)
                {
                    Flightor.MountHelper.MountUp();
                    shared.nextPathIndex = Utils.findNearestHotspotIndex();
                }

                // Start of the path
                if (shared.nextPathIndex == 0)
                    shared.inversePath = false;

                // End of the path
                if (shared.nextPathIndex == (ProfileManager.CurrentProfile.HotspotManager.Hotspots.Count - 1))
                {
                    if (settings.circlePathing)
                        shared.inversePath = false;
                    else
                        shared.inversePath = true;
                }

                // Next hotspot
                WoWPoint nextPoint = ProfileManager.CurrentProfile.HotspotManager.Hotspots.ElementAt(shared.nextPathIndex);

                // Next hotspot is too far, continue running
                if (nextPoint.Distance(Me.Location) > (Navigator.PathPrecision +5.0F))
                {
                    Flightor.MoveTo(ProfileManager.CurrentProfile.HotspotManager.Hotspots.ElementAt(shared.nextPathIndex));
                    return RunStatus.Success;
                }

                if (shared.inversePath)
                    shared.nextPathIndex--;
                else
                    shared.nextPathIndex++;

                nextPoint = ProfileManager.CurrentProfile.HotspotManager.Hotspots.ElementAt(shared.nextPathIndex);

                Flightor.MoveTo(nextPoint);
                Utils.changeStatusText(String.Format("Moving to hotspot at {0}", nextPoint));

                return RunStatus.Success;
            }
        }
    }
 
Last edited:
You're doing far, far too much in an action.

Code:
new Decorator(ret=> Me.Location.Distance(CurrentHotspot) > Navigator.PathPrecision, new Action(ret=>Flightor.MoveTo(CurrentHotspot)),
new Action(ret=>Hotspots.Dequeue())

That's all you should need.

If you're using a circular type path, use Styx.Helpers.CircularQueue to store the hotspots. (Edit the above code if thats not the case)
 
Back
Top