Пример #1
0
 public static void TakeFarmingLoots()
 {
     if (CountThisLoot)
     {
         _wasLooted    = true;
         CountThisLoot = false;
         LootingTask.LootAndConfirmBoPForAllItems(nManagerSetting.CurrentSetting.AutoConfirmOnBoPItems);
         Thread.Sleep(200);
         if (!Others.IsFrameVisible("LootFrame"))
         {
             Statistics.Farms++;
             Logging.Write("Farm successful");
         }
         else
         {
             Statistics.Farms++;
             Logging.Write("Farm partially successful");
             // LootWindow is still open after we accepted BoP, so one item must be stuck. (Unique(X), InventoryFull, ...)
         }
         // We had a valid LOOT_READY anyway, with our force loot function, that would have taken < 1 sec to loot anyway.
         // So let's blacklist inode/unit !
         if (NodeOrUnit && _curNode != null && _curNode.IsValid)
         {
             nManagerSetting.AddBlackList(_curNode.Guid, 60 * 1000);
         }
         if (!NodeOrUnit && CurUnit != null && CurUnit.IsValid)
         {
             nManagerSetting.AddBlackList(CurUnit.Guid, 60 * 1000);
         }
         _curNode = null;
         CurUnit  = null;
     }
 }
Пример #2
0
 public static void AcceptQuest()
 {
     Lua.LuaDoString("AcceptQuest()");
     if (Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
     {
         Lua.RunMacroText("/click QuestFrameCompleteQuestButton");
     }
     // hack for SelfComplete quests
 }
Пример #3
0
        public static void SendMessage(string target, string titleMsg, string txtMsg, List <String> itemSend,
                                       List <string> itemNoSend, List <Enums.WoWItemQuality> itemQuality,
                                       out bool mailSendingCompleted)
        {
            try
            {
                string syntaxSellItem = itemSend.Aggregate("", (current, s) => current + " or namei == \"" + s + "\" ");

                string syntaxQualityItem = itemQuality.Aggregate(" 1 == 2 ",
                                                                 (current, s) => current + " or r == " + (uint)s + " ");

                string syntaxNoSellItem    = "";
                string syntaxNoSellItemEnd = "";
                if (itemNoSend.Count > 0)
                {
                    syntaxNoSellItemEnd = " end ";
                    syntaxNoSellItem    = itemNoSend.Aggregate(" if ",
                                                               (current, s) => current + " and namei ~= \"" + s + "\" ");
                    syntaxNoSellItem = syntaxNoSellItem.Replace("if  and", "if ");
                    syntaxNoSellItem = syntaxNoSellItem + " then ";
                }

                string scriptLua = "";


                scriptLua = scriptLua + "MailFrameTab_OnClick(0,2) ";
                scriptLua = scriptLua + "local c,l,r,_=0 ";

                scriptLua = scriptLua + "for b=0,4 do ";
                scriptLua = scriptLua + "for s=1,40 do  ";
                scriptLua = scriptLua + "local l=GetContainerItemLink(b,s) ";
                scriptLua = scriptLua + "if l then namei,_,r=GetItemInfo(l) ";
                scriptLua = scriptLua + "if " + syntaxQualityItem + " " + syntaxSellItem + " then ";
                scriptLua = scriptLua + syntaxNoSellItem;
                scriptLua = scriptLua + "UseContainerItem(b,s) ";
                scriptLua = scriptLua + syntaxNoSellItemEnd;
                scriptLua = scriptLua + " end ";
                scriptLua = scriptLua + "end ";
                scriptLua = scriptLua + "end ";
                scriptLua = scriptLua + "end ";

                scriptLua = scriptLua +
                            " numAttachments = 0; for i=1, ATTACHMENTS_MAX_SEND do local itemName, itemTexture, stackCount, quality = GetSendMailItem(i); if itemName then numAttachments = numAttachments + 1; end end ";

                scriptLua = scriptLua + "if numAttachments>0 then ";
                if (titleMsg != "" && txtMsg != "")
                {
                    scriptLua = scriptLua + "SendMail(\"" + target + "\", \"" + titleMsg + "\", \"" + txtMsg + "\") ";
                }
                else
                {
                    scriptLua = scriptLua + "SendMail(\"" + target + "\", \"" + titleMsg + " \", \"" + titleMsg +
                                " \") ";
                }

                scriptLua = scriptLua + "end ";

                mailSendingCompleted = Others.ToInt32(Lua.LuaDoString(scriptLua, "numAttachments")) <= 0;
                Thread.Sleep(Usefuls.Latency + 1000);
                if (Others.IsFrameVisible("SecureTransferDialog"))
                {
                    Thread.Sleep(2000);
                    Lua.LuaDoString("SecureCapsuleGet('C_SecureTransfer').SendMail();");
                    Lua.LuaDoString("SecureTransferDialog:Hide();");
                    Thread.Sleep(Usefuls.Latency + 500);
                }
            }
            catch (Exception exception)
            {
                mailSendingCompleted = true;
                Logging.WriteError(
                    "Mail > SendMessage(string target, string titleMsg, string txtMsg, List<String> itemSend, List<string> itemNoSend, List<Enums.WoWItemQuality> itemQuality): " +
                    exception);
            }
        }
Пример #4
0
        private static void LoopFishThread()
        {
            try
            {
                while (true)
                {
                    try
                    {
                        while (_fishBotLaunched)
                        {
                            if (ObjectManager.ObjectManager.Me.InCombat)
                            {
                                StopLoopFish();
                                continue;
                            }
                            Fishing.EquipFishingPoles(_fishingPoleName);
                            if (_useLure)
                            {
                                Fishing.UseLure(_lureName, _automaticallyUseDraenorSecondaryBait);
                            }

                            if (fishingSpell == null)
                            {
                                fishingSpell = new Spell("Fishing");
                            }
                            fishingSpell.Launch(false, false, true);
                            Thread.Sleep(4000);
                            WoWGameObject objBobber =
                                new WoWGameObject(Fishing.SearchBobber());

                            if (objBobber.IsValid)
                            {
                                WoWGameObject node = new WoWGameObject(ObjectManager.ObjectManager.GetObjectByGuid(_guidNode).GetBaseAddress);
                                if (node.Position.DistanceTo2D(objBobber.Position) > distanceBobber && node.IsValid &&
                                    _guidNode > 0 && _precision)
                                {
                                    continue;
                                }

                                while (_fishBotLaunched && ObjectManager.ObjectManager.Me.IsCast && objBobber.IsValid &&
                                       1 != Memory.WowMemory.Memory.ReadShort(objBobber.GetBaseAddress + (uint)Patchables.Addresses.Fishing.BobberHasMoved))
                                {
                                    /*
                                     * BobberHasMoved FINDER
                                     * uint i = 148;
                                     * while (false)
                                     * {
                                     *  short info = Memory.WowMemory.Memory.ReadShort(objBobber.GetBaseAddress + (uint) i);
                                     *  if (info == 1)
                                     *  {
                                     *      Logging.Write("Info is " + info + " with i=" + i);
                                     *  }
                                     *  i += 4;
                                     *  if (i > 350)
                                     *      i = 148;
                                     *  Thread.Sleep(30);
                                     * }
                                     */
                                    Thread.Sleep(250);
                                }
                                if (_fishBotLaunched && ObjectManager.ObjectManager.Me.IsCast && objBobber.IsValid)
                                {
                                    FarmingTask.CountThisLoot = true;
                                    FarmingTask.NodeOrUnit    = true;
                                    Interact.InteractWith(objBobber.GetBaseAddress);
                                    _lastSuccessfullFishing = Environment.TickCount;
                                    Statistics.Farms++;
                                    Thread.Sleep(Usefuls.Latency + 400); // Arround 450
                                    for (int i = 0; i < 10; i++)
                                    {
                                        if (!Others.IsFrameVisible("LootFrame"))
                                        {
                                            break;
                                        }
                                        Thread.Sleep(150); // usually stop at i = 2 for me
                                        // it's like the old 1sec sleep, but can be faster sometimes to recast.
                                        // and this will loot 100% of the time, while if you have high latency, 1sec wont loot everything.
                                    }

                                    /*if (Others.IsFrameVisible("LootFrame"))
                                     * {
                                     *  Logging.WriteDebug("We did not loot all items within < 2 second + latency.");
                                     *  // More of a debug code, no need.
                                     * }*/
                                }
                            }
                        }
                    }
                    catch
                    {
                    }

                    Thread.Sleep(400);
                }
            }
            catch (Exception e)
            {
                Logging.WriteError("FishingTask > LoopFishThread(): " + e);
            }
        }
Пример #5
0
 public static void AutoCompleteQuest()
 {
     lock (_threadLock)
     {
         for (int i = 1; i < 20; i++)
         {
             string questIdRet     = Others.GetRandomString(Others.Random(4, 10));
             string questStatusRet = Others.GetRandomString(Others.Random(4, 10));
             Lua.LuaDoString(questIdRet + ", " + questStatusRet + " = GetAutoQuestPopUp(" + i + ");");
             string questStatus = Lua.GetLocalizedText(questStatusRet);
             int    questId     = Others.ToInt32(Lua.GetLocalizedText(questIdRet));
             if (questId == 0 && string.IsNullOrEmpty(questStatus) && i > 10)
             {
                 return;
             }
             if (questId == 0 && string.IsNullOrEmpty(questStatus))
             {
                 continue;
             }
             if (questStatus == "COMPLETE")
             {
                 if (!GetLogQuestId().Contains(questId))
                 {
                     continue;
                 }
                 string questLogEntry = Others.GetRandomString(Others.Random(4, 10));
                 string luaString     = questLogEntry + " = GetQuestLogIndexByID(" + questId + "); ";
                 luaString += "ShowQuestComplete(" + questLogEntry + ");";
                 Lua.LuaDoString(luaString);
                 Thread.Sleep(300);
                 if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                 {
                     Lua.RunMacroText("/click QuestFrameCompleteButton");
                     Thread.Sleep(300);
                 }
                 CompleteQuest();
                 Thread.Sleep(500);
                 if (!GetLogQuestId().Contains(questId)) // It's no more in the quest log, then we did turn in it sucessfuly
                 {
                     FinishedQuestSet.Add(questId);
                 }
             }
             else if (questStatus == "OFFER")
             {
                 if (GetLogQuestId().Contains(questId) || GetLogQuestIsComplete(questId) || IsQuestFlaggedCompletedLUA(questId))
                 {
                     continue;
                 }
                 string questLogEntry = Others.GetRandomString(Others.Random(4, 10));
                 string luaString     = questLogEntry + " = GetQuestLogIndexByID(" + questId + "); ";
                 luaString += "ShowQuestOffer(" + questLogEntry + ");";
                 Lua.LuaDoString(luaString);
                 Thread.Sleep(300);
                 if (Others.IsFrameVisible("QuestFrameAcceptButton") && !Others.IsFrameVisible("QuestFrameAcceptQuestButton"))
                 {
                     Lua.RunMacroText("/click QuestFrameAcceptButton");
                     Thread.Sleep(300);
                 }
                 AcceptQuest();
                 Thread.Sleep(500);
             }
         }
     }
 }
Пример #6
0
        public static void QuestTurnIn(ref Npc npc, string questName, int questId, bool ignoreBlacklist = false, bool forceTravel = false)
        {
            if (npc.ForceTravel)
            {
                forceTravel = true;
            }
            Point   me   = ObjectManager.ObjectManager.Me.Position;
            WoWUnit mNpc = ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetWoWUnitByEntry(npc.Entry, true), false, ignoreBlacklist, true);

            if (mNpc.IsValid && mNpc.CanTurnIn)
            {
                npc.Position = mNpc.Position;
            }
            WoWGameObject mObj = ObjectManager.ObjectManager.GetNearestWoWGameObject(ObjectManager.ObjectManager.GetWoWGameObjectByEntry(npc.Entry), ignoreBlacklist);

            if (mObj.IsValid && mObj.CanTurnIn)
            {
                npc.Position = mObj.Position;
            }
            bool bypassTravel = false;

            if (me.DistanceTo(npc.Position) <= 800f)
            {
                PathFinder.FindPath(npc.Position, out bypassTravel);
            }
            if (Usefuls.IsFlying && npc.ContinentIdInt == Usefuls.ContinentId)
            {
                bypassTravel = true;
            }
            else if (Usefuls.IsFlying)
            {
                MountTask.DismountMount();
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(me) > 0.1f)
            {
                if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid)
                {
                    _travelLocation = Products.Products.TravelFrom;
                    Products.Products.TravelRegenerated = false;
                }
            }
            if (!bypassTravel && (_travelLocation == null || _travelLocation.DistanceTo(me) > 0.1f) && !_travelDisabled)
            {
                MovementManager.StopMove();
                Logging.Write("Calling travel system for TurnInQuest " + questName + "(" + questId + ") from " + npc.Name + " (" + npc.Entry + ")...");
                Products.Products.TravelToContinentId   = npc.ContinentIdInt;
                Products.Products.TravelTo              = npc.Position;
                Products.Products.TravelFromContinentId = Usefuls.ContinentId;
                Products.Products.TravelFrom            = me;
                Products.Products.ForceTravel           = forceTravel;
                // Pass the check for valid destination as a lambda
                Products.Products.TargetValidationFct = IsNearQuestGiver;
                _travelLocation = Products.Products.TravelFrom;
                return;
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(me) <= 0.1f)
            {
                _travelDisabled = true;
            }
            //Start target finding based on QuestGiver.
            uint baseAddress = MovementManager.FindTarget(ref npc, 4.5f, true, true, 0f, ignoreBlacklist);

            if (MovementManager.InMovement)
            {
                return;
            }

            if (baseAddress > 0)
            {
                var tmpNpc = ObjectManager.ObjectManager.GetObjectByGuid(npc.Guid);
                if (tmpNpc is WoWUnit)
                {
                    var unitTest = tmpNpc as WoWUnit;
                    if (unitTest.IsValid && unitTest.GetDistance < 20f && !unitTest.CanTurnIn)
                    {
                        _travelDisabled = false; // reset travel
                        nManagerSetting.AddBlackList(unitTest.Guid, 30000);
                        Logging.Write("Npc QuestGiver " + unitTest.Name + " (" + unitTest.Entry + ", distance: " + unitTest.GetDistance +
                                      ") cannot TurnIn any quest right now. Blacklisting it for 30 seconds.");
                        return;
                    }
                }
            }
            _travelDisabled = false; // reset travel
            ItemInfo equip = null;

            //End target finding based on QuestGiver.
            if (mObj.IsValid && mObj.GetDistance <= 4.5f || npc.Position.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) < 4.5f && npc.Position.DistanceZ(ObjectManager.ObjectManager.Me.Position) < 6f ||
                npc.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 4.5f)
            {
                if (baseAddress <= 0)
                {
                    npc.Ignore(120000);
                    return;
                }
                if (Usefuls.IsFlying)
                {
                    MountTask.Land();
                }
                InteractTarget(ref npc, baseAddress);
                Logging.Write("QuestTurnIn " + questName + " (" + questId + ") to " + npc.Name + " (" + npc.Entry + ")");
                int id = GetQuestID();
                if (GetNumGossipActiveQuests() == 0 && id == questId)
                {
                    if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                    {
                        Lua.RunMacroText("/click QuestFrameCompleteButton");
                        Thread.Sleep(300);
                    }
                    equip = CompleteQuest();
                    Thread.Sleep(Usefuls.Latency + 500);
                }
                if (!GetLogQuestId().Contains(questId)) // It's no more in the quest log, then we did turn in it sucessfuly
                {
                    id = GetQuestID();
                    FinishedQuestSet.Add(questId);
                    CloseWindow();
                    AbandonnedId = id;
                }
                else
                {
                    bool systemWorks = GetGossipActiveQuestsWorks();
                    if (systemWorks) // 2 quest gossip systems = 2 different codes :(
                    {
                        for (int i = 1; i <= GetNumGossipActiveQuests(); i++)
                        {
                            SelectGossipActiveQuest(i);
                            Thread.Sleep(Usefuls.Latency + 500);
                            id = GetQuestID();
                            if (id == 0)
                            {
                                systemWorks = false;
                                break;
                            }
                            if (id == questId)
                            {
                                if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                                {
                                    Lua.RunMacroText("/click QuestFrameCompleteButton");
                                    Thread.Sleep(300);
                                }
                                equip = CompleteQuest();
                                Thread.Sleep(Usefuls.Latency + 500);
                                // here it can be the next quest id presented automatically when the current one is turned in
                                id = GetQuestID();
                                CloseWindow();
                                if (GetLogQuestId().Contains(questId))
                                {
                                    equip = null;
                                    Logging.WriteError("Could not turn-in quest " + questId + ": \"" + questName + "\"");
                                    break;
                                }
                                FinishedQuestSet.Add(questId);
                                AbandonnedId = id;
                                break;
                            }
                            CloseWindow();
                            Thread.Sleep(Usefuls.Latency + 500);
                            Interact.InteractWith(baseAddress);
                            Thread.Sleep(Usefuls.Latency + 500);
                        }
                    }
                    if (!systemWorks)
                    {
                        int gossipid = 1;
                        while (GetActiveTitle(gossipid) != "")
                        {
                            SelectActiveQuest(gossipid);
                            Thread.Sleep(Usefuls.Latency + 500);
                            id = GetQuestID();
                            if (id == questId)
                            {
                                if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                                {
                                    Lua.RunMacroText("/click QuestFrameCompleteButton");
                                    Thread.Sleep(300);
                                }
                                equip = CompleteQuest();
                                Thread.Sleep(Usefuls.Latency + 500);
                                CloseWindow();
                                if (GetLogQuestId().Contains(questId))
                                {
                                    equip = null;
                                    Logging.WriteError("Could not turn-in quest " + questId + ": \"" + questName + "\"");
                                    break;
                                }
                                FinishedQuestSet.Add(questId);
                                break;
                            }
                            CloseWindow();
                            Thread.Sleep(Usefuls.Latency + 500);
                            Interact.InteractWith(baseAddress);
                            Thread.Sleep(Usefuls.Latency + 500);
                            gossipid++;
                        }
                    }
                }
            }
            Thread.Sleep(Usefuls.Latency);
            if (equip != null)
            {
                ItemSelection.EquipItem(equip);
                Thread.Sleep(Usefuls.Latency + 500);
            }
            CloseWindow();
            if (!GetLogQuestId().Contains(questId))
            {
                FinishedQuestSet.Add(questId);
            }
        }
Пример #7
0
        public static void SellItems(List <String> itemSell, List <string> itemNoSell,
                                     List <Enums.WoWItemQuality> itemQuality)
        {
            try
            {
                if (nManagerSetting.CurrentSetting.DontSellReagents)
                {
                    itemNoSell.AddRange(ItemsManager.GetAllReagentsItems());
                }
                if (Products.Products.ProductName.ToLower().Contains("quest"))
                {
                    itemNoSell.AddRange(ItemsManager.GetAllQuestsItems());
                }

                string syntaxSellItem = itemSell.Aggregate("", (current, s) => current + " or namei == \"" + s + "\" ");

                string syntaxQualityItem = itemQuality.Aggregate(" 1 == 2 ",
                                                                 (current, s) => current + " or r == " + (uint)s + " ");

                string syntaxNoSellItem    = "";
                string syntaxNoSellItemEnd = "";
                if (itemNoSell.Count > 0)
                {
                    syntaxNoSellItemEnd = " end ";
                    syntaxNoSellItem    = itemNoSell.Aggregate(" if ",
                                                               (current, s) => current + " and namei ~= \"" + s + "\" ");
                    syntaxNoSellItem = syntaxNoSellItem.Replace("if  and", "if ");
                    syntaxNoSellItem = syntaxNoSellItem + " then ";
                }
                for (int i = 0; i <= 4; i++)
                {
                    string resultString = Others.GetRandomString(Others.Random(4, 10));
                    Lua.LuaDoString(resultString + " = GetContainerNumSlots(" + i + ")");
                    var result = Others.ToUInt32(Lua.GetLocalizedText(resultString));
                    for (int j = 0; j < result + 1; j++)
                    {
                        if (!Others.IsFrameVisible("MerchantFrame"))
                        {
                            return;
                        }
                        string scriptLua = "";

                        scriptLua = scriptLua + "local l,r,_=0 ";
                        scriptLua = scriptLua + "local l=GetContainerItemLink(" + i + ", " + j + ") ";
                        scriptLua = scriptLua + "if l then namei,_,r=GetItemInfo(l) ";
                        scriptLua = scriptLua + "if " + syntaxQualityItem + " " + syntaxSellItem + " then ";
                        scriptLua = scriptLua + syntaxNoSellItem;
                        scriptLua = scriptLua + " UseContainerItem(" + i + ", " + j + ") ";
                        scriptLua = scriptLua + syntaxNoSellItemEnd;
                        scriptLua = scriptLua + " end ";
                        scriptLua = scriptLua + "end ";
                        Lua.LuaDoString(scriptLua);
                        System.Threading.Thread.Sleep(150);
                    }
                }
            }
            catch (Exception e)
            {
                Logging.WriteError(
                    "SellItems(List<String> itemSell, List<string> itemNoSell, List<Enums.WoWItemQuality> itemQuality): " +
                    e);
            }
        }