private static async Task <bool> SellGems() { var inventoryGems = Inventories.InventoryItems.Where(i => i.Components.SkillGemComponent != null).Select(i => i.LocationTopLeft).ToList(); if (inventoryGems.Count == 0) { GlobalLog.Error("[SellGems] Unexpected error. Fail to find any skill gem in inventory."); return(false); } return(await TownNpcs.SellItems(inventoryGems)); }
public async Task <bool> Run() { if (ErrorLimitReached) { return(false); } var area = World.CurrentArea; if (!area.IsTown && !area.IsHideoutArea) { return(false); } if (_shouldUpdateStashData) { GlobalLog.Debug("[SellExtraMapsTask] Updating map tab stash data (every Start)"); if (!await OpenMapTab()) { return(true); } else { Class1.MapStashData.SyncWithStashTab(); } _shouldUpdateStashData = false; } else { if (!await Inventories.OpenStashTab(settings.Instance.MapStashTab)) { ReportError(); return(true); } Class1.MapStashData.SyncWithStashTab(); if (Class1.MapStashData.GetMapCount() > settings.Instance.MaxNumMaps) { var mapsInStashTab = Inventories.StashTabItems .Where(m => m.IsMap() && m.Rarity != Rarity.Unique) .OrderBy(m => m.Priority()) .ThenBy(m => m.MapTier).Take(settings.Instance.SellNumMaps); foreach (var mapItem in mapsInStashTab) { if (!await Inventories.FastMoveFromStashTab(mapItem.LocationTopLeft)) { ReportError(); return(true); } } await Wait.SleepSafe(300); Class1.MapStashData.SyncWithStashTab(); var mapSellItems = Inventories.InventoryItems .Where(m => m.IsMap()) .Select(i => i.LocationTopLeft) .ToList(); if (mapSellItems.Count == 0) { GlobalLog.Error("[SellExtraMapsTask] Unknown error. There are no map items in player's inventory after taking them from stash."); ReportError(); return(true); } if (!await TownNpcs.SellItems(mapSellItems)) { ReportError(); } } else { return(false); } } return(true); }
public async Task <bool> Run() { if (MapBot.IsOnRun) { return(false); } var area = World.CurrentArea; if (!area.IsTown && !area.IsHideoutArea) { return(false); } MapExtensions.AtlasData.Update(); if (!Settings.SellEnabled) { return(false); } if (Inventories.AvailableInventorySquares < 3) { GlobalLog.Error("[SellMapTask] Not enough inventory space."); return(false); } var firstMapTab = ExSettings.Instance.GetTabsForCategory(ExSettings.StashingCategory.Map).First(); if (!await Inventories.OpenStashTab(firstMapTab)) { GlobalLog.Error($"[SellMapTask] Fail to open stash tab \"{firstMapTab}\"."); return(false); } var maps = Inventories.StashTabItems .Where(m => m.IsMap() && m.ShouldSell()) .OrderBy(m => m.Priority()) .ThenBy(m => m.MapTier) .ToList(); if (maps.Count == 0) { return(false); } var mapGroups = new List <Item[]>(); foreach (var mapGroup in maps.GroupBy(m => m.Name)) { var groupList = mapGroup.ToList(); for (int i = 3; i <= groupList.Count; i += 3) { var group = new Item[3]; group[0] = groupList[i - 3]; group[1] = groupList[i - 2]; group[2] = groupList[i - 1]; mapGroups.Add(group); } } if (mapGroups.Count == 0) { GlobalLog.Info("[SellMapTask] No map group for sale was found."); return(false); } GlobalLog.Info($"[SellMapTask] Map groups for sale: {mapGroups.Count}"); foreach (var mapGroup in mapGroups) { if (Inventories.AvailableInventorySquares < 3) { GlobalLog.Error("[SellMapTask] Not enough inventory space."); break; } //exclude ignored maps from min map amount check, if sell ignored maps is enabled if (!Settings.SellIgnoredMaps || !mapGroup[0].Ignored()) { int mapAmount = Inventories.StashTabItems.Count(i => i.IsMap() && i.Rarity != Rarity.Unique); if ((mapAmount - 3) < Settings.MinMapAmount) { GlobalLog.Warn($"[SellMapTask] Min map amount is reached {mapAmount}(-3) from required {Settings.MinMapAmount}"); break; } } for (int i = 0; i < 3; i++) { var map = mapGroup[i]; GlobalLog.Info($"[SellMapTask] Now getting {i + 1}/{3} \"{map.Name}\"."); if (!await Inventories.FastMoveFromStashTab(map.LocationTopLeft)) { ErrorManager.ReportError(); return(true); } } } await Wait.SleepSafe(200); var forSell = Inventories.InventoryItems.Where(i => i.IsMap()).Select(m => m.LocationTopLeft).ToList(); if (forSell.Count == 0) { return(false); } if (!await TownNpcs.SellItems(forSell)) { ErrorManager.ReportError(); } return(true); }
public async Task <bool> Run() { if (ErrorLimitReached) { return(false); } var area = World.CurrentArea; if (!area.IsTown && !area.IsHideoutArea) { return(false); } if (!ChaosRecipe.StashData.HasCompleteSet()) { GlobalLog.Info("[SellRecipeTask] No chaos recipe set to sell."); return(false); } GlobalLog.Debug("[SellRecipeTask] Now going to take and sell a set of rare items for chaos recipe."); if (!await Inventories.OpenStashTab(Settings.Instance.StashTab)) { ReportError(); return(true); } ChaosRecipe.StashData.SyncWithStashTab(); if (!ChaosRecipe.StashData.HasCompleteSet()) { GlobalLog.Error("[SellRecipeTask] Saved stash data does not match actual stash data."); await Coroutines.CloseBlockingWindows(); return(false); } var takenItemData = new RecipeData(); int lowestItemType = RecipeItemType.None; var lowestItem = Inventories.StashTabItems .OrderBy(i => i.ItemLevel) .FirstOrDefault(i => RecipeData.IsItemForChaosRecipe(i, out lowestItemType)); if (lowestItem == null) { GlobalLog.Error("[SellRecipeTask] Unknown error. Fail to find actual item for chaos recipe."); ReportError(); return(true); } GlobalLog.Debug($"[SellRecipeTask] Now taking \"{lowestItem.Name}\" (iLvl: {lowestItem.ItemLevel})"); if (!await Inventories.FastMoveFromStashTab(lowestItem.LocationTopLeft)) { ReportError(); return(true); } takenItemData.IncreaseItemCount(lowestItemType); while (true) { int type = RecipeItemType.None; for (int i = 0; i < RecipeItemType.TotalTypeCount; i++) { var count = takenItemData.GetItemCount(i); if (count == 0 || (count == 1 && i == RecipeItemType.Ring)) { type = i; break; } } if (type == RecipeItemType.None) { break; } var item = Inventories.StashTabItems .Where(i => RecipeData.IsItemForChaosRecipe(i, out var t) && t == type) .OrderByDescending(i => i.ItemLevel) .FirstOrDefault(); if (item == null) { GlobalLog.Error("[SellRecipeTask] Unknown error. Fail to find actual item for chaos recipe."); ReportError(); return(true); } GlobalLog.Debug($"[SellRecipeTask] Now taking \"{item.Name}\" (iLvl: {item.ItemLevel})"); if (!await Inventories.FastMoveFromStashTab(item.LocationTopLeft)) { ReportError(); return(true); } takenItemData.IncreaseItemCount(type); } await Wait.SleepSafe(300); ChaosRecipe.StashData.SyncWithStashTab(); var recipeItems = Inventories.InventoryItems .Where(i => RecipeData.IsItemForChaosRecipe(i, out var t)) .Select(i => i.LocationTopLeft) .ToList(); if (recipeItems.Count == 0) { GlobalLog.Error("[SellRecipeTask] Unknown error. There are no items in player's inventory after taking them from stash."); ReportError(); return(true); } if (!await TownNpcs.SellItems(recipeItems)) { ReportError(); } return(true); }
public async Task <bool> Run() { var area = World.CurrentArea; if (!area.IsTown && !area.IsHideoutArea) { return(false); } var itemsToSell = new List <Vector2i>(); var itemFilter = ItemEvaluator.Instance; foreach (var item in Inventories.InventoryItems) { var c = item.Class; if (c == ItemClasses.QuestItem || c == ItemClasses.PantheonSoul) { continue; } if (item.HasMicrotransitionAttachment || item.HasSkillGemsEquipped) { continue; } if (!itemFilter.Match(item, EvaluationType.Sell)) { continue; } if (itemFilter.Match(item, EvaluationType.Save)) { continue; } itemsToSell.Add(item.LocationTopLeft); } if (Settings.Instance.SellExcessPortals) { foreach (var portal in Inventories.GetExcessCurrency(CurrencyNames.Portal)) { itemsToSell.Add(portal.LocationTopLeft); } } if (itemsToSell.Count == 0) { GlobalLog.Info("[SellTask] No items to sell."); return(false); } GlobalLog.Info($"[SellTask] {itemsToSell.Count} items to sell."); if (!await TownNpcs.SellItems(itemsToSell)) { ErrorManager.ReportError(); } return(true); }