Exemplo n.º 1
0
        /// <summary>
        /// Finds the next slot that matches a single color filter
        /// </summary>
        /// <param name="emptySlotNumber">Set to a number higher than 1 to find the second, third, etc empty slot.</param>
        /// <returns>The first matching inventory slot scanning left to right then top to bottom. Returns null if no match is found.</returns>
        public Point?FirstColorMatchingSlot(ColorFilter colorFilter, double matchStrictness = 0.1, bool safeTab = true, int emptySlotNumber = 1)
        {
            emptySlotNumber = (int)Numerical.LimitToRange(emptySlotNumber, 1, INVENTORY_CAPACITY);
            if (OpenInventory(safeTab))
            {
                Screen.Value = ScreenScraper.GetRGB(ScreenScraper.CaptureWindow());
            }
            Point?inventorySlot;

            int slotCount = 0;

            for (int slot = 0; slot < INVENTORY_CAPACITY; slot++)
            {
                inventorySlot = InventoryIndexToCoordinates(slot);
                if (SlotMatchesColorFilter(inventorySlot.Value.X, inventorySlot.Value.Y, colorFilter, matchStrictness, false, false))
                {
                    slotCount++;
                    if (slotCount >= emptySlotNumber)
                    {
                        return(inventorySlot);
                    }
                }

                if (BotProgram.StopFlag)
                {
                    return(null);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the user-selected custom settings
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveSettings_Click(object sender, EventArgs e)
        {
            settings.FairyRing       = (NatureRingsSettingsData.FairyRingOptions)FairyRingSelect.SelectedIndex;
            settings.GloryType       = (NatureRingsSettingsData.GloryOptions)GloryTypeSelect.SelectedIndex;
            settings.BankChoice      = (NatureRingsSettingsData.BankOptions)BankSelect.SelectedIndex;
            settings.NumberOfPouches = (int)Numerical.LimitToRange(PouchesSelect.SelectedIndex, 0, 4);

            Close();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clicks a point on the minimap specified by radial coordinates
        /// </summary>
        /// <param name="angle">counterclockwise angle from the right direction in degrees</param>
        /// <param name="radius">fraction of the radius of the minimap to move (0-1)</param>
        /// <param name="waitToArrive">set to true to wait until the player almost reaches the destination before returning</param>
        /// <param name="randomization">maximum allowed randomized deviation from the exact click point</param>
        /// <returns>true if successful</returns>
        public bool MoveToPosition(double angle, double radius, bool waitToArrive, int randomization, int minimumWaitTime = 0, Point?restMouse = null, int timeout = 30000)
        {
            radius = Numerical.LimitToRange(radius, 0, 1);
            Point click = RadialToRectangular(angle, radius);

            Mouse.LeftClick(click.X, click.Y, randomization);
            if (waitToArrive)
            {
                //safe minimum time before we expect the red flag to disappear
                //This is also necessary to ensure that the red flag appears on the minimap before we start looking for it.
                Stopwatch watch = new Stopwatch();
                watch.Start();
                int waitTime = Math.Max(minimumWaitTime, (int)(500 + radius * 2500 - watch.ElapsedMilliseconds));
                if (BotProgram.SafeWait(waitTime))
                {
                    return(false);
                }
                Mouse.Move(restMouse);
                return(WaitDuringMovement(timeout));
            }
            Mouse.Move(restMouse);
            return(true);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the start time and length of a new bot state
 /// </summary>
 /// <param name="stateLength">length of the new bot state in milliseconds</param>
 public void SetNewState(long stateLength)
 {
     stateLength       = (long)Numerical.LimitToRange(stateLength, 0, UnitConversions.HoursToMilliseconds(168)); //limit state length to 1 week as a sanity check
     CurrentStateStart = DateTime.Now;
     CurrentStateEnd   = CurrentStateStart.AddMilliseconds(stateLength);
 }
Exemplo n.º 5
0
        public void LimitToRangeTest(double input, double minimum, double maximum, double expectedResult)
        {
            double result = Numerical.LimitToRange(input, minimum, maximum);

            Assert.AreEqual(expectedResult, result);
        }