Beispiel #1
0
        public static void OpenRewardBag(Interactor intr, ImageSearchResult bagImageResult)
        {
            const int CLICK_OFS_MAX = 25;

            Mouse.DoubleClick(intr, bagImageResult.Point.X + intr.Rand(5, CLICK_OFS_MAX),
                              bagImageResult.Point.Y + intr.Rand(5, CLICK_OFS_MAX));
        }
Beispiel #2
0
        public static void MoveAround(Interactor intr)
        {
            string moveLeftKey  = intr.AccountSettings.GetSettingValOr("moveLeft", "gameHotkeys", Global.Default.MoveLeftKey);
            string moveRightKey = intr.AccountSettings.GetSettingValOr("moveRight", "gameHotkeys", Global.Default.MoveRightKey);
            string moveForeKey  = intr.AccountSettings.GetSettingValOr("moveForward", "gameHotkeys", Global.Default.MoveForwardKey);
            string moveBackKey  = intr.AccountSettings.GetSettingValOr("moveBackward", "gameHotkeys", Global.Default.MoveBackwardKey);

            intr.WaitRand(40, 120);

            int dirRand = intr.Rand(0, 6);

            int keyDelay = 20;

            if (dirRand == 0 || dirRand == 1)
            {
                Keyboard.KeyPress(intr, moveLeftKey, keyDelay);
            }
            else if (dirRand == 2 || dirRand == 3)
            {
                Keyboard.KeyPress(intr, moveRightKey, keyDelay);
            }
            else if (dirRand == 4)
            {
                Keyboard.KeyPress(intr, moveForeKey, keyDelay);
            }
            else if (dirRand == 5)
            {
                Keyboard.KeyPress(intr, moveBackKey, keyDelay);
            }

            intr.WaitRand(120, 220);
        }
Beispiel #3
0
        public static void MoveAround(Interactor intr)
        {
            string moveLeftKey = intr.AccountSettings.GetSettingValOr("moveLeft", "gameHotkeys", Global.Default.MoveLeftKey);
            string moveRightKey = intr.AccountSettings.GetSettingValOr("moveRight", "gameHotkeys", Global.Default.MoveRightKey);
            string moveForeKey = intr.AccountSettings.GetSettingValOr("moveForward", "gameHotkeys", Global.Default.MoveForwardKey);
            string moveBackKey = intr.AccountSettings.GetSettingValOr("moveBackward", "gameHotkeys", Global.Default.MoveBackwardKey);

            intr.WaitRand(40, 120);

            int dirRand = intr.Rand(0, 6);

            int keyDelay = 20;

            if (dirRand == 0 || dirRand == 1) {
                Keyboard.KeyPress(intr, moveLeftKey, keyDelay);
            } else if (dirRand == 2 || dirRand == 3) {
                Keyboard.KeyPress(intr, moveRightKey, keyDelay);
            } else if (dirRand == 4) {
                Keyboard.KeyPress(intr, moveForeKey, keyDelay);
            } else if (dirRand == 5) {
                Keyboard.KeyPress(intr, moveBackKey, keyDelay);
            }

            intr.WaitRand(120, 220);
        }
Beispiel #4
0
        // Searches inventory for rewards such as Celestial Bags of Refining and opens each one.
        //
        // [TODO]: Need error handling channels if detected states don't align with expected.
        //
        public static CompletionStatus OpenRewardBags(Interactor intr, string RewardIconImgCode, bool InventoryOpened)
        {
            // Open inventory:
            if (!InventoryOpened)
            {
                OpenInventory(intr);
            }

            // If bags tab is not active, click it's icon.
            if (!(States.IsInventoryState(intr, InventoryState.Bags)))
            {
                var iconBags = Screen.ImageSearch(intr, "InventoryTabIconBags");
                //Mouse.ClickImage(intr, "InventoryTabIconBags");
                if (iconBags.Found)
                {
                    Mouse.Click(intr, iconBags.Point);
                    Mouse.Move(intr, iconBags.Point.X - 30, iconBags.Point.Y);
                    intr.WaitRand(50, 100);
                }
                else
                {
                    intr.Log(LogEntryType.Info, "Unable to find inventory tab: 'Bags'. Probably just a random timing error.");
                    return(CompletionStatus.Failed);
                }
            }

            //
            //var imgCode = "InventoryCelestialBagOfRefinement";
            int afterSearchDelay = 3200;

            // Determine if any reward bags are present:
            // First Search:
            var bagSearchResult = Screen.ImageSearch(intr, RewardIconImgCode);

            //var openAnotherBtnLoc = new Point();

            if (bagSearchResult.Found)
            {
                intr.Log(LogEntryType.Debug, "Found reward icon with image code: '{0}'.", RewardIconImgCode);

                // Find a place to move the mouse out of the way to:
                var iconBags = Screen.ImageSearch(intr, "InventoryTabIconBags");
                if (!iconBags.Found)
                {
                    intr.Log(LogEntryType.Error, "Error determining inventory state.");
                }

                intr.Log(LogEntryType.Debug, "Opening reward bags...");
                OpenRewardBag(intr, bagSearchResult);
                intr.Wait(100);

                // Move mouse out of the way:
                Mouse.Move(intr, iconBags.Point.X - 30, iconBags.Point.Y);
                intr.Wait(afterSearchDelay);

                // Determine 'Open Another' button location for future presses:
                var openAnotherBtnSearchResult = Screen.ImageSearch(intr,
                                                                    "InventoryRewardWindowOpenAnotherButton_2", "InventoryRewardWindowOpenAnotherButton");

                if (openAnotherBtnSearchResult.Found)
                {
                    var randOfs           = new Point(intr.Rand(1, 60), intr.Rand(1, 10));
                    var openAnotherBtnLoc = new Point(openAnotherBtnSearchResult.Point.X + randOfs.X,
                                                      openAnotherBtnSearchResult.Point.Y + randOfs.Y);
                    int bagsOpened = 0;

                    // Open remaining bags:
                    while (true)
                    {
                        Mouse.Click(intr, openAnotherBtnLoc);
                        intr.WaitRand(20, 40);
                        bagsOpened += 1;

                        if (!Screen.ImageSearch(intr, RewardIconImgCode).Found)
                        {
                            break;
                        }

                        // Something is probably stuck:
                        if (bagsOpened >= 100)
                        {
                            TransferOverflow(intr, true, true);
                            break;
                        }
                    }
                }
                else
                {
                    // 'Open Another' button not found, just click them individually:
                    while (true)
                    {
                        // Move mouse out of the way:
                        Mouse.Move(intr, iconBags.Point.X - 30, iconBags.Point.Y);

                        // Search for bag icon:
                        bagSearchResult = Screen.ImageSearch(intr, RewardIconImgCode);
                        if (!bagSearchResult.Found)
                        {
                            break;
                        }

                        // Open bag:
                        OpenRewardBag(intr, bagSearchResult);
                        intr.Wait(afterSearchDelay);
                    }
                }
            }
            else
            {
                intr.Log(LogEntryType.Debug, "No reward icons with image code: '{0}' detected.", RewardIconImgCode);
            }

            return(CompletionStatus.Complete);
        }
Beispiel #5
0
        // Searches inventory for rewards such as Celestial Bags of Refining and opens each one.
        //
        // [TODO]: Need error handling channels if detected states don't align with expected.
        //
        public static CompletionStatus OpenRewardBags(Interactor intr, string RewardIconImgCode, bool InventoryOpened)
        {
            // Open inventory:
            if (!InventoryOpened) {
                OpenInventory(intr);
            }

            // If bags tab is not active, click it's icon.
            if (!(States.IsInventoryState(intr, InventoryState.Bags))) {
                var iconBags = Screen.ImageSearch(intr, "InventoryTabIconBags");
                //Mouse.ClickImage(intr, "InventoryTabIconBags");
                if (iconBags.Found) {
                    Mouse.Click(intr, iconBags.Point);
                    Mouse.Move(intr, iconBags.Point.X - 30, iconBags.Point.Y);
                    intr.WaitRand(50, 100);
                } else {
                    intr.Log(LogEntryType.Info, "Unable to find inventory tab: 'Bags'. Probably just a random timing error.");
                    return CompletionStatus.Failed;
                }
            }

            //
            //var imgCode = "InventoryCelestialBagOfRefinement";
            int afterSearchDelay = 3200;

            // Determine if any reward bags are present:
            // First Search:
            var bagSearchResult = Screen.ImageSearch(intr, RewardIconImgCode);
            //var openAnotherBtnLoc = new Point();

            if (bagSearchResult.Found) {
                intr.Log(LogEntryType.Debug, "Found reward icon with image code: '{0}'.", RewardIconImgCode);

                // Find a place to move the mouse out of the way to:
                var iconBags = Screen.ImageSearch(intr, "InventoryTabIconBags");
                if (!iconBags.Found) { intr.Log(LogEntryType.Error, "Error determining inventory state."); }

                intr.Log(LogEntryType.Debug, "Opening reward bags...");
                OpenRewardBag(intr, bagSearchResult);
                intr.Wait(100);

                // Move mouse out of the way:
                Mouse.Move(intr, iconBags.Point.X - 30, iconBags.Point.Y);
                intr.Wait(afterSearchDelay);

                // Determine 'Open Another' button location for future presses:
                var openAnotherBtnSearchResult = Screen.ImageSearch(intr,
                    "InventoryRewardWindowOpenAnotherButton_2", "InventoryRewardWindowOpenAnotherButton");

                if (openAnotherBtnSearchResult.Found) {
                    var randOfs = new Point(intr.Rand(1, 60), intr.Rand(1, 10));
                    var openAnotherBtnLoc = new Point(openAnotherBtnSearchResult.Point.X + randOfs.X,
                        openAnotherBtnSearchResult.Point.Y + randOfs.Y);
                    int bagsOpened = 0;

                    // Open remaining bags:
                    while (true) {
                        Mouse.Click(intr, openAnotherBtnLoc);
                        intr.WaitRand(20, 40);
                        bagsOpened += 1;

                        if (!Screen.ImageSearch(intr, RewardIconImgCode).Found) {
                            break;
                        }

                        // Something is probably stuck:
                        if (bagsOpened >= 100) {
                            TransferOverflow(intr, true, true);
                            break;
                        }
                    }
                } else {
                    // 'Open Another' button not found, just click them individually:
                    while (true) {
                        // Move mouse out of the way:
                        Mouse.Move(intr, iconBags.Point.X - 30, iconBags.Point.Y);

                        // Search for bag icon:
                        bagSearchResult = Screen.ImageSearch(intr, RewardIconImgCode);
                        if (!bagSearchResult.Found) { break; }

                        // Open bag:
                        OpenRewardBag(intr, bagSearchResult);
                        intr.Wait(afterSearchDelay);
                    }

                }
            } else {
                intr.Log(LogEntryType.Debug, "No reward icons with image code: '{0}' detected.", RewardIconImgCode);
            }

            return CompletionStatus.Complete;
        }
Beispiel #6
0
 public static void OpenRewardBag(Interactor intr, ImageSearchResult bagImageResult)
 {
     const int CLICK_OFS_MAX = 25;
     Mouse.DoubleClick(intr, bagImageResult.Point.X + intr.Rand(5, CLICK_OFS_MAX),
             bagImageResult.Point.Y + intr.Rand(5, CLICK_OFS_MAX));
 }