diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 453c8d97a6..ebdce6c769 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -92,7 +92,7 @@ internal static readonly float MovingStealthGenRatio = 0.5f; #endregion - #region Defense and Health + #region Defense, Health and Mana (Armor set stuff) // Beetle Shell's multiplicative DR is removed by Calamity. In compensation, you get this much regular DR per beetle. internal static readonly float BeetleShellDRPerBeetle = 0.1f; @@ -101,6 +101,18 @@ // Nebula Armor Life Regen internal static readonly int NebulaLifeRegenPerBooster = 4; // 6 in vanilla + + // Nebula Armor Mana Regen + // This value works differently than you might expect. Raising it actually nerfs the mana regeneration of Nebula Armor + // Every frame, Terraria adds 1 to a counter for each Mana Booster the player has. + // If this counter reaches the below threshold, that player gains 1 mana. + // By default, it's 6, which has the following effects: + // 1 booster = +1 mana every 6 frames = +10 mana per second + // 2 boosters = +1 mana every 3 frames = +20 mana per second + // 3 boosters = +1 mana every 2 frames = +30 mana per second + // + // Calamity just halves this, that's probably good enough. + internal static readonly int NebulaManaRegenFrameCounterThreshold = 12; // 6 in vanilla #endregion #region Defense Damage diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 6b8ee28786..2582d40c30 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -509,6 +509,24 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Pop); cursor.Emit(OpCodes.Ldc_I4_0); } + + private static void NerfNebulaArmorManaRegen(ILContext il) + { + // Reduce Nebula armor mana regen. + // The regen is controlled by a frame counter threshold right at the top of the function, typically 6. + // 1 value is added to the counter for every Mana Booster you have. + // If the value reaches the threshold, you gain 1 mana. + // All that needs to be done is raising the threshold, so it takes more frames to get each point of mana. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcI4(6))) + { + LogFailure("Nebula Armor Mana Regen Nerf", "Could not locate the Nebula Armor mana regeneration frame counter threshold."); + return; + } + + // Swap the threshold with Calamity's value. + cursor.Next.Operand = BalancingConstants.NebulaManaRegenFrameCounterThreshold; + } #endregion #region Remove Melee Armor (Beetle Shell + Solar Flare) Multiplicative DR diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 5f32c45ebc..cf53fdf790 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -114,6 +114,7 @@ namespace CalamityMod.ILEditing // Mana regen balance IL_Player.Update += ManaRegenDelayAdjustment; IL_Player.UpdateManaRegen += ManaRegenAdjustment; + IL_Player.UpdateManaRegen += NerfNebulaArmorManaRegen; // Debuff balancing IL_Projectile.StatusPlayer += RemoveFrozenInflictionFromDeerclopsIceSpikes;