Пример #1
0
        private void MoveToAh()
        {
            WoWPoint movetoPoint = _loc;
            WoWUnit  auctioneer;

            if (AutoFindAh || movetoPoint == WoWPoint.Zero)
            {
                auctioneer =
                    ObjectManager.GetObjectsOfType <WoWUnit>()
                    .Where(o => o.IsAuctioneer && o.IsAlive)
                    .OrderBy(o => o.Distance)
                    .FirstOrDefault();
            }
            else
            {
                auctioneer =
                    ObjectManager.GetObjectsOfType <WoWUnit>()
                    .Where(o => o.IsAuctioneer && o.Location.Distance(_loc) < 5)
                    .OrderBy(o => o.Distance)
                    .FirstOrDefault();
            }
            if (auctioneer != null)
            {
                movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, auctioneer.Location, 3);
            }
            else if (movetoPoint == WoWPoint.Zero)
            {
                movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestAH, 0);
            }
            if (movetoPoint == WoWPoint.Zero)
            {
                PBLog.Warn(Strings["Error_UnableToFindAuctioneer"]);
            }
            if (movetoPoint.Distance(StyxWoW.Me.Location) > 4.5)
            {
                Util.MoveTo(movetoPoint);
            }
            else if (auctioneer != null)
            {
                auctioneer.Interact();
            }
        }
Пример #2
0
        private void MoveToBanker()
        {
            WoWPoint  movetoPoint = _loc;
            WoWObject bank        = GetLocalBanker();

            if (bank != null)
            {
                movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, bank.Location, 4);
            }
            // search the database
            else if (movetoPoint == WoWPoint.Zero)
            {
                movetoPoint = MoveToAction.GetLocationFromDB(
                    Bank == BankType.Personal
                                                ? MoveToAction.MoveToType.NearestBanker
                                                : MoveToAction.MoveToType.NearestGB,
                    NpcEntry);
            }
            if (movetoPoint == WoWPoint.Zero)
            {
                IsDone = true;
                PBLog.Warn("Unable to find bank");
            }
            if (movetoPoint.Distance(StyxWoW.Me.Location) > 4)
            {
                Util.MoveTo(movetoPoint);
            }
            // since there are many personal bank replacement addons I can't just check if frame is open and be generic.. using events isn't reliable
            else if (bank != null)
            {
                bank.Interact();
            }
            else
            {
                IsDone = true;
                PBLog.Warn(Strings["Error_UnableToFindBank"]);
            }
        }
Пример #3
0
        protected override async Task Run()
        {
            if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible)
            {
                WoWPoint movetoPoint = _loc;
                if (_entry == 0)
                {
                    _entry = NpcEntry;
                }
                if (_entry == 0)
                {
                    MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestVendor, 0);
                    NpcResult npcResults = NpcQueries.GetNearestNpc(
                        StyxWoW.Me.MapId,
                        StyxWoW.Me.Location,
                        UnitNPCFlags.Vendor);
                    _entry      = (uint)npcResults.Entry;
                    movetoPoint = npcResults.Location;
                }
                WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == _entry).
                               OrderBy(o => o.Distance).FirstOrDefault();
                if (unit != null)
                {
                    movetoPoint = unit.Location;
                }
                else if (movetoPoint == WoWPoint.Zero)
                {
                    movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry);
                }
                if (movetoPoint != WoWPoint.Zero && StyxWoW.Me.Location.Distance(movetoPoint) > 4.5)
                {
                    Util.MoveTo(movetoPoint);
                }
                else if (unit != null)
                {
                    unit.Target();
                    unit.Interact();
                }

                if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible &&
                    GossipFrame.Instance.GossipOptionEntries != null)
                {
                    foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries)
                    {
                        if (ge.Type == GossipEntry.GossipEntryType.Vendor)
                        {
                            GossipFrame.Instance.SelectGossipOption(ge.Index);
                            return;
                        }
                    }
                }
            }
            else
            {
                if (SellItemType == SellItemActionType.Specific)
                {
                    var      idList  = new List <uint>();
                    string[] entries = ItemID.Split(',');
                    if (entries.Length > 0)
                    {
                        foreach (string entry in entries)
                        {
                            uint itemID;
                            if (!uint.TryParse(entry.Trim(), out itemID))
                            {
                                PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                                continue;
                            }
                            idList.Add(itemID);
                        }
                    }
                    else
                    {
                        PBLog.Warn(Strings["Error_NoItemEntries"]);
                        IsDone = true;
                        return;
                    }
                    List <WoWItem> itemList = StyxWoW.Me.BagItems.Where(u => idList.Contains(u.Entry)).
                                              Take(Sell == DepositWithdrawAmount.All ? int.MaxValue : Count).ToList();
                    using (StyxWoW.Memory.AcquireFrame())
                    {
                        foreach (WoWItem item in itemList)
                        {
                            item.UseContainerItem();
                        }
                    }
                }
                else
                {
                    List <WoWItem>        itemList  = null;
                    IEnumerable <WoWItem> itemQuery = from item in Me.BagItems
                                                      where !ProtectedItemsManager.Contains(item.Entry) &&
                                                      !ProfessionbuddyBot.Instance.TradeskillTools.Contains(item.Entry)
                                                      select item;
                    switch (SellItemType)
                    {
                    case SellItemActionType.Greys:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Poor).ToList();
                        break;

                    case SellItemActionType.Whites:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Common).ToList();
                        break;

                    case SellItemActionType.Greens:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Uncommon).ToList();
                        break;

                    case SellItemActionType.Blues:
                        itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Rare).ToList();
                        break;
                    }
                    if (itemList != null)
                    {
                        using (StyxWoW.Memory.AcquireFrame())
                        {
                            foreach (WoWItem item in itemList)
                            {
                                item.UseContainerItem();
                            }
                        }
                    }
                }
                PBLog.Log("SellItemAction Completed for {0}", ItemID);
                IsDone = true;
            }
        }
Пример #4
0
        protected override async Task Run()
        {
            if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible)
            {
                WoWPoint movetoPoint = _loc;
                WoWUnit  unit        = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry).
                                       OrderBy(o => o.Distance).FirstOrDefault();
                if (unit != null)
                {
                    movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3);
                }
                else if (movetoPoint == WoWPoint.Zero)
                {
                    movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry);
                }
                if (movetoPoint != WoWPoint.Zero && StyxWoW.Me.Location.Distance(movetoPoint) > 4.5)
                {
                    Util.MoveTo(movetoPoint);
                }
                else if (unit != null)
                {
                    unit.Target();
                    unit.Interact();
                }
                if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible &&
                    GossipFrame.Instance.GossipOptionEntries != null)
                {
                    foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries)
                    {
                        if (ge.Type == GossipEntry.GossipEntryType.Vendor)
                        {
                            GossipFrame.Instance.SelectGossipOption(ge.Index);
                            break;
                        }
                    }
                }
            }
            else
            {
                // check if we have merchant frame open at correct NPC
                if (NpcEntry > 0 && Me.GotTarget && Me.CurrentTarget.Entry != NpcEntry)
                {
                    MerchantFrame.Instance.Close();
                    return;
                }
                if (!_concludingSw.IsRunning)
                {
                    if (BuyItemType == BuyItemActionType.SpecificItem)
                    {
                        var      idList  = new List <uint>();
                        string[] entries = ItemID.Split(',');
                        if (entries.Length > 0)
                        {
                            foreach (string entry in entries)
                            {
                                uint itemID;
                                if (!uint.TryParse(entry.Trim(), out itemID))
                                {
                                    PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim());
                                    continue;
                                }
                                idList.Add(itemID);
                            }
                        }
                        else
                        {
                            PBLog.Warn(Strings["Error_NoItemEntries"]);
                            IsDone = true;
                            return;
                        }
                        foreach (uint id in idList)
                        {
                            int count = !BuyAdditively?Math.Max(Count - Util.GetCarriedItemCount(id), 0) : Count;

                            if (count > 0)
                            {
                                BuyItem(id, (uint)count);
                            }
                        }
                    }
                    else if (BuyItemType == BuyItemActionType.Material)
                    {
                        foreach (var kv in ProfessionbuddyBot.Instance.MaterialList)
                        {
                            // only buy items if we don't have enough in bags...
                            int amount = kv.Value - (int)Ingredient.GetInBagItemCount(kv.Key);
                            if (amount > 0)
                            {
                                BuyItem(kv.Key, (uint)amount);
                            }
                        }
                    }
                    _concludingSw.Start();
                }
                if (_concludingSw.ElapsedMilliseconds >= 2000)
                {
                    PBLog.Log("BuyItemAction Completed");
                    IsDone = true;
                }
            }
        }
Пример #5
0
        protected override async Task Run()
        {
            if (!_interactTimer.IsFinished)
            {
                return;
            }

            if (!TrainerFrame.Instance.IsVisible || !StyxWoW.Me.GotTarget || StyxWoW.Me.CurrentTarget.Entry != NpcEntry)
            {
                WoWPoint movetoPoint = _loc;
                WoWUnit  unit        = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry).
                                       OrderBy(o => o.Distance).FirstOrDefault();

                if (unit != null)
                {
                    movetoPoint = unit.Location;
                }
                else if (movetoPoint == WoWPoint.Zero)
                {
                    movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry);
                }

                if (movetoPoint != WoWPoint.Zero && StyxWoW.Me.Location.Distance(movetoPoint) > 4.5)
                {
                    Util.MoveTo(movetoPoint);
                    return;
                }

                if (GossipFrame.Instance.IsVisible)
                {
                    foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries)
                    {
                        if (ge.Type == GossipEntry.GossipEntryType.Trainer)
                        {
                            GossipFrame.Instance.SelectGossipOption(ge.Index);
                            return;
                        }
                    }
                    PBLog.Warn("NPC does not provide a train gossip option");
                    // we should not continue at this point.
                    TreeRoot.Stop();
                    return;
                }

                if (Me.IsMoving)
                {
                    WoWMovement.MoveStop();
                    return;
                }

                if (unit != null)
                {
                    if (Me.CurrentTargetGuid != unit.Guid)
                    {
                        unit.Target();
                        return;
                    }
                    _interactTimer.Reset();
                    unit.Interact();
                }

                return;
            }

            if (_trainWaitTimer.IsFinished)
            {
                using (StyxWoW.Memory.AcquireFrame())
                {
                    Lua.DoString("SetTrainerServiceTypeFilter('available', 1)");
                    // check if there is any abilities to that need training.
                    var numOfAvailableAbilities =
                        Lua.GetReturnVal <int>(
                            "local a=0 for n=GetNumTrainerServices(),1,-1 do if select(3,GetTrainerServiceInfo(n)) == 'available' then a=a+1 end end return a ",
                            0);
                    if (numOfAvailableAbilities == 0)
                    {
                        IsDone = true;
                        PBLog.Log("Done training");
                        return;
                    }
                    Lua.DoString("BuyTrainerService(0) ");
                    _trainWaitTimer.Reset();
                }
            }
        }