Ejemplo n.º 1
0
        private void Awake()
        {
            _magicRarityColor           = Config.Bind("Item Colors", "Magic Rarity Color", "Blue", "The color of Magic rarity items, the lowest magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _magicMaterialIconColor     = Config.Bind("Item Colors", "Magic Crafting Material Icon Index", 5, "Indicates the color of the icon used for magic crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _rareRarityColor            = Config.Bind("Item Colors", "Rare Rarity Color", "Yellow", "The color of Rare rarity items, the second magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _rareMaterialIconColor      = Config.Bind("Item Colors", "Rare Crafting Material Icon Index", 2, "Indicates the color of the icon used for rare crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _epicRarityColor            = Config.Bind("Item Colors", "Epic Rarity Color", "Purple", "The color of Epic rarity items, the third magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _epicMaterialIconColor      = Config.Bind("Item Colors", "Epic Crafting Material Icon Index", 7, "Indicates the color of the icon used for epic crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _legendaryRarityColor       = Config.Bind("Item Colors", "Legendary Rarity Color", "Teal", "The color of Legendary rarity items, the highest magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _legendaryMaterialIconColor = Config.Bind("Item Colors", "Legendary Crafting Material Icon Index", 4, "Indicates the color of the icon used for legendary crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _setItemColor                = Config.Bind("Item Colors", "Set Item Color", "#26ffff", "The color of set item text and the set item icon. Use a hex color, default is cyan");
            _magicRarityDisplayName      = Config.Bind("Rarity", "Magic Rarity Display Name", "Magic", "The name of the lowest rarity.");
            _rareRarityDisplayName       = Config.Bind("Rarity", "Rare Rarity Display Name", "Rare", "The name of the second rarity.");
            _epicRarityDisplayName       = Config.Bind("Rarity", "Epic Rarity Display Name", "Epic", "The name of the third rarity.");
            _legendaryRarityDisplayName  = Config.Bind("Rarity", "Legendary Rarity Display Name", "Legendary", "The name of the highest rarity.");
            UseScrollingCraftDescription = Config.Bind("Crafting UI", "Use Scrolling Craft Description", true, "Changes the item description in the crafting panel to scroll instead of scale when it gets too long for the space.");
            _gatedItemTypeModeConfig     = Config.Bind("Balance", "Item Drop Limits", GatedItemTypeMode.MustKnowRecipe, "Sets how the drop system limits what item types can drop. Unlimited: no limits, exactly what's in the loot table will drop. MustKnowRecipe: items will drop so long as the player has discovered their recipe. MustHaveCrafted: items will only drop once the player has crafted one or picked one up. If an item type cannot drop, it will downgrade to an item of the same type and skill that the player has unlocked (i.e. swords will stay swords)");

            MagicItemEffectDefinitions.Initialize(LoadJsonFile <MagicItemEffectsList>("magiceffects.json"));
            LootRoller.Initialize(LoadJsonFile <LootConfig>("loottables.json"));
            GatedItemTypeHelper.Initialize(LoadJsonFile <ItemInfoConfig>("iteminfo.json"));
            RecipesHelper.Initialize(LoadJsonFile <RecipesConfig>("recipes.json"));
            PrintInfo();

            LoadAssets();

            ExtendedItemData.LoadExtendedItemData += SetupTestMagicItem;
            ExtendedItemData.LoadExtendedItemData += MagicItemComponent.OnNewExtendedItemData;
            ExtendedItemData.NewExtendedItemData  += MagicItemComponent.OnNewExtendedItemData;

            _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginId);

            LootTableLoaded?.Invoke();
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            _magicRarityColor           = Config.Bind("Item Colors", "Magic Rarity Color", "Blue", "The color of Magic rarity items, the lowest magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _magicMaterialIconColor     = Config.Bind("Item Colors", "Magic Crafting Material Icon Index", 5, "Indicates the color of the icon used for magic crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _rareRarityColor            = Config.Bind("Item Colors", "Rare Rarity Color", "Yellow", "The color of Rare rarity items, the second magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _rareMaterialIconColor      = Config.Bind("Item Colors", "Rare Crafting Material Icon Index", 2, "Indicates the color of the icon used for rare crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _epicRarityColor            = Config.Bind("Item Colors", "Epic Rarity Color", "Purple", "The color of Epic rarity items, the third magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _epicMaterialIconColor      = Config.Bind("Item Colors", "Epic Crafting Material Icon Index", 7, "Indicates the color of the icon used for epic crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _legendaryRarityColor       = Config.Bind("Item Colors", "Legendary Rarity Color", "Teal", "The color of Legendary rarity items, the highest magic item tier. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Indigo, Purple, Pink, Gray");
            _legendaryMaterialIconColor = Config.Bind("Item Colors", "Legendary Crafting Material Icon Index", 4, "Indicates the color of the icon used for legendary crafting materials. A number between 0 and 9. Available options: 0=Red, 1=Orange, 2=Yellow, 3=Green, 4=Teal, 5=Blue, 6=Indigo, 7=Purple, 8=Pink, 9=Gray");
            _setItemColor                = Config.Bind("Item Colors", "Set Item Color", "#26ffff", "The color of set item text and the set item icon. Use a hex color, default is cyan");
            _magicRarityDisplayName      = Config.Bind("Rarity", "Magic Rarity Display Name", "Magic", "The name of the lowest rarity.");
            _rareRarityDisplayName       = Config.Bind("Rarity", "Rare Rarity Display Name", "Rare", "The name of the second rarity.");
            _epicRarityDisplayName       = Config.Bind("Rarity", "Epic Rarity Display Name", "Epic", "The name of the third rarity.");
            _legendaryRarityDisplayName  = Config.Bind("Rarity", "Legendary Rarity Display Name", "Legendary", "The name of the highest rarity.");
            UseScrollingCraftDescription = Config.Bind("Crafting UI", "Use Scrolling Craft Description", true, "Changes the item description in the crafting panel to scroll instead of scale when it gets too long for the space.");

            MagicItemEffectDefinitions.SetupMagicItemEffectDefinitions();

            LootRoller.Initialize(LoadJsonFile <LootConfig>("loottables.json"));
            PrintInfo();

            LoadAssets();

            ExtendedItemData.LoadExtendedItemData += SetupTestMagicItem;
            ExtendedItemData.LoadExtendedItemData += MagicItemComponent.OnNewExtendedItemData;
            ExtendedItemData.NewExtendedItemData  += MagicItemComponent.OnNewExtendedItemData;

            _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginId);

            LootTableLoaded?.Invoke();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public static void AddDebugMagicEffects(MagicItem item)
 {
     if (!string.IsNullOrEmpty(ForcedMagicEffect) && !item.HasEffect(ForcedMagicEffect))
     {
         EpicLoot.Log($"AddDebugMagicEffect {ForcedMagicEffect}");
         item.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(ForcedMagicEffect), item.Rarity));
     }
 }
Ejemplo n.º 5
0
        public static bool CanBeAugmented(this ItemDrop.ItemData itemData)
        {
            if (!itemData.IsMagic())
            {
                return(false);
            }

            return(itemData.GetMagicItem().Effects.Select(effect => MagicItemEffectDefinitions.Get(effect.EffectType)).Any(effectDef => effectDef.CanBeAugmented));
        }
Ejemplo n.º 6
0
        public static void AddMagicEffectsPage(TextsDialog textsDialog, Player player)
        {
            var magicEffects = new Dictionary <string, List <KeyValuePair <MagicItemEffect, ItemDrop.ItemData> > >();

            var allEquipment = player.GetEquipment();

            foreach (var item in allEquipment)
            {
                if (item.IsMagic())
                {
                    foreach (var effect in item.GetMagicItem().Effects)
                    {
                        if (!magicEffects.TryGetValue(effect.EffectType, out var effectList))
                        {
                            effectList = new List <KeyValuePair <MagicItemEffect, ItemDrop.ItemData> >();
                            magicEffects.Add(effect.EffectType, effectList);
                        }

                        effectList.Add(new KeyValuePair <MagicItemEffect, ItemDrop.ItemData>(effect, item));
                    }
                }
            }

            var t = new StringBuilder();

            foreach (var entry in magicEffects)
            {
                var effectType      = entry.Key;
                var effectDef       = MagicItemEffectDefinitions.Get(effectType);
                var sum             = entry.Value.Sum(x => x.Key.EffectValue);
                var totalEffectText = MagicItem.GetEffectText(effectDef, sum);
                var highestRarity   = (ItemRarity)entry.Value.Max(x => (int)x.Value.GetRarity());

                t.AppendLine($"<size=20><color={EpicLoot.GetRarityColor(highestRarity)}>{totalEffectText}</color></size>");
                foreach (var entry2 in entry.Value)
                {
                    var effect = entry2.Key;
                    var item   = entry2.Value;
                    t.AppendLine($" <color=silver>- {MagicItem.GetEffectText(effect, item.GetRarity(), false)} ({item.GetDecoratedName()})</color>");
                }

                t.AppendLine();
            }

            textsDialog.m_texts.Insert(EpicLoot.HasAuga ? 0 : 2,
                                       new TextsDialog.TextInfo(
                                           Localization.instance.Localize($"{EpicLoot.GetMagicEffectPip(false)} $mod_epicloot_active_magic_effects"),
                                           Localization.instance.Localize(t.ToString())));
        }
Ejemplo n.º 7
0
        public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange, string legendaryID, MagicItemEffectDefinition.ValueDef valuesOverride)
        {
            var effectDef = MagicItemEffectDefinitions.Get(effect.EffectType);
            var result    = GetEffectText(effectDef, effect.EffectValue);
            var values    = valuesOverride ?? (string.IsNullOrEmpty(legendaryID) ? effectDef.GetValuesForRarity(rarity) : UniqueLegendaryHelper.GetLegendaryEffectValues(legendaryID, effect.EffectType));

            if (showRange && values != null)
            {
                if (!Mathf.Approximately(values.MinValue, values.MaxValue))
                {
                    result += $" [{values.MinValue}-{values.MaxValue}]";
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        private static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange)
        {
            var effectDef = MagicItemEffectDefinitions.Get(effect.EffectType);
            var result    = string.Format(effectDef.DisplayText, effect.EffectValue);
            var values    = effectDef.GetValuesForRarity(rarity);

            if (showRange && values != null)
            {
                if (!Mathf.Approximately(values.MinValue, values.MaxValue))
                {
                    result += $" [{values.MinValue}-{values.MaxValue}]";
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        public string GetFirstEquipEffect(out FxAttachMode mode)
        {
            foreach (var effect in Effects)
            {
                var effectDef = MagicItemEffectDefinitions.Get(effect.EffectType);
                if (effectDef != null && !string.IsNullOrEmpty(effectDef.EquipFx))
                {
                    mode = effectDef.EquipFxMode;
                    return(effectDef.EquipFx);
                }
            }

            mode = FxAttachMode.None;
            return(null);
        }
Ejemplo n.º 10
0
        public static string GetSetTooltip(this ItemDrop.ItemData item)
        {
            var text    = new StringBuilder();
            var setID   = item.GetSetID(out var isMundane);
            var setSize = item.GetSetSize();

            var setPieces          = ItemDataExtensions.GetSetPieces(setID);
            var currentSetEquipped = Player.m_localPlayer.GetEquippedSetPieces(setID);

            var setDisplayName = GetSetDisplayName(item, isMundane);

            text.Append($"\n\n<color={EpicLoot.GetSetItemColor()}> $mod_epicloot_set: {setDisplayName} ({currentSetEquipped.Count}/{setSize}):</color>");

            foreach (var setItemName in setPieces)
            {
                var isEquipped  = IsSetItemEquipped(currentSetEquipped, setItemName, isMundane);
                var color       = isEquipped ? "white" : "grey";
                var displayName = GetSetItemDisplayName(setItemName, isMundane);
                text.Append($"\n  <color={color}>{displayName}</color>");
            }

            if (isMundane)
            {
                var setEffectColor = currentSetEquipped.Count == setSize?EpicLoot.GetSetItemColor() : "grey";

                text.Append($"\n<color={setEffectColor}>({setSize}) ‣ {item.GetSetStatusEffectTooltip().Replace("\n", " ")}</color>");
            }
            else
            {
                var setInfo = item.GetLegendarySetInfo();
                foreach (var setBonusInfo in setInfo.SetBonuses.OrderBy(x => x.Count))
                {
                    var hasEquipped = currentSetEquipped.Count >= setBonusInfo.Count;
                    var effectDef   = MagicItemEffectDefinitions.Get(setBonusInfo.Effect.Type);
                    if (effectDef == null)
                    {
                        EpicLoot.LogError($"Set Tooltip: Could not find effect ({setBonusInfo.Effect.Type}) for set ({setInfo.ID}) bonus ({setBonusInfo.Count})!");
                        continue;
                    }

                    var display = MagicItem.GetEffectText(effectDef, setBonusInfo.Effect.Values?.MinValue ?? 0);
                    text.Append($"\n<color={(hasEquipped ? EpicLoot.GetSetItemColor() : "grey")}>({setBonusInfo.Count}) ‣ {display}</color>");
                }
            }

            return(text.ToString());
        }
Ejemplo n.º 11
0
        public static object GetPrefix(MagicItem magicItem)
        {
            if (magicItem.Effects.Count == 0)
            {
                return(null);
            }

            var firstEffect = magicItem.Effects[0];
            var effectDef   = MagicItemEffectDefinitions.Get(firstEffect.EffectType);

            if (effectDef == null)
            {
                return(null);
            }

            var prefixes     = effectDef.Prefixes ?? Config.Rare.GenericPrefixes;
            var randomPrefix = GetRandomStringFromList(prefixes);

            // Include trailing space
            return(string.IsNullOrEmpty(randomPrefix) ? null : $"{randomPrefix} ");
        }
Ejemplo n.º 12
0
        public static object GetSuffix(MagicItem magicItem)
        {
            if (magicItem.Effects.Count < 2)
            {
                return(null);
            }

            var secondEffect = magicItem.Effects[1];
            var effectDef    = MagicItemEffectDefinitions.Get(secondEffect.EffectType);

            if (effectDef == null)
            {
                return(null);
            }

            var suffixes     = effectDef.Suffixes ?? Config.Rare.GenericSuffixes;
            var randomSuffix = GetRandomStringFromList(suffixes);

            // Include " of "
            return(string.IsNullOrEmpty(randomSuffix) ? null : $" of {randomSuffix}");
        }
Ejemplo n.º 13
0
        private static MagicItemEffectDefinition GetReplacementEffectDef(MagicItemEffect effect)
        {
            switch (effect.EffectType)
            {
            case "AddFireResistance":
                return(MagicItemEffectDefinitions.Get(MagicEffectType.AddFireResistancePercentage));

            case "AddFrostResistance":
                return(MagicItemEffectDefinitions.Get(MagicEffectType.AddFrostResistancePercentage));

            case "AddLightningResistance":
                return(MagicItemEffectDefinitions.Get(MagicEffectType.AddLightningResistancePercentage));

            case "AddPoisonResistance":
                return(MagicItemEffectDefinitions.Get(MagicEffectType.AddPoisonResistancePercentage));

            case "AddSpiritResistance":
                return(MagicItemEffectDefinitions.Get(MagicEffectType.AddElementalResistancePercentage));
            }
            return(null);
        }
Ejemplo n.º 14
0
        public static object GetSuffix(MagicItem magicItem)
        {
            if (magicItem.Effects.Count < 2)
            {
                return(null);
            }

            var secondEffect = magicItem.Effects[1];
            var effectDef    = MagicItemEffectDefinitions.Get(secondEffect.EffectType);

            if (effectDef == null)
            {
                return(null);
            }

            var suffixes     = effectDef.Suffixes ?? Config.Rare.GenericSuffixes;
            var randomSuffix = GetRandomStringFromList(suffixes);

            // Include " of "
            var format = Localization.instance.Localize("$mod_epicloot_suffixformat");

            return(string.IsNullOrEmpty(randomSuffix) ? null : string.Format(format, randomSuffix));
        }
Ejemplo n.º 15
0
        public static object GetPrefix(MagicItem magicItem)
        {
            if (magicItem.Effects.Count == 0)
            {
                return(null);
            }

            var firstEffect = magicItem.Effects[0];
            var effectDef   = MagicItemEffectDefinitions.Get(firstEffect.EffectType);

            if (effectDef == null)
            {
                return(null);
            }

            var prefixes     = effectDef.Prefixes ?? Config.Rare.GenericPrefixes;
            var randomPrefix = GetRandomStringFromList(prefixes);

            // Include trailing space
            var format = Localization.instance.Localize("$mod_epicloot_prefixformat");

            return(string.IsNullOrEmpty(randomPrefix) ? null : string.Format(format, randomPrefix));
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
        public static void SpawnMagicItemWithEffect(Console __instance, string[] args)
        {
            if (args.Length < 3)
            {
                EpicLoot.LogError("Specify effect and item name");
                return;
            }

            if (Player.m_localPlayer == null)
            {
                return;
            }

            var effectArg         = args[1];
            var itemPrefabNameArg = args[2];

            __instance.AddString($"magicitem - {itemPrefabNameArg} with effect: {effectArg}");

            var magicItemEffectDef = MagicItemEffectDefinitions.Get(effectArg);

            if (magicItemEffectDef == null)
            {
                __instance.AddString($"> Could not find effect: {effectArg}");
                return;
            }

            var itemPrefab = ObjectDB.instance.GetItemPrefab(itemPrefabNameArg);

            if (itemPrefab == null)
            {
                __instance.AddString($"> Could not find item: {itemPrefabNameArg}");
                return;
            }

            var fromItemData = itemPrefab.GetComponent <ItemDrop>().m_itemData;

            if (!EpicLoot.CanBeMagicItem(fromItemData))
            {
                __instance.AddString($"> Can't be magic item: {itemPrefabNameArg}");
                return;
            }

            var effectRequirements = magicItemEffectDef.Requirements;
            var itemRarity         = effectRequirements.AllowedRarities.Count == 0 ? ItemRarity.Legendary : effectRequirements.AllowedRarities.First();
            var rarityTable        = GetRarityTable(itemRarity.ToString());
            var loot = new LootTable
            {
                Object = "Console",
                Drops  = new[] { new[] { 1, 1 } },
                Loot   = new[]
                {
                    new LootDrop
                    {
                        Item   = itemPrefab.name,
                        Rarity = rarityTable
                    }
                }
            };

            var randomOffset = UnityEngine.Random.insideUnitSphere;
            var dropPoint    = Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 3 + Vector3.up * 1.5f + randomOffset;

            // TODO add better hook for desired effect - currently effect will be discarded on next game load
            // if effect was added when magicItem had maximum of available effect
            // however still good for debug
            LootRoller.CheatForceMagicEffect = true;
            LootRoller.ForcedMagicEffect     = effectArg;
            LootRoller.RollLootTableAndSpawnObjects(loot, 1, loot.Object, dropPoint);
            LootRoller.CheatForceMagicEffect = false;
            LootRoller.ForcedMagicEffect     = string.Empty;
        }
Ejemplo n.º 18
0
        public static void SpawnMagicItemWithEffect(Terminal context, string[] args)
        {
            if (args.Length < 3)
            {
                EpicLoot.LogError("Specify effect and item name");
                return;
            }

            if (Player.m_localPlayer == null)
            {
                return;
            }

            var effectArg         = args[1];
            var itemPrefabNameArg = args[2];

            context.AddString($"magicitem - {itemPrefabNameArg} with effect: {effectArg}");

            var magicItemEffectDef = MagicItemEffectDefinitions.Get(effectArg);

            if (magicItemEffectDef == null)
            {
                context.AddString($"> Could not find effect: {effectArg}");
                return;
            }

            var itemPrefab = ObjectDB.instance.GetItemPrefab(itemPrefabNameArg);

            if (itemPrefab == null)
            {
                context.AddString($"> Could not find item: {itemPrefabNameArg}");
                return;
            }

            var fromItemData = itemPrefab.GetComponent <ItemDrop>().m_itemData;

            if (!EpicLoot.CanBeMagicItem(fromItemData))
            {
                context.AddString($"> Can't be magic item: {itemPrefabNameArg}");
                return;
            }

            var effectRequirements = magicItemEffectDef.Requirements;
            var itemRarity         = effectRequirements.AllowedRarities.Count == 0 ? ItemRarity.Magic : effectRequirements.AllowedRarities.First();
            var rarityTable        = GetRarityTable(itemRarity.ToString());
            var loot = new LootTable
            {
                Object = "Console",
                Drops  = new[] { new float[] { 1, 1 } },
                Loot   = new[]
                {
                    new LootDrop
                    {
                        Item   = itemPrefab.name,
                        Rarity = rarityTable
                    }
                }
            };

            var randomOffset = UnityEngine.Random.insideUnitSphere;
            var dropPoint    = Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 3 + Vector3.up * 1.5f + randomOffset;

            LootRoller.CheatForceMagicEffect = true;
            LootRoller.ForcedMagicEffect     = effectArg;
            LootRoller.RollLootTableAndSpawnObjects(loot, 1, loot.Object, dropPoint);
            LootRoller.CheatForceMagicEffect = false;
            LootRoller.ForcedMagicEffect     = string.Empty;
        }