/// <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; } //Core.Logger.Log("[CubeRaresToLegendary] CubeRaresToLegendary Started! Wooo!"); var backpackGuids = new HashSet <int>(InventoryManager.Backpack.Select(i => i.ACDId)); if (HasMaterialsRequired) { if (TownInfo.KanaisCube.Distance > 10f || !GameUI.KanaisCubeWindow.IsVisible) { if (!await MoveToAndInteract.Execute(TownInfo.KanaisCube)) { Core.Logger.Log("Failed to move to the cube, quite unfortunate."); break; } continue; } //Core.Logger.Log("[CubeRaresToLegendary] Ready to go, Lets transmute!"); var item = GetBackPackRares(types).First(); var itemName = item.Name; var itemAnnId = item.AnnId; var itemInternalName = item.InternalName; await Transmute.Execute(item, TransmuteRecipe.UpgradeRareItem); await Coroutine.Sleep(1500); var newItem = InventoryManager.Backpack.FirstOrDefault(i => !backpackGuids.Contains(i.ACDId)); if (newItem != null) { var newLegendaryItem = Legendary.GetItemByACD(newItem); var newTrinityItem = Core.Actors.ItemByAnnId(newItem.AnnId); ItemEvents.FireItemCubed(newTrinityItem); if (newTrinityItem.IsPrimalAncient) { Core.Logger.Warn($"[CubeRaresToLegendary] Upgraded Rare '{itemName}' ---> '{newLegendaryItem.Name}' ({newItem.ActorSnoId}) PRIMAL!~"); } else { Core.Logger.Log($"[CubeRaresToLegendary] Upgraded Rare '{itemName}' ---> '{newLegendaryItem.Name}' ({newItem.ActorSnoId})"); } } else { Core.Logger.Log("[CubeRaresToLegendary] Failed to upgrade Item '{0}' {1} DynId={2} HasBackpackMaterials={3}", itemName, itemInternalName, itemAnnId, HasMaterialsRequired); } Core.Inventory.InvalidAnnIds.Add(itemAnnId); } else { Core.Logger.Log("[CubeRaresToLegendary] Oh no! Out of materials!"); return(true); } await Coroutine.Sleep(500); await Coroutine.Yield(); } return(true); }