Example #1
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);
        }
Example #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);
        }
Example #3
0
        // Attempts to transfer overflow items to regular inventory.
        //
        // [TODO]: Need error handling channels if detected states don't align with expected.
        //
        public static void TransferOverflow(Interactor intr, bool inventoryOpened, bool bagsTabActive)
        {
            if (!inventoryOpened)
            {
                OpenInventory(intr);
            }

            // If bags tab is not active, click it's icon.
            if (!bagsTabActive)
            {
                if (!(States.DetermineInventoryState(intr) == InventoryState.Bags))
                {
                    Mouse.ClickImage(intr, "InventoryTabIconBags");
                    intr.WaitRand(1200, 2200);
                }
            }

            if (Mouse.ClickImage(intr, "InventoryOverflowTransferButton"))
            {
                intr.WaitRand(500, 800);
            }
        }
Example #4
0
        public static void AutoCycle(
					Interactor intr,
					int startDelaySec)
        {
            if (intr.CancelSource.IsCancellationRequested) { return; }

            var queue = new TaskQueue();
            int charsTotal = intr.AccountSettings.GetSettingValOr("characterCount", "general", 0);

            if (queue.IsEmpty) {
                intr.Log("Populating task queue: (0 -> " + (charsTotal).ToString() + ")");
                queue.Populate(intr, charsTotal, RESET_DAY);
                intr.UpdateQueueList(queue.ListClone(intr));
            }

            intr.Log("Starting AutoCycle in " + startDelaySec.ToString() + " seconds...");
            intr.Wait(startDelaySec * 1000);
            if (intr.CancelSource.IsCancellationRequested) { return; }
            intr.Log("Beginning AutoCycle.");

            // ##### BEGIN AUTOCYCLE LOOP #####
            while (!queue.IsEmpty && !intr.CancelSource.IsCancellationRequested) {
                if (IsCurfew()) {
                    int sleepTime = intr.WaitRand(300000, 1800000);
                    intr.Log("Curfew time. Sleeping for " + (sleepTime / 60000).ToString() + " minutes.");
                }

                intr.Log(LogEntryType.Debug, "AutoCycle(): Loop iteration starting.");

                TimeSpan nextTaskMatureDelay = queue.NextTaskMatureDelay();
                intr.Log(LogEntryType.Debug, "AutoCycle(): Next task mature delay: " + nextTaskMatureDelay);

                if (nextTaskMatureDelay.Ticks <= 0) {
                    // TASK TIMER HAS MATURED -> CONTINUE
                    // ##### ENTRY POINT -- INVOKING & PROCESSING CHARACTER #####
                    ProcessCharacter(intr, queue);
                } else {
                    // TASK TIMER NOT MATURE YET -> WAIT
                    intr.Wait(1000);
                    intr.Log("Next task matures in " + nextTaskMatureDelay.TotalMinutes.ToString("F0") + " minutes.");

                    TimeSpan waitDelay = nextTaskMatureDelay;

                    if (nextTaskMatureDelay.TotalMinutes > 8) {
                        if (queue.NextTask.Kind == TaskKind.Profession) {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 25);
                        } else {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 15);
                        }

                        ProduceClientState(intr, ClientState.None, 0);
                    } else if (nextTaskMatureDelay.TotalSeconds > 1) {
                        // Delay more than 1 sec, let the train catch up...
                        ProduceClientState(intr, ClientState.Inactive, 0);
                        waitDelay = nextTaskMatureDelay + intr.RandomDelay(5, 11);
                        intr.Log("Minimizing client and waiting " + waitDelay.TotalMinutes.ToString("F0") + " minutes.");
                    }

                    if (waitDelay.TotalSeconds > 1) {
                        intr.Log("Sleeping for " + waitDelay.TotalMinutes.ToString("F0") + " minutes before continuing...");
                        intr.Wait(waitDelay);
                        Screen.Wake(intr);
                    }
                }

                intr.Wait(100);
            }

            intr.Log(LogEntryType.Info, "Autocycle complete.");
        }
Example #5
0
        public static bool Redeem(Interactor intr, uint charIdx)
        {
            VaultOfPietyItem item;

            try {
                item = (VaultOfPietyItem)Enum.Parse(typeof(VaultOfPietyItem),
                                                    intr.AccountSettings.GetCharSetting(charIdx, "vaultOfPietyItem"), true);
            } catch (Exception) {
                item = DEFAULT_REDEMPTION_ITEM;
            }

            intr.Log(LogEntryType.Debug, "VaultOfPietyItem: " + item.ToString());

            intr.Wait(500);
            string cursorModeKey = intr.AccountSettings.GetSettingValOr("toggleMouseCursor", "gameHotkeys",
                                                                        Global.Default.ToggleMouseCursor);

            if (Screen.ImageSearch(intr, "InvocationMaximumBlessings").Found)
            {
                intr.Wait(200);
                Mouse.ClickImage(intr, "InvocationMaximumBlessingsVaultOfPietyButton");
            }
            else
            {
                intr.Wait(1000);
                Keyboard.SendKey(intr, cursorModeKey);
                intr.Wait(500);
                bool clicked = false;
                clicked |= Mouse.ClickImage(intr, "InvocationNotReady");
                clicked |= Mouse.ClickImage(intr, "InvocationReady");

                if (!clicked)
                {
                    intr.Log(LogEntryType.FatalWithScreenshot, "Unable to click Vault of Piety button");
                }
            }

            intr.WaitRand(2100, 2500);

            if (!Screen.ImageSearch(intr, "VaultOfPietyWindowTitle").Found)
            {
                return(false);
            }

            Mouse.ClickImage(intr, "VaultOfPietyCelestialSynergyTabTitle");
            intr.Wait(2000);

            string panelImage;
            string purchaseConfirmImage;

            //if (item == VaultOfPietyItem.ElixirOfFate) {
            //	var panel = Screen.ImageSearch(intr, "VaultOfPietyCelestialSynergyElixirOfFate");

            //	if (panel.Found) {
            //		Mouse.DoubleClick(intr, panel.Point);
            //		intr.Wait(500);
            //		Mouse.ClickImage(intr, "VaultOfPietyElixirOfFateSelectAmountOkButton");
            //		intr.Log(LogEntryType.Info, "Vault of Piety: 'Elixir of Fate' purchased successfully.");
            //	} else {
            //		intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find 'Elixir of Fate' icon/tile.");
            //		return false;
            //	}
            //} else if (item == VaultOfPietyItem.CofferOfCelestialArtifactEquipment) {
            //	var panel = Screen.ImageSearch(intr, "VaultOfPietyCelestialSynergyCofferOfCelestialArtifactEquipment");

            //	if (panel.Found) {
            //		Mouse.DoubleClick(intr, panel.Point);
            //		intr.Wait(500);
            //		Mouse.ClickImage(intr, "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton");
            //		intr.Log(LogEntryType.Info, "Vault of Piety: 'Coffer of Celestial Artifact Equipment' purchased successfully.");
            //	} else {
            //		intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find 'Coffer of Celestial Artifact Equipment' icon/tile.");
            //		return false;
            //	}
            //}

            if (item == VaultOfPietyItem.ElixirOfFate)
            {
                panelImage           = "VaultOfPietyCelestialSynergyElixirOfFate";
                purchaseConfirmImage = "VaultOfPietyElixirOfFateSelectAmountOkButton";
            }
            else if (item == VaultOfPietyItem.BlessedProfessionsElementalPack)
            {
                panelImage           = "VaultOfPietyCelestialSynergyBlessedProfessionsElementalPack";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else if (item == VaultOfPietyItem.CofferOfCelestialEnchantments)
            {
                panelImage           = "VaultOfPietyCelestialSynergyCofferOfCelestialEnchantments";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else if (item == VaultOfPietyItem.CofferOfCelestialArtifacts)
            {
                panelImage           = "VaultOfPietyCelestialSynergyCofferOfCelestialArtifacts";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else if (item == VaultOfPietyItem.CofferOfCelestialArtifactEquipment)
            {
                panelImage           = "VaultOfPietyCelestialSynergyCofferOfCelestialArtifactEquipment";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else
            {
                intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Unknown item: '{0:G}'.", item);
                return(false);
            }

            var panel = Screen.ImageSearch(intr, panelImage);

            if (panel.Found)
            {
                Mouse.DoubleClick(intr, panel.Point);
                intr.Wait(500);
                Mouse.ClickImage(intr, purchaseConfirmImage);
                intr.Log(LogEntryType.Info, "Vault of Piety: '{0:G}' purchased successfully.", item);
            }
            else
            {
                intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find '{0:G}' icon/panel.", item);
                return(false);
            }

            // [FIXME]: Handle the fact that the VaultOfPietyItem is:  `5`
            // [FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME]
            // [FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME]

            return(true);
        }
Example #6
0
        public static void AutoCycle(
            Interactor intr,
            int startDelaySec)
        {
            if (intr.CancelSource.IsCancellationRequested)
            {
                return;
            }

            var queue      = new TaskQueue();
            int charsTotal = intr.AccountSettings.GetSettingValOr("characterCount", "general", 0);

            if (queue.IsEmpty)
            {
                intr.Log("Populating task queue: (0 -> " + (charsTotal).ToString() + ")");
                queue.Populate(intr, charsTotal, RESET_DAY);
                intr.UpdateQueueList(queue.ListClone(intr));
            }

            intr.Log("Starting AutoCycle in " + startDelaySec.ToString() + " seconds...");
            intr.Wait(startDelaySec * 1000);
            if (intr.CancelSource.IsCancellationRequested)
            {
                return;
            }
            intr.Log("Beginning AutoCycle.");


            // ##### BEGIN AUTOCYCLE LOOP #####
            while (!queue.IsEmpty && !intr.CancelSource.IsCancellationRequested)
            {
                if (IsCurfew())
                {
                    int sleepTime = intr.WaitRand(300000, 1800000);
                    intr.Log("Curfew time. Sleeping for " + (sleepTime / 60000).ToString() + " minutes.");
                }

                intr.Log(LogEntryType.Debug, "AutoCycle(): Loop iteration starting.");

                TimeSpan nextTaskMatureDelay = queue.NextTaskMatureDelay();
                intr.Log(LogEntryType.Debug, "AutoCycle(): Next task mature delay: " + nextTaskMatureDelay);

                if (nextTaskMatureDelay.Ticks <= 0)
                {
                    // TASK TIMER HAS MATURED -> CONTINUE
                    // ##### ENTRY POINT -- INVOKING & PROCESSING CHARACTER #####
                    ProcessCharacter(intr, queue);
                }
                else
                {
                    // TASK TIMER NOT MATURE YET -> WAIT
                    intr.Wait(1000);
                    intr.Log("Next task matures in " + nextTaskMatureDelay.TotalMinutes.ToString("F0") + " minutes.");

                    TimeSpan waitDelay = nextTaskMatureDelay;

                    if (nextTaskMatureDelay.TotalMinutes > 8)
                    {
                        if (queue.NextTask.Kind == TaskKind.Profession)
                        {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 25);
                        }
                        else
                        {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 15);
                        }

                        ProduceClientState(intr, ClientState.None, 0);
                    }
                    else if (nextTaskMatureDelay.TotalSeconds > 1)
                    {
                        // Delay more than 1 sec, let the train catch up...
                        ProduceClientState(intr, ClientState.Inactive, 0);
                        waitDelay = nextTaskMatureDelay + intr.RandomDelay(5, 11);
                        intr.Log("Minimizing client and waiting " + waitDelay.TotalMinutes.ToString("F0") + " minutes.");
                    }

                    if (waitDelay.TotalSeconds > 1)
                    {
                        intr.Log("Sleeping for " + waitDelay.TotalMinutes.ToString("F0") + " minutes before continuing...");
                        intr.Wait(waitDelay);
                        Screen.Wake(intr);
                    }
                }

                intr.Wait(100);
            }

            intr.Log(LogEntryType.Info, "Autocycle complete.");
        }
Example #7
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);
        }
Example #8
0
        public static bool Redeem(Interactor intr, uint charIdx)
        {
            VaultOfPietyItem item;

            try {
                item = (VaultOfPietyItem)Enum.Parse(typeof(VaultOfPietyItem),
                    intr.AccountSettings.GetCharSetting(charIdx, "vaultOfPietyItem"), true);
            } catch (Exception) {
                item = DEFAULT_REDEMPTION_ITEM;
            }

            intr.Log(LogEntryType.Debug, "VaultOfPietyItem: " + item.ToString());

            intr.Wait(500);
            string cursorModeKey = intr.AccountSettings.GetSettingValOr("toggleMouseCursor", "gameHotkeys",
                Global.Default.ToggleMouseCursor);

            if (Screen.ImageSearch(intr, "InvocationMaximumBlessings").Found) {
                intr.Wait(200);
                Mouse.ClickImage(intr, "InvocationMaximumBlessingsVaultOfPietyButton");
            } else {
                intr.Wait(1000);
                Keyboard.SendKey(intr, cursorModeKey);
                intr.Wait(500);
                bool clicked = false;
                clicked |= Mouse.ClickImage(intr, "InvocationNotReady");
                clicked |= Mouse.ClickImage(intr, "InvocationReady");

                if (!clicked) {
                    intr.Log(LogEntryType.FatalWithScreenshot, "Unable to click Vault of Piety button");
                }
            }

            intr.WaitRand(2100, 2500);

            if (!Screen.ImageSearch(intr, "VaultOfPietyWindowTitle").Found) {
                return false;
            }

            Mouse.ClickImage(intr, "VaultOfPietyCelestialSynergyTabTitle");
            intr.Wait(2000);

            string panelImage;
            string purchaseConfirmImage;

            //if (item == VaultOfPietyItem.ElixirOfFate) {
            //	var panel = Screen.ImageSearch(intr, "VaultOfPietyCelestialSynergyElixirOfFate");

            //	if (panel.Found) {
            //		Mouse.DoubleClick(intr, panel.Point);
            //		intr.Wait(500);
            //		Mouse.ClickImage(intr, "VaultOfPietyElixirOfFateSelectAmountOkButton");
            //		intr.Log(LogEntryType.Info, "Vault of Piety: 'Elixir of Fate' purchased successfully.");
            //	} else {
            //		intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find 'Elixir of Fate' icon/tile.");
            //		return false;
            //	}
            //} else if (item == VaultOfPietyItem.CofferOfCelestialArtifactEquipment) {
            //	var panel = Screen.ImageSearch(intr, "VaultOfPietyCelestialSynergyCofferOfCelestialArtifactEquipment");

            //	if (panel.Found) {
            //		Mouse.DoubleClick(intr, panel.Point);
            //		intr.Wait(500);
            //		Mouse.ClickImage(intr, "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton");
            //		intr.Log(LogEntryType.Info, "Vault of Piety: 'Coffer of Celestial Artifact Equipment' purchased successfully.");
            //	} else {
            //		intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find 'Coffer of Celestial Artifact Equipment' icon/tile.");
            //		return false;
            //	}
            //}

            if (item == VaultOfPietyItem.ElixirOfFate) {
                panelImage = "VaultOfPietyCelestialSynergyElixirOfFate";
                purchaseConfirmImage = "VaultOfPietyElixirOfFateSelectAmountOkButton";
            } else if (item == VaultOfPietyItem.BlessedProfessionsElementalPack) {
                panelImage = "VaultOfPietyCelestialSynergyBlessedProfessionsElementalPack";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            } else if (item == VaultOfPietyItem.CofferOfCelestialEnchantments) {
                panelImage = "VaultOfPietyCelestialSynergyCofferOfCelestialEnchantments";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            } else if (item == VaultOfPietyItem.CofferOfCelestialArtifacts) {
                panelImage = "VaultOfPietyCelestialSynergyCofferOfCelestialArtifacts";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            } else if (item == VaultOfPietyItem.CofferOfCelestialArtifactEquipment) {
                panelImage = "VaultOfPietyCelestialSynergyCofferOfCelestialArtifactEquipment";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            } else {
                intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Unknown item: '{0:G}'.", item);
                return false;
            }

            var panel = Screen.ImageSearch(intr, panelImage);

            if (panel.Found) {
                Mouse.DoubleClick(intr, panel.Point);
                intr.Wait(500);
                Mouse.ClickImage(intr, purchaseConfirmImage);
                intr.Log(LogEntryType.Info, "Vault of Piety: '{0:G}' purchased successfully.", item);
            } else {
                intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find '{0:G}' icon/panel.", item);
                return false;
            }

            // [FIXME]: Handle the fact that the VaultOfPietyItem is:  `5`
            // [FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME]
            // [FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME]

            return true;
        }
Example #9
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;
        }
Example #10
0
        // Attempts to transfer overflow items to regular inventory.
        //
        // [TODO]: Need error handling channels if detected states don't align with expected.
        //
        public static void TransferOverflow(Interactor intr, bool inventoryOpened, bool bagsTabActive)
        {
            if (!inventoryOpened) {
                OpenInventory(intr);
            }

            // If bags tab is not active, click it's icon.
            if (!bagsTabActive) {
                if (!(States.DetermineInventoryState(intr) == InventoryState.Bags)) {
                    Mouse.ClickImage(intr, "InventoryTabIconBags");
                    intr.WaitRand(1200, 2200);
                }
            }

            if (Mouse.ClickImage(intr, "InventoryOverflowTransferButton")) {
                intr.WaitRand(500, 800);
            }
        }