Exemple #1
0
        internal static bool ShouldStashItem(CachedACDItem cItem, bool test = false)
        {
            if (cItem.AcdItem != null && cItem.AcdItem.IsValid)
            {
                var item = Legendary.GetItemByACD(cItem.AcdItem);
                if (item == null)
                {
                    Logger.Log(TrinityLogLevel.Info, "  >>  Unknown Item {0} {1} - Auto-keeping", cItem.RealName, cItem.ActorSNO);
                    return(true);
                }

                return(ShouldStashItem(item, cItem, test));;
            }
            return(false);
        }
        /// <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>
        /// 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);
        }