public static async Task <bool> Execute(ItemQualityColor qualityColor, List <ItemType> types = null, int totalAmount = -1, int vendorId = -1) { Logger.Log("BuyItemsFromVendor Started!"); //if (ZetaDia.Me.Inventory.NumFreeBackpackSlots < totalAmount * 2) //{ // Logger.Log("Not enough bag space to buy {0} items", totalAmount); // await BrainBehavior.CreateVendorBehavior().ExecuteCoroutine(); //} foreach (var item in ZetaDia.Me.Inventory.MerchantItems) { item.PrintEFlags(); } var items = ZetaDia.Me.Inventory.MerchantItems.ToList(); var vendorLocation = Town.Locations.GetLocationFromActorId(vendorId); if (!await MoveToAndInteract.Execute(vendorLocation, vendorId, 5f)) { return(false); } Logger.Log("BuyItemsFromVendor Finished!"); return(true); }
public static async Task <bool> Execute() { if (!ZetaDia.IsInTown) { IsDumpingShards = false; } try { while (CanRun() && (!ShouldSaveShards || IsDumpingShards)) { IsDumpingShards = true; var distance = Town.Locations.Kadala.Distance(ZetaDia.Me.Position); if (distance > 8f && !await MoveToAndInteract.Execute(Town.Locations.Kadala, Town.ActorIds.Kadala, 3f)) { Logger.Log("[Gamble] Failed to move to Kadala, quite unfortunate."); break; } if (CanBuyItems) { await BuyItem(); } else { Resources.GameUI.CloseVendorWindow(); } if (!TrinityItemManager.IsAnyTwoSlotBackpackLocation) { BrainBehavior.ForceTownrun(); } await Coroutine.Sleep(100); await Coroutine.Yield(); } } catch (Exception ex) { Logger.LogError("Exception in Gamble.Execute, {0}", ex); if (ex is CoroutineStoppedException) { throw; } } return(true); }
public static async Task <bool> Execute(List <ACDItem> transmuteGroup) { if (!ZetaDia.IsInGame) { return(false); } if (transmuteGroup.Count > 9) { Logger.Log(" --> Can't convert more than 9 items!"); return(false); } Logger.Log("Transmuting:"); foreach (var item in transmuteGroup) { if (item == null || !item.IsValid || item.IsDisposed) { Logger.Log(" --> Invalid Item Found {0}"); return(false); } Logger.Log(" --> {0} StackQuantity={1} Quality={2} CraftingMaterial={3}", item.Name, item.ItemStackQuantity, item.GetItemQuality(), item.IsCraftingReagent); } await Coroutine.Yield(); if (!UIElements.TransmuteItemsDialog.IsVisible) { await Coroutine.Sleep(500); await MoveToAndInteract.Execute(Town.Locations.KanaisCube, Town.ActorIds.KanaisCube, 8f); await Coroutine.Sleep(1000); if (!UIElements.TransmuteItemsDialog.IsVisible) { Logger.Log("Cube window needs to be open before you can transmute anything."); return(false); } } Logger.Log("Zip Zap!"); ZetaDia.Me.Inventory.TransmuteItems(transmuteGroup); return(true); }
public static async Task <bool> Execute(List <ItemSelectionType> types = null) { if (!CanRun()) { return(true); } Logger.LogVerbose("[CubeItemsToMaterials] Getting Materials from Stash"); if (!Inventory.Materials.HasStackQuantityOfTypes(Inventory.MaterialConversionTypes, InventorySlot.BackpackItems, 100) && !await TakeItemsFromStash.Execute(Inventory.RareUpgradeIds, 5000)) { return(true); } Logger.LogVerbose("[CubeItemsToMaterials] Time to Convert some junk into delicious crafting materials."); if (!await MoveToAndInteract.Execute(Town.Locations.KanaisCube, Town.ActorIds.KanaisCube, 3f)) { Logger.Log("[CubeItemsToMaterials] Failed to move to the cube, quite unfortunate."); return(true); } if (_highest.Type == InventoryItemType.None) { Logger.Log("[CubeItemsToMaterials] Error: Highest material count is unknown."); return(true); } foreach (var material in _materials) { if (!await ConvertMaterials.Execute(_highest.Type, material.Key)) { Logger.Log("[Cube] Failed! Finished!"); return(true); } await Coroutine.Sleep(100); await Coroutine.Yield(); } Logger.LogVerbose("[Cube] CubeItemsToMaterials Finished!"); return(true); }
/// <summary> /// Convert rares into legendaries with Kanai's cube /// </summary> /// <param name="types">restrict the rares that can be selected by ItemType</param> public static async Task <bool> Execute(List <ItemSelectionType> types = null) { while (CanRun(types)) { if (!ZetaDia.IsInTown) { break; } Logger.Log("[CubeRaresToLegendary] CubeRaresToLegendary Started! Wooo!"); var backpackGuids = new HashSet <int>(ZetaDia.Me.Inventory.Backpack.Select(i => i.ACDGuid)); if (BackpackHasMaterials) { if (Town.Locations.KanaisCube.Distance(ZetaDia.Me.Position) > 10f || !GameUI.KanaisCubeWindow.IsVisible) { if (!await MoveToAndInteract.Execute(Town.Locations.KanaisCube, Town.ActorIds.KanaisCube, 3f)) { Logger.Log("Failed to move to the cube, quite unfortunate."); break; } continue; } Logger.Log("[CubeRaresToLegendary] Ready to go, Lets transmute!"); var item = GetBackPackRares(types).First(); var itemName = item.Name; var itemDynamicId = item.DynamicId; var itemInternalName = item.InternalName; var transmuteGroup = new List <ACDItem> { item, }; transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.ArcaneDust, 50)); transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.VeiledCrystals, 50)); transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.ReusableParts, 50)); transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.DeathsBreath, 25)); await Transmute.Execute(transmuteGroup); await Coroutine.Sleep(1500); var newItem = ZetaDia.Me.Inventory.Backpack.FirstOrDefault(i => !backpackGuids.Contains(i.ACDGuid)); if (newItem != null) { var newLegendaryItem = Legendary.GetItemByACD(newItem); Logger.Log("[CubeRaresToLegendary] Upgraded Rare '{0}' ---> '{1}' ({2})", itemName, newLegendaryItem.Name, newItem.ActorSNO); } else { Logger.Log("[CubeRaresToLegendary] Failed to upgrade Item '{0}' {1} DynId={2} HasBackpackMaterials={3}", itemName, itemInternalName, itemDynamicId, BackpackHasMaterials); } Inventory.InvalidItemDynamicIds.Add(itemDynamicId); } else if (StashHasMaterials) { Logger.Log("[CubeRaresToLegendary] Getting Materials from Stash"); if (!await TakeItemsFromStash.Execute(Inventory.RareUpgradeIds, 5000)) { return(true); } } else { Logger.Log("[CubeRaresToLegendary] Oh no! Out of materials!"); return(true); } await Coroutine.Sleep(500); await Coroutine.Yield(); } return(true); }
/// <summary> /// Moves items from the Stash to the Backpack /// </summary> /// <param name="itemIds">list of items to withdraw</param> /// <param name="maxAmount">amount to withdraw up to (including counts already in backpack)</param> /// <returns></returns> public static async Task <bool> Execute(IEnumerable <int> itemIds, int maxAmount) { Logger.Log("TakeItemsFromStash Started!"); if (!ZetaDia.IsInGame || !ZetaDia.IsInTown) { return(true); } if (Town.Locations.Stash.Distance(ZetaDia.Me.Position) > 3f) { await MoveToAndInteract.Execute(Town.Locations.Stash, Town.ActorIds.Stash, 8f); } var stash = Town.Actors.Stash; if (stash == null) { Logger.Log("Unable to find Stash"); return(false); } if (!UIElements.StashWindow.IsVisible && Town.Locations.Stash.Distance(ZetaDia.Me.Position) <= 10f) { Logger.Log("Stash window not open, interacting"); stash.Interact(); } var itemIdsHashSet = new HashSet <int>(itemIds); var amountWithdrawn = itemIdsHashSet.ToDictionary(k => k, v => (long)0); var overageTaken = itemIdsHashSet.ToDictionary(k => k, v => false); var lastStackTaken = itemIdsHashSet.ToDictionary(k => k, v => default(ACDItem)); foreach (var item in ZetaDia.Me.Inventory.Backpack.Where(i => i.ACDGuid != 0 && i.IsValid && itemIdsHashSet.Contains(i.ActorSNO)).ToList()) { amountWithdrawn[item.ActorSNO] += item.ItemStackQuantity; lastStackTaken[item.ActorSNO] = item; } foreach (var item in ZetaDia.Me.Inventory.StashItems.Where(i => i.ACDGuid != 0 && i.IsValid && itemIdsHashSet.Contains(i.ActorSNO)).ToList()) { try { if (!item.IsValid || item.IsDisposed) { continue; } var stackSize = item.ItemStackQuantity; var numTakenAlready = amountWithdrawn[item.ActorSNO]; // We have enough of this material already var alreadyTakenEnough = numTakenAlready >= maxAmount; if (alreadyTakenEnough) { continue; } // We have enough of everything already. if (amountWithdrawn.All(i => i.Value >= maxAmount)) { break; } // Only take up to the required amount. var willBeOverMax = numTakenAlready + stackSize > maxAmount; if (!willBeOverMax || !overageTaken[item.ActorSNO]) { var lastItem = lastStackTaken[item.ActorSNO]; var amountRequiredToMax = maxAmount - numTakenAlready; if (willBeOverMax && lastItem != null && lastItem.IsValid && !lastItem.IsDisposed && stackSize > amountRequiredToMax) { // Tried InventoryManager.SplitStack but it didnt work, reverting to moving onto existing stacks. var amountToSplit = stackSize - lastItem.ItemStackQuantity; Logger.Log("Merging Stash Stack {0} onto Backpack Stack. StackSize={1} WithdrawnAlready={2}", item.Name, amountToSplit, numTakenAlready); ZetaDia.Me.Inventory.MoveItem(item.DynamicId, ZetaDia.Me.CommonData.DynamicId, InventorySlot.BackpackItems, lastItem.InventoryColumn, lastItem.InventoryRow); amountWithdrawn[item.ActorSNO] += amountToSplit; overageTaken[item.ActorSNO] = true; } else { Logger.Log("Removing {0} ({3}) from stash. StackSize={1} WithdrawnAlready={2}", item.Name, stackSize, numTakenAlready, item.ActorSNO); if (item.IsValid && !item.IsDisposed) { ZetaDia.Me.Inventory.QuickWithdraw(item); amountWithdrawn[item.ActorSNO] += stackSize; lastStackTaken[item.ActorSNO] = item; } } await Coroutine.Sleep(25); await Coroutine.Yield(); } } catch (Exception ex) { Logger.LogError(ex.ToString()); } } await Coroutine.Sleep(1000); Logger.Log("TakeItemsFromStash Finished!"); return(true); }