diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 6727261828..c58d00d018 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -16,6 +16,7 @@ using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; using CalamityMod.NPCs.Abyss; @@ -232,6 +233,7 @@ namespace CalamityMod.CalPlayer public bool stealthStrikeHalfCost = false; public bool stealthStrikeAlwaysCrits = false; public bool wearingRogueArmor = false; + public float accStealthGenBoost = 0f; public float throwingDamage = 1f; public float throwingVelocity = 1f; @@ -1284,6 +1286,7 @@ namespace CalamityMod.CalPlayer throwingAmmoCost75 = false; throwingAmmoCost66 = false; throwingAmmoCost50 = false; + accStealthGenBoost = 0f; dashMod = 0; externalAbyssLight = 0; @@ -4001,11 +4004,6 @@ namespace CalamityMod.CalPlayer { add += 0.05f; } - //Boost (or lower) the weapon's damage if it has a stealth strike available and an associated prefix - if (item.Calamity().rogue && player.Calamity().StealthStrikeAvailable() && item.prefix > 0) - { - mult += item.Calamity().StealthStrikeDamage - 1f; - } if (item.ranged) { @@ -9825,6 +9823,10 @@ namespace CalamityMod.CalPlayer if (etherealExtorter && Main.moonPhase == 3) // 3 = Waning Crescent stealthGenStandstill += 0.15f; + //Accessory modifiers can boost these stats + stealthGenStandstill += accStealthGenBoost; + stealthGenMoving += accStealthGenBoost; + // // Other code which affects stealth generation goes here. // Increase stealthGenStandstill (default 1.0) to give a % boost to stealth gen while standing still. diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index b63a22c7ed..9e3931424b 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -56,57 +56,32 @@ namespace CalamityMod.Items } #endregion - public bool rogue = false; - public float StealthStrikeDamage; + public bool rogue = false; + public float StealthGenBonus; - public int timesUsed = 0; + public int timesUsed = 0; - // Rarity is provided both as the classic int and the new enum. - public CalamityRarity customRarity = CalamityRarity.NoEffect; - public int postMoonLordRarity - { - get => (int)customRarity; - set => customRarity = (CalamityRarity)value; - } + // Rarity is provided both as the classic int and the new enum. + public CalamityRarity customRarity = CalamityRarity.NoEffect; + public int postMoonLordRarity + { + get => (int)customRarity; + set => customRarity = (CalamityRarity)value; + } + ///See RogueWeapon.cs for rogue modifier shit #region Modifiers public CalamityGlobalItem() { - StealthStrikeDamage = 1.0f; + StealthGenBonus = 1f; } public override GlobalItem Clone(Item item, Item itemClone) { CalamityGlobalItem myClone = (CalamityGlobalItem)base.Clone(item, itemClone); - myClone.StealthStrikeDamage = StealthStrikeDamage; + myClone.StealthGenBonus = StealthGenBonus; return myClone; } - - public override int ChoosePrefix(Item item, UnifiedRandom rand) - { - if (rogue) - { - WeightedRandom newPrefix = new WeightedRandom(); - newPrefix.Add("Pointy", 1); - newPrefix.Add("Sharp", 1); - newPrefix.Add("Feathered", 1); - newPrefix.Add("Sleek", 1); - newPrefix.Add("Hefty", 1); - newPrefix.Add("Mighty", 1); - newPrefix.Add("Glorious", 1); - newPrefix.Add("Serrated", 1); - newPrefix.Add("Vicious", 1); - newPrefix.Add("Lethal", 1); - newPrefix.Add("Flawless", 1); - newPrefix.Add("Radical", 1); - newPrefix.Add("Blunt", 1); - newPrefix.Add("Flimsy", 1); - newPrefix.Add("Unbalanced", 1); - newPrefix.Add("Atrocious", 1); - return mod.GetPrefix(newPrefix).Type; - } - return -1; - } #endregion #region SetDefaults @@ -1131,28 +1106,19 @@ namespace CalamityMod.Items } #endregion - #region Rogue Modifier Display - if (rogue) + #region Accessory Modifier Display + if (item.accessory) { - if (item.prefix > 0) + if (!item.social && item.prefix > 0) { - float ssDmgBoost = item.Calamity().StealthStrikeDamage - 1f; - if (ssDmgBoost > 0) + float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; + if (stealthGenBoost > 0) { - TooltipLine StealthBonus = new TooltipLine(mod, "PrefixSSDmg", "+" + Math.Round(ssDmgBoost * 100f) + "% stealth strike damage") + TooltipLine StealthGen = new TooltipLine(mod, "PrefixStealthGenBoost", "+" + Math.Round(stealthGenBoost * 100f) + "% stealth generation") { isModifier = true }; - tooltips.Add(StealthBonus); - } - else if (ssDmgBoost < 0) - { - TooltipLine StealthBonus = new TooltipLine(mod, "PrefixSSDmg", "-" + Math.Round(Math.Abs(ssDmgBoost) * 100f) + "% stealth strike damage") - { - isModifier = true, - isModifierBad = true - }; - tooltips.Add(StealthBonus); + tooltips.Add(StealthGen); } } } @@ -3026,6 +2992,15 @@ Provides heat and cold protection in Death Mode"; { CalamityPlayer modPlayer = player.Calamity(); + if (item.prefix > 0) + { + float stealthGenBoost = item.Calamity().StealthGenBonus - 1f; + if (stealthGenBoost > 0) + { + modPlayer.accStealthGenBoost += stealthGenBoost; + } + } + if (item.type == ItemID.FireGauntlet) { player.meleeDamage += 0.04f; diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index ba11775685..286aefb989 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -1,7 +1,13 @@ +using CalamityMod.Items; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using Terraria; +using Terraria.DataStructures; using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using Terraria.Utilities; namespace CalamityMod.Items.Weapons.Rogue { public abstract class RogueWeapon : ModItem @@ -10,6 +16,42 @@ namespace CalamityMod.Items.Weapons.Rogue { } + public float StealthStrikeDamage; + + public RogueWeapon() + { + StealthStrikeDamage = 1f; + } + + public override ModItem Clone(Item itemClone) + { + RogueWeapon myClone = (RogueWeapon)base.Clone(itemClone); + myClone.StealthStrikeDamage = StealthStrikeDamage; + return myClone; + } + + public override int ChoosePrefix(UnifiedRandom rand) + { + WeightedRandom newPrefix = new WeightedRandom(); + newPrefix.Add("Pointy", 1); + newPrefix.Add("Sharp", 1); + newPrefix.Add("Feathered", 1); + newPrefix.Add("Sleek", 1); + newPrefix.Add("Hefty", 1); + newPrefix.Add("Mighty", 1); + newPrefix.Add("Glorious", 1); + newPrefix.Add("Serrated", 1); + newPrefix.Add("Vicious", 1); + newPrefix.Add("Lethal", 1); + newPrefix.Add("Flawless", 1); + newPrefix.Add("Radical", 1); + newPrefix.Add("Blunt", 1); + newPrefix.Add("Flimsy", 1); + newPrefix.Add("Unbalanced", 1); + newPrefix.Add("Atrocious", 1); + return mod.GetPrefix(newPrefix).Type; + } + public sealed override void SetDefaults() { SafeSetDefaults(); @@ -26,6 +68,11 @@ namespace CalamityMod.Items.Weapons.Rogue public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { add += player.Calamity().throwingDamage - 1f; + //Boost (or lower) the weapon's damage if it has a stealth strike available and an associated prefix + if (player.Calamity().StealthStrikeAvailable() && item.prefix > 0) + { + mult += StealthStrikeDamage - 1f; + } } // Simply add the player's dedicated rogue crit chance. @@ -55,6 +102,27 @@ namespace CalamityMod.Items.Weapons.Rogue string damageWord = splitText.Last(); tt.text = damageValue + " rogue " + damageWord; } + if (item.prefix > 0) + { + float ssDmgBoost = StealthStrikeDamage - 1f; + if (ssDmgBoost > 0) + { + TooltipLine StealthBonus = new TooltipLine(mod, "PrefixSSDmg", "+" + Math.Round(ssDmgBoost * 100f) + "% stealth strike damage") + { + isModifier = true + }; + tooltips.Add(StealthBonus); + } + else if (ssDmgBoost < 0) + { + TooltipLine StealthBonus = new TooltipLine(mod, "PrefixSSDmg", "-" + Math.Round(Math.Abs(ssDmgBoost) * 100f) + "% stealth strike damage") + { + isModifier = true, + isModifierBad = true + }; + tooltips.Add(StealthBonus); + } + } } public override bool ConsumeItem(Player player) diff --git a/Prefixes/AccessoryPrefix.cs b/Prefixes/AccessoryPrefix.cs new file mode 100644 index 0000000000..e71da80f2f --- /dev/null +++ b/Prefixes/AccessoryPrefix.cs @@ -0,0 +1,80 @@ +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes +{ + public class AccessoryPrefix : ModPrefix + { + //Thank you Thomas for helping me set this up =D + internal static List AccessoryModifiers; + internal float stealthGenBonus = 1f; + + public override PrefixCategory Category => PrefixCategory.Accessory; + + public AccessoryPrefix() + { + + } + + public AccessoryPrefix(float stealthGenBonus = 1f) + { + this.stealthGenBonus = stealthGenBonus; + } + + public override bool Autoload(ref string name) + { + if (base.Autoload(ref name)) + { + //Damage, Use Time, Crit, Velocity, SS Dmg + AccessoryModifiers = new List(); + AddAccessoryPrefix(mod, AccPrefixType.Quiet, 1.02f); + AddAccessoryPrefix(mod, AccPrefixType.Cloaked, 1.04f); + AddAccessoryPrefix(mod, AccPrefixType.Camouflaged, 1.06f); + AddAccessoryPrefix(mod, AccPrefixType.Silent, 1.08f); + } + return false; + } + + public override void Apply(Item item) + { + item.Calamity().StealthGenBonus = stealthGenBonus; + } + + public override void ModifyValue(ref float valueMult) + { + float extraValue = 1f + (2.56f * (stealthGenBonus - 1f)); + valueMult *= extraValue; + } + + public override float RollChance(Item item) + { + if (item.vanity) + return 0f; + if (item.type == ItemID.GuideVoodooDoll || item.type == ItemID.MusicBox || item.type == ItemID.ClothierVoodooDoll) + return 0f; + if (item.type >= ItemID.MusicBoxOverworldDay && item.type <= ItemID.MusicBoxBoss3) + return 0f; + if (item.type >= ItemID.MusicBoxSnow && item.type <= ItemID.MusicBoxMushrooms) + return 0f; + + return 1f; + } + + private static void AddAccessoryPrefix(Mod mod, AccPrefixType prefixType, float stealthGenBonus = 1f) + { + string name = prefixType.ToString(); + mod.AddPrefix(name, new AccessoryPrefix(stealthGenBonus)); + AccessoryModifiers.Add(mod.GetPrefix(name).Type); + } + } + + public enum AccPrefixType : byte + { + Quiet, + Cloaked, + Camouflaged, + Silent + } +} \ No newline at end of file diff --git a/Prefixes/RoguePrefix.cs b/Prefixes/RoguePrefix.cs index cbf4652124..10f6d1d015 100644 --- a/Prefixes/RoguePrefix.cs +++ b/Prefixes/RoguePrefix.cs @@ -1,3 +1,5 @@ +using CalamityMod.Items.Weapons.Rogue; +using System; using System.Collections.Generic; using Terraria; using Terraria.ID; @@ -59,16 +61,20 @@ namespace CalamityMod.Prefixes public override void Apply(Item item) { - item.Calamity().StealthStrikeDamage = stealthDmgMult; + ModItem moddedItem = item.modItem; + if(moddedItem != null && moddedItem is RogueWeapon rogueWep) + { + rogueWep.StealthStrikeDamage = stealthDmgMult; + } } public override void ModifyValue(ref float valueMult) { - float extraValue = 1f + (0.333f * (stealthDmgMult - 1f)); + float extraValue = 1f + (2f * (stealthDmgMult - 1f)); valueMult *= extraValue; } - public override bool CanRoll(Item item) => item.Calamity().rogue; + public override bool CanRoll(Item item) => item.Calamity().rogue && !item.consumable; 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) { @@ -84,6 +90,14 @@ namespace CalamityMod.Prefixes mod.AddPrefix(name, new RoguePrefix(damageMult, useTimeMult, critBonus, shootSpeedMult, stealthDmgMult)); RogueModifiers.Add(mod.GetPrefix(name).Type); } + + public override void ValidateItem(Item item, ref bool invalid) + { + if (item.damage == Math.Round(item.damage * damageMult)) + invalid = true; + if (item.useAnimation == Math.Round(item.useAnimation * useTimeMult)) + invalid = true; + } } public enum RoguePrefixType : byte