Пример #1
0
        /// <summary>
        /// Waits for inventory runes to be crafted and disappear from the inventory
        /// </summary>
        /// <param name="shortWait">Waits a constant time without visual confirmation</param>
        /// <returns></returns>
        protected bool WaitForRunesToCraft(bool shortWait = false, int waitToStartLooking = 2 *BotRegistry.GAME_TICK, int timeout = 10 *BotRegistry.GAME_TICK)
        {
            if (shortWait)
            {
                SafeWaitPlus((long)(1.5 * BotRegistry.GAME_TICK), 100);
                return(true);
            }

            Stopwatch watch = new Stopwatch();

            watch.Start();
            if (SafeWait(waitToStartLooking))
            {
                return(false);
            }

            while (watch.ElapsedMilliseconds < timeout)
            {
                Screen.ReadWindow();
                if (Inventory.SlotIsEmpty(InventorySlotEssenceCheck, true))
                {
                    if (SafeWait((int)(1.5 * BotRegistry.GAME_TICK)))
                    {
                        return(false);
                    }
                    return(true);
                }
                else if (SafeWait(100))
                {
                    return(false);
                }
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// Called once for each iteration of the bot
 /// </summary>
 /// <returns></returns>
 protected override bool Execute()
 {
     Screen.ReadWindow();
     if (!Inventory.SlotIsEmpty(Inventory.INVENTORY_COLUMNS - 1, Inventory.INVENTORY_ROWS - 4))
     {
         Inventory.DropInventory(false, true);
     }
     else
     {
         Blob rockLocation = StationaryLocateUnminedOre();
         if (rockLocation == null)
         {
             missedRocks++;
             if (missedRocks > 5)
             {
                 MessageBox.Show("Unable to find any iron rocks");
                 return(false);
             }
         }
         else
         {
             Point rockPoint = (Point)rockLocation.RandomBlobPixel();
             LeftClick(rockPoint.X, rockPoint.Y);
             SafeWaitPlus(1200, 100);
             RunParams.Iterations--;
             missedRocks = 0;
         }
     }
     return(true);
 }
Пример #3
0
        /// <summary>
        /// Attempts to retrieve a falcon after launching it at a kebbit.
        /// </summary>
        /// <param name="target">The expected location of the falcon catching the kebbit.</param>
        /// <returns>True if the falcon catches the kebbit and is successfully retrieved.</returns>
        protected bool RetrieveFalcon(Point target)
        {
            //Find the second inventory slot that should fill when we retrieve the falcon so as not to confuse with accidentally picking up an item from the ground.
            Point?nextEmptyInventorySlot = Inventory.FirstEmptySlot(false, 2);

            if (nextEmptyInventorySlot == null)
            {
                return(false);
            }

            if (!WaitForCatch(ref target) || !WaitForFalconToStop(ref target, (Point)nextEmptyInventorySlot))
            {
                return(false);
            }

            Stopwatch retrieveWatch = new Stopwatch();

            retrieveWatch.Start();
            while (retrieveWatch.ElapsedMilliseconds < 60000 && !StopFlag)
            {
                if (HandEye.MouseOverNPC(new Blob(target), true, 0))
                {
                    SafeWait((int)(RunTime(target) / 2));
                    if (Inventory.WaitForSlotToFill((Point)nextEmptyInventorySlot, 5000))
                    {
                        return(true);
                    }
                }
                else if (HandEye.MouseOverStationaryObject(new Blob(target), false, 0, 0))
                {
                    //LeftClick(target.X, target.Y, 12);
                    //WaitDuringPlayerAnimation((int) (RunTime(target) * 1.5));

                    RightClick(target.X, target.Y, 0);
                    RightClick falconMenu = new RightClick(target.X, target.Y, RSClient, Keyboard);
                    falconMenu.WaitForPopup();
                    falconMenu.CustomOption(1);
                    if (SafeWait(1000))
                    {
                        return(false);
                    }
                    //TODO Search for the first row in the popup with NPC yellow text instead of picking the second row.
                }

                //We accidentally collected the falcon at some point.
                if (!Inventory.SlotIsEmpty(nextEmptyInventorySlot.Value, true))
                {
                    return(true);
                }
                //The falcon ran away.
                else if (!LocateFlashingArrow(ref target))
                {
                    FalconRanAway = true;
                    return(false);
                }
            }

            return(false);
        }
Пример #4
0
        /// <summary>
        /// Determines if the inventory looks like it is ready
        /// </summary>
        /// <returns>true if the inventory appears to be set up correctly</returns>
        protected override bool InventoryIsReady()
        {
            if (!ItemsAreReady() || Inventory.SlotIsEmpty(Inventory.INVENTORY_CAPACITY - 1))
            {
                return(false);   //TODO restock at the GE
            }

            return(true);
        }
Пример #5
0
 /// <summary>
 /// Makes a stack of inventory slots with food in them
 /// </summary>
 protected override void SetFoodSlots()
 {
     FoodSlots = new Queue <int>();
     for (int i = 0; i < Inventory.INVENTORY_CAPACITY - 1; i++)    //leave the last inventory spot for stolen coins
     {
         if (!Inventory.SlotIsEmpty(i))
         {
             FoodSlots.Enqueue(i);
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Deposits leftover food into the bank. Assumes that the bank is open. Does not close the bank.
        /// </summary>
        protected void DepositFood(Bank bank)
        {
            Point slot;

            for (int i = 0; i < EmptySlots.Length; i++)
            {
                slot = Inventory.InventoryIndexToCoordinates(i);
                if (EmptySlots[slot.X, slot.Y] && !Inventory.SlotIsEmpty(i, false, false))
                {
                    bank.DepositAll(slot);
                    SafeWait(3 * BotRegistry.GAME_TICK);
                    Screen.ReadWindow();
                }
            }
        }
Пример #7
0
        protected override bool Execute()
        {
            //Drop kebbit pickups to make room for more.
            if (!Inventory.SlotIsEmpty(18, true))
            {
                Inventory.DropInventory(false);
            }

            List <Kebbit> kebbits = LocateKebbits();

            kebbits = SortAndFilterKebbits(kebbits);
            kebbits = kebbits.GetRange(0, Math.Min(kebbits.Count, 2));   //Only try the first 2 kebbits.

            foreach (Kebbit kebbit in kebbits)
            {
                if (StopFlag)
                {
                    return(false);
                }

                if (HandEye.MouseOverNPC(new Blob(kebbit.Location.Center), true, 1, 500))
                {
                    if (RetrieveFalcon(kebbit.Location.Center))
                    {
                        FailedRuns = 0;
                        RunParams.Iterations--;
                        return(true);
                    }
                    break;  //Don't keep trying after a failed catch attempt.
                }
            }

            FailedRuns++;
            if (FailedRuns >= 5)
            {
                if (FailedRuns % 10 == 0)
                {
                    Minimap.MoveToPosition(225, 0.95, true, 3, 2500, null, 10000);
                    Vision.WaitDuringPlayerAnimation(6000);
                }
                else if (FailedRuns % 5 == 0)
                {
                    Minimap.MoveToPosition(315, 0.95, true, 3, 2500, null, 10000);
                    Vision.WaitDuringPlayerAnimation(6000);
                }
            }
            return(FailedRuns < 60 && !FalconRanAway);
        }
Пример #8
0
        protected override bool Execute()
        {
            if (!Screen.ReadWindow())
            {
                return(false);
            }
            Blob teaStall;

            if (!Vision.LocateObject(TeaStallRoof, out teaStall, minTeaStallSize))
            {
                MessageBox.Show("Unable to locate a tea stall");
                return(false);
            }
            Point click = (Point)teaStall.RandomBlobPixel();

            Mouse.Move(click.X, click.Y);
            SafeWait(2000);
            if (!Vision.WaitForMouseOverText(MouseOverText))
            {
                return(++FailedRuns < FAIL_LIMIT);
            }
            SafeWaitPlus(0, 150);
            LeftClick(click.X, click.Y);

            SafeWait(1000);
            Stopwatch watch = new Stopwatch();

            watch.Start();
            while (Inventory.SlotIsEmpty(TeaInventorySlot.X, TeaInventorySlot.Y, true, false))
            {
                SafeWait(200);
                if (watch.ElapsedMilliseconds > 5000)
                {
                    return(++FailedRuns < FAIL_LIMIT);
                }
            }
            Inventory.DropItem(TeaInventorySlot.X, TeaInventorySlot.Y, false, new int[1] {
                0
            });

            FailedRuns = 0;
            RunParams.Iterations--;
            return(true);
        }
Пример #9
0
 /// <summary>
 /// Called once for each iteration of the bot
 /// </summary>
 /// <returns></returns>
 protected override bool Execute()
 {
     if (!emptySlotsSet)
     {
         Inventory.SetEmptySlots(); // this tells the inventory to record which spots are empty
         for (int x = 0; x < Inventory.INVENTORY_COLUMNS; x++)
         {
             for (int y = Inventory.INVENTORY_ROWS - 2; y < Inventory.INVENTORY_ROWS; y++)
             {
                 Inventory.SetEmptySlot(x, y, false);
             }
         }
         emptySlotsSet = true;
     }
     Screen.ReadWindow();
     if (!Inventory.SlotIsEmpty(Inventory.INVENTORY_COLUMNS - 1, Inventory.INVENTORY_ROWS - 3, true))
     {
         Inventory.DropInventory(false, true);
     }
     else
     {
         if (!IsCurrentlyFishing())
         {
             Blob fishLocation = Vision.LocateClosestObject(FishTileFilter);
             if (fishLocation != null)
             {
                 if (fishLocation.Center.X != 0 && fishLocation.Center.Y != 0)
                 {
                     Point fishPoint = (Point)fishLocation.RandomBlobPixel();
                     LeftClick(fishPoint.X, fishPoint.Y);
                     Mouse.RadialOffset(187, 689, 6, 223);
                     SafeWaitPlus(8000, 1200);
                 }
             }
             else if (!MoveToNewFishingSpot())
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #10
0
        /// <summary>
        /// Called once for each iteration of the bot
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (!LocateTrees() || !ChopTree())
            {
                FailedTreeSearches++;
                if (FailedTreeSearches > 10)
                {
                    Inventory.DropInventory(false, true);
                    return(false);
                }
                return(true);
            }

            SafeWait(2000); //Give the player time to start the chopping animation
            Vision.WaitDuringPlayerAnimation();

            //Drop logs when inventory fills up. Use the second from bottom row to avoid looking at the Windows 10 watermark.
            if (!Inventory.SlotIsEmpty(Inventory.INVENTORY_COLUMNS - 1, Inventory.INVENTORY_ROWS - 4))
            {
                Inventory.DropInventory(false, true);
            }
            return(true);
        }
Пример #11
0
        /// <summary>
        /// Collects the Gyr falcon after it kills a kebbit.
        /// </summary>
        /// <returns>true if the falcon catches a kebbit </returns>
        protected bool WaitForFalconToStop(ref Point target, Point nextEmptyInventorySlot)
        {
            Point     lastFalcon = new Point(-1000, -1000);
            Stopwatch watch      = new Stopwatch();

            watch.Start();
            while (watch.ElapsedMilliseconds < 12000 && !StopFlag)
            {
                if (LocateFlashingArrow(ref target))
                {
                    if (Geometry.DistanceBetweenPoints(lastFalcon, target) < Screen.ArtifactLength(0.01))
                    {
                        return(true);
                    }
                    else
                    {
                        lastFalcon = target;
                        if (Geometry.DistanceBetweenPoints(Screen.Center, target) > Screen.ArtifactLength(0.25))
                        {
                            LeftClick(target.X, target.Y, 0);
                            if (SafeWait((long)(RunTime(target) / 2)))
                            {
                                return(false);
                            }
                            Vision.WaitDuringPlayerAnimation(3000);
                            if (!Inventory.SlotIsEmpty(nextEmptyInventorySlot, true))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Пример #12
0
 /// <summary>
 /// Determines if the logs, law runes, and coins are in te inventory
 /// </summary>
 /// <returns>true if the first 3 inventory slots are not empty</returns>
 protected bool ItemsAreReady()
 {
     return(!Inventory.SlotIsEmpty(InventoryLogSlot) && !Inventory.SlotIsEmpty(InventoryLawRuneSlot) && !Inventory.SlotIsEmpty(InventoryCashSlot));
 }