From 692d9a72aa4e34f8113511c8e8f963f10e6517c2 Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Fri, 16 Feb 2024 17:34:43 +0700 Subject: [PATCH 1/3] Added ItemName in MagicItem definition and implemented it's proper setting on item creation --- EpicLoot/Crafting/AugmentChoiceDialog.cs | 2 +- EpicLoot/Crafting/AugmentHelper.cs | 4 ++-- EpicLoot/Crafting/AugmentsAvailableDialog.cs | 2 +- EpicLoot/CraftingV2/EnchantingUIController.cs | 6 ++--- EpicLoot/LootRoller.cs | 23 ++++++++++--------- EpicLoot/MagicItem.cs | 17 +++++++------- EpicLoot/MagicItemEffectDefinition.cs | 4 ++-- EpicLoot/Multiplayer_Player_Patch.cs | 2 +- EpicLoot/Terminal_Patch.cs | 2 +- EpicLoot/TextsDialog_Patch.cs | 2 +- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/EpicLoot/Crafting/AugmentChoiceDialog.cs b/EpicLoot/Crafting/AugmentChoiceDialog.cs index 0e04e73c..2a0c67b5 100644 --- a/EpicLoot/Crafting/AugmentChoiceDialog.cs +++ b/EpicLoot/Crafting/AugmentChoiceDialog.cs @@ -137,7 +137,7 @@ public void Show(ItemDrop.ItemData fromItem, int effectIndex, Action(); - text.text = Localization.instance.Localize((index == 0 ? "($mod_epicloot_augment_keep) " : "") + MagicItem.GetEffectText(effect, rarity, true)); + text.text = Localization.instance.Localize((index == 0 ? "($mod_epicloot_augment_keep) " : "") + MagicItem.GetEffectText(effect, rarity, fromItem.m_shared.m_name, true)); text.color = rarityColor; if (EpicLoot.HasAuga) diff --git a/EpicLoot/Crafting/AugmentHelper.cs b/EpicLoot/Crafting/AugmentHelper.cs index a044e00d..35d79e94 100644 --- a/EpicLoot/Crafting/AugmentHelper.cs +++ b/EpicLoot/Crafting/AugmentHelper.cs @@ -169,7 +169,7 @@ public static List GetAvailableAugments(AugmentRecipe if (recipe.EffectIndex >= 0 && recipe.EffectIndex < magicItem.Effects.Count) { var currentEffectDef = MagicItemEffectDefinitions.Get(magicItem.Effects[recipe.EffectIndex].EffectType); - valuelessEffect = currentEffectDef.GetValuesForRarity(rarity) == null; + valuelessEffect = currentEffectDef.GetValuesForRarity(rarity, item.m_shared.m_name) == null; } return MagicItemEffectDefinitions.GetAvailableEffects(item.Extended(), item.GetMagicItem(), valuelessEffect ? -1 : recipe.EffectIndex); @@ -179,7 +179,7 @@ public static string GetAugmentSelectorText(MagicItem magicItem, int i, IReadOnl { var pip = EpicLoot.GetMagicEffectPip(magicItem.IsEffectAugmented(i)); bool free = EnchantCostsHelper.EffectIsDeprecated(augmentableEffects[i].EffectType); - return $"{pip} {Localization.instance.Localize(MagicItem.GetEffectText(augmentableEffects[i], rarity, true))}{(free ? " [*FREE]" : "")}"; + return $"{pip} {Localization.instance.Localize(MagicItem.GetEffectText(augmentableEffects[i], rarity, magicItem.ItemName, true))}{(free ? " [*FREE]" : "")}"; } public static List> GetAugmentCosts(ItemDrop.ItemData item, int recipeEffectIndex) diff --git a/EpicLoot/Crafting/AugmentsAvailableDialog.cs b/EpicLoot/Crafting/AugmentsAvailableDialog.cs index f3c8a655..b29c1750 100644 --- a/EpicLoot/Crafting/AugmentsAvailableDialog.cs +++ b/EpicLoot/Crafting/AugmentsAvailableDialog.cs @@ -72,7 +72,7 @@ public void Show(AugmentHelper.AugmentRecipe recipe) foreach (var effectDef in availableEffects) { - var values = effectDef.GetValuesForRarity(item.GetRarity()); + var values = effectDef.GetValuesForRarity(item.GetRarity(), item.m_shared.m_name); var valueDisplay = values != null ? Mathf.Approximately(values.MinValue, values.MaxValue) ? $"{values.MinValue}" : $"({values.MinValue}-{values.MaxValue})" : ""; t.AppendLine($"‣ {string.Format(Localization.instance.Localize(effectDef.DisplayText), valueDisplay)}"); } diff --git a/EpicLoot/CraftingV2/EnchantingUIController.cs b/EpicLoot/CraftingV2/EnchantingUIController.cs index e5e57b18..2dcfed35 100644 --- a/EpicLoot/CraftingV2/EnchantingUIController.cs +++ b/EpicLoot/CraftingV2/EnchantingUIController.cs @@ -388,7 +388,7 @@ private static string GetEnchantInfo(ItemDrop.ItemData item, MagicRarityUnity _r foreach (var effectDef in availableEffects) { - var values = effectDef.GetValuesForRarity(rarity); + var values = effectDef.GetValuesForRarity(rarity, item.m_shared.m_name); var valueDisplay = values != null ? Mathf.Approximately(values.MinValue, values.MaxValue) ? $"{values.MinValue}" : $"({values.MinValue}-{values.MaxValue})" : ""; sb.AppendLine($"‣ {string.Format(Localization.instance.Localize(effectDef.DisplayText), valueDisplay)}"); } @@ -520,7 +520,7 @@ private static string GetAvailableAugmentEffects(ItemDrop.ItemData item, int aug if (augmentindex >= 0 && augmentindex < magicItem.Effects.Count) { var currentEffectDef = MagicItemEffectDefinitions.Get(magicItem.Effects[augmentindex].EffectType); - valuelessEffect = currentEffectDef.GetValuesForRarity(rarity) == null; + valuelessEffect = currentEffectDef.GetValuesForRarity(rarity, item.m_shared.m_name) == null; } var availableEffects = MagicItemEffectDefinitions.GetAvailableEffects(item.Extended(), item.GetMagicItem(), valuelessEffect ? -1 : augmentindex); @@ -529,7 +529,7 @@ private static string GetAvailableAugmentEffects(ItemDrop.ItemData item, int aug sb.Append($""); foreach (var effectDef in availableEffects) { - var values = effectDef.GetValuesForRarity(item.GetRarity()); + var values = effectDef.GetValuesForRarity(item.GetRarity(), item.m_shared.m_name); var valueDisplay = values != null ? Mathf.Approximately(values.MinValue, values.MaxValue) ? $"{values.MinValue}" : $"({values.MinValue}-{values.MaxValue})" : ""; sb.AppendLine($"‣ {string.Format(Localization.instance.Localize(effectDef.DisplayText), valueDisplay)}"); } diff --git a/EpicLoot/LootRoller.cs b/EpicLoot/LootRoller.cs index a36f64a5..928c3127 100644 --- a/EpicLoot/LootRoller.cs +++ b/EpicLoot/LootRoller.cs @@ -351,7 +351,7 @@ private static List RollLootTableInternal(LootTable lootTable, int l var magicItem = RollMagicItem(lootDrop, itemData, luckFactor); if (CheatForceMagicEffect) { - AddDebugMagicEffects(magicItem); + AddDebugMagicEffects(magicItem, itemData.m_shared.m_name); } magicItemComponent.SetMagicItem(magicItem); itemDrop.m_itemData = itemData; @@ -464,7 +464,7 @@ public static MagicItem RollMagicItem(ItemRarity rarity, ItemDrop.ItemData baseI rarity = ItemRarity.Legendary; } - var magicItem = new MagicItem { Rarity = rarity }; + var magicItem = new MagicItem { Rarity = rarity, ItemName = baseItem.m_shared.m_name }; var effectCount = CheatEffectCount >= 1 ? CheatEffectCount : RollEffectCountPerRarity(magicItem.Rarity); @@ -512,7 +512,7 @@ public static MagicItem RollMagicItem(ItemRarity rarity, ItemDrop.ItemData baseI continue; } - var effect = RollEffect(effectDef, ItemRarity.Legendary, guaranteedMagicEffect.Values); + var effect = RollEffect(effectDef, ItemRarity.Legendary, baseItem.m_shared.m_name, guaranteedMagicEffect.Values); magicItem.Effects.Add(effect); effectCount--; } @@ -532,7 +532,7 @@ public static MagicItem RollMagicItem(ItemRarity rarity, ItemDrop.ItemData baseI _weightedEffectTable.Setup(availableEffects, x => x.SelectionWeight); var effectDef = _weightedEffectTable.Roll(); - var effect = RollEffect(effectDef, magicItem.Rarity); + var effect = RollEffect(effectDef, magicItem.Rarity, baseItem.m_shared.m_name); magicItem.Effects.Add(effect); } @@ -612,10 +612,10 @@ public static List> GetEffectCountsPerRarity(ItemRarity return result; } - public static MagicItemEffect RollEffect(MagicItemEffectDefinition effectDef, ItemRarity itemRarity, MagicItemEffectDefinition.ValueDef valuesOverride = null) + public static MagicItemEffect RollEffect(MagicItemEffectDefinition effectDef, ItemRarity itemRarity, string itemName, MagicItemEffectDefinition.ValueDef valuesOverride = null) { float value = MagicItemEffect.DefaultValue; - var valuesDef = valuesOverride ?? effectDef.GetValuesForRarity(itemRarity); + var valuesDef = valuesOverride ?? effectDef.GetValuesForRarity(itemRarity, itemName); if (valuesDef != null) { value = valuesDef.MinValue; @@ -630,7 +630,8 @@ public static MagicItemEffect RollEffect(MagicItemEffectDefinition effectDef, It return new MagicItemEffect(effectDef.Type, value); } - public static List RollEffects(List availableEffects, ItemRarity itemRarity, int count, bool removeOnSelect = true) + + public static List RollEffects(List availableEffects, ItemRarity itemRarity, string itemName, int count, bool removeOnSelect = true) { var results = new List(); @@ -644,7 +645,7 @@ public static List RollEffects(List EpicLoot.LogError($"EffectDef was null! RollEffects({itemRarity}, {count})"); continue; } - results.Add(RollEffect(effectDef, itemRarity)); + results.Add(RollEffect(effectDef, itemRarity, itemName)); } return results; @@ -818,7 +819,7 @@ public static List RollAugmentEffects(ItemDrop.ItemData item, M for (var i = 0; i < augmentChoices && i < availableEffects.Count; i++) { - var newEffect = RollEffects(availableEffects, rarity, 1, false).FirstOrDefault(); + var newEffect = RollEffects(availableEffects, rarity, item.m_shared.m_name, 1, false).FirstOrDefault(); if (newEffect == null) { EpicLoot.LogError($"Rolled a null effect: item:{item.m_shared.m_name}, index:{effectIndex}"); @@ -837,12 +838,12 @@ public static List RollAugmentEffects(ItemDrop.ItemData item, M return results; } - public static void AddDebugMagicEffects(MagicItem item) + public static void AddDebugMagicEffects(MagicItem item, string itemName) { if (!string.IsNullOrEmpty(ForcedMagicEffect) && !item.HasEffect(ForcedMagicEffect)) { EpicLoot.Log($"AddDebugMagicEffect {ForcedMagicEffect}"); - item.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(ForcedMagicEffect), item.Rarity)); + item.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(ForcedMagicEffect), item.Rarity, itemName)); } } diff --git a/EpicLoot/MagicItem.cs b/EpicLoot/MagicItem.cs index 0a8743a2..ac46241f 100644 --- a/EpicLoot/MagicItem.cs +++ b/EpicLoot/MagicItem.cs @@ -39,7 +39,7 @@ public MagicItemEffect(string type, float value = DefaultValue) [Serializable] public class MagicItem { - public int Version = 2; + public int Version = 3; public ItemRarity Rarity; public List Effects = new List(); public string TypeNameOverride; @@ -48,6 +48,7 @@ public class MagicItem public string DisplayName; public string LegendaryID; public string SetID; + public string ItemName; public string GetItemTypeName(ItemDrop.ItemData baseItem) { @@ -71,7 +72,7 @@ public string GetTooltip() { var effect = Effects[index]; var pip = EpicLoot.GetMagicEffectPip(IsEffectAugmented(index)); - tooltip.AppendLine($"{pip} {GetEffectText(effect, Rarity, showRange)}"); + tooltip.AppendLine($"{pip} {GetEffectText(effect, Rarity, ItemName, showRange)}"); } tooltip.Append($""); @@ -127,11 +128,11 @@ public static string GetEffectText(MagicItemEffectDefinition effectDef, float va return result; } - public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange, string legendaryID, MagicItemEffectDefinition.ValueDef valuesOverride) + public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, string itemName, 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)); + var values = valuesOverride ?? (string.IsNullOrEmpty(legendaryID) ? effectDef.GetValuesForRarity(rarity, itemName) : UniqueLegendaryHelper.GetLegendaryEffectValues(legendaryID, effect.EffectType)); if (showRange && values != null) { if (!Mathf.Approximately(values.MinValue, values.MaxValue)) @@ -142,14 +143,14 @@ public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bo return result; } - public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange, string legendaryID = null) + public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, string itemName, bool showRange, string legendaryID = null) { - return GetEffectText(effect, rarity, showRange, legendaryID, null); + return GetEffectText(effect, rarity, itemName, showRange, legendaryID, null); } - public static string GetEffectText(MagicItemEffect effect, MagicItemEffectDefinition.ValueDef valuesOverride) + public static string GetEffectText(MagicItemEffect effect, string itemName, MagicItemEffectDefinition.ValueDef valuesOverride) { - return GetEffectText(effect, ItemRarity.Legendary, false, null, valuesOverride); + return GetEffectText(effect, ItemRarity.Legendary, itemName, false, null, valuesOverride); } public void ReplaceEffect(int index, MagicItemEffect newEffect) diff --git a/EpicLoot/MagicItemEffectDefinition.cs b/EpicLoot/MagicItemEffectDefinition.cs index 7668918e..b0598f15 100644 --- a/EpicLoot/MagicItemEffectDefinition.cs +++ b/EpicLoot/MagicItemEffectDefinition.cs @@ -336,7 +336,7 @@ public bool HasRarityValues() return ValuesPerRarity.Magic != null && ValuesPerRarity.Epic != null && ValuesPerRarity.Rare != null && ValuesPerRarity.Legendary != null; } - public ValueDef GetValuesForRarity(ItemRarity itemRarity) + public ValueDef GetValuesForRarity(ItemRarity itemRarity, string itemName) { switch (itemRarity) { @@ -426,7 +426,7 @@ public static bool IsValuelessEffect(string effectType, ItemRarity rarity) return false; } - return effectDef.GetValuesForRarity(rarity) == null; + return effectDef.GetValuesForRarity(rarity, null) == null; } } } diff --git a/EpicLoot/Multiplayer_Player_Patch.cs b/EpicLoot/Multiplayer_Player_Patch.cs index 58e3f3b4..e9b9cf3d 100644 --- a/EpicLoot/Multiplayer_Player_Patch.cs +++ b/EpicLoot/Multiplayer_Player_Patch.cs @@ -119,7 +119,7 @@ private static bool DoCheck(Player player, ZDO zdo, string equipKey, string lege itemData = targetItemData.Clone(); itemData.m_durability = float.PositiveInfinity; var magicItemComponent = itemData.Data().GetOrCreate(); - var stubMagicItem = new MagicItem { Rarity = ItemRarity.Legendary, LegendaryID = zdoLegendaryID }; + var stubMagicItem = new MagicItem { Rarity = ItemRarity.Legendary, ItemName = itemData.m_shared.m_name, LegendaryID = zdoLegendaryID }; magicItemComponent.SetMagicItem(stubMagicItem); ForceResetVisEquipment(player, itemData); diff --git a/EpicLoot/Terminal_Patch.cs b/EpicLoot/Terminal_Patch.cs index f2720211..a4625f8a 100644 --- a/EpicLoot/Terminal_Patch.cs +++ b/EpicLoot/Terminal_Patch.cs @@ -618,7 +618,7 @@ private static void ReplaceMagicEffect(ItemDrop.ItemData itemData, MagicItem mag return; } - var replacementEffect = LootRoller.RollEffect(replacementEffectDef, magicItem.Rarity); + var replacementEffect = LootRoller.RollEffect(replacementEffectDef, magicItem.Rarity, itemData.m_shared.m_name); magicItem.Effects[index] = replacementEffect; itemData.SaveMagicItem(magicItem); } diff --git a/EpicLoot/TextsDialog_Patch.cs b/EpicLoot/TextsDialog_Patch.cs index 195a7159..259e5682 100644 --- a/EpicLoot/TextsDialog_Patch.cs +++ b/EpicLoot/TextsDialog_Patch.cs @@ -64,7 +64,7 @@ public static void AddMagicEffectsPage(TextsDialog textsDialog, Player player) { var effect = entry2.Key; var item = entry2.Value; - t.AppendLine($" - {MagicItem.GetEffectText(effect, item.GetRarity(), false)} ({item.GetDecoratedName()})"); + t.AppendLine($" - {MagicItem.GetEffectText(effect, item.GetRarity(), item.m_shared.m_name, false)} ({item.GetDecoratedName()})"); } t.AppendLine(); From a985a25ffeba6d5accfb9a65cc2e1e32caffec55 Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Wed, 21 Feb 2024 13:27:15 +0700 Subject: [PATCH 2/3] Added ValuesPerItemName filter --- EpicLoot/MagicItemEffectDefinition.cs | 48 +++++++++++++++++++++------ 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/EpicLoot/MagicItemEffectDefinition.cs b/EpicLoot/MagicItemEffectDefinition.cs index b0598f15..3cfa078e 100644 --- a/EpicLoot/MagicItemEffectDefinition.cs +++ b/EpicLoot/MagicItemEffectDefinition.cs @@ -300,12 +300,20 @@ public class ValuesPerRarityDef public ValueDef Mythic; } + [Serializable] + public class ValuesPerItemNameDef + { + public List ItemNames = new List(); + public ValuesPerRarityDef ValuesPerRarity = new ValuesPerRarityDef(); + } + public string Type { get; set; } public string DisplayText = ""; public string Description = ""; public MagicItemEffectRequirements Requirements = new MagicItemEffectRequirements(); public ValuesPerRarityDef ValuesPerRarity = new ValuesPerRarityDef(); + public List ValuesPerItemName = new List(); public float SelectionWeight = 1; public bool CanBeAugmented = true; public bool CanBeDisenchanted = true; @@ -338,18 +346,36 @@ public bool HasRarityValues() public ValueDef GetValuesForRarity(ItemRarity itemRarity, string itemName) { - switch (itemRarity) - { - case ItemRarity.Magic: return ValuesPerRarity.Magic; - case ItemRarity.Rare: return ValuesPerRarity.Rare; - case ItemRarity.Epic: return ValuesPerRarity.Epic; - case ItemRarity.Legendary: return ValuesPerRarity.Legendary; - case ItemRarity.Mythic: - // TODO: Mythic Hookup - return null;//ValuesPerRarity.Mythic; - default: - throw new ArgumentOutOfRangeException(nameof(itemRarity), itemRarity, null); + ValueDef ValueForRarity(ValuesPerRarityDef valuesPerRarity) + { + switch (itemRarity) + { + case ItemRarity.Magic: return valuesPerRarity.Magic; + case ItemRarity.Rare: return valuesPerRarity.Rare; + case ItemRarity.Epic: return valuesPerRarity.Epic; + case ItemRarity.Legendary: return valuesPerRarity.Legendary; + case ItemRarity.Mythic: + // TODO: Mythic Hookup + return null;//ValuesPerRarity.Mythic; + default: + throw new ArgumentOutOfRangeException(nameof(itemRarity), itemRarity, null); + } + } + + if (string.IsNullOrEmpty(itemName) || ValuesPerItemName == null) + { + return ValueForRarity(ValuesPerRarity); + } + + for (var i = 0; i < ValuesPerItemName.Count; i++) + { + if (ValuesPerItemName[i].ItemNames.Contains(itemName)) + { + return ValueForRarity(ValuesPerItemName[i].ValuesPerRarity); + } } + + return ValueForRarity(ValuesPerRarity); } } From 5e8df4d6991a90c1a4bcef1930eab31f000e1023 Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Mon, 26 Feb 2024 12:36:33 +0700 Subject: [PATCH 3/3] Fixed unique legendaries custom effect ranges not being shown properly in hints --- EpicLoot/Crafting/AugmentChoiceDialog.cs | 2 +- EpicLoot/Crafting/AugmentHelper.cs | 2 +- EpicLoot/MagicItem.cs | 24 +++++++++++++++++------- EpicLoot/TextsDialog_Patch.cs | 3 ++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/EpicLoot/Crafting/AugmentChoiceDialog.cs b/EpicLoot/Crafting/AugmentChoiceDialog.cs index 2a0c67b5..23983d30 100644 --- a/EpicLoot/Crafting/AugmentChoiceDialog.cs +++ b/EpicLoot/Crafting/AugmentChoiceDialog.cs @@ -137,7 +137,7 @@ public void Show(ItemDrop.ItemData fromItem, int effectIndex, Action(); - text.text = Localization.instance.Localize((index == 0 ? "($mod_epicloot_augment_keep) " : "") + MagicItem.GetEffectText(effect, rarity, fromItem.m_shared.m_name, true)); + text.text = Localization.instance.Localize((index == 0 ? "($mod_epicloot_augment_keep) " : "") + MagicItem.GetEffectText(effect, rarity, fromItem.m_shared.m_name, true, magicItem.LegendaryID)); text.color = rarityColor; if (EpicLoot.HasAuga) diff --git a/EpicLoot/Crafting/AugmentHelper.cs b/EpicLoot/Crafting/AugmentHelper.cs index 35d79e94..62a5101e 100644 --- a/EpicLoot/Crafting/AugmentHelper.cs +++ b/EpicLoot/Crafting/AugmentHelper.cs @@ -179,7 +179,7 @@ public static string GetAugmentSelectorText(MagicItem magicItem, int i, IReadOnl { var pip = EpicLoot.GetMagicEffectPip(magicItem.IsEffectAugmented(i)); bool free = EnchantCostsHelper.EffectIsDeprecated(augmentableEffects[i].EffectType); - return $"{pip} {Localization.instance.Localize(MagicItem.GetEffectText(augmentableEffects[i], rarity, magicItem.ItemName, true))}{(free ? " [*FREE]" : "")}"; + return $"{pip} {Localization.instance.Localize(MagicItem.GetEffectText(augmentableEffects[i], rarity, magicItem.ItemName, true, magicItem.LegendaryID))}{(free ? " [*FREE]" : "")}"; } public static List> GetAugmentCosts(ItemDrop.ItemData item, int recipeEffectIndex) diff --git a/EpicLoot/MagicItem.cs b/EpicLoot/MagicItem.cs index ac46241f..6dc50c2a 100644 --- a/EpicLoot/MagicItem.cs +++ b/EpicLoot/MagicItem.cs @@ -72,7 +72,7 @@ public string GetTooltip() { var effect = Effects[index]; var pip = EpicLoot.GetMagicEffectPip(IsEffectAugmented(index)); - tooltip.AppendLine($"{pip} {GetEffectText(effect, Rarity, ItemName, showRange)}"); + tooltip.AppendLine($"{pip} {GetEffectText(effect, Rarity, ItemName, showRange, LegendaryID)}"); } tooltip.Append($""); @@ -132,7 +132,22 @@ public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, st { var effectDef = MagicItemEffectDefinitions.Get(effect.EffectType); var result = GetEffectText(effectDef, effect.EffectValue); - var values = valuesOverride ?? (string.IsNullOrEmpty(legendaryID) ? effectDef.GetValuesForRarity(rarity, itemName) : UniqueLegendaryHelper.GetLegendaryEffectValues(legendaryID, effect.EffectType)); + MagicItemEffectDefinition.ValueDef values = null; + if (valuesOverride != null) + { + values = valuesOverride; + } + else + { + if (!string.IsNullOrEmpty(legendaryID)) + { + values = UniqueLegendaryHelper.GetLegendaryEffectValues(legendaryID, effect.EffectType); + } + if (values == null) + { + values = effectDef.GetValuesForRarity(rarity, itemName); + } + } if (showRange && values != null) { if (!Mathf.Approximately(values.MinValue, values.MaxValue)) @@ -148,11 +163,6 @@ public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, st return GetEffectText(effect, rarity, itemName, showRange, legendaryID, null); } - public static string GetEffectText(MagicItemEffect effect, string itemName, MagicItemEffectDefinition.ValueDef valuesOverride) - { - return GetEffectText(effect, ItemRarity.Legendary, itemName, false, null, valuesOverride); - } - public void ReplaceEffect(int index, MagicItemEffect newEffect) { if (index < 0 || index >= Effects.Count) diff --git a/EpicLoot/TextsDialog_Patch.cs b/EpicLoot/TextsDialog_Patch.cs index 259e5682..f4cb06df 100644 --- a/EpicLoot/TextsDialog_Patch.cs +++ b/EpicLoot/TextsDialog_Patch.cs @@ -64,7 +64,8 @@ public static void AddMagicEffectsPage(TextsDialog textsDialog, Player player) { var effect = entry2.Key; var item = entry2.Value; - t.AppendLine($" - {MagicItem.GetEffectText(effect, item.GetRarity(), item.m_shared.m_name, false)} ({item.GetDecoratedName()})"); + var magicItem = item.GetMagicItem(); + t.AppendLine($" - {MagicItem.GetEffectText(effect, item.GetRarity(), item.m_shared.m_name, false, magicItem?.LegendaryID)} ({item.GetDecoratedName()})"); } t.AppendLine();