Example #1
0
        private static void StopBot()
        {
            BotManager.StopActiveBot();
            Task.Run(() =>
            {
                for (int i = 0; i < 3; i++)
                {
                    SystemSounds.Hand.Play();
                    Thread.Sleep(3000);
                }
            });

            if (UserPreferences.Default.LogoutOnStop && BotManager.LoggedIn)
            {
                DxHook.ExecuteScript("Logout();");
            }

            if (UserPreferences.Default.CloseWoWOnStop)
            {
                BotManager.SafeShutdown(true);
            }

            if (UserPreferences.Default.ShutdownPcOnStop)
            {
                Process.Start("shutdown", "/s /t 0");
            }
        }
Example #2
0
 /// <summary>
 ///     Attach all manipulation related classes to the passed process.
 ///     ObjectManager and Hook related operations will be available after this call
 /// </summary>
 /// <param name="process"></param>
 public static void AttachToProcess(Process process)
 {
     lock (LockObject)
     {
         try
         {
             if (process.HasExited)
             {
                 Logger.Warn("The process you have selected has exited. Please select another.");
                 return;
             }
             if (IsAttached)
             {
                 DetachFromProcess();
             }
             if (Offsets.FindOffsets(process))
             {
                 Memory = new ExternalProcessReader(process);
                 if (DxHook.Apply())
                 {
                     Memory.ProcessExited += (sender, args) => DetachFromProcess();
                     Logger.Info("Attached to: " + process.Id);
                     return;
                 }
             }
         }
         catch (Exception ex)
         {
             Logger.Error("Failed to attach do to an exception.", ex);
         }
         DetachFromProcess();
         Logger.Warn("Failed to attach to: " + process.Id);
     }
 }
Example #3
0
        /// <summary>
        ///     Runs this state and apply the lure.
        /// </summary>
        public override bool Run()
        {
            if (!UserPreferences.Default.UseSpear)
            {
                return(false);
            }

            if (!NeedToRun)
            {
                return(false);
            }
            Logger.Info(Name);

            DxHook.ExecuteScript("SpellStopCasting() " +
                                 " CFweaponId = GetInventoryItemID(\"player\", 16); " +
                                 " EquipItemByName(88535);");
            Thread.Sleep(1000);

            DxHook.ExecuteScript("RunMacroText(\"/use 16 \"); ");


            Thread.Sleep(1500);

            DxHook.ExecuteScript("EquipItemByName(CFweaponId);");

            Thread.Sleep(500);
            return(true);
        }
Example #4
0
 /// <summary>
 ///     If the loot window is open, then execute the lua to loot the items. See DoLoot.lua in the Resources for code
 /// </summary>
 public override bool Run()
 {
     if (!UserPreferences.Default.DoLoot)
     {
         return(false);
     }
     if (DxHook.ExecuteScript(Resources.DoLoot, "StateResult") == "1")
     {
         Logger.Info(Name);
         return(true);
     }
     return(false);
 }
Example #5
0
        /// <summary>
        ///     Cast fishing
        /// </summary>
        public override bool Run()
        {
            if (!NeedToRun)
            {
                return(false);
            }
            Thread.Sleep(_random.Next(1000));
            Logger.Info(Name);
            DxHook.ExecuteScript("local name = GetSpellInfo(131490);  CastSpellByName(name);");

            BotManager.ResetAFK();
            Thread.Sleep(500);
            return(true);
        }
Example #6
0
        /// <summary>
        ///     Execute Lua code to use Raft/Water Walking. See UseRaft.lua in Resources for code.
        /// </summary>
        public override bool Run()
        {
            if (!UserPreferences.Default.UseRaft)
            {
                return(false);
            }
            string res = DxHook.ExecuteScript(Resources.UseRaft, "UsedRaft");

            if (res == "1")
            {
                Logger.Info(Name);
                Thread.Sleep(1000);
                return(true);
            }
            return(false);
        }
Example #7
0
 /// <summary>
 ///     Attach all manipulation related classes to the passed process.
 ///     ObjectManager and Hook related operations will be available after this call
 /// </summary>
 /// <param name="process"></param>
 public static void AttachToProcess(Process process)
 {
     lock (LockObject)
     {
         try
         {
             if (process.HasExited)
             {
                 Logger.Warn("The process you have selected has exited. Please select another.");
                 return;
             }
             if (IsAttached)
             {
                 DetachFromProcess();
             }
             if (Offsets.FindOffsets(process))
             {
                 Memory = new ExternalProcessReader(process);
                 if (DxHook.Apply())
                 {
                     Memory.ProcessExited += (sender, args) => DetachFromProcess();
                     Logger.Info("Attached to: " + process.Id);
                     return;
                 }
             }
         }
         catch (FileNotFoundException ex)
         {
             if (ex.FileName.Contains("fasmdll_managed"))
             {
                 Logger.Fatal(
                     "You have not downloaded a required prerequisite for CoolFish. Please visit the following download page for the Visual C++ Redistributable: http://www.microsoft.com/en-us/download/details.aspx?id=40784 (Download the vcredist_x86.exe when asked)");
             }
             else
             {
                 Logger.Error("Failed to attach do to an exception. Missing File: " + ex.FileName, (Exception)ex);
             }
         }
         catch (Exception ex)
         {
             Logger.Error("Failed to attach do to an exception.", ex);
         }
         DetachFromProcess();
         Logger.Warn("Failed to attach to: " + process.Id);
     }
 }
Example #8
0
        /// <summary>
        ///     Runs this state and apply the lure.
        /// </summary>
        public override bool Run()
        {
            if (UserPreferences.Default.BaitIndex <= 0)
            {
                return(false);
            }

            string result = DxHook.ExecuteScript(Resources.NeedToApplyBait, "AppliedBait");

            if (result == "1")
            {
                Logger.Info(Name);
                Thread.Sleep(1500);
                return(true);
            }
            return(false);
        }
Example #9
0
        private void InitOptions()
        {
            UserPreferences.Default.StopTime = UserPreferences.Default.StopOnTime
                ? (DateTime?)DateTime.Now.AddMinutes(UserPreferences.Default.MinutesToStop)
                : null;


            var builder = new StringBuilder();

            foreach (SerializableItem serializableItem in UserPreferences.Default.Items.Where(item => !string.IsNullOrWhiteSpace(item.Value)))
            {
                builder.Append("[\"");
                builder.Append(serializableItem.Value);
                builder.Append("\"] = true, ");
            }
            string items = builder.ToString();

            if (items.Length > 0)
            {
                items = items.Remove(items.Length - 2);
            }

            builder.Clear();

            builder.AppendLine("ItemsList = {" + items + "}");
            builder.AppendLine("LootLeftOnly = " +
                               UserPreferences.Default.LootOnlyItems.ToString().ToLower());
            builder.AppendLine("DontLootLeft = " +
                               UserPreferences.Default.DontLootLeft.ToString().ToLower());
            builder.AppendLine("LootQuality = " + UserPreferences.Default.LootQuality);
            builder.AppendLine(Resources.WhisperNotes);

            if (UserPreferences.Default.BaitItem != null)
            {
                builder.AppendLine("BaitItemId = " + UserPreferences.Default.BaitItem.Value);
                builder.AppendLine("BaitSpellId = " + UserPreferences.Default.BaitItem.ValueTwo);
            }
            builder.AppendLine("LootLog = {}; ");
            builder.AppendLine("NoLootLog = {}; ");

            DxHook.ExecuteScript(builder.ToString());
        }
Example #10
0
        /// <summary>
        ///     Runs this state and apply the lure.
        /// </summary>
        public override bool Run()
        {
            if (UserPreferences.Default.NoLure)
            {
                return(false);
            }

            string result = DxHook.ExecuteScript("if GetWeaponEnchantInfo() then enchant = 1 else enchant = 0 end;", "enchant");

            if (result != "1" && PlayerInventory.HasLures())
            {
                Logger.Info(Name);

                DxHook.ExecuteScript("RunMacroText(\"/use \" .. LureName);");

                Thread.Sleep(3000);
                return(true);
            }
            return(false);
        }
Example #11
0
        /// <summary>
        /// </summary>
        public static void DetachFromProcess()
        {
            lock (LockObject)
            {
                try
                {
                    StopActiveBot();
                    DxHook.Restore();
                    if (Memory != null)
                    {
                        Memory.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("Exception thrown while detaching from process", ex);
                }

                Memory = null;
            }
        }
Example #12
0
        private void Run()
        {
            Logger.Info("Started Engine");

            try
            {
                InitOptions();
                while (Running && BotManager.LoggedIn)
                {
                    Pulse();
                    Thread.Sleep(1000 / 60);
                }

                if (BotManager.LoggedIn)
                {
                    DxHook.ExecuteScript(
                        "if CoolFrame then CoolFrame:UnregisterAllEvents(); end print(\"|cff00ff00---Loot Log---\"); for key,value in pairs(LootLog) do local _, itemLink = GetItemInfo(key); print(itemLink .. \": \" .. value) end print(\"|cffff0000---DID NOT Loot Log---\"); for key,value in pairs(NoLootLog) do _, itemLink = GetItemInfo(key); print(itemLink .. \": \" .. value) end");
                }
            }
            catch (CodeInjectionFailedException ex)
            {
                const string msg = "Stopping bot because we could not execute code required to continue";
                Logger.Error(msg, (Exception)ex);
            }
            catch (HookNotAppliedException ex)
            {
                Logger.Warn("Stopping bot because required hook is no longer applied", (Exception)ex);
            }
            catch (AccessViolationException ex)
            {
                Logger.Warn("Stopping bot because we failed to read memory.", (Exception)ex);
            }
            catch (Exception ex)
            {
                Logger.Error("Unhandled error occurred. LoggedIn: " + BotManager.LoggedIn + " Attached: " + BotManager.IsAttached, ex);
            }

            Running = false;
            Logger.Info("Engine Stopped");
        }
Example #13
0
        /// <summary>
        ///     Get the message and author of the whisper and display it to the user and play a sound.
        /// </summary>
        public override bool Run()
        {
            if (!UserPreferences.Default.SoundOnWhisper)
            {
                return(false);
            }
            if (DxHook.GetLocalizedText("NewMessage") == "1")
            {
                Dictionary <string, string> result = DxHook.ExecuteScript("NewMessage = 0;", new[] { "Message", "Author" });

                Logger.Info("Whisper from: " + result["Author"] + " Message: " + result["Message"]);

                Task.Run(() =>
                {
                    for (int i = 0; i < 2; i++)
                    {
                        SystemSounds.Hand.Play();
                        Thread.Sleep(3000);
                    }
                });
                return(true);
            }
            return(false);
        }
Example #14
0
 public void Interact()
 {
     BotManager.Memory.Write(Offsets.Addresses["MouseOverGUID"], Guid);
     DxHook.ExecuteScript("InteractUnit(\"mouseover\");");
 }