Пример #1
0
        private void RecordWaypoint(int interval, string pathName, GatherWindow Gwindow)
        {
            if (RecordFlag)
            {
                return;
            }
            // Set recording as true.
            RecordFlag = true;

            // Get ID of current zone.
            var zoneId = Marshal.ReadInt32(NativeStructs.ZoneAddress);

            // Check if we need to make a new Zone entry.
            var nozones = _Waypoints.Zone.All(p => p.ID != zoneId);

            // We need to make a new entry.
            if (nozones)
            {
                // Add new Zone entry for our current zone.
                _Waypoints.Zone.Add(new Zones(zoneId));

                // Add an empty Path entry.
                _Waypoints.AddPathToZone(zoneId, pathName);

                // This is a new entry, so grab the last Zone we added, and the first Path in that Zone,
                // Then start adding new Point entries (at the rate of the given interval), and wait for the user to click stop.
                _Waypoints.Zone.Last().Path.First().AddPoints(interval, Gwindow);
            }
            else
            {
                // We already have the Zone in our xml, so lets go strait to adding points.
                _Waypoints.Zone.First(p => p.ID == zoneId).AddPoints(pathName, interval, Gwindow);
            }

            // If this is a single add, just reset the record flag and save the xml.
            if (interval == 0)
            {
                StopRecord();
            }
        }
Пример #2
0
 public void Play(string pathName, GatherWindow Gwindow, Pathing pType, bool forward = true, int index = 0)
 {
     new Thread(() => PlayPath(pathName, Gwindow, pType, forward, index)).Start();
 }
Пример #3
0
 /// <summary>
 /// Starts recording waypoints on a new thread.
 /// </summary>
 /// <param name="interval">Time in ms, between waypoints</param>
 /// <param name="pathName">Name of the path to save the waypoints to. A new on will be created, if it does not exist</param>
 /// <param name="logBox"></param>
 public void Record(int interval, string pathName, GatherWindow Gwindow)
 {
     new Thread(() => RecordWaypoint(interval, pathName, Gwindow)).Start();
 }
Пример #4
0
        private void PlayPath(string pathName, GatherWindow Gwindow, Pathing pType, bool forawrd, int index)
        {
            if (Moving)
            {
                return;
            }
            Moving = true;

            var zoneId = Marshal.ReadInt32(NativeStructs.ZoneAddress);

            HaltFlag = false;
            float heading;
            float tobeHeading;

            foreach (
                var waypoint in
                RebuildList(_Waypoints.Zone.First(p => p.ID == zoneId).Path.First(i => i.Name == pathName).Point,
                            forawrd, pType, index))
            {
                if (CorDelay)
                {
                    Game.MovementAdj->Status = WalkingStatus.Standing;
                }

                ModelRotation(new D3DXVECTOR2(waypoint.x, waypoint.y));

                SendKeyPress(KeyStates.Toggled, Key.End);

                if (CorDelay)
                {
                    Thread.Sleep(HeadToll);
                }

                var decX = (Game.GetPos(Axis.X) > waypoint.x);

                Game.MovementAdj->Status = WalkingStatus.Autorun | WalkingStatus.Running;

                if (decX)
                {
                    while (Game.GetPos(Axis.X) > waypoint.x)
                    {
                        if (HaltFlag)
                        {
                            Game.MovementAdj->Status = WalkingStatus.Standing;
                            Moving = false;
                            return;
                        }
                        if (AICorrection)
                        {
                            heading = Game.PCMobEntity[0].PCMob->Heading;

                            tobeHeading = HeadingToRad(Game.Get2DPos(), waypoint);

                            // Check if our heading is within our tolerance.
                            if (tobeHeading - heading < 0 ? tobeHeading - heading <-0.1f : tobeHeading - heading> 0.1f)
                            {
                                ModelRotation(waypoint);
                            }
                        }
                        Thread.Sleep(10);
                    }
                }
                else
                {
                    while (Game.GetPos(Axis.X) < waypoint.x)
                    {
                        if (HaltFlag)
                        {
                            Game.MovementAdj->Status = WalkingStatus.Standing;
                            Moving = false;
                            return;
                        }
                        if (AICorrection)
                        {
                            heading     = Game.PCMobEntity[0].PCMob->Heading;
                            tobeHeading = HeadingToRad(Game.Get2DPos(), waypoint);

                            // Check if our heading is within our tolerance.
                            if (tobeHeading - heading < 0 ? tobeHeading - heading <-0.1f : tobeHeading - heading> 0.1f)
                            {
                                ModelRotation(waypoint);
                            }
                        }
                        Thread.Sleep(10);
                    }
                }
                if (Gwindow != null)
                {
                    Gwindow.AddTextNav(0, "", pathName, waypoint.x, waypoint.y);
                }
            }
            Game.MovementAdj->Status = WalkingStatus.Standing;
            Moving = false;
        }