diff --git a/EpicLoot/LootRoller.cs b/EpicLoot/LootRoller.cs index a36f64a53..1cb70f3ee 100644 --- a/EpicLoot/LootRoller.cs +++ b/EpicLoot/LootRoller.cs @@ -673,7 +673,16 @@ public static Dictionary GetRarityWeights(float[] rarity, flo { ItemRarity.Legendary, rarity.Length >= 4 ? rarity[3] : 0 } }; - return ModifyRarityByLuck(rarityWeights, luckFactor); + for (var r = ItemRarity.Legendary; r >= ItemRarity.Magic; r--) + { + if (rarityWeights[r] > 0) + { + rarityWeights[r] = rarityWeights[r] * (1 + luckFactor); + break; + } + } + + return rarityWeights; } public static List GetLootTable(string objectName) @@ -878,37 +887,6 @@ public static void DebugLuckFactor() } } - public static Dictionary ModifyRarityByLuck(IReadOnlyDictionary rarityWeights, float luckFactor = 0) - { - var results = new Dictionary(); - for (var rarity = ItemRarity.Magic; rarity <= ItemRarity.Legendary; rarity++) - { - var skewFactor = GetSkewFactor(rarity); - results.Add(rarity, rarityWeights[rarity] * GetSkewedLuckFactor(luckFactor, skewFactor)); - } - - return results; - } - - public static float GetSkewFactor(ItemRarity rarity) - { - switch (rarity) - { - case ItemRarity.Magic: return -0.2f; - case ItemRarity.Rare: return 0.0f; - case ItemRarity.Epic: return 0.2f; - case ItemRarity.Legendary: return 1; - case ItemRarity.Mythic: return 1.1f; - default: - throw new ArgumentOutOfRangeException(nameof(rarity), rarity, null); - } - } - - public static float GetSkewedLuckFactor(float luckFactor, float skewFactor) - { - return Mathf.Max(0, 1 + luckFactor * skewFactor); - } - public static void PrintLuckTest(string lootTableName, float luckFactor) { var lootTable = GetLootTable(lootTableName)[0];