Rogue weapons now can get a random modifier on crafting, similar to vanilla weapons

This commit is contained in:
ben-tk committed 2022-08-20 22:27:51 -04:00
1 parent cc73dda111
commit d67b11f431
4 files changed
+66 -2

No files matched your search

+23
View File
@@ -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)
{
+1 -1
View File
@@ -152,7 +152,7 @@ namespace CalamityMod.Prefixes
valueMult *= extraValue;
}
public override bool CanRoll(Item item) => item.CountsAsClass<RogueDamageClass>() && 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)
{
+42
View File
@@ -525,5 +525,47 @@ namespace CalamityMod
Recipe.FindRecipes();
}
}
#region Rogue Prefixes
public static bool CanGetRoguePrefix(this Item item) => item.CountsAsClass<RogueDamageClass>() && item.maxStack == 1;
public static int RandomRoguePrefix()
{
Mod mod = ModContent.GetInstance<CalamityMod>();
int roguePrefix = Utils.SelectRandom(Main.rand, new int[]
{
mod.Find<ModPrefix>("Radical").Type,
mod.Find<ModPrefix>("Pointy").Type,
mod.Find<ModPrefix>("Sharp").Type,
mod.Find<ModPrefix>("Glorious").Type,
mod.Find<ModPrefix>("Feathered").Type,
mod.Find<ModPrefix>("Sleek").Type,
mod.Find<ModPrefix>("Hefty").Type,
mod.Find<ModPrefix>("Mighty").Type,
mod.Find<ModPrefix>("Serrated").Type,
mod.Find<ModPrefix>("Vicious").Type,
mod.Find<ModPrefix>("Lethal").Type,
mod.Find<ModPrefix>("Flawless").Type,
mod.Find<ModPrefix>("Blunt").Type,
mod.Find<ModPrefix>("Flimsy").Type,
mod.Find<ModPrefix>("Unbalanced").Type,
mod.Find<ModPrefix>("Atrocious").Type
});
return roguePrefix;
}
public static bool NegativeRoguePrefix(int prefix)
{
Mod mod = ModContent.GetInstance<CalamityMod>();
List<int> badPrefixes = new List<int>()
{
mod.Find<ModPrefix>("Blunt").Type,
mod.Find<ModPrefix>("Flimsy").Type,
mod.Find<ModPrefix>("Unbalanced").Type,
mod.Find<ModPrefix>("Atrocious").Type
};
return badPrefixes.Contains(prefix);
}
#endregion
}
}
-1
View File
@@ -685,7 +685,6 @@ namespace CalamityMod
{
velocityMult = 1f;
}
Mod mod = ModContent.GetInstance<CalamityMod>();
int type = Main.rand.Next(61, 64);
int smoke = Gore.NewGore(projectile.GetSource_Death(), source, default, type, 1f);
Gore gore = Main.gore[smoke];