Ejemplo n.º 1
0
        public static void ClearDialogues(Interactor intr)
        {
            intr.Log(LogEntryType.Debug, "Attempting to clear dialogues...");

            Point topLeft  = new Point(680, 400);
            Point botRight = new Point(1240, 680);

            Keyboard.SendKey(intr, Keyboard.KeyMod.Ctrl, "2");

            // These probably don't work:
            Mouse.ClickImage(intr, "CharSelectOkayButton", 0, 0, topLeft, botRight);
            Mouse.ClickImage(intr, "CharSelectOkButton", 0, 0, topLeft, botRight);
            Mouse.ClickImage(intr, "CharSelectOkButton_3", 0, 0, topLeft, botRight);
            //Mouse.ClickImage(intr, "DeclineButton", 0, 0, topLeft, botRight);
            //Mouse.ClickImage(intr, "DeclineButton_2", 0, 0, topLeft, botRight);
        }
Ejemplo n.º 2
0
        private static void SelectProfTask(Interactor intr, string taskName)
        {
            intr.Log(LogEntryType.Debug, "Attempting to select profession task: '{0}'.", taskName);
            var searchButton = Screen.ImageSearch(intr, "ProfessionsSearchButton");

            intr.Wait(50);

            Mouse.Click(intr, searchButton.Point, -100, 0);
            intr.Wait(50);

            Keyboard.SendKey(intr, "Shift", "Home");
            intr.Wait(50);

            Keyboard.Send(intr, taskName);
            intr.Wait(50);

            Keyboard.SendKey(intr, "Enter");
            intr.Wait(100);
        }
Ejemplo n.º 3
0
        //// Checks to ensure that the inventory was successfully opened.
        //public static bool InventoryIsOpen(Interactor intr) {
        //	var invState = States.DetermineInventoryState(intr);

        //	if (invState == InventoryState.None) {
        //		return false;
        //	} else {
        //		return true;
        //	}
        //}

        // Opens inventory.
        public static bool OpenInventory(Interactor intr)
        {
            intr.Log(LogEntryType.Debug, "Opening inventory...");
            string openInventoryKey = intr.AccountSettings.GetSettingValOr("inventory", "gameHotkeys", Global.Default.InventoryKey);

            MoveAround(intr);
            Keyboard.SendKey(intr, openInventoryKey);
            intr.Wait(300);

            if (intr.WaitUntil(8, WorldWindowState.Inventory, States.IsWorldWindowState, null, 1))
            {
                intr.Log(LogEntryType.Debug, "Inventory is open.");
                return(true);
            }
            else
            {
                intr.Log(LogEntryType.Info, "Unable to open inventory. Could be a random glitch.");
                return(false);
            }
        }
Ejemplo n.º 4
0
        //public static bool ActivateClient(Interactor intr) {
        //	//intr.ExecuteStatement("ActivateNeverwinter()");

        //	Screen.WindowActivate(intr, Game.GAMECLIENTEXE);

        //	intr.Wait(1000);

        //	return true;
        //}

        public static bool LogOut(Interactor intr)
        {
            //intr.ExecuteStatement("Logout()");
            intr.Log(LogEntryType.Info, "Logging out...");

            ClearDialogues(intr);

            MoveAround(intr);

            Keyboard.SendKey(intr, "Enter");
            intr.Wait(50);

            Keyboard.Send(intr, "/gotocharacterselect");
            intr.Wait(100);

            Keyboard.SendKey(intr, "Enter");
            intr.Wait(100);

            //intr.Wait(3000);

            return(true);
        }
Ejemplo n.º 5
0
        //public static bool ActivateClient(Interactor intr) {
        //	//intr.ExecuteStatement("ActivateNeverwinter()");

        //	Screen.WindowActivate(intr, Game.GAMECLIENTEXE);

        //	intr.Wait(1000);

        //	return true;
        //}

        //public static bool LogOut(Interactor intr) {
        //	//intr.ExecuteStatement("Logout()");
        //	intr.Log("Logging out...", LogEntryType.Info);

        //	MoveAround(intr);

        //	Keyboard.SendKey(intr, "Enter");
        //	intr.Wait(50);

        //	Keyboard.Send(intr, "/gotocharacterselect");
        //	intr.Wait(100);

        //	Keyboard.SendKey(intr, "Enter");
        //	intr.Wait(100);

        //	intr.Wait(3000);

        //	return true;
        //}


        public static bool ClientSignIn(Interactor intr)
        {
            intr.Log(LogEntryType.Info, "Signing in Client...");

            //intr.ExecuteStatement("ClientLogin()");

            intr.Wait(5000);

            ClearDialogues(intr);

            //if (!intr.WaitUntil(15, ClientState.LogIn, Game.IsClientState, null, 0)) { return false; }

            string gameUserName = intr.AccountSettings.GetSettingValOr("accountName", "general", "");
            string gamePassword = intr.AccountSettings.GetSettingValOr("password", "general", "");

            intr.Wait(1000);

            //var shiftHome = @"Send {Shift down}
            //	Sleep 20
            //	Send { Home down}
            //	Sleep 20
            //	Send { Shift up}
            //	Sleep 20
            //	Send { Home up}
            //	Sleep 20
            //";

            //intr.ExecuteStatement(shiftHome);
            Keyboard.SendKeyWithMod(intr, "Shift", "Tab", Keyboard.SendMode.Input);
            intr.Wait(200);

            Keyboard.SendKeyWithMod(intr, "Shift", "Home", Keyboard.SendMode.Input);

            Keyboard.Send(intr, gameUserName);

            Keyboard.SendKey(intr, "Tab");
            intr.Wait(200);

            Keyboard.Send(intr, gamePassword);
            intr.Wait(200);

            Keyboard.SendKey(intr, "Enter");

            intr.Wait(3000);

            // [TODO]: THIS NEEDS TO CLEAR VERIFY? DIALOGUE
            //ClearDialogues(intr);

            return(true);

            //ClientLogin() {
            //	global

            //	While ((ToggleInv && !FindClientLoginButton()) && (A_Index < 10))  {
            //		LogAppend("[Attempting to find ClientLoginButton.]")
            //		sleep 1500
            //	}

            //	if (ToggleInv && !FindClientLoginButton()) {
            //			LogAppend("[Not sure if we found ClientLoginButton but continuing...]")
            //			; msgbox ClientLogin() Waited too long for Login Screen to appear. If you are at login screen please check or remake %Lb_ImageFile%.
            //	}

            //	if (ToggleInv) {
            //		Sleep 2000 + Ran(500)
            //		Send {Shift down}
            //		Sleep 20
            //		Send {Home down}
            //		Sleep 20
            //		Send {Shift up}
            //		Sleep 20
            //		Send {Home up}
            //		Sleep 20
            //		Send %NwUserName%
            //		Sleep 50
            //		Send {Tab}
            //		Sleep 200 + Ran(100)
            //		Send %NwActPwd%
            //		Sleep 200 + Ran(100)
            //		Send {Enter}
            //		Sleep AfterLoginDelay + Ran(120)
            //	}
            //}
        }
Ejemplo n.º 6
0
        public static CompletionStatus Invoke(Interactor intr, uint charIdx)
        {
            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }

            string charLabel = intr.AccountSettings.CharNames[(int)charIdx];
            string invokeKey = intr.AccountSettings.GetSettingValOr("invoke", "gameHotkeys", Global.Default.InvokeKey);

            // Invocation Attempt (first):
            Keyboard.SendKey(intr, invokeKey);
            intr.Wait(300);

            if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionWindowTitle").Found)
            {
                intr.Wait(200);

                if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionInvokeReady").Found)
                {
                    intr.Wait(2000);
                    // Invocation Attempt:
                    Keyboard.SendKey(intr, invokeKey);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionDoneForDay").Found)
                {
                    intr.Log("Unable to invoke: Invocation already finished for the day on " + charLabel + ".");
                    return(CompletionStatus.DayComplete);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionPatience").Found)
                {
                    intr.Log("Unable to invoke: Still waiting to invoke on " + charLabel + ".");
                    return(CompletionStatus.Immature);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionNotInRestZone").Found)
                {
                    intr.Log(LogEntryType.Error, "Unable to invoke: " + charLabel + " not in rest zone.");
                    return(CompletionStatus.Complete);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionItemsInOverflow").Found)
                {
                    intr.Log(LogEntryType.Error, "Unable to invoke: Items in overflow bag are preventing invocation for "
                             + charLabel + ". Attempting to move to regular inventory...");

                    // Attempt to transfer overflow items to regular inventory:
                    //
                    // [NOTE]: Possibly Redundant.
                    // - Determine if it is possible for new items to be added to inventory
                    //   between inventory management and here.
                    //
                    TransferOverflow(intr, false, false);
                    MoveAround(intr);

                    // Invocation Attempt:
                    Keyboard.SendKey(intr, invokeKey);
                }
                else
                {
                    intr.Log(LogEntryType.FatalWithScreenshot, "Unable to invoke for " + charLabel +
                             "." + "[IN0]");
                    intr.Wait(30000);
                    return(CompletionStatus.Failed);
                }
            }
            else if (Screen.ImageSearch(intr, "InvocationMaximumBlessings").Found || DEBUG_ALWAYS_REDEEM)
            {
                // Vault of Piety //
                intr.Log(LogEntryType.Info, "Maximum blessings reached for " + charLabel
                         + ". Redeeming through Vault of Piety...");

                if (DEBUG_ALWAYS_REDEEM)
                {
                                        #pragma warning disable CS0162 // Unreachable code detected
                    MoveAround(intr);
                                        #pragma warning restore CS0162 // Unreachable code detected
                }

                if (Redeem(intr, charIdx))
                {
                    MoveAround(intr);
                    intr.Log(LogEntryType.Debug, "Redeeming Vault of Piety...");
                    // Invocation Attempt:
                    Keyboard.SendKey(intr, invokeKey);
                }
                else
                {
                    intr.Log(LogEntryType.Error, "Unable to invoke: Error collecting Vault of Piety rewards for " + charLabel + ".");
                    return(CompletionStatus.Failed);
                }
            }

            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }
            intr.Wait(2800);

            if (!intr.WaitUntil(5, DialogueBoxState.InvocationSuccess, States.IsDialogueBoxState, null, 0))
            {
                // Invocation Attempt:
                Keyboard.SendKey(intr, invokeKey);
                intr.Wait(1500);
                MoveAround(intr);
            }

            //// [FIXME]: Not sure why this is here still or why it was needed:
            //if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionWindowTitle").Found) {
            //	intr.Log("Closing Rewards of Devotion window and reassessing invocation success...", LogEntryType.Debug);
            //	//Mouse.ClickImage(intr, "InvocationRewardsOfDevotionCloseButton");
            //}

            if (!intr.WaitUntil(9, DialogueBoxState.InvocationSuccess, States.IsDialogueBoxState, null, 0))
            {
                // Invocation Attempt Failure -- Display invocation screen for the screenshot:
                Keyboard.SendKey(intr, invokeKey);
                intr.Wait(1500);

                intr.Log(LogEntryType.FatalWithScreenshot, "Unable to invoke for character " + charLabel +
                         "." + "[FN1]");

                intr.Wait(30000);
                MoveAround(intr);
                return(CompletionStatus.Failed);
            }

            intr.Log(LogEntryType.Info, "Invocation successful. Continuing...");

            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }

            return(CompletionStatus.Complete);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public static CompletionStatus MaintainProfs(Interactor intr, uint charIdx,
                                                     List <ProfessionTaskResult> completionList)
        {
            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }

            string charLabel   = intr.AccountSettings.CharNames[(int)charIdx];
            string profsWinKey = intr.AccountSettings.GetSettingValOr("professions", "gameHotkeys", Global.Default.ProfessionsWindowKey);

            intr.Log(LogEntryType.Debug, "Opening professions window for " + charLabel + ".");

            Keyboard.SendKey(intr, profsWinKey);
            intr.Wait(1000);

            if (!Screen.ImageSearch(intr, "ProfessionsWindowTitle").Found)
            {
                MoveAround(intr);
                Keyboard.SendKey(intr, profsWinKey);
                intr.Wait(200);

                if (!Screen.ImageSearch(intr, "ProfessionsWindowTitle").Found)
                {
                    intr.Log(LogEntryType.FatalWithScreenshot, "Unable to open professions window");
                    return(CompletionStatus.Failed);
                }
            }

            if (Mouse.ClickImage(intr, "ProfessionsOverviewInactiveTile"))
            {
                intr.Wait(500);
            }

            int profResultsCollected = 0;

            if (Screen.ImageSearch(intr, "ProfessionsCollectResult").Found)
            {
                while (profResultsCollected < 9)
                {
                    if (!CollectCompleted(intr))
                    {
                        break;
                    }
                    else
                    {
                        profResultsCollected += 1;
                    }
                }

                intr.Log(LogEntryType.Debug, "Collected " + profResultsCollected + " profession results for " +
                         charLabel + ".");
            }

            int noValidTaskId      = 0;
            int noValidTaskCounter = 0;
            int currentTaskId      = 0;
            var anySuccess         = false;

            for (int slotId = 0; slotId < 9; slotId++)
            {
                if (intr.CancelSource.IsCancellationRequested)
                {
                    return(CompletionStatus.Cancelled);
                }
                ;

                if (Mouse.ClickImage(intr, "ProfessionsOverviewInactiveTile"))
                {
                    intr.Wait(400);
                }

                var EmptySlotResult = Screen.ImageSearch(intr, "ProfessionsEmptySlot");

                if (EmptySlotResult.Found)
                {
                    intr.Log(LogEntryType.Info, "Empty professions slot found at: " + EmptySlotResult.Point.ToString() + ".");
                }
                else
                {
                    intr.Log(LogEntryType.Info, "All professions slots busy.");
                    break;
                }

                // Click the "Choose Task" button below the empty slot:
                Mouse.Click(intr, EmptySlotResult.Point, 30, 90);
                intr.Wait(400);

                // Click the "Leadership" category tile if it is not selected (determined by color):
                Mouse.ClickImage(intr, "ProfessionsLeadershipTileUnselected");
                intr.Wait(200);

                var taskContinueResult = Screen.ImageSearch(intr, "ProfessionsTaskContinueButton");

                if (slotId == 0 || !taskContinueResult.Found)
                {
                    while (true)
                    {
                        if (currentTaskId < ProfessionTasksRef.ProfessionTaskNames.Length)
                        {
                            SelectProfTask(intr, ProfessionTasksRef.ProfessionTaskNames[currentTaskId]);
                            taskContinueResult = Screen.ImageSearch(intr, "ProfessionsTaskContinueButton");

                            if (taskContinueResult.Found)
                            {
                                intr.Log(LogEntryType.Debug, "Profession task: '{0}' has been selected.",
                                         ProfessionTasksRef.ProfessionTaskNames[currentTaskId]);
                                break;
                            }
                            else
                            {
                                currentTaskId += 1;
                                continue;
                            }
                        }
                        else
                        {
                            // We've been stuck //
                            if (noValidTaskId == currentTaskId)
                            {
                                // We have already set `noValidTaskId` for this task //
                                if (noValidTaskCounter >= 2)
                                {
                                    // This is the 3rd time we've been here //
                                    intr.Log(LogEntryType.Error, "Error starting profession task on " + charLabel + ":");
                                    intr.Log(LogEntryType.Error, "- Ensure that profession assets are sorted correctly in inventory.");
                                    return(CompletionStatus.Stuck);
                                }
                                else
                                {
                                    noValidTaskCounter += 1;
                                }
                            }
                            else
                            {
                                noValidTaskId      = currentTaskId;
                                noValidTaskCounter = 1;
                            }

                            intr.Log(LogEntryType.Normal, "Could not find valid professions task.");
                            CollectCompleted(intr);
                            Mouse.ClickImage(intr, "ProfessionsWindowTitle");
                            Mouse.Move(intr, Screen.ImageSearch(intr, "ProfessionsWindowTitle").Point);
                        }
                    }
                }

                if (taskContinueResult.Found && currentTaskId < ProfessionTasksRef.ProfessionTaskNames.Length)
                {
                    float bonusFactor = 0.0f;

                    // Start the in-game task:
                    if (ContinueTask(intr, taskContinueResult.Point, out bonusFactor))
                    {
                        intr.Log(LogEntryType.Debug, "Profession task '{0}' (id: {1}, bf: {2}) started.",
                                 ProfessionTasksRef.ProfessionTaskNames[currentTaskId], currentTaskId, bonusFactor);

                        completionList.Add(new ProfessionTaskResult(currentTaskId, bonusFactor));
                        anySuccess = true;
                    }
                }
            }

            // Condense tasks into groups (of 3 generally):
            CondenseTasks(intr, completionList);

            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }

            if (anySuccess)
            {
                return(CompletionStatus.Complete);
            }
            else
            {
                return(CompletionStatus.Immature);
            }
        }