Esempio n. 1
0
 private void StartBtn_Click(object sender, EventArgs e)
 {
     if (StartBtn.Text == "Start" && !TestWorker.IsBusy)
     {
         TestWorker.RunWorkerAsync();
         StartBtn.Text = "Stop";
     }
     else if (TestWorker.IsBusy)
     {
         Character.Navi.Reset();
         TestWorker.CancelAsync();
         StartBtn.Text = "Start";
         Character.Navi.Reset();
     }
 }
Esempio n. 2
0
        private void TestWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!TestWorker.CancellationPending)
            {
                var start2 = new position_t {
                    X = Character.Api.Player.X, Y = Character.Api.Player.Y, Z = Character.Api.Player.Z
                };

                var mob = Character.Api.Entity.GetEntity(Character.Target.FindBestTarget());
                var end = new position_t {
                    X = mob.X, Z = mob.Z
                };
                var mobid = Character.Target.FindBestTarget();

                if (FFxiNAV.waypoints.Count > 0)
                {
                    foreach (var wp in FFxiNAV.waypoints)
                    {
                        dist = Character.Navi.DistanceTo(wp);
                        while (dist > 6 && !TestWorker.CancellationPending && mob.Distance > 6)
                        {
                            var start3 = new position_t {
                                X = Character.Api.Player.X, Z = Character.Api.Player.Z
                            };
                            dist = Character.Navi.DistanceTo(wp);
                            Character.Logger.AddDebugText(rtbDebug, string.Format(@"start x {0} target x {1} distance {2}", start3.X.ToString(), wp.X.ToString(), dist.ToString()));
                            Character.Navi.GoTo(wp.X, wp.Z);
                            Thread.Sleep(200);
                        }
                        if (mob.Distance < 5 && !TestWorker.CancellationPending)
                        {
                            Character.Navi.FaceHeading(end);
                            Character.Navi.Reset();
                            Character.Target.TargetNpc(mobid);
                            Thread.Sleep(100);
                            Character.Api.ThirdParty.SendString("/attack <t>");
                        }
                    }
                    if (mob.Distance > 2.5 && FFxiNAV.waypoints.Count > 0 && !TestWorker.CancellationPending)
                    {
                        var end1 = new position_t {
                            X = mob.X, Z = mob.Z
                        };
                        var mobid1 = Character.Target.FindBestTarget();
                        Character.Navi.FaceHeading(end1);
                        Character.Navi.MoveForwardTowardsPosition(end1, true);

                        Character.Navi.FaceHeading(end1);
                        Character.Navi.Reset();
                        Character.Target.TargetNpc(mobid1);
                        Thread.Sleep(100);
                        Character.Api.ThirdParty.SendString("/attack <t>");
                    }
                    if (mob.Distance < 3)
                    {
                        FFxiNAV.waypoints.Clear();
                        Character.Navi.Reset();
                        mob = null;
                        TestWorker.CancelAsync();
                        Character.Navi.Reset();
                    }
                }

                Thread.Sleep(200);
            }
        }