protected override RunStatus Run(object context) { Vendor ven = BotPoi.Current.AsVendor; WoWUnit vendor = ObjectManager.GetObjectsOfType <WoWUnit>(). FirstOrDefault(m => m.Entry == ven.Entry || m.Entry == ven.Entry2); WoWPoint loc = vendor != null ? vendor.Location : ven.Location; if (_me.Location.Distance(loc) > 4) { if (AutoAngler.Instance.MySettings.Fly) { Flightor.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, loc, 4)); } else { if (!ObjectManager.Me.Mounted && Mount.ShouldMount(loc) && Mount.CanMount()) { Mount.MountUp(() => loc); } Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, loc, 4)); } } else { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { if (vendor == null) { AutoAngler.Instance.Log("No vendor found at location {0}. hearth + logging out instead", loc); BotPoi.Current = new BotPoi(PoiType.InnKeeper); return(RunStatus.Failure); } vendor.Interact(); } else { // sell all poor and common items not in protected Items list. List <WoWItem> itemList = _me.BagItems.Where(i => !ProtectedItemsManager.Contains(i.Entry) && !i.IsSoulbound && !i.IsConjured && (i.Quality == WoWItemQuality.Poor || i.Quality == WoWItemQuality.Common)).ToList(); foreach (var item in itemList) { item.UseContainerItem(); } MerchantFrame.Instance.RepairAllItems(); BotPoi.Current = new BotPoi(PoiType.None); } } return(RunStatus.Success); }
public static async Task <bool> VendorItems() { Vendor ven = BotPoi.Current.AsVendor; WoWUnit vendor = ObjectManager.GetObjectsOfType <WoWUnit>(). FirstOrDefault(m => m.Entry == ven.Entry || m.Entry == ven.Entry2); if (vendor == null) { if (Me.Location.DistanceSqr(BotPoi.Current.Location) > 4 * 4) { return(await FlyTo(BotPoi.Current.Location, "Vendor")); } // just wait at location, maybe vendor got killed by opposite faction return(true); } if (!vendor.WithinInteractRange) { return(await FlyTo(vendor.Location, vendor.SafeName)); } if (!MerchantFrame.Instance.IsVisible) { vendor.Interact(); await CommonCoroutines.SleepForLagDuration(); return(true); } // sell all poor and common items not in protected Items list. List <WoWItem> itemList = StyxWoW.Me.BagItems.Where( i => !ProtectedItemsManager.Contains(i.Entry) && !i.IsSoulbound && !i.IsConjured && (i.Quality == WoWItemQuality.Poor || i.Quality == WoWItemQuality.Common)).ToList(); foreach (var item in itemList) { item.UseContainerItem(); await Coroutine.Sleep(Utility.Rnd.Next(200, 500)); } MerchantFrame.Instance.RepairAllItems(); BotPoi.Current = new BotPoi(PoiType.None); return(true); }
private List <WoWItem> BuildItemList() { using (StyxWoW.Memory.AcquireFrame()) { int skillLevel = 0; // cache the skillevel for this pulse.. if (ActionType == DeActionType.Disenchant) { skillLevel = StyxWoW.Me.GetSkill(SkillLine.Enchanting).CurrentValue; } else if (ActionType == DeActionType.Mill) { skillLevel = StyxWoW.Me.GetSkill(SkillLine.Inscription).CurrentValue; } else if (ActionType == DeActionType.Prospect) { skillLevel = StyxWoW.Me.GetSkill(SkillLine.Jewelcrafting).CurrentValue; } IEnumerable <WoWItem> itemQuery = from item in StyxWoW.Me.BagItems where !IsBlackListed(item) && ((ItemTarget == ItemTargetType.Specific && item.Entry == ItemId) || ItemTarget == ItemTargetType.All) select item; switch (ActionType) { case DeActionType.Disenchant: return(itemQuery.Where( i => !ProtectedItemsManager.Contains(i.Entry) && i.CanDisenchant(skillLevel) && CheckItemQuality(i) && !ProfessionbuddyBot.Instance.TradeskillTools.Contains(i.Entry)).ToList()); case DeActionType.Mill: return(itemQuery.Where(i => i.CanMill(skillLevel) && i.StackCount >= 5).ToList()); case DeActionType.Prospect: return(itemQuery.Where(i => i.CanProspect(skillLevel) && i.StackCount >= 5).ToList()); } } return(null); }
public override void Start() { ProtectedItemsManager.Add((uint)FisherSettings.Instance.LureId); // Load an empty profile if (Directory.Exists(Path.Combine(Logging.ApplicationPath, "Bots")) && Directory.Exists(Path.Combine(Logging.ApplicationPath, @"Bots\MrFishIt"))) { string emtpyProfile = Path.Combine(Logging.ApplicationPath, @"Bots\MrFishIt\EmptyProfile.xml"); if (File.Exists(emtpyProfile)) { ProfileManager.LoadNew(emtpyProfile, false); return; } throw new HonorbuddyUnableToStartException("Couldn't find empty profile for MrFishIt!"); } Lua.Events.AttachEvent("LOOT_OPENED", HandleLootOpened); // Make sure we don't get logged out StyxSettings.Instance.LogoutForInactivity = false; }
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; } }
protected override RunStatus Run(object context) { WoWPoint mboxLoc = BotPoi.Current.Location; WoWGameObject mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>(). FirstOrDefault(m => m.SubType == WoWGameObjectType.Mailbox && m.Location.Distance(mboxLoc) < 10); WoWPoint loc = mailbox != null ? mailbox.Location : mboxLoc; if (_me.Location.Distance(loc) > 4) { if (AutoAngler.Instance.MySettings.Fly) { Flightor.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, loc, 3)); } else { if (!StyxWoW.Me.Mounted && Mount.ShouldMount(loc) && Mount.CanMount()) { Mount.MountUp(() => loc); } Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, loc, 4)); } } else { if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (mailbox == null) { AutoAngler.Instance.Log("No Mailbox found at location {0}. Vendoring instead", loc); Vendor ven = ProfileManager.CurrentOuterProfile.VendorManager.GetClosestVendor(); if (ven != null) { BotPoi.Current = new BotPoi(ven, PoiType.Repair); } else { BotPoi.Current = new BotPoi(PoiType.InnKeeper); } return(RunStatus.Failure); } mailbox.Interact(); } else { Vendor ven = ProfileManager.CurrentOuterProfile.VendorManager.GetClosestVendor(); if (ven != null) { // mail all except grey items which we will vendor. MailFrame.Instance.SendMailWithManyAttachments(CharacterSettings.Instance.MailRecipient, 0, _me.BagItems.Where( i => !i.IsSoulbound && !i.IsConjured && i.Quality != WoWItemQuality.Poor && !ProtectedItemsManager.Contains(i.Entry)) . ToArray()); BotPoi.Current = new BotPoi(ven, PoiType.Repair); } else { // mail all since no vender is in profile MailFrame.Instance.SendMailWithManyAttachments(CharacterSettings.Instance.MailRecipient, 0, _me.BagItems.Where( i => !i.IsSoulbound && !i.IsConjured && !ProtectedItemsManager.Contains(i.Entry)) . ToArray()); BotPoi.Current = new BotPoi(PoiType.None); } } } return(RunStatus.Success); }