From 8b54fdfb2ea5e6bb24d25d7f5c54e01a3886a649 Mon Sep 17 00:00:00 2001 From: Huard Ouadi Date: Sun, 26 May 2019 18:32:30 +0200 Subject: [PATCH] rarity rework Killing unique boss increase odd of getting better rarity on item Reaching hardmode and defeating moonlord Increase "base rarity" for rarity roll on item --- RPGModule/Items/ModifierManager.cs | 44 ++++++++++++++++++++++++-- RPGModule/Items/RarityWeightManager.cs | 11 +++++-- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/RPGModule/Items/ModifierManager.cs b/RPGModule/Items/ModifierManager.cs index 0a36073..9797b03 100644 --- a/RPGModule/Items/ModifierManager.cs +++ b/RPGModule/Items/ModifierManager.cs @@ -244,6 +244,33 @@ public static WeaponType GetWeaponType (Item item) new RarityWeight(Rarity.Mythical,0.75f) }) }, + { 14 , + new RarityWeightManager(new RarityWeight[3]{ + new RarityWeight(Rarity.Epic,1.75f), + new RarityWeight(Rarity.Legendary,1.75f), + new RarityWeight(Rarity.Mythical,1.25f) + }) + }, + { 15 , + new RarityWeightManager(new RarityWeight[3]{ + new RarityWeight(Rarity.Epic,1.5f), + new RarityWeight(Rarity.Legendary,2f), + new RarityWeight(Rarity.Mythical,1.5f) + }) + }, + { 16 , + new RarityWeightManager(new RarityWeight[3]{ + new RarityWeight(Rarity.Epic,1), + new RarityWeight(Rarity.Legendary,1.5f), + new RarityWeight(Rarity.Mythical,3f) + }) + }, + { 17 , + new RarityWeightManager(new RarityWeight[2]{ + new RarityWeight(Rarity.Legendary,2f), + new RarityWeight(Rarity.Mythical,5f) + }) + }, { -12 , new RarityWeightManager(new RarityWeight[4]{ new RarityWeight(Rarity.MasterPiece,2.1f), @@ -324,9 +351,20 @@ public static Color GetRarityColor (Rarity rarity) public static Rarity GetRarity(Item item) { - if (rarityConversion.ContainsKey(item.rare)) - return rarityConversion[item.rare].DrawRarity(); - else return rarityConversion[5].DrawRarity(); + int rarity = item.rare; + if (rarity >= -1) { + if (Main.hardMode) + { + rarity++; + } + if (NPC.downedMoonlord) + { + rarity++; + } + } + if (rarityConversion.ContainsKey(rarity)) + return rarityConversion[rarity].DrawRarity(); + else return rarityConversion[17].DrawRarity(); } diff --git a/RPGModule/Items/RarityWeightManager.cs b/RPGModule/Items/RarityWeightManager.cs index c734fdd..a4f9ba6 100644 --- a/RPGModule/Items/RarityWeightManager.cs +++ b/RPGModule/Items/RarityWeightManager.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using AnotherRpgMod.Utils; namespace AnotherRpgMod.Items { @@ -17,10 +18,14 @@ public RarityWeightManager(RarityWeight[] weights) public Rarity DrawRarity() { - float totalWeight = 0; + int bossKilled = WorldManager.BossDefeated; + + float totalWeight = 0; for (int i = 0; i < weights.Length; i++) totalWeight += weights[i].weight; - float rn = Utils.Mathf.Random(0, totalWeight); + float rn = Mathf.Random(0, totalWeight); + + rn += bossKilled * totalWeight * 0.01f; float actualWeight = 0; for (int i = 0; i < weights.Length; i++) { @@ -28,7 +33,7 @@ public Rarity DrawRarity() return weights[i].rarity; actualWeight += weights[i].weight; } - return weights[0].rarity; + return weights[weights.Length-1].rarity; }