private static async Task <bool> ExtractPower(TrinityItem item)
        {
            if (item == null)
            {
                return(false);
            }

            var itemName         = item.Name;
            var itemDynamicId    = item.AnnId;
            var itemInternalName = item.InternalName;
            var itemSnoId        = item.ActorSnoId;
            var affixDescription = item.Reference.LegendaryAffix;

            await Transmute.Execute(item, TransmuteRecipe.ExtractLegendaryPower);

            await Coroutine.Sleep(1500);

            var shouldBeDestroyedItem = InventoryManager.Backpack.FirstOrDefault(i => i.AnnId == itemDynamicId);

            if (shouldBeDestroyedItem == null && ZetaDia.Storage.PlayerDataManager.ActivePlayerData.KanaisPowersExtractedActorSnoIds.Contains(itemSnoId))
            {
                Core.Logger.Log($"[ExtractLegendaryPowers] Item Power Extracted! '{itemName}' ({itemSnoId}) Description={affixDescription}");
                Core.Inventory.InvalidAnnIds.Add(itemDynamicId);
                _itemsTakenFromStashAnnId.Remove(itemDynamicId);
                return(true);
            }

            Core.Logger.Log($"[ExtractLegendaryPowers] Failed to Extract Power! '{itemName}' ({itemSnoId}) {itemInternalName} DynId={itemDynamicId}");
            _blacklistedActorSnoIds.Add(itemSnoId);
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Converts crafting materials into other types of crafting materials
        /// </summary>
        /// <param name="from">the type of material you will consume</param>
        /// <param name="to">the type of material you will get more of</param>
        public static async Task <bool> Execute(CurrencyType from, CurrencyType to)
        {
            Core.Logger.Log("[ConvertMaterials] Wooo! Lets convert some {0} to {1}", from, to);

            if (!ZetaDia.IsInGame || !ZetaDia.IsInTown)
            {
                return(false);
            }

            if (!CurrencyConversionTypes.Contains(to) || !CurrencyConversionTypes.Contains(from))
            {
                Core.Logger.Log("[Cube] Unable to convert from {0} to {1}", from, to);
                return(false);
            }

            var fromAmount       = GetCurrency(from);
            var toAmount         = GetCurrency(to);
            var sacraficialItems = GetSacraficialItems(to);

            Core.Logger.Verbose($"[ConvertMaterials] Starting Material Counts DeathsBreath={Core.Inventory.Currency.DeathsBreath} {from}={fromAmount} {to}={toAmount} SacraficialItems={sacraficialItems.Count}");

            while (CanRun(from, to))
            {
                var item   = GetSacraficialItems(to).First();
                var recipe = GetRecipeFromCurrency(from);

                await Transmute.Execute(item, recipe);

                await Coroutine.Yield();

                Core.Update();

                var newToAmount = GetCurrency(to);
                if (newToAmount > toAmount)
                {
                    Core.Logger.Log("[ConvertMaterials] Converted materials '{0}' ---> '{1}'", from, to);
                    toAmount            = newToAmount;
                    fromAmount          = GetCurrency(from);
                    ConsecutiveFailures = 0;
                    Core.Inventory.InvalidAnnIds.Add(item.AnnId);
                }
                else
                {
                    ConsecutiveFailures++;
                    if (ConsecutiveFailures > 3)
                    {
                        Core.Inventory.InvalidAnnIds.Add(item.AnnId);
                    }
                    Core.Logger.Error("[ConvertMaterials] Failed to convert materials");
                    return(false);
                }

                await Coroutine.Yield();
            }

            Core.Logger.Verbose($"[ConvertMaterials] Finishing Material Counts DeathsBreath={Core.Inventory.Currency.DeathsBreath} {from}={fromAmount} {to}={toAmount} SacraficialItems={sacraficialItems.Count}");

            return(true);
        }
예제 #3
0
        /// <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);
        }