Skip to content

Commit

Permalink
rarity rework
Browse files Browse the repository at this point in the history
Killing unique boss increase odd of getting better rarity on item

Reaching hardmode and defeating moonlord Increase "base rarity" for rarity roll on item
  • Loading branch information
PlexusDuMenton committed May 26, 2019
1 parent 3d51721 commit 8b54fdf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
44 changes: 41 additions & 3 deletions RPGModule/Items/ModifierManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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();
}


Expand Down
11 changes: 8 additions & 3 deletions RPGModule/Items/RarityWeightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AnotherRpgMod.Utils;

namespace AnotherRpgMod.Items
{
Expand All @@ -17,18 +18,22 @@ 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++)
{
if (rn < actualWeight + weights[i].weight)
return weights[i].rarity;
actualWeight += weights[i].weight;
}
return weights[0].rarity;
return weights[weights.Length-1].rarity;


}
Expand Down

0 comments on commit 8b54fdf

Please sign in to comment.