From 78018d1876bd57cd286e1d202e7211cd0ea5e98c Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Fri, 22 Oct 2021 05:46:57 -0500 Subject: [PATCH] 1 - Nerfed Magic Power to 10% damage. 2 - Nerfed Magic Hat to 5% damage and crit. 3 - Nerfed Wizard Hat to 5% damage. 4 - Mana Regen and Mana Regen Delay IL Edits. --- Buffs/CalamityGlobalBuff.cs | 12 +++++- ILEditing/ILChanges.cs | 65 +++++++++++++++++++++++++++--- Items/CalamityGlobalItem.cs | 11 ++++- Items/CalamityGlobalItemTooltip.cs | 13 ++++++ 4 files changed, 92 insertions(+), 9 deletions(-) diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 2a9e74d96e..14a6ba60c0 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -11,7 +11,11 @@ namespace CalamityMod.Buffs { public override void Update(int type, Player player, ref int buffIndex) { - if (type == BuffID.Panic) + if (type == BuffID.MagicPower) + { + player.magicDamage -= 0.1f; + } + else if (type == BuffID.Panic) { player.moveSpeed -= 0.5f; } @@ -85,9 +89,13 @@ namespace CalamityMod.Buffs { Player player = Main.player[Main.myPlayer]; - //Vanilla buffs + // Vanilla buffs switch (type) { + case BuffID.MagicPower: + tip = "10% increased magic damage"; + break; + case BuffID.Archery: tip = "20% increased arrow speed and 1.05x arrow damage"; break; diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index 50c61bd87a..bacbae6458 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -147,6 +147,10 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.Update += RunSpeedAdjustments; IL.Terraria.Player.Update += ReduceWingHoverVelocities; + // Mana regen balance + IL.Terraria.Player.Update += ManaRegenDelayAdjustment; + IL.Terraria.Player.UpdateManaRegen += ManaRegenAdjustment; + // World generation IL.Terraria.WorldGen.Pyramid += ReplacePharaohSetInPyramids; IL.Terraria.WorldGen.MakeDungeon += PreventDungeonHorizontalCollisions; @@ -205,8 +209,12 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.Update -= RunSpeedAdjustments; IL.Terraria.Player.Update -= ReduceWingHoverVelocities; - // World generation - IL.Terraria.WorldGen.Pyramid -= ReplacePharaohSetInPyramids; + // Mana regen balance + IL.Terraria.Player.Update -= ManaRegenDelayAdjustment; + IL.Terraria.Player.UpdateManaRegen -= ManaRegenAdjustment; + + // World generation + IL.Terraria.WorldGen.Pyramid -= ReplacePharaohSetInPyramids; IL.Terraria.WorldGen.MakeDungeon -= PreventDungeonHorizontalCollisions; IL.Terraria.WorldGen.DungeonHalls -= PreventDungeonHallCollisions; IL.Terraria.WorldGen.GrowLivingTree -= BlockLivingTreesNearOcean; @@ -882,12 +890,57 @@ namespace CalamityMod.ILEditing cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. } - #endregion + #endregion - #region World generation + #region Mana regen balance + private static void ManaRegenDelayAdjustment(ILContext il) + { + // Decrease the max mana regen delay so that mage is less annoying to play without mana regen buffs. + // Decreases the max mana regen delay from a range of 31.5 - 199.5 to 4 - 52. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(45f))) // The flat amount added to max regen delay in the formula. + { + LogFailure("Max Mana Regen Delay Reduction", "Could not locate the max mana regen flat variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 20f); // Decrease to 20f. - // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. - private static void ReplacePharaohSetInPyramids(ILContext il) + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.7f))) // The multiplier for max mana regen delay. + { + LogFailure("Max Mana Regen Delay Reduction", "Could not locate the max mana regen delay multiplier variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.2f); // Decrease to 0.2f. + } + + private static void ManaRegenAdjustment(ILContext il) + { + // Increase the base mana regen so that mage is less annoying to play without mana regen buffs. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.8f))) // The multiplier for the mana regen formula: (float)statMana / (float)statManaMax2 * 0.8f + 0.2f. + { + LogFailure("Mana Regen Buff", "Could not locate the mana regen multiplier variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.25f); // Decrease to 0.25f. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.2f))) // The flat added mana regen amount. + { + LogFailure("Mana Regen Buff", "Could not locate the flat mana regen variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.75f); // Increase to 0.75f. + } + #endregion + + #region World generation + + // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. + private static void ReplacePharaohSetInPyramids(ILContext il) { var cursor = new ILCursor(il); diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index a99b35e506..932c98f36f 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1007,7 +1007,7 @@ namespace CalamityMod.Items } #endregion - #region SavingAndLoading + #region Saving And Loading public override bool NeedsSaving(Item item) { return rogue || canFirePointBlankShots || trueMelee || timesUsed != 0 || customRarity != 0 || Charge != 0 || reforgeTier != 0 || AppliedEnchantment.HasValue || DischargeEnchantExhaustion != 0; @@ -1665,6 +1665,15 @@ namespace CalamityMod.Items { switch (item.type) { + case ItemID.MagicHat: + player.magicDamage -= 0.02f; + player.magicCrit -= 2; + break; + + case ItemID.WizardHat: + player.magicDamage -= 0.1f; + break; + case ItemID.GladiatorHelmet: case ItemID.ObsidianHelm: player.Calamity().throwingDamage += 0.03f; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 4180d8fb13..3a1f749b46 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -493,6 +493,19 @@ namespace CalamityMod.Items // Rebalances to vanilla item stats #region Vanilla Item Rebalance Tooltips + // Magic Power Potion nerf + if (item.type == ItemID.MagicPowerPotion) + EditTooltipByNum(0, (line) => line.text = "10% increased magic damage"); + + // Magic and Wizard Hat nerfs + // Magic Hat + if (item.type == ItemID.MagicHat) + EditTooltipByNum(0, (line) => line.text = "5% increased magic damage and critical strike chance"); + + // Wizard Hat + if (item.type == ItemID.WizardHat) + EditTooltipByNum(0, (line) => line.text = "5% increased magic damage"); + // Reduce DD2 armor piece bonuses because they're overpowered // Squire armor if (item.type == ItemID.SquirePlating)