Exemple #1
0
 private static void InitializeMagicItem(ExtendedItemData baseItem)
 {
     if (baseItem.m_shared.m_useDurability)
     {
         baseItem.m_durability = Random.Range(0.2f, 1.0f) * baseItem.GetMaxDurability();
     }
 }
        public static void OnNewExtendedItemData(ExtendedItemData itemdata)
        {
            if (itemdata.m_shared.m_name == "$item_helmet_dverger")
            {
                var magicItem = new MagicItem();
                magicItem.Rarity = ItemRarity.Rare;
                magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.DvergerCirclet));
                magicItem.TypeNameOverride = "$mod_epicloot_circlet";

                itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem;
            }
            else if (itemdata.m_shared.m_name == "$item_beltstrength")
            {
                var magicItem = new MagicItem();
                magicItem.Rarity = ItemRarity.Rare;
                magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.Megingjord));
                magicItem.TypeNameOverride = "$mod_epicloot_belt";

                itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem;
            }
            else if (itemdata.m_shared.m_name == "$item_wishbone")
            {
                var magicItem = new MagicItem();
                magicItem.Rarity = ItemRarity.Epic;
                magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.Wishbone));
                magicItem.TypeNameOverride = "$mod_epicloot_remains";

                itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem;
            }
        }
Exemple #3
0
        public static List <MagicItemEffect> RollAugmentEffects(ExtendedItemData item, MagicItem magicItem, int effectIndex)
        {
            var results = new List <MagicItemEffect>();

            var rarity        = magicItem.Rarity;
            var currentEffect = magicItem.Effects[effectIndex];

            results.Add(currentEffect);

            var valuelessEffect  = MagicItemEffectDefinitions.IsValuelessEffect(currentEffect.EffectType, rarity);
            var availableEffects = MagicItemEffectDefinitions.GetAvailableEffects(item, magicItem, valuelessEffect ? -1 : effectIndex);

            for (var i = 0; i < 2 && i < availableEffects.Count; i++)
            {
                var newEffect = RollEffects(availableEffects, rarity, 1, false).FirstOrDefault();
                if (newEffect == null)
                {
                    EpicLoot.LogError($"Rolled a null effect: item:{item.m_shared.m_name}, index:{effectIndex}");
                    continue;
                }

                results.Add(newEffect);

                var newEffectIsValueless = MagicItemEffectDefinitions.IsValuelessEffect(newEffect.EffectType, rarity);
                if (newEffectIsValueless)
                {
                    availableEffects.RemoveAll(x => x.Type == newEffect.EffectType);
                }
            }

            return(results);
        }
 public static void OnNewExtendedItemData(ExtendedItemData itemdata)
 {
     if (itemdata.GetComponent <ShippableItemData>() == null)
     {
         itemdata.AddComponent <ShippableItemData>();
     }
 }
        public static List <MagicItemEffectDefinition> GetAvailableEffects(ExtendedItemData itemData, MagicItem magicItem, int ignoreEffectIndex = -1)
        {
            MagicItemEffect effect = null;

            if (ignoreEffectIndex >= 0 && ignoreEffectIndex < magicItem.Effects.Count)
            {
                effect = magicItem.Effects[ignoreEffectIndex];
                magicItem.Effects.RemoveAt(ignoreEffectIndex);
            }

            var results = AllDefinitions.Values.Where(x => x.CheckRequirements(itemData, magicItem)).ToList();

            if (effect != null)
            {
                magicItem.Effects.Insert(ignoreEffectIndex, effect);
                if (AllDefinitions.TryGetValue(effect.EffectType, out var ignoredEffectDef))
                {
                    if (!results.Contains(ignoredEffectDef))
                    {
                        results.Add(ignoredEffectDef);
                    }
                }
            }

            return(results);
        }
        public bool CheckRequirements(ExtendedItemData itemData, MagicItem magicItem)
        {
            if (Requirements == null)
            {
                return(true);
            }

            return(Requirements.CheckRequirements(itemData, magicItem, Type));
        }
Exemple #7
0
        public override void DoCrafting(InventoryGui __instance, Player player)
        {
            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe = Recipes[SelectedRecipe];

                if (!recipe.FromItem.IsExtended())
                {
                    var inventory = player.GetInventory();
                    inventory.RemoveItem(recipe.FromItem);
                    var extendedItemData = new ExtendedItemData(recipe.FromItem);
                    inventory.m_inventory.Add(extendedItemData);
                    inventory.Changed();
                    recipe.FromItem = extendedItemData;
                }

                float previousDurabilityPercent = 0;
                if (recipe.FromItem.m_shared.m_useDurability)
                {
                    previousDurabilityPercent = recipe.FromItem.m_durability / recipe.FromItem.GetMaxDurability();
                }

                var luckFactor         = player.GetTotalActiveMagicEffectValue(MagicEffectType.Luck, 0.01f);
                var magicItemComponent = recipe.FromItem.Extended().AddComponent <MagicItemComponent>();
                var magicItem          = LootRoller.RollMagicItem(SelectedRarity, recipe.FromItem.Extended(), luckFactor);
                magicItemComponent.SetMagicItem(magicItem);

                EquipmentEffectCache.Reset(player);

                // Spend Resources
                if (!player.NoCostCheat())
                {
                    player.ConsumeResources(GetRecipeRequirementArray(recipe, SelectedRarity), 1);
                }

                // Maintain durability
                if (recipe.FromItem.m_shared.m_useDurability)
                {
                    recipe.FromItem.m_durability = previousDurabilityPercent * recipe.FromItem.GetMaxDurability();
                }

                __instance.UpdateCraftingPanel();

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

                SuccessDialog.Show(recipe.FromItem.Extended());

                MagicItemEffects.Indestructible.MakeItemIndestructible(recipe.FromItem);

                Game.instance.GetPlayerProfile().m_playerStats.m_crafts++;
                Gogan.LogEvent("Game", "Enchanted", recipe.FromItem.m_shared.m_name, 1);
            }
        }
        public static IList <LegendaryInfo> GetAvailableLegendaries(ExtendedItemData baseItem, MagicItem magicItem, bool rollSetItem)
        {
            var availableLegendaries = LegendaryInfo.Values.Where(x => x.IsSetItem == rollSetItem && x.Requirements.CheckRequirements(baseItem, magicItem)).AddItem(GenericLegendaryInfo).ToList();

            if (rollSetItem && availableLegendaries.Count > 1)
            {
                availableLegendaries.Remove(UniqueLegendaryHelper.GenericLegendaryInfo);
            }

            return(availableLegendaries);
        }
Exemple #9
0
        public void Modify(DropContext context)
        {
            CharacterDropModConfigEpicLoot config;

            if (context.Extended.Config.TryGet(CharacterDropModConfigEpicLoot.ModName, out Config cfg) && cfg is CharacterDropModConfigEpicLoot modConfig)
            {
                config = modConfig;
            }
            else
            {
                return;
            }

#if DEBUG
            Log.LogDebug("Adding magic modifiers.");
#endif

            if (InitializeMagicItem is null)
            {
#if DEBUG
                Log.LogDebug("Couldn't find LootRoller.InitializeMagicItem.");
#endif
                return;
            }

            var itemDrop = ComponentCache.GetComponent <ItemDrop>(context.Item);

            if (EpicLoot.EpicLoot.CanBeMagicItem(itemDrop.m_itemData))
            {
                var extendedItemData = new ExtendedItemData(itemDrop.m_itemData);

                var rarity = RollRarity(config);

                if (rarity is Rarity.None)
                {
                    return;
                }

                if (rarity is Rarity.Unique)
                {
                    MakeUnique(itemDrop, extendedItemData, modConfig);
                }
                else
                {
                    //Make magic.
                    var epicLootRarity = RarityToItemRarity(rarity);
                    if (epicLootRarity is not null)
                    {
                        MakeMagic(epicLootRarity.Value, itemDrop, extendedItemData, context.Pos);
                    }
                }
            }
        }
Exemple #10
0
        private void MakeMagic(ItemRarity rarity, ItemDrop itemDrop, ExtendedItemData itemData, Vector3 position)
        {
            MagicItemComponent magicComponent = itemData.AddComponent <MagicItemComponent>();

            var       luck      = LootRoller.GetLuckFactor(position);
            MagicItem magicItem = magicItem = LootRoller.RollMagicItem(rarity, itemData, luck);

            magicComponent.SetMagicItem(magicItem);
            itemDrop.m_itemData = itemData;

            InitializeMagicItem.Invoke(null, new[] { itemData });
        }
Exemple #11
0
        private static List <GameObject> RollLootTableInternal(LootTable lootTable, string objectName, Vector3 dropPoint, bool initializeObject)
        {
            var results = new List <GameObject>();

            _weightedDropCountTable.Setup(lootTable.Drops, dropPair => dropPair.Length == 2 ? dropPair[1] : 1);
            var dropCountRollResult = _weightedDropCountTable.Roll();
            var dropCount           = dropCountRollResult.Length >= 1 ? dropCountRollResult[0] : 0;

            if (dropCount == 0)
            {
                return(results);
            }

            _weightedLootTable.Setup(lootTable.Loot, x => x.Weight);
            var selectedDrops = _weightedLootTable.Roll(dropCount);

            foreach (var ld in selectedDrops)
            {
                var lootDrop = ResolveLootDrop(ld, ld.Rarity);

                var itemPrefab = ObjectDB.instance.GetItemPrefab(lootDrop.Item);
                if (itemPrefab == null)
                {
                    Debug.LogError($"Tried to spawn loot ({lootDrop.Item}) for ({objectName}), but the item prefab was not found!");
                    continue;
                }

                var randomRotation = Quaternion.Euler(0.0f, Random.Range(0.0f, 360.0f), 0.0f);
                ZNetView.m_forceDisableInit = !initializeObject;
                var item = Object.Instantiate(itemPrefab, dropPoint, randomRotation);
                ZNetView.m_forceDisableInit = false;
                var itemDrop = item.GetComponent <ItemDrop>();
                if (EpicLoot.CanBeMagicItem(itemDrop.m_itemData) && !ArrayUtils.IsNullOrEmpty(lootDrop.Rarity))
                {
                    var itemData           = new ExtendedItemData(itemDrop.m_itemData);
                    var magicItemComponent = itemData.AddComponent <MagicItemComponent>();
                    var magicItem          = RollMagicItem(lootDrop, itemData);
                    magicItemComponent.SetMagicItem(magicItem);

                    itemDrop.m_itemData = itemData;
                    InitializeMagicItem(itemData);
                    MagicItemGenerated?.Invoke(itemData, magicItem);
                }

                results.Add(item);
            }

            return(results);
        }
Exemple #12
0
        public void Show(ExtendedItemData item)
        {
            gameObject.SetActive(true);

            var rarityColor = item.GetRarityColor();

            MagicBG.enabled = item.IsMagic();
            MagicBG.color   = rarityColor;

            NameText.text    = Localization.instance.Localize(item.GetDecoratedName());
            Description.text = Localization.instance.Localize(item.GetTooltip());
            Icon.sprite      = item.GetIcon();

            _audioSource.PlayOneShot(EpicLoot.GetMagicItemDropSFX(item.GetRarity()));
        }
Exemple #13
0
        public static ItemDrop.ItemData Roll(ItemDrop.ItemData itemData, Vector3 dropPos, EpicLootItemConfiguration config)
        {
            if (!EpicLoot.EpicLoot.CanBeMagicItem(itemData))
            {
#if DEBUG
                Log.LogTrace($"Item '{itemData.m_shared.m_name}' can't be made magic.");
#endif
                return(null);
            }

            var extendedItemData = new ExtendedItemData(itemData);

            var rarity = ItemService.RollRarity(config);

#if DEBUG
            Log.LogTrace($"Item '{itemData.m_shared.m_name}' rolled rarity '{rarity}'.");
#endif

            if (rarity is Rarity.None)
            {
                return(null);
            }

            ItemDrop.ItemData magicItemData = null;

            if (rarity is Rarity.Unique)
            {
                magicItemData = ItemService.MakeUnique(itemData, extendedItemData, config);
            }
            else
            {
                //Make magic.
                var epicLootRarity = ItemService.RarityToItemRarity(rarity);
                if (epicLootRarity is not null)
                {
                    magicItemData = ItemService.MakeMagic(
                        epicLootRarity.Value,
                        itemData,
                        extendedItemData,
                        dropPos);
                }
            }

            return(magicItemData);
        }
Exemple #14
0
        private static void SetupTestMagicItem(ExtendedItemData itemdata)
        {
            // Weapon (Club)

            /*if (itemdata.GetUniqueId() == "1493f9a4-65b4-41e3-8871-611ec8cb7564")
             * {
             *  var magicItem = new MagicItem {Rarity = ItemRarity.Epic};
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.ModifyAttackStaminaUse), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.Indestructible), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.Weightless), magicItem.Rarity));
             *  //var magicItem = RollMagicItem(new LootDrop() { Rarity = { 6, 4, 2, 1 } }, itemdata);
             *  itemdata.ReplaceComponent<MagicItemComponent>().SetMagicItem(magicItem);
             * }
             * // Armor (Bronze Cuirass)
             * else if (itemdata.GetUniqueId() == "84c006c7-3819-463c-b3b6-cb812f184655")
             * {
             *  var magicItem = new MagicItem {Rarity = ItemRarity.Epic };
             *  //var magicItem = RollMagicItem(new LootDrop() { Rarity = { 6, 4, 2, 1 } }, itemdata);
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.ModifyMovementSpeed), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.Indestructible), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.Weightless), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.AddCarryWeight), magicItem.Rarity));
             *  itemdata.ReplaceComponent<MagicItemComponent>().SetMagicItem(magicItem);
             * }
             * // Shield (Wood Shield)
             * else if (itemdata.GetUniqueId() == "c0d8fb31-04dd-4499-b347-d0484416f159")
             * {
             *  var magicItem = new MagicItem {Rarity = ItemRarity.Epic};
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.ModifyBlockStaminaUse), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.Weightless), magicItem.Rarity));
             *  //var magicItem = RollMagicItem(new LootDrop() { Rarity = { 6, 4, 2, 1 } }, itemdata);
             *  itemdata.ReplaceComponent<MagicItemComponent>().SetMagicItem(magicItem);
             * }
             * // Legs (Troll Hide Legs)
             * else if (itemdata.GetUniqueId() == "ec539738-6a73-492b-85d8-ce80eb0944f1")
             * {
             *  var magicItem = new MagicItem { Rarity = ItemRarity.Epic };
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.ModifyMovementSpeed), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.ModifySprintStaminaUse), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.ModifyJumpStaminaUse), magicItem.Rarity));
             *  magicItem.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(MagicEffectType.AddCarryWeight), magicItem.Rarity));
             *  itemdata.ReplaceComponent<MagicItemComponent>().SetMagicItem(magicItem);
             * }*/
        }
Exemple #15
0
            private static bool DoCheck(Player player, ZDO zdo, string equipKey, string legendaryDataKey, ref ItemDrop.ItemData itemData)
            {
                var zdoLegendaryID = zdo.GetString(legendaryDataKey);

                if (string.IsNullOrEmpty(zdoLegendaryID))
                {
                    var hadItem = itemData != null;
                    if (hadItem)
                    {
                        ForceResetVisEquipment(player, itemData);
                    }
                    itemData = null;
                    return(hadItem);
                }

                var currentLegendaryID = itemData?.GetMagicItem()?.LegendaryID;

                if (currentLegendaryID == zdoLegendaryID)
                {
                    return(false);
                }

                var itemHash   = zdo.GetInt(equipKey);
                var itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash);

                if (itemPrefab?.GetComponent <ItemDrop>()?.m_itemData is ItemDrop.ItemData targetItemData)
                {
                    itemData = new ExtendedItemData(targetItemData);
                    itemData.m_durability = float.PositiveInfinity;
                    var magicItemComponent = itemData.Extended().AddComponent <MagicItemComponent>();
                    var stubMagicItem      = new MagicItem {
                        Rarity = ItemRarity.Legendary, LegendaryID = zdoLegendaryID
                    };
                    magicItemComponent.SetMagicItem(stubMagicItem);

                    ForceResetVisEquipment(player, itemData);
                }

                return(false);
            }
        public static void OnNewExtendedItemData(ExtendedItemData itemdata)
        {
            if (itemdata.m_shared.m_name == "$item_helmet_dverger")
            {
                var magicItem = new MagicItem();
                magicItem.Rarity = ItemRarity.Legendary;
                magicItem.Effects.Add(new MagicItemEffect()
                {
                    EffectType = MagicEffectType.DvergerCirclet
                });
                magicItem.DisplayNameOverride = "circlet";

                itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem;
            }
            else if (itemdata.m_shared.m_name == "$item_beltstrength")
            {
                var magicItem = new MagicItem();
                magicItem.Rarity = ItemRarity.Legendary;
                magicItem.Effects.Add(new MagicItemEffect()
                {
                    EffectType = MagicEffectType.Megingjord
                });
                magicItem.DisplayNameOverride = "belt";

                itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem;
            }
            else if (itemdata.m_shared.m_name == "$item_wishbone")
            {
                var magicItem = new MagicItem();
                magicItem.Rarity = ItemRarity.Legendary;
                magicItem.Effects.Add(new MagicItemEffect()
                {
                    EffectType = MagicEffectType.Wishbone
                });
                magicItem.DisplayNameOverride = "remains";

                itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem;
            }
        }
        public override void DoCrafting(InventoryGui __instance, Player player)
        {
            if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count)
            {
                var recipe = Recipes[SelectedRecipe];

                if (!recipe.FromItem.IsExtended())
                {
                    var inventory = player.GetInventory();
                    inventory.RemoveItem(recipe.FromItem);
                    var extendedItemData = new ExtendedItemData(recipe.FromItem);
                    inventory.m_inventory.Add(extendedItemData);
                    inventory.Changed();
                    recipe.FromItem = extendedItemData;
                }

                var magicItemComponent = recipe.FromItem.Extended().AddComponent <MagicItemComponent>();
                var magicItem          = LootRoller.RollMagicItem(recipe.ToRarity, recipe.FromItem.Extended());
                magicItemComponent.SetMagicItem(magicItem);

                // Spend Resources
                if (!player.NoCostCheat())
                {
                    player.ConsumeResources(recipe.GetRequirementArray(), 1);
                }
                __instance.UpdateCraftingPanel();

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

                Game.instance.GetPlayerProfile().m_playerStats.m_crafts++;
                Gogan.LogEvent("Game", "Disenchanted", recipe.FromItem.m_shared.m_name, 1);
            }
        }
Exemple #18
0
        public static ItemDrop.ItemData MakeMagic(ItemRarity rarity, ItemDrop.ItemData itemDrop, ExtendedItemData itemData, Vector3 position)
        {
            MagicItemComponent magicComponent = itemData.AddComponent <MagicItemComponent>();

            var       luck      = LootRoller.GetLuckFactor(position);
            MagicItem magicItem = LootRoller.RollMagicItem(rarity, itemData, luck);

#if DEBUG
            Log.LogTrace("\t" + magicItem.Effects.Join(x => x.EffectType));
#endif

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

            return(itemData);
        }
Exemple #19
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);
        }
Exemple #20
0
 public string GetDisplayName(ExtendedItemData baseItem)
 {
     return(string.IsNullOrEmpty(DisplayNameOverride) ? baseItem.m_shared.m_name.ToLowerInvariant() : DisplayNameOverride);
 }
 public CrafterNameData(ExtendedItemData parent)
     : base(TypeID, parent)
 {
 }
Exemple #22
0
 public string GetItemTypeName(ExtendedItemData baseItem)
 {
     return(string.IsNullOrEmpty(TypeNameOverride) ? Localization.instance.Localize(baseItem.m_shared.m_name).ToLowerInvariant() : TypeNameOverride);
 }
 public ShippableItemData(ExtendedItemData parent) : base(typeof(ShippableItemData).AssemblyQualifiedName, parent)
 {
 }
 public MagicItemComponent(ExtendedItemData parent)
     : base(TypeID, parent)
 {
 }
Exemple #25
0
        public static MagicItem RollMagicItem(ItemRarity rarity, ExtendedItemData baseItem, float luckFactor)
        {
            var cheatLegendary = !string.IsNullOrEmpty(CheatForceLegendary);

            if (cheatLegendary)
            {
                rarity = ItemRarity.Legendary;
            }

            var magicItem = new MagicItem {
                Rarity = rarity
            };

            var effectCount = CheatEffectCount >= 1 ? CheatEffectCount : RollEffectCountPerRarity(magicItem.Rarity);

            if (rarity == ItemRarity.Legendary)
            {
                LegendaryInfo legendary = null;
                if (cheatLegendary)
                {
                    UniqueLegendaryHelper.TryGetLegendaryInfo(CheatForceLegendary, out legendary);
                }

                if (legendary == null)
                {
                    var roll        = Random.Range(0.0f, 1.0f);
                    var rollSetItem = roll < EpicLoot.SetItemDropChance.Value;
                    Debug.LogWarning($"Rolling Legendary: set={rollSetItem} ({roll}/{EpicLoot.SetItemDropChance.Value})");
                    var availableLegendaries = UniqueLegendaryHelper.GetAvailableLegendaries(baseItem, magicItem, rollSetItem);
                    Debug.LogWarning($"Available Legendaries: {string.Join(", ", availableLegendaries.Select(x => x.ID))}");
                    _weightedLegendaryTable.Setup(availableLegendaries, x => x.SelectionWeight);
                    legendary = _weightedLegendaryTable.Roll();
                }

                if (legendary.IsSetItem)
                {
                    var setID = UniqueLegendaryHelper.GetSetForLegendaryItem(legendary);
                    magicItem.SetID = setID;
                }

                if (!UniqueLegendaryHelper.IsGenericLegendary(legendary))
                {
                    magicItem.LegendaryID = legendary.ID;
                    magicItem.DisplayName = legendary.Name;

                    if (legendary.GuaranteedEffectCount > 0)
                    {
                        effectCount = legendary.GuaranteedEffectCount;
                    }

                    foreach (var guaranteedMagicEffect in legendary.GuaranteedMagicEffects)
                    {
                        var effectDef = MagicItemEffectDefinitions.Get(guaranteedMagicEffect.Type);
                        if (effectDef == null)
                        {
                            EpicLoot.LogError($"Could not find magic effect (Type={guaranteedMagicEffect.Type}) while creating legendary item (ID={legendary.ID})");
                            continue;
                        }

                        var effect = RollEffect(effectDef, ItemRarity.Legendary, guaranteedMagicEffect.Values);
                        magicItem.Effects.Add(effect);
                        effectCount--;
                    }
                }
            }

            for (var i = 0; i < effectCount; i++)
            {
                var availableEffects = MagicItemEffectDefinitions.GetAvailableEffects(baseItem, magicItem);
                if (availableEffects.Count == 0)
                {
                    EpicLoot.LogWarning($"Tried to add more effects to magic item ({baseItem.m_shared.m_name}) but there were no more available effects. " +
                                        $"Current Effects: {(string.Join(", ", magicItem.Effects.Select(x => x.EffectType.ToString())))}");
                    break;
                }

                _weightedEffectTable.Setup(availableEffects, x => x.SelectionWeight);
                var effectDef = _weightedEffectTable.Roll();

                var effect = RollEffect(effectDef, magicItem.Rarity);
                magicItem.Effects.Add(effect);
            }

            if (string.IsNullOrEmpty(magicItem.DisplayName))
            {
                magicItem.DisplayName = MagicItemNames.GetNameForItem(baseItem, magicItem);
            }

            return(magicItem);
        }
 public static List <MagicItemEffectDefinition> GetAvailableEffects(ExtendedItemData itemData, MagicItem magicItem)
 {
     return(AllDefinitions.Values.Where(x => x.CheckRequirements(itemData, magicItem)).ToList());
 }
        public bool CheckRequirements(ExtendedItemData itemData, MagicItem magicItem)
        {
            if (Requirements == null)
            {
                return(true);
            }

            if (Requirements.NoRoll)
            {
                return(false);
            }

            if (Requirements.ExclusiveSelf && magicItem.HasEffect(Type))
            {
                return(false);
            }

            if (Requirements.ExclusiveEffectTypes?.Count > 0 && magicItem.HasAnyEffect(Requirements.ExclusiveEffectTypes))
            {
                return(false);
            }

            if (Requirements.AllowedItemTypes?.Count > 0 && !Requirements.AllowedItemTypes.Contains(itemData.m_shared.m_itemType))
            {
                return(false);
            }

            if (Requirements.AllowedRarities?.Count > 0 && !Requirements.AllowedRarities.Contains(magicItem.Rarity))
            {
                return(false);
            }

            if (Requirements.AllowedItemNames?.Count > 0 && !Requirements.AllowedItemNames.Contains(itemData.m_shared.m_name))
            {
                return(false);
            }

            if (Requirements.ItemHasPhysicalDamage && itemData.m_shared.m_damages.GetTotalPhysicalDamage() <= 0)
            {
                return(false);
            }

            if (Requirements.ItemHasElementalDamage && itemData.m_shared.m_damages.GetTotalElementalDamage() <= 0)
            {
                return(false);
            }

            if (Requirements.ItemUsesDurability && !itemData.m_shared.m_useDurability)
            {
                return(false);
            }

            if (Requirements.ItemHasNegativeMovementSpeedModifier && itemData.m_shared.m_movementModifier >= 0)
            {
                return(false);
            }

            if (Requirements.ItemHasBlockPower && itemData.m_shared.m_blockPower <= 0)
            {
                return(false);
            }

            if (Requirements.ItemHasParryPower && itemData.m_shared.m_deflectionForce <= 0)
            {
                return(false);
            }

            if (Requirements.ItemHasArmor && itemData.m_shared.m_armor <= 0)
            {
                return(false);
            }

            if (Requirements.ItemHasBackstabBonus && itemData.m_shared.m_backstabBonus <= 0)
            {
                return(false);
            }

            if (Requirements.ItemUsesStaminaOnAttack && itemData.m_shared.m_attack.m_attackStamina <= 0 && itemData.m_shared.m_secondaryAttack.m_attackStamina <= 0)
            {
                return(false);
            }

            return(true);
        }
Exemple #28
0
        private static List <GameObject> RollLootTableInternal(LootTable lootTable, int level, string objectName, Vector3 dropPoint, bool initializeObject)
        {
            var results = new List <GameObject>();

            if (lootTable == null || level <= 0 || string.IsNullOrEmpty(objectName))
            {
                return(results);
            }

            var luckFactor = GetLuckFactor(dropPoint);

            var drops = GetDropsForLevel(lootTable, level);

            if (drops.Count == 0)
            {
                return(results);
            }

            if (EpicLoot.AlwaysDropCheat)
            {
                drops = drops.Where(x => x.Key > 0).ToList();
            }

            _weightedDropCountTable.Setup(drops, dropPair => dropPair.Value);
            var dropCountRollResult = _weightedDropCountTable.Roll();
            var dropCount           = dropCountRollResult.Key;

            if (dropCount == 0)
            {
                return(results);
            }

            var loot = GetLootForLevel(lootTable, level);

            _weightedLootTable.Setup(loot, x => x.Weight);
            var selectedDrops = _weightedLootTable.Roll(dropCount);

            foreach (var ld in selectedDrops)
            {
                if (ld == null)
                {
                    EpicLoot.LogError($"Loot drop was null! RollLootTableInternal({lootTable.Object}, {level}, {objectName})");
                    continue;
                }
                var lootDrop = ResolveLootDrop(ld);
                var itemID   = CheatDisableGating ? lootDrop.Item : GatedItemTypeHelper.GetGatedItemID(lootDrop.Item);

                var itemPrefab = ObjectDB.instance.GetItemPrefab(itemID);
                if (itemPrefab == null)
                {
                    EpicLoot.LogError($"Tried to spawn loot ({itemID}) for ({objectName}), but the item prefab was not found!");
                    continue;
                }

                var randomRotation = Quaternion.Euler(0.0f, Random.Range(0.0f, 360.0f), 0.0f);
                ZNetView.m_forceDisableInit = !initializeObject;
                var item = Object.Instantiate(itemPrefab, dropPoint, randomRotation);
                ZNetView.m_forceDisableInit = false;
                var itemDrop = item.GetComponent <ItemDrop>();
                if (EpicLoot.CanBeMagicItem(itemDrop.m_itemData) && !ArrayUtils.IsNullOrEmpty(lootDrop.Rarity))
                {
                    var itemData           = new ExtendedItemData(itemDrop.m_itemData);
                    var magicItemComponent = itemData.AddComponent <MagicItemComponent>();
                    var magicItem          = RollMagicItem(lootDrop, itemData, luckFactor);
                    if (CheatForceMagicEffect)
                    {
                        AddDebugMagicEffects(magicItem);
                    }

                    magicItemComponent.SetMagicItem(magicItem);

                    itemDrop.m_itemData = itemData;
                    itemDrop.Save();
                    InitializeMagicItem(itemData);

                    MagicItemGenerated?.Invoke(itemData, magicItem);
                }

                results.Add(item);
            }

            return(results);
        }
Exemple #29
0
 public MagicItemComponent(ExtendedItemData parent)
     : base(typeof(MagicItemComponent).AssemblyQualifiedName, parent)
 {
 }
Exemple #30
0
        public static MagicItem RollMagicItem(LootDrop lootDrop, ExtendedItemData baseItem, float luckFactor)
        {
            var rarity = RollItemRarity(lootDrop, luckFactor);

            return(RollMagicItem(rarity, baseItem, luckFactor));
        }