From bdc2ae5253fc8443a8718a921ad962d4d6beaead Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 29 Oct 2025 17:16:54 -0500 Subject: [PATCH 1/5] Reworked dodges - Dodge effects all apply at once when dodging - Stacking dodges reduces dodge cooldown - Dodge order changed --- CalPlayer/CalamityPlayer.cs | 32 +++- CalPlayer/CalamityPlayerHitHurt.cs | 165 +++++------------- Items/Accessories/AbyssalMirror.cs | 34 +++- Items/Accessories/EclipseMirror.cs | 31 +++- Items/CalamityGlobalItemTooltip.cs | 11 +- .../en-US/Mods.CalamityMod.Common.hjson | 7 +- .../Mods.CalamityMod.Items.Accessories.hjson | 33 ++-- .../en-US/Mods.CalamityMod.Vanilla.hjson | 6 +- 8 files changed, 165 insertions(+), 154 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 847de0e75b..7259de2127 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1092,6 +1092,22 @@ namespace CalamityMod.CalPlayer /// Used for spawning Quiver of Nihility's void fields. public bool voidField = false; public bool copyrightInfringementShield = false; + + /// + /// This is the maximum cooldown of general Dodge effects, in frames. Can be modified by equipment. + /// Defaults to 90 seconds, or 5400 frames. + /// + public int ConsumableDodgeCooldown = 0; + /// + /// A list of on dodge effects for every dodge the player has equipped. + /// Also used to determine the amount of dodges for cooldowns. + /// Returns the string for the dodge cooldown icon to use. + /// + public List> DodgeEffects = []; + /// + /// Used internally to disable Player.shadowDodge so we can use custom dodge ordering. + /// + bool storedShadowDodge = false; #endregion #region Armor Set @@ -2354,7 +2370,10 @@ namespace CalamityMod.CalPlayer voidField = false; copyrightInfringementShield = false; - daedalusReflect = false; + ConsumableDodgeCooldown = BalancingConstants.BeltDodgeCooldownMax; + DodgeEffects = []; + + daedalusReflect = false; daedalusSplit = false; daedalusAbsorb = false; daedalusShard = false; @@ -4174,6 +4193,17 @@ namespace CalamityMod.CalPlayer if (Player.accRunSpeed < accRunSpeedMin) Player.accRunSpeed = accRunSpeedMin; + if (Player.blackBelt) + DodgeEffects.Add((Player, hit) => { + Player.NinjaDodge(); + return null; + }); + if (Player.brainOfConfusionItem != null && !Player.brainOfConfusionItem.IsAir) + DodgeEffects.Add((Player, hit) => { + Player.BrainOfConfusionDodge(); + return null; + }); + if (Player.Transformation().Type == ItemType()) { if (Player.whoAmI == Main.myPlayer && !snowmanNoseless) diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 40d4b27f70..e40fa676e0 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -145,86 +145,7 @@ namespace CalamityMod.CalPlayer NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } - public void AbyssMirrorDodge(double dodgeDamageGateValuePercent, int dodgeDamageGateValue, int hitDamage) - { - double maxCooldownDurationDamagePercent = 0.5; - int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); - - // Just in case... - if (maxCooldownDurationDamageValue <= 0) - maxCooldownDurationDamageValue = 1; - - float cooldownDurationScalar = MathHelper.Clamp((hitDamage - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); - - if (Player.whoAmI == Main.myPlayer && abyssalMirror && !eclipseMirror) - { - int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.MirrorDodgeCooldownMin, BalancingConstants.MirrorDodgeCooldownMax, cooldownDurationScalar); - Player.AddCooldown(GlobalDodge.ID, cooldownDuration, true, "abyssmirror"); - - // 17APR2024: Ozzatron: Abyssal Mirror is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. - int abyssalMirrorDodgeIFrames = Player.ComputeDodgeIFrames(); - Player.GiveUniversalIFrames(abyssalMirrorDodgeIFrames, true); - - rogueStealth += 0.5f; - SoundEngine.PlaySound(SilvaArmor.ActivationSound, Player.Center); - - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - for (int i = 0; i < 10; i++) - { - int damage = (int)Player.GetTotalDamage().ApplyTo(55); - - int lumenyl = Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), ModContent.ProjectileType(), damage, 0, Player.whoAmI); - Main.projectile[lumenyl].rotation = Main.rand.NextFloat(0, 360); - Main.projectile[lumenyl].frame = Main.rand.Next(0, 4); - if (lumenyl.WithinBounds(Main.maxProjectiles)) - Main.projectile[lumenyl].DamageType = DamageClass.Generic; - } - - // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust - if (Player.whoAmI == Main.myPlayer) - { - NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); - } - } - } - - public void EclipseMirrorDodge(double dodgeDamageGateValuePercent, int dodgeDamageGateValue, int hitDamage) - { - double maxCooldownDurationDamagePercent = 0.5; - int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); - - // Just in case... - if (maxCooldownDurationDamageValue <= 0) - maxCooldownDurationDamageValue = 1; - - float cooldownDurationScalar = MathHelper.Clamp((hitDamage - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); - - if (Player.whoAmI == Main.myPlayer && eclipseMirror) - { - int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.MirrorDodgeCooldownMin, BalancingConstants.MirrorDodgeCooldownMax, cooldownDurationScalar); - Player.AddCooldown(GlobalDodge.ID, cooldownDuration, true, "eclipsemirror"); - - // 17APR2024: Ozzatron: Eclipse Mirror is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. - int eclipseMirrorDodgeIFrames = Player.ComputeDodgeIFrames(); - Player.GiveUniversalIFrames(eclipseMirrorDodgeIFrames, true); - - rogueStealth += 0.5f; - SoundEngine.PlaySound(SoundID.Item68, Player.Center); - - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - int damage = (int)Player.GetTotalDamage().ApplyTo(2000); - - int eclipse = Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Player.whoAmI); - if (eclipse.WithinBounds(Main.maxProjectiles)) - Main.projectile[eclipse].DamageType = DamageClass.Generic; - - // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust - if (Player.whoAmI == Main.myPlayer) - { - NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); - } - } - } + #endregion #region Pre Kill @@ -1600,12 +1521,37 @@ namespace CalamityMod.CalPlayer } } + //Here we store the Holy Protection bool so that we can have Holy Protection run in the right order among our dodges + storedShadowDodge = Player.shadowDodge; + Player.shadowDodge = false; + // If no other effects occurred, run vanilla code return base.FreeDodge(info); } public override bool ConsumableDodge(Player.HurtInfo info) { + //Dodge activation order is as follows: + // 2. Spectral Veil + // 3. Evasion/Counter Scarf + // 1. Hallowed Armor + // 4. General Dodge + + if (spectralVeil && spectralVeilImmunity > 0) + { + SpectralVeilDodge(); + return true; + } + + if (HandleDashDodges()) + return true; + // Hallowed Armor dodge + if (storedShadowDodge) + { + Player.ShadowDodge(); + storedShadowDodge = false; + return true; + } // Vanilla dodges are gated behind the global dodge cooldown // The dodges will only trigger if the player has taken greater than or equal to 5% of their max HP in damage double dodgeDamageGateValuePercent = 0.05; @@ -1615,7 +1561,7 @@ namespace CalamityMod.CalPlayer int actualDamageTaken = chaliceOfTheBloodGod ? chaliceHitOriginalDamage : info.Damage; bool sufficientDamageForDodging = actualDamageTaken >= dodgeDamageGateValue; - if (!Player.HasCooldown(GlobalDodge.ID) && sufficientDamageForDodging) + if (!Player.HasCooldown(GlobalDodge.ID) && sufficientDamageForDodging && DodgeEffects.Count > 0) { double maxCooldownDurationDamagePercent = 0.5; int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); @@ -1625,26 +1571,26 @@ namespace CalamityMod.CalPlayer maxCooldownDurationDamageValue = 1; float cooldownDurationScalar = MathHelper.Clamp((actualDamageTaken - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); - - // Re-implementation of vanilla item Black Belt as a consumable dodge - if (Player.whoAmI == Main.myPlayer && Player.blackBelt) + //Every dodge after the first reduces the dodge cooldown by 15%, stacking multiplicatively + float cooldownMultiplier = 1; + if (DodgeEffects.Count > 1) + cooldownMultiplier = MathF.Pow(0.85f, DodgeEffects.Count - 1); + + string? IconToUse = null; + foreach (var dodge in DodgeEffects) { - Player.NinjaDodge(); - int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.BeltDodgeCooldownMin, BalancingConstants.BeltDodgeCooldownMax, cooldownDurationScalar); + string? str = dodge(Player, info); + if (str is not null) + IconToUse = str; + } + //This is set after DodgeEffects in case some dodge wants to modify ConsumableDodgeCooldown, and so custom dodge icons for mirror line work + int cooldownDuration = (int)MathHelper.Lerp(ConsumableDodgeCooldown * cooldownMultiplier * 0.2f, ConsumableDodgeCooldown * cooldownMultiplier, cooldownDurationScalar); + if (IconToUse is null) Player.AddCooldown(GlobalDodge.ID, cooldownDuration); - return true; - } + else + Player.AddCooldown(GlobalDodge.ID, cooldownDuration,true, IconToUse); - // Re-implementation of vanilla item Brain of Confusion as a consumable dodge - if (Player.whoAmI == Main.myPlayer && Player.brainOfConfusionItem != null && !Player.brainOfConfusionItem.IsAir) - { - Player.BrainOfConfusionDodge(); - int cooldownTime = amalgam ? - (int)MathHelper.Lerp(BalancingConstants.AmalgamDodgeCooldownMin, BalancingConstants.AmalgamDodgeCooldownMax, cooldownDurationScalar) : - (int)MathHelper.Lerp(BalancingConstants.BrainDodgeCooldownMin, BalancingConstants.BrainDodgeCooldownMax, cooldownDurationScalar); - Player.AddCooldown(GlobalDodge.ID, cooldownTime); - return true; - } + return true; } // @@ -1654,30 +1600,7 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI != Main.myPlayer || disableAllDodges) return false; - if (spectralVeil && spectralVeilImmunity > 0) - { - SpectralVeilDodge(); - return true; - } - // TODO -- drag all dodge code into a CalamityPlayer sub-file dedicated to dodging and nothing else - if (HandleDashDodges()) - return true; - - // Mirror evades do not work if the global dodge cooldown is active. This cooldown can be triggered by either mirror. - if (!Player.HasCooldown(GlobalDodge.ID) && actualDamageTaken >= dodgeDamageGateValue) - { - if (eclipseMirror) - { - EclipseMirrorDodge(dodgeDamageGateValuePercent, dodgeDamageGateValue, actualDamageTaken); - return true; - } - else if (abyssalMirror) - { - AbyssMirrorDodge(dodgeDamageGateValuePercent, dodgeDamageGateValue, actualDamageTaken); - return true; - } - } return base.ConsumableDodge(info); } diff --git a/Items/Accessories/AbyssalMirror.cs b/Items/Accessories/AbyssalMirror.cs index 40e9b7a0eb..2578405a55 100644 --- a/Items/Accessories/AbyssalMirror.cs +++ b/Items/Accessories/AbyssalMirror.cs @@ -1,7 +1,9 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.Armor.Silva; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; +using CalamityMod.Projectiles.Rogue; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -27,6 +29,36 @@ namespace CalamityMod.Items.Accessories modPlayer.stealthGenMoving += 0.12f; modPlayer.abyssalMirror = true; player.aggro -= 450; + modPlayer.DodgeEffects.Add(AbyssMirrorDodge); + } + + public string AbyssMirrorDodge(Player Player, Player.HurtInfo info) + { + // 17APR2024: Ozzatron: Abyssal Mirror is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int abyssalMirrorDodgeIFrames = Player.ComputeDodgeIFrames(); + Player.GiveUniversalIFrames(abyssalMirrorDodgeIFrames, true); + + Player.Calamity().rogueStealth += 0.5f; + SoundEngine.PlaySound(SilvaArmor.ActivationSound, Player.Center); + + var source = Player.GetSource_Accessory(Player.Calamity().FindAccessory(ModContent.ItemType())); + for (int i = 0; i < 10; i++) + { + int damage = (int)Player.GetTotalDamage().ApplyTo(55); + + int lumenyl = Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), ModContent.ProjectileType(), damage, 0, Player.whoAmI); + Main.projectile[lumenyl].rotation = Main.rand.NextFloat(0, 360); + Main.projectile[lumenyl].frame = Main.rand.Next(0, 4); + if (lumenyl.WithinBounds(Main.maxProjectiles)) + Main.projectile[lumenyl].DamageType = DamageClass.Generic; + } + + // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust + if (Player.whoAmI == Main.myPlayer) + { + NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); + } + return "abyssmirror"; } public override void AddRecipes() diff --git a/Items/Accessories/EclipseMirror.cs b/Items/Accessories/EclipseMirror.cs index ac0edf72ef..c9f19c4b3d 100644 --- a/Items/Accessories/EclipseMirror.cs +++ b/Items/Accessories/EclipseMirror.cs @@ -1,8 +1,13 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Balancing; +using CalamityMod.CalPlayer; +using CalamityMod.Cooldowns; using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -32,8 +37,32 @@ namespace CalamityMod.Items.Accessories player.GetCritChance() += 6; player.GetDamage() += 0.06f; player.aggro -= 700; + modPlayer.DodgeEffects.Add(EclipseMirrorDodge); } + public string EclipseMirrorDodge(Player Player, Player.HurtInfo info) + { + + // 17APR2024: Ozzatron: Eclipse Mirror is a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int eclipseMirrorDodgeIFrames = Player.ComputeDodgeIFrames(); + Player.GiveUniversalIFrames(eclipseMirrorDodgeIFrames, true); + + Player.Calamity().rogueStealth += 0.5f; + SoundEngine.PlaySound(SoundID.Item68, Player.Center); + + var source = Player.GetSource_Accessory(Player.Calamity().FindAccessory(ModContent.ItemType())); + int damage = (int)Player.GetTotalDamage().ApplyTo(2000); + + int eclipse = Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Player.whoAmI); + if (eclipse.WithinBounds(Main.maxProjectiles)) + Main.projectile[eclipse].DamageType = DamageClass.Generic; + + // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust + NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); + return "eclipsemirror"; + } + + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index fe2fc77e95..56a129a1ec 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -728,12 +728,15 @@ namespace CalamityMod.Items // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. #region Guaranteed Dodge Tooltips if (item.type == ItemID.BlackBelt) - EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BeltDodgeCooldownMin / 60, BalancingConstants.BeltDodgeCooldownMax / 60)); + EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetTextValue("Common.DodgeProvided") + "\n" + CalamityUtils.GetTextValue("Common.DodgeInformation")); if (item.type == ItemID.MasterNinjaGear) - EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BeltDodgeCooldownMin / 60, BalancingConstants.BeltDodgeCooldownMax / 60)); - + EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetTextValue("Common.DodgeProvided") + "\n" + CalamityUtils.GetTextValue("Common.DodgeInformation")); if (item.type == ItemID.BrainOfConfusion) - EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BrainDodgeCooldownMin / 60, BalancingConstants.BrainDodgeCooldownMax / 60)); + { + EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetTextValue("Common.DodgeProvided")); + + EditTooltipByNum(2, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.DodgeInformation")); + } #endregion // Whip tag is dynamically generated for all whips based on the SummonTagDebuffDict, so we'll remove the vanilla tag tootlips. diff --git a/Localization/en-US/Mods.CalamityMod.Common.hjson b/Localization/en-US/Mods.CalamityMod.Common.hjson index de36dce08e..7f55d57ca5 100644 --- a/Localization/en-US/Mods.CalamityMod.Common.hjson +++ b/Localization/en-US/Mods.CalamityMod.Common.hjson @@ -26,11 +26,12 @@ NotConsumable: Not consumable SummonTagDamageFlat: "{0} summon tag damage" SummonTagDamageMult: "{0}x summon tag damage" SummonTagCrit: "{0}% summon tag critical strike chance" +DodgeProvided: Grants or improves the ability to dodge attacks DodgeInformation: ''' - Attacks that deal less than 5% of your max life in damage will not be dodged - The dodge has a cooldown that ranges between 20 and 90 seconds depending on the dodged attack's damage - This cooldown is shared with all other dodges and reflects + [i/Terraria:BlackBelt] Attacks that deal less than 5% of your max life in damage will not be dodged + [i/Terraria:BlackBelt] This dodge has a maximum cooldown of 90 seconds, shortened depending on the dodged attack's damage + [i/Terraria:BlackBelt] Equipping multiple accessories that give this ability to dodge will reduce the cooldown by 15% each ''' ReflectInformation: ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 60b3c0f0b4..4937a96bfa 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -43,13 +43,10 @@ AbyssalMirror: { ''' Enemies are less likely to target you, even in the abyss Generate stealth 25% faster when standing still and 12% faster while moving - Grants the ability to dodge attacks, releasing a cloud of lumenyl fluid which damages and stuns nearby enemies - ''' - HoldShiftTooltip: - ''' - {$Common.DodgeInformation} - Dodging an attack gives stealth + {$Common.DodgeProvided} + Dodging an attack restores stealth and releases a cloud that damages and stuns nearby enemies ''' + HoldShiftTooltip: "{$Common.DodgeInformation}" FlavorTooltip: "'Light does not reach the depths of the ocean'" } @@ -94,7 +91,7 @@ AmalgamatedBrain: { 5% increased damage Taking damage confuses nearby enemies and spawns a dank creeper The dank creeper flies above you, exploding into several shaderain clouds - Grants the ability to dodge attacks + {$Common.DodgeProvided} After dodging, summon damage and crit chance are boosted by 10% ''' HoldShiftTooltip: "{$Common.DodgeInformation}" @@ -668,13 +665,10 @@ EclipseMirror: { Enemies are less likely to target you, even in the abyss Stealth generates 25% faster when standing still and is boosted while moving if not attacking Stealth strikes only expend 50% of your max stealth - Grants the ability to dodge attacks in a blast of darksun light, which inflicts extreme damage in a wide area - ''' - HoldShiftTooltip: - ''' - {$Common.DodgeInformation} - Dodging an attack grants a lot of stealth + {$Common.DodgeProvided} + Dodging an attack restores stealth and releases a burst of highly damaging darksun light ''' + HoldShiftTooltip: "{$Common.DodgeInformation}" FlavorTooltip: "'Its reflection shows naught but darkness'" } @@ -1732,9 +1726,10 @@ StatisNinjaBelt: { Tooltip: ''' Provides a high-speed dash - 10% increased movement speed, 32% increased jump speed, allows auto-jump, and negates fall damage + 10% increased movement speed, 32% increased jump speed and negates fall damage Increases movement acceleration and deceleration by 1.6x - Grants the ability to swim[TOGGLE] and dodge attacks + Allows the user to swim[TOGGLE] and auto jump + {$Common.DodgeProvided} [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:ClimbingClaws] [c/aaaaaa:Climbing Claws] ''' ToggleEffect: ", climb walls," @@ -1746,10 +1741,10 @@ StatisVoidSash: { Tooltip: ''' Provides a high-speed dash - 20% increased movement speed, 32% increased jump speed, allows auto-jump, and negates fall damage + 20% increased movement speed, 32% increased jump speed, and negates fall damage Increases movement acceleration and deceleration by 1.85x - Grants the ability to swim[TOGGLE] and dodge attacks - Visual effects are reduced if visibility is disabled + Allows the user to swim[TOGGLE] and auto-jump + {$Common.DodgeProvided} [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:ClimbingClaws] [c/aaaaaa:Climbing Claws] ''' ToggleEffect: ", climb walls," @@ -1880,7 +1875,7 @@ TheAmalgam: { Most buffs last twice as long, and persist after dying Taking damage confuses nearby enemies and spawns a dank creeper The dank creeper flies above you, exploding into several shaderain clouds - Grants the ability to dodge attacks + {$Common.DodgeProvided} After dodging, summon damage and crit chance are boosted by 10% 'You have no idea how it's staying together' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index 0a9ec85a57..05f378a5bf 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -1,10 +1,8 @@ DashKey: Press {0} while facing a direction DodgeInfo: ''' - Grants the ability to dodge attacks - Attacks that deal less than 5% of your max life in damage will not be dodged - The dodge has a cooldown that ranges between {0} and {1} seconds depending on the dodged attack's damage - The cooldown is shared with all other dodges and reflects + {$Common.DodgeProvided} + {$Common.DodgeInformation} ''' AddedTooltip: { From ec9fedb27cdd1abd31d923b11d66fe73f1eb8775 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Sun, 8 Feb 2026 21:25:55 -0600 Subject: [PATCH 2/5] Cleaned up Balancing Constants for dodges, Evolution now supported --- Balancing/BalancingConstants.cs | 24 +++---- CalPlayer/CalamityPlayer.cs | 3 +- CalPlayer/CalamityPlayerHitHurt.cs | 100 +++++++++++++++-------------- 3 files changed, 67 insertions(+), 60 deletions(-) diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index ec3d67b330..e8d05be133 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -62,18 +62,18 @@ internal const int SolarFlareIFrames = 12; internal const float SolarFlareBaseDamage = 400f; - // Dodge cooldowns (in frames) - // TODO -- Some of these could be moved to the respective item files - internal static readonly int BeltDodgeCooldownMin = 1200; - internal static readonly int BeltDodgeCooldownMax = 5400; - internal static readonly int BrainDodgeCooldownMin = 1200; - internal static readonly int BrainDodgeCooldownMax = 5400; - internal static readonly int AmalgamDodgeCooldownMin = 1200; - internal static readonly int AmalgamDodgeCooldownMax = 5400; - internal static readonly int MirrorDodgeCooldownMin = 1200; - internal static readonly int MirrorDodgeCooldownMax = 5400; - internal static readonly int EvolutionReflectCooldownMin = 1200; - internal static readonly int EvolutionReflectCooldownMax = 5400; + /// + /// How long the dodge cooldown is at maximum damage + /// + internal static readonly int DodgeCooldownMax = 5400; // 90 seconds + /// + /// How much the dodge cooldown is reduced when at minimum damage + /// + internal static float DodgeCooldownDamageMult => 0.33f; // 30 seconds + /// + /// How much the dodge cooldown is reduced per stacked dodge. Each stack applies multiplicatively. + /// + internal static float DodgeCooldownMultPerStack => 0.85f; // -15% per stack, multiplicatively #endregion #region Damage diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 5d4d52244b..165b26a524 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -949,6 +949,7 @@ namespace CalamityMod.CalPlayer public bool seraphTracers = false; public bool frostFlare = false; public bool evolution = false; + public bool procDodgeEffects = true; public bool nanotech = false; public bool deadshotBrooch = false; public bool shadowMinions = false; @@ -2505,7 +2506,7 @@ namespace CalamityMod.CalPlayer voidField = false; copyrightInfringementShield = false; - ConsumableDodgeCooldown = BalancingConstants.BeltDodgeCooldownMax; + ConsumableDodgeCooldown = BalancingConstants.DodgeCooldownMax; DodgeEffects = []; daedalusReflect = false; diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 9d3c816c14..ba3a3815b5 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -859,16 +859,8 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(source, Player.Center + Vector2.UnitX.RotatedBy(MathHelper.TwoPi * (i / 10f)), Vector2.Zero, ModContent.ProjectileType(), mirrorDamage, 5, Main.myPlayer, 1); } } - - //Doze - This gives the same iframes as vanilla dodges, including accounting for cross necklace. - int evolutionIFrames = Player.ComputeDodgeIFrames(); - Player.GiveUniversalIFrames(evolutionIFrames, true); - - modifiers.Cancel(); projTypeJustHitBy = proj.type; - - int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.EvolutionReflectCooldownMin, BalancingConstants.EvolutionReflectCooldownMax, cooldownDurationScalar); - Player.AddCooldown(GlobalDodge.ID, cooldownDuration); + procDodgeEffects = true; //This tells the game to dodge in the Consumable Dodge step, which procs all generic dodge effects at once. return; } @@ -1446,11 +1438,59 @@ namespace CalamityMod.CalPlayer public override bool ConsumableDodge(Player.HurtInfo info) { + // Vanilla dodges are gated behind the global dodge cooldown + // The dodges will only trigger if the player has taken greater than or equal to 5% of their max HP in damage + double dodgeDamageGateValuePercent = 0.05; + int dodgeDamageGateValue = (int)Math.Round(Player.statLifeMax2 * dodgeDamageGateValuePercent); + + // 14MAY2024: Ozzatron: Chalice of the Blood God now works with dodges + int actualDamageTaken = chaliceOfTheBloodGod ? chaliceHitOriginalDamage : info.Damage; + bool sufficientDamageForDodging = actualDamageTaken >= dodgeDamageGateValue; + + //This is in a method here so the logic below can call it in multiple places + void GenericDodgeEffects() { + double maxCooldownDurationDamagePercent = 0.5; + int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); + + // Just in case... + if (maxCooldownDurationDamageValue <= 0) + maxCooldownDurationDamageValue = 1; + + float cooldownDurationScalar = MathHelper.Clamp((actualDamageTaken - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); + //Every dodge after the first reduces the dodge cooldown by 15%, stacking multiplicatively + float cooldownMultiplier = 1; + if (DodgeEffects.Count > 1) + cooldownMultiplier = MathF.Pow(BalancingConstants.DodgeCooldownMultPerStack, DodgeEffects.Count - 1); + + string? IconToUse = null; + foreach (var dodge in DodgeEffects) + { + string? str = dodge(Player, info); + if (str is not null) + IconToUse = str; + } + //This is set after DodgeEffects in case some dodge wants to modify ConsumableDodgeCooldown, and so custom dodge icons for mirror line work + int cooldownDuration = (int)MathHelper.Lerp(ConsumableDodgeCooldown * cooldownMultiplier * BalancingConstants.DodgeCooldownDamageMult, ConsumableDodgeCooldown * cooldownMultiplier, cooldownDurationScalar); + if (IconToUse is null) + Player.AddCooldown(GlobalDodge.ID, cooldownDuration); + else + Player.AddCooldown(GlobalDodge.ID, cooldownDuration, true, IconToUse); + } + //Dodge activation order is as follows: + // 1. Evolution dodge (which also procs Generals) // 2. Spectral Veil // 3. Evasion/Counter Scarf - // 1. Hallowed Armor - // 4. General Dodge + // 4. Hallowed Armor + // 5. General Dodge + + if (procDodgeEffects) + { + DodgeEffects.Add((_, _) => null); //This is to account for whatever procced the dodge when counting dodge cooldown stacking + GenericDodgeEffects(); + procDodgeEffects = false; + return true; + } if (spectralVeil && spectralVeilImmunity > 0) { @@ -1467,44 +1507,10 @@ namespace CalamityMod.CalPlayer storedShadowDodge = false; return true; } - // Vanilla dodges are gated behind the global dodge cooldown - // The dodges will only trigger if the player has taken greater than or equal to 5% of their max HP in damage - double dodgeDamageGateValuePercent = 0.05; - int dodgeDamageGateValue = (int)Math.Round(Player.statLifeMax2 * dodgeDamageGateValuePercent); - - // 14MAY2024: Ozzatron: Chalice of the Blood God now works with dodges - int actualDamageTaken = chaliceOfTheBloodGod ? chaliceHitOriginalDamage : info.Damage; - bool sufficientDamageForDodging = actualDamageTaken >= dodgeDamageGateValue; - + if (!Player.HasCooldown(GlobalDodge.ID) && sufficientDamageForDodging && DodgeEffects.Count > 0) { - double maxCooldownDurationDamagePercent = 0.5; - int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); - - // Just in case... - if (maxCooldownDurationDamageValue <= 0) - maxCooldownDurationDamageValue = 1; - - float cooldownDurationScalar = MathHelper.Clamp((actualDamageTaken - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); - //Every dodge after the first reduces the dodge cooldown by 15%, stacking multiplicatively - float cooldownMultiplier = 1; - if (DodgeEffects.Count > 1) - cooldownMultiplier = MathF.Pow(0.85f, DodgeEffects.Count - 1); - - string? IconToUse = null; - foreach (var dodge in DodgeEffects) - { - string? str = dodge(Player, info); - if (str is not null) - IconToUse = str; - } - //This is set after DodgeEffects in case some dodge wants to modify ConsumableDodgeCooldown, and so custom dodge icons for mirror line work - int cooldownDuration = (int)MathHelper.Lerp(ConsumableDodgeCooldown * cooldownMultiplier * 0.2f, ConsumableDodgeCooldown * cooldownMultiplier, cooldownDurationScalar); - if (IconToUse is null) - Player.AddCooldown(GlobalDodge.ID, cooldownDuration); - else - Player.AddCooldown(GlobalDodge.ID, cooldownDuration,true, IconToUse); - + GenericDodgeEffects(); return true; } From 1c8bbc15d2df01e0b00e371aa77308ae81451118 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Tue, 10 Feb 2026 09:40:37 -0600 Subject: [PATCH 3/5] build fix --- Items/CalamityGlobalItemTooltip.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index ddbda80f0a..b9186993cb 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -678,7 +678,7 @@ namespace CalamityMod.Items if (item.type == ItemID.SlimeCrown || item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.WormFood || item.type == ItemID.BloodySpine || item.type == ItemID.Abeemination || item.type == ItemID.DeerThing || item.type == ItemID.QueenSlimeCrystal || item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || item.type == ItemID.CelestialSigil) EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.NotConsumable")); - + #endregion // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. #region Guaranteed Dodge Tooltips if (item.type == ItemID.BlackBelt) @@ -721,11 +721,11 @@ namespace CalamityMod.Items #region Accessories // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. if (item.type == ItemID.BlackBelt) - EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BeltDodgeCooldownMin / 60, BalancingConstants.BeltDodgeCooldownMax / 60)); + EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format((Math.Round((BalancingConstants.DodgeCooldownMax * BalancingConstants.DodgeCooldownDamageMult) / 60f), BalancingConstants.DodgeCooldownMax / 60))); if (item.type == ItemID.MasterNinjaGear) - EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BeltDodgeCooldownMin / 60, BalancingConstants.BeltDodgeCooldownMax / 60)); + EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format((Math.Round((BalancingConstants.DodgeCooldownMax * BalancingConstants.DodgeCooldownDamageMult) / 60f), BalancingConstants.DodgeCooldownMax / 60))); if (item.type == ItemID.BrainOfConfusion) - EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BrainDodgeCooldownMin / 60, BalancingConstants.BrainDodgeCooldownMax / 60)); + EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format((Math.Round((BalancingConstants.DodgeCooldownMax * BalancingConstants.DodgeCooldownDamageMult) / 60f), BalancingConstants.DodgeCooldownMax / 60))); // Nerfed Ancient Chisel and its upgrade. if (item.type == ItemID.AncientChisel) From 06bfe5a4a381bffd6f3421fd1e5de01e027f6a9c Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Tue, 10 Feb 2026 09:48:06 -0600 Subject: [PATCH 4/5] fixed duplicate dodge infos --- Items/CalamityGlobalItemTooltip.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index b9186993cb..6d72d7db19 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -719,13 +719,6 @@ namespace CalamityMod.Items #endregion #region Accessories - // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. - if (item.type == ItemID.BlackBelt) - EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format((Math.Round((BalancingConstants.DodgeCooldownMax * BalancingConstants.DodgeCooldownDamageMult) / 60f), BalancingConstants.DodgeCooldownMax / 60))); - if (item.type == ItemID.MasterNinjaGear) - EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format((Math.Round((BalancingConstants.DodgeCooldownMax * BalancingConstants.DodgeCooldownDamageMult) / 60f), BalancingConstants.DodgeCooldownMax / 60))); - if (item.type == ItemID.BrainOfConfusion) - EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format((Math.Round((BalancingConstants.DodgeCooldownMax * BalancingConstants.DodgeCooldownDamageMult) / 60f), BalancingConstants.DodgeCooldownMax / 60))); // Nerfed Ancient Chisel and its upgrade. if (item.type == ItemID.AncientChisel) From ab5bef1caf1621dd7456db1913469dcf1ce7deda Mon Sep 17 00:00:00 2001 From: Cameron Ewell Date: Tue, 10 Feb 2026 20:31:19 -0500 Subject: [PATCH 5/5] Fix minor issues in dodges PR --- Items/Accessories/AbyssalMirror.cs | 2 +- Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson | 6 +++--- Localization/en-US/Mods.CalamityMod.Vanilla.hjson | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Items/Accessories/AbyssalMirror.cs b/Items/Accessories/AbyssalMirror.cs index 3dd48b65a6..0a71cbd439 100644 --- a/Items/Accessories/AbyssalMirror.cs +++ b/Items/Accessories/AbyssalMirror.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Accessories modPlayer.stealthGenStandstill += StandingStealthRegenBoost; modPlayer.stealthGenMoving += MovingStealthRegenBoost; modPlayer.abyssalMirror = true; - player.aggro -= 450; + player.aggro -= AggroReduction; modPlayer.DodgeEffects.Add(AbyssMirrorDodge); } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 4367917e8d..f1d5672f0e 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -659,7 +659,7 @@ EclipseMirror: { Stealth generates 25% faster when standing still and is boosted while moving if not attacking Stealth strikes only expend 50% of your max stealth {$Common.DodgeProvided} - Dodging an attack restores stealth and releases a burst of highly damaging darksun light + Dodging an attack restores stealth and releases a burst of highly damaging darksun light ''' HoldShiftTooltip: "{$Common.DodgeInformation}" FlavorTooltip: "'Its reflection shows naught but darkness'" @@ -1747,8 +1747,8 @@ StatisVoidSash: { Provides a high-speed dash 20% increased movement speed, 32% increased jump speed, and negates fall damage Increases movement acceleration and deceleration by 1.85x - Allows the user to swim[TOGGLE] and auto-jump - {$Common.DodgeProvided} + Allows the user to swim[TOGGLE] and auto jump + {$Common.DodgeProvided} [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:ClimbingClaws] [c/aaaaaa:Climbing Claws] ''' ToggleEffect: ", climb walls," diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index 6d80fdb9d0..cee11fbd9b 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -2,7 +2,7 @@ DashKey: Press {0} while facing a direction DodgeInfo: ''' {$Common.DodgeProvided} - {$Common.DodgeInformation} + {$Common.DodgeInformation} ''' AddedTooltip: {