From d2265053d7237ca7d070a3d994b8791849ebd49f Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Fri, 16 Feb 2024 14:19:07 +0700 Subject: [PATCH 1/3] Implemented config parameter to turn off generic legendary item drop --- EpicLoot/EpicLoot.cs | 2 ++ EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/EpicLoot/EpicLoot.cs b/EpicLoot/EpicLoot.cs index 884bdd427..4a7f9fb2f 100644 --- a/EpicLoot/EpicLoot.cs +++ b/EpicLoot/EpicLoot.cs @@ -130,6 +130,7 @@ public class EpicLoot : BaseUnityPlugin public static ConfigEntry AbilityBarLayoutAlignment; public static ConfigEntry AbilityBarIconSpacing; public static ConfigEntry SetItemDropChance; + public static ConfigEntry AlwaysDropUniqueLegendaries; public static ConfigEntry GlobalDropRateModifier; public static ConfigEntry ItemsToMaterialsDropRatio; public static ConfigEntry AlwaysShowWelcomeMessage; @@ -232,6 +233,7 @@ private void Awake() _andvaranautRange = SyncedConfig("Balance", "Andvaranaut Range", 20, "Sets the range that Andvaranaut will locate a treasure chest."); _serverConfigLocked = SyncedConfig("Config Sync", "Lock Config", false, new ConfigDescription("[Server Only] The configuration is locked and may not be changed by clients once it has been synced from the server. Only valid for server config, will have no effect on clients.")); SetItemDropChance = SyncedConfig("Balance", "Set Item Drop Chance", 0.15f, "The percent chance that a legendary item will be a set item. Min = 0, Max = 1"); + AlwaysDropUniqueLegendaries = SyncedConfig("Balance", "Always Drop Unique Legendaries", false, "If set to true, general legendaries will drop only when no appropriate unique or set item found"); GlobalDropRateModifier = SyncedConfig("Balance", "Global Drop Rate Modifier", 1.0f, "A global percentage that modifies how likely items are to drop. 1 = Exactly what is in the loot tables will drop. 0 = Nothing will drop. 2 = The number of items in the drop table are twice as likely to drop (note, this doesn't double the number of items dropped, just doubles the relative chance for them to drop). Min = 0, Max = 4"); ItemsToMaterialsDropRatio = SyncedConfig("Balance", "Items To Materials Drop Ratio", 0.0f, "Sets the chance that item drops are instead dropped as magic crafting materials. 0 = all items, no materials. 1 = all materials, no items. Values between 0 and 1 change the ratio of items to materials that drop. At 0.5, half of everything that drops would be items and the other half would be materials. Min = 0, Max = 1"); TransferMagicItemToCrafts = SyncedConfig("Balance", "Transfer Enchants to Crafted Items", false, "When enchanted items are used as ingredients in recipes, transfer the highest enchant to the newly crafted item. Default: False."); diff --git a/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs b/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs index 134a65441..52ea69630 100644 --- a/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs +++ b/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs @@ -60,10 +60,14 @@ public static bool IsGenericLegendary(LegendaryInfo legendaryInfo) public static IList GetAvailableLegendaries(ItemDrop.ItemData 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) + var availableLegendaries = LegendaryInfo.Values.Where(x => x.IsSetItem == rollSetItem && x.Requirements.CheckRequirements(baseItem, magicItem)).ToList(); + if (availableLegendaries.Count == 0) { - availableLegendaries.Remove(UniqueLegendaryHelper.GenericLegendaryInfo); + availableLegendaries.AddItem(GenericLegendaryInfo); + } + else if(!rollSetItem && !EpicLoot.AlwaysDropUniqueLegendaries.Value) + { + availableLegendaries.AddItem(GenericLegendaryInfo); } return availableLegendaries; From d8d23d2b366a250548e95e0c55136a6c0917a7b5 Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Sat, 24 Feb 2024 15:17:10 +0700 Subject: [PATCH 2/3] Fixed issue with "Set Item Drop Chance" and "Always Drop Unique Legendaries" interaction (no sense in set drop chance filter if the latter set to true) --- EpicLoot/EpicLoot.cs | 2 +- EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EpicLoot/EpicLoot.cs b/EpicLoot/EpicLoot.cs index 4a7f9fb2f..3e8ab552f 100644 --- a/EpicLoot/EpicLoot.cs +++ b/EpicLoot/EpicLoot.cs @@ -233,7 +233,7 @@ private void Awake() _andvaranautRange = SyncedConfig("Balance", "Andvaranaut Range", 20, "Sets the range that Andvaranaut will locate a treasure chest."); _serverConfigLocked = SyncedConfig("Config Sync", "Lock Config", false, new ConfigDescription("[Server Only] The configuration is locked and may not be changed by clients once it has been synced from the server. Only valid for server config, will have no effect on clients.")); SetItemDropChance = SyncedConfig("Balance", "Set Item Drop Chance", 0.15f, "The percent chance that a legendary item will be a set item. Min = 0, Max = 1"); - AlwaysDropUniqueLegendaries = SyncedConfig("Balance", "Always Drop Unique Legendaries", false, "If set to true, general legendaries will drop only when no appropriate unique or set item found"); + AlwaysDropUniqueLegendaries = SyncedConfig("Balance", "Always Drop Unique Legendaries", false, "If set to true, general legendaries will drop only when no appropriate unique item found, Set Item Drop Chance is ignored in the case (use SelectionWeight in legendaries.json instead)"); GlobalDropRateModifier = SyncedConfig("Balance", "Global Drop Rate Modifier", 1.0f, "A global percentage that modifies how likely items are to drop. 1 = Exactly what is in the loot tables will drop. 0 = Nothing will drop. 2 = The number of items in the drop table are twice as likely to drop (note, this doesn't double the number of items dropped, just doubles the relative chance for them to drop). Min = 0, Max = 4"); ItemsToMaterialsDropRatio = SyncedConfig("Balance", "Items To Materials Drop Ratio", 0.0f, "Sets the chance that item drops are instead dropped as magic crafting materials. 0 = all items, no materials. 1 = all materials, no items. Values between 0 and 1 change the ratio of items to materials that drop. At 0.5, half of everything that drops would be items and the other half would be materials. Min = 0, Max = 1"); TransferMagicItemToCrafts = SyncedConfig("Balance", "Transfer Enchants to Crafted Items", false, "When enchanted items are used as ingredients in recipes, transfer the highest enchant to the newly crafted item. Default: False."); diff --git a/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs b/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs index 52ea69630..d1ff5a906 100644 --- a/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs +++ b/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs @@ -60,7 +60,7 @@ public static bool IsGenericLegendary(LegendaryInfo legendaryInfo) public static IList GetAvailableLegendaries(ItemDrop.ItemData baseItem, MagicItem magicItem, bool rollSetItem) { - var availableLegendaries = LegendaryInfo.Values.Where(x => x.IsSetItem == rollSetItem && x.Requirements.CheckRequirements(baseItem, magicItem)).ToList(); + var availableLegendaries = LegendaryInfo.Values.Where(x => (x.IsSetItem == rollSetItem || EpicLoot.AlwaysDropUniqueLegendaries.Value) && x.Requirements.CheckRequirements(baseItem, magicItem)).ToList(); if (availableLegendaries.Count == 0) { availableLegendaries.AddItem(GenericLegendaryInfo); From 8795c381f40cc151b786b6f789b362ce50e43099 Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Sat, 24 Feb 2024 19:22:00 +0700 Subject: [PATCH 3/3] Reworked condition to avoid GenericLegendaryInfo adding exception bug --- EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs b/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs index d1ff5a906..72326fb58 100644 --- a/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs +++ b/EpicLoot/LegendarySystem/UniqueLegendaryHelper.cs @@ -60,14 +60,10 @@ public static bool IsGenericLegendary(LegendaryInfo legendaryInfo) public static IList GetAvailableLegendaries(ItemDrop.ItemData baseItem, MagicItem magicItem, bool rollSetItem) { - var availableLegendaries = LegendaryInfo.Values.Where(x => (x.IsSetItem == rollSetItem || EpicLoot.AlwaysDropUniqueLegendaries.Value) && x.Requirements.CheckRequirements(baseItem, magicItem)).ToList(); - if (availableLegendaries.Count == 0) + var availableLegendaries = LegendaryInfo.Values.Where(x => (x.IsSetItem == rollSetItem || EpicLoot.AlwaysDropUniqueLegendaries.Value) && x.Requirements.CheckRequirements(baseItem, magicItem)).AddItem(GenericLegendaryInfo).ToList(); + if ((rollSetItem || EpicLoot.AlwaysDropUniqueLegendaries.Value) && availableLegendaries.Count > 1) { - availableLegendaries.AddItem(GenericLegendaryInfo); - } - else if(!rollSetItem && !EpicLoot.AlwaysDropUniqueLegendaries.Value) - { - availableLegendaries.AddItem(GenericLegendaryInfo); + availableLegendaries.Remove(UniqueLegendaryHelper.GenericLegendaryInfo); } return availableLegendaries;