Ejemplo n.º 1
0
            private void InitializeGatheringSpot(Character user, GatheringWindow uiWindow, Gathering currentSpot)
            {
                user.Refresh();
                Debug.Print("User Status: " + user.Status.ToString() + "  -  " + user.Status.ToString("X"));
                currentSpot.Target();
                Thread.Sleep(100);

                while (uiWindow.RefreshPointers() == false)
                {
                    user.Refresh();

                    user.Heading = user.Coordinate.AngleTo(currentSpot.Coordinate);

                    Utilities.Keyboard.KeyBoardHelper.KeyDown(Keys.W);

                    if (user.Coordinate.Distance2D(currentSpot.Coordinate) > DistanceThreshold)
                    {
                        user.Heading = user.Coordinate.AngleTo(currentSpot.Coordinate);

                        Utilities.Keyboard.KeyBoardHelper.KeyDown(Keys.W);
                        continue;
                    }

                    Utilities.Keyboard.KeyBoardHelper.KeyUp(Keys.W);

                    Thread.Sleep(350);
                    user.Refresh();
                    user.Heading = user.Coordinate.AngleTo(currentSpot.Coordinate);

                    Debug.Print("Waiting for window...");
                    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.NumPad0);
                    Thread.Sleep(750);
                }
            }
Ejemplo n.º 2
0
            public void DoWork()
            {
                try
                {
                    List <Character> monsters    = new List <Character>();
                    List <Character> fate        = new List <Character>();
                    List <Character> players     = new List <Character>();
                    List <Gathering> gathering   = new List <Gathering>();
                    GatheringWindow  uiWindow    = new GatheringWindow();
                    long             gathercount = 0;

                    Character user          = null;
                    Gathering currentTarget = null;

                    Stopwatch _claimwatch;
                    byte      lastPosition = 1;

                    MemoryFunctions.GetCharacters(monsters, fate, players, ref user);
                    MemoryFunctions.GetGathering(gathering);
                    _botstage = BotStage.Detection;
                    _navigation.Start();

                    _initial = true;
                    while (true)
                    {
                        //Debug.Print(_botstage.ToString());
                        switch (_botstage)
                        {
                        case BotStage.Detection:

                            currentTarget = FindClosestGatheringSpot();
                            if (currentTarget != null)
                            {
                                _navigation.Stop();
                                _botstage = BotStage.Initialize;
                                // Start timer to see if we have run into a problem claiming the monster.
                                _claimwatch = new Stopwatch();
                                _claimwatch.Start();
                            }

                            break;

                        case BotStage.Initialize:

                            InitializeGatheringSpot(user, uiWindow, currentTarget);

                            Debug.Print("Window open...");
                            uiWindow.Refresh();

                            Debug.Print("Items Found: " + uiWindow.Items.Count.ToString());
                            GatheringWindow.GatheringItems idealItem = null;

                            bool found = false;
                            foreach (string lstitem in SearchItems)
                            {
                                foreach (GatheringWindow.GatheringItems item in uiWindow.Items)
                                {
                                    if (item.Name.ToLower().Contains(lstitem.ToLower()))
                                    {
                                        idealItem = item;
                                        found     = true;
                                        break;
                                    }
                                }


                                if (found)
                                {
                                    break;
                                }
                            }


                            //foreach (GatheringWindow.GatheringItems item in uiWindow.Items)
                            //{
                            //    foreach (string lstitem in SearchItems)
                            //    {
                            //        if (item.Name.ToLower().Contains(lstitem.ToLower()))
                            //        {
                            //            idealItem = item;
                            //            found = true;
                            //            break;
                            //        }
                            //    }

                            //    if (found)
                            //        break;
                            //}


                            if (idealItem == null)
                            {
                                idealItem = uiWindow.Items.First();
                            }

                            Thread.Sleep(1000);
                            Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.NumPad6);
                            Thread.Sleep(150);
                            Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.NumPad6);
                            Thread.Sleep(150);
                            Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.NumPad6);
                            Thread.Sleep(200);

                            Debug.Print("Found Item: " + idealItem.Name + " Pos: " + idealItem.Position.ToString() + " " + found);
                            int positionShift = idealItem.Position - lastPosition;
                            Debug.Print("Shift: " + positionShift);
                            for (int i = 1; i <= Math.Abs(positionShift); i++)
                            {
                                if (positionShift > 0)
                                {
                                    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.NumPad2);
                                }
                                else
                                {
                                    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.NumPad8);
                                }


                                Thread.Sleep(350);
                            }

                            lastPosition = idealItem.Position;


                            if (_initial)
                            {
                                MessageBox.Show("Make sure your current selection is: " + idealItem.Name +
                                                "... Click OK to continue.", "Chocobot", MessageBoxButton.OK, MessageBoxImage.Information);
                                _initial = false;
                            }

                            user.Refresh();

                            if (idealItem.Name.ToLower().Contains("shard") || idealItem.Name.ToLower().Contains("crystal") || idealItem.Name.ToLower().Contains("cluster"))
                            {
                                if (user.CurrentGP >= 400 && user.Level >= 20)
                                {
                                    if (idealItem.Name.ToLower().Contains("fire"))
                                    {
                                        Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.Dash);
                                    }
                                    else if (idealItem.Name.ToLower().Contains("lightning"))
                                    {
                                        Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.D0);
                                    }
                                    else if (idealItem.Name.ToLower().Contains("water"))
                                    {
                                        Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.VK_OEM_PLUS);
                                    }
                                    else if (user.Level >= 30)
                                    {
                                        Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.D1);
                                    }

                                    Thread.Sleep(500);
                                }
                            }
                            else
                            {
                                if (user.CurrentGP >= 100 && user.Level >= 15)
                                {
                                    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.D4);
                                    Thread.Sleep(500);
                                }

                                //if (user.CurrentGP >= 400 && user.Level >= 30)
                                //{

                                //    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.D1);
                                //    Thread.Sleep(500);
                                //}

                                //if (user.CurrentGP >= 100 && user.Level >= 15)
                                //{
                                //    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.D9);
                                //    Thread.Sleep(500);
                                //}

                                //user.Refresh();
                                //if (user.CurrentGP >= 250 && user.Level >= 10)
                                //{


                                //    Utilities.Keyboard.KeyBoardHelper.KeyPress(Keys.D7);
                                //    Thread.Sleep(500);
                                //}
                            }
                            gathercount += 1;
                            _botstage    = BotStage.Gather;

                            break;

                        case BotStage.Gather:
                            GatherSpot(user, currentTarget);

                            break;
                        }



                        Thread.Sleep(250);
                    }
                }
                catch (Exception)
                {
                    _navigation.Stop();
                    throw;
                }
            }