diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 00232b0c2e..5ecd63536e 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1765,6 +1765,29 @@ namespace CalamityMod.Items } #endregion + #region On Create + public override void OnCreate(Item item, ItemCreationContext context) + { + // Crafting a rogue weapon has a 75% chance for a random modifier + // Negative modifiers have a 66.66% chance of being voided + // Note, the modifier doesn't show up in the craft text (the one that indicates you got a new item) + if (context is RecipeCreationContext) + { + if (item.CanGetRoguePrefix()) + { + if (Main.rand.Next(4) < 3) + { + int prefix = CalamityUtils.RandomRoguePrefix(); + if (!CalamityUtils.NegativeRoguePrefix(prefix) || Main.rand.NextBool(3)) + { + item.Prefix(prefix); + } + } + } + } + } + #endregion + #region Reforging private int NewPrefixType(Item item) { diff --git a/Prefixes/RogueWeaponPrefix.cs b/Prefixes/RogueWeaponPrefix.cs index 344b611d79..6c6788a843 100644 --- a/Prefixes/RogueWeaponPrefix.cs +++ b/Prefixes/RogueWeaponPrefix.cs @@ -152,7 +152,7 @@ namespace CalamityMod.Prefixes valueMult *= extraValue; } - public override bool CanRoll(Item item) => item.CountsAsClass() && item.maxStack == 1 && GetType() != typeof(RogueWeaponPrefix); + public override bool CanRoll(Item item) => item.CanGetRoguePrefix() && GetType() != typeof(RogueWeaponPrefix); public override void SetStats(ref float damageMult, ref float knockbackMult, ref float useTimeMult, ref float scaleMult, ref float shootSpeedMult, ref float manaMult, ref int critBonus) { diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 27d43a5a51..b25bf13bd2 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -525,5 +525,47 @@ namespace CalamityMod Recipe.FindRecipes(); } } + + #region Rogue Prefixes + public static bool CanGetRoguePrefix(this Item item) => item.CountsAsClass() && item.maxStack == 1; + + public static int RandomRoguePrefix() + { + Mod mod = ModContent.GetInstance(); + int roguePrefix = Utils.SelectRandom(Main.rand, new int[] + { + mod.Find("Radical").Type, + mod.Find("Pointy").Type, + mod.Find("Sharp").Type, + mod.Find("Glorious").Type, + mod.Find("Feathered").Type, + mod.Find("Sleek").Type, + mod.Find("Hefty").Type, + mod.Find("Mighty").Type, + mod.Find("Serrated").Type, + mod.Find("Vicious").Type, + mod.Find("Lethal").Type, + mod.Find("Flawless").Type, + mod.Find("Blunt").Type, + mod.Find("Flimsy").Type, + mod.Find("Unbalanced").Type, + mod.Find("Atrocious").Type + }); + return roguePrefix; + } + + public static bool NegativeRoguePrefix(int prefix) + { + Mod mod = ModContent.GetInstance(); + List badPrefixes = new List() + { + mod.Find("Blunt").Type, + mod.Find("Flimsy").Type, + mod.Find("Unbalanced").Type, + mod.Find("Atrocious").Type + }; + return badPrefixes.Contains(prefix); + } + #endregion } } diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 9b789a4eb3..dae97659bb 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -685,7 +685,6 @@ namespace CalamityMod { velocityMult = 1f; } - Mod mod = ModContent.GetInstance(); int type = Main.rand.Next(61, 64); int smoke = Gore.NewGore(projectile.GetSource_Death(), source, default, type, 1f); Gore gore = Main.gore[smoke];