Ejemplo n.º 1
0
        private void OnAugmentComplete(AugmentRecipe recipe, MagicItemEffect newEffect)
        {
            if (recipe != null)
            {
                var magicItem = recipe.FromItem.GetMagicItem();

                if (magicItem.HasEffect(MagicEffectType.Indestructible))
                {
                    recipe.FromItem.m_shared.m_useDurability = recipe.FromItem.m_dropPrefab?.GetComponent <ItemDrop>().m_itemData.m_shared.m_useDurability ?? false;

                    if (recipe.FromItem.m_shared.m_useDurability)
                    {
                        recipe.FromItem.m_durability = recipe.FromItem.GetMaxDurability();
                    }
                }

                magicItem.ReplaceEffect(recipe.EffectIndex, newEffect);

                if (magicItem.Rarity == ItemRarity.Rare)
                {
                    magicItem.DisplayName = MagicItemNames.GetNameForItem(recipe.FromItem, magicItem);
                }

                // Note: I do not know why I have to do this, but this is the only thing that causes this item to save correctly
                recipe.FromItem.Extended().RemoveComponent <MagicItemComponent>();
                recipe.FromItem.Extended().AddComponent <MagicItemComponent>().SetMagicItem(magicItem);

                InventoryGui.instance?.UpdateCraftingPanel();

                var player = Player.m_localPlayer;
                if (player.GetCurrentCraftingStation() != null)
                {
                    player.GetCurrentCraftingStation().m_craftItemDoneEffects.Create(player.transform.position, Quaternion.identity);
                }

                OnSelectorValueChanged(recipe.EffectIndex, true);

                MagicItemEffects.Indestructible.MakeItemIndestructible(recipe.FromItem);

                Game.instance.GetPlayerProfile().m_playerStats.m_crafts++;
                Gogan.LogEvent("Game", "Augmented", recipe.FromItem.m_shared.m_name, 1);

                EquipmentEffectCache.Reset(player);
            }
        }
Ejemplo n.º 2
0
        private void OnAugmentComplete(AugmentRecipe recipe, MagicItemEffect newEffect)
        {
            if (recipe != null)
            {
                var magicItem = recipe.FromItem.GetMagicItem();

                if (magicItem.HasBeenAugmented())
                {
                    magicItem.ReplaceEffect(magicItem.AugmentedEffectIndex, newEffect);
                }
                else
                {
                    magicItem.ReplaceEffect(recipe.EffectIndex, newEffect);
                }

                if (magicItem.Rarity == ItemRarity.Rare)
                {
                    magicItem.DisplayName = MagicItemNames.GetNameForItem(recipe.FromItem, magicItem);
                }

                // Note: I do not know why I have to do this, but this is the only thing that causes this item to save correctly
                recipe.FromItem.Extended().RemoveComponent <MagicItemComponent>();
                recipe.FromItem.Extended().AddComponent <MagicItemComponent>().SetMagicItem(magicItem);

                InventoryGui.instance?.UpdateCraftingPanel();

                var player = Player.m_localPlayer;
                if (player.GetCurrentCraftingStation() != null)
                {
                    player.GetCurrentCraftingStation().m_craftItemDoneEffects.Create(player.transform.position, Quaternion.identity);
                }

                OnSelectorValueChanged(recipe.EffectIndex, true);

                Game.instance.GetPlayerProfile().m_playerStats.m_crafts++;
                Gogan.LogEvent("Game", "Augmented", recipe.FromItem.m_shared.m_name, 1);
            }
        }
Ejemplo n.º 3
0
        public static ItemDrop.ItemData MakeUnique(ItemDrop.ItemData itemDrop, ExtendedItemData itemData, EpicLootItemConfiguration config)
        {
            var uniqueIds = config.UniqueIDs.Value.SplitByComma();

            if (uniqueIds.Count > 0)
            {
                var randomId = uniqueIds[Random.Range(0, uniqueIds.Count)];

                if (UniqueLegendaryHelper.TryGetLegendaryInfo(randomId, out LegendaryInfo legendaryInfo))
                {
                    MagicItem magicItem = new MagicItem
                    {
                        Rarity      = ItemRarity.Legendary,
                        LegendaryID = legendaryInfo.ID,
                        DisplayName = legendaryInfo.Name,
                    };

                    if (!legendaryInfo.Requirements.CheckRequirements(itemDrop, magicItem))
                    {
                        Log.LogWarning($"Attempted to roll Epic Loot unique legendary with id '{randomId}' for Drop That config entry '{config.SectionKey}' but requirements were not met. Skipping.");
                        return(null);
                    }

                    if (legendaryInfo.IsSetItem)
                    {
                        magicItem.SetID = UniqueLegendaryHelper.GetSetForLegendaryItem(legendaryInfo);
                    }

                    if ((legendaryInfo.GuaranteedMagicEffects?.Count ?? 0) > 0)
                    {
                        foreach (var effect in legendaryInfo.GuaranteedMagicEffects)
                        {
                            if (MagicItemEffectDefinitions.AllDefinitions.TryGetValue(effect.Type, out MagicItemEffectDefinition effectDefinition))
                            {
                                MagicItemEffect itemEffect = LootRoller.RollEffect(effectDefinition, ItemRarity.Legendary, effect.Values);
                                magicItem.Effects.Add(itemEffect);
                            }
                            else
                            {
                                Log.LogWarning($"Unable to find a guaranteed Epic Loot magic effect '{effect.Type}' while rolling unique legendary with id '{randomId}'. Skipping effect.");
                            }
                        }
                    }

                    var randomEffectCount = LootRoller.RollEffectCountPerRarity(ItemRarity.Legendary) - magicItem.Effects.Count;

                    if (randomEffectCount > 0)
                    {
                        List <MagicItemEffectDefinition> availableEffects = MagicItemEffectDefinitions.GetAvailableEffects(itemData, magicItem, -1);

                        for (int i = 0; i < randomEffectCount; ++i)
                        {
                            MagicItemEffectDefinition effectDefinition = RollWeightedEffect(availableEffects, false);
                            MagicItemEffect           itemEffect       = LootRoller.RollEffect(effectDefinition, ItemRarity.Legendary);
                            magicItem.Effects.Add(itemEffect);
                        }
                    }

                    MagicItemComponent magicComponent = itemData.AddComponent <MagicItemComponent>();

                    magicComponent.SetMagicItem(magicItem);

                    InitializeMagicItem.Invoke(null, new[] { itemData });

                    return(itemData);
                }
                else
                {
                    Log.LogWarning($"Attempted to roll Epic Loot unique legendary with id '{randomId}' but was unable to find matching info registered in Epic Loot.");
                }
            }

            return(null);
        }