Separate StealthStrikePrefixBonus from CalamityGlobalItem

This commit is contained in:
Flowaria authored and Cameron Ewell committed 2025-12-17 16:43:56 -05:00
1 parent 5e2618a6df
commit d0167ffe4e
4 files changed
+39 -24

No files matched your search

+3 -3
View File
@@ -4861,13 +4861,13 @@ namespace CalamityMod.CalPlayer
#region Get Weapon Damage And KB
public override void ModifyWeaponDamage(Item item, ref StatModifier damage)
{
if (item.CountsAsClass<RogueDamageClass>())
if (item.CountsAsClass<RogueDamageClass>() && item.TryGetGlobalItem<RogueGlobalItem>(out var rogueItem))
{
// Apply weapon modifier stealth strike damage bonus
// 01OCT2023: Ozzatron: This is a multiplicative bonus because it is a prefix.
// It should be equivalent to x1.15 (or whatever multiplier) on the base damage of the weapon for stealth only.
if (item.Calamity().StealthStrikePrefixBonus != 0f && StealthStrikeAvailable())
damage *= item.Calamity().StealthStrikePrefixBonus; // This number centers on 1f, so 1.15f = 1.15x damage.
if (rogueItem.StealthStrikePrefixBonus != 0f && StealthStrikeAvailable())
damage *= rogueItem.StealthStrikePrefixBonus; // This number centers on 1f, so 1.15f = 1.15x damage.
}
}
-19
View File
@@ -52,10 +52,6 @@ namespace CalamityMod.Items
{
public override bool InstancePerEntity => true;
// TODO -- split out a separate GlobalItem for rogue behavior?
/// <summary> Tracks the stealth strike damage modifier for this item, derived from its prefix. </summary>
internal float StealthStrikePrefixBonus;
private BitsByte flag0 = 0;
#region Chargeable Item Variables
@@ -150,11 +146,6 @@ namespace CalamityMod.Items
public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64);
public CalamityGlobalItem()
{
StealthStrikePrefixBonus = 0f;
}
// Ozzatron 21MAY2022: This function is required by TML 1.4's new clone behavior.
// This behavior is sadly mandatory because there are a few places in vanilla Terraria which use cloning.
// Most notably: reforging and item tooltips.
@@ -169,9 +160,6 @@ namespace CalamityMod.Items
// BitFlags
myClone.flag0 = flag0;
// Rogue
myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus;
// Charge (Draedon's Arsenal)
myClone.UsesCharge = UsesCharge;
myClone.Charge = Charge;
@@ -1684,13 +1672,6 @@ namespace CalamityMod.Items
public static int RarityCalamityRedBuyPrice => Rarity17BuyPrice;
#endregion
#region PreReforge
public override void PreReforge(Item item)
{
StealthStrikePrefixBonus = 0f;
}
#endregion
//
// !! WARNING !!
//
+33
View File
@@ -0,0 +1,33 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Items
{
public sealed class RogueGlobalItem : GlobalItem
{
public override bool InstancePerEntity => true;
/// <summary> Tracks the stealth strike damage modifier for this item, derived from its prefix. </summary>
internal float StealthStrikePrefixBonus = 0.0f;
public override GlobalItem Clone(Item from, Item to)
{
RogueGlobalItem myClone = (RogueGlobalItem)base.Clone(from, to);
// Rogue
myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus;
return myClone;
}
public override bool AppliesToEntity(Item entity, bool lateInstantiation)
{
return entity.CountsAsClass<RogueDamageClass>();
}
public override void PreReforge(Item item)
{
StealthStrikePrefixBonus = 0f;
}
}
}
+3 -2
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using CalamityMod.Items;
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;
@@ -153,8 +154,8 @@ namespace CalamityMod.Prefixes
// Applying stealth strike damage
public override void Apply(Item item)
{
if (item.CountsAsClass<RogueDamageClass>())
item.Calamity().StealthStrikePrefixBonus = stealthDmgMult;
if (item.CountsAsClass<RogueDamageClass>() && item.TryGetGlobalItem<RogueGlobalItem>(out var rogueItem))
rogueItem.StealthStrikePrefixBonus = stealthDmgMult;
}
// Changing value based on prefix tier (rarity is set automatically around value multiplier)