From e10fc35aa45b0fa3103f74f33661c0bdc14edebf Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Sat, 9 Mar 2024 02:59:22 -0600 Subject: [PATCH] 1 - Changed Black Belt and its upgrades, Brain of Confusion and The Amalgam dodges to not trigger if an attack deals less than 5% of the player's max life in damage. 2 - The dodge cooldown for the above items ranges from 15 to 90 seconds depending on the amount of damage dodged over or equal to 5% max life damage, with 5% max life damage being 15 second cooldown and 50% max life damage being 90 second cooldown. 3 - For the above items, any damage dodged over 50% max life will be a 90 second cooldown. --- Balancing/BalancingConstants.cs | 9 ++++++--- CalPlayer/CalamityPlayerHitHurt.cs | 21 ++++++++++++++++++--- Items/CalamityGlobalItemTooltip.cs | 8 ++++++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index ebdce6c769..2f6e09e2d2 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -33,9 +33,12 @@ // Dodge cooldowns (in frames) // TODO -- Some of these could be moved to the respective item files - internal static readonly int BeltDodgeCooldown = 5400; - internal static readonly int BrainDodgeCooldown = 5400; - internal static readonly int AmalgamDodgeCooldown = 5400; + internal static readonly int BeltDodgeCooldownMin = 900; + internal static readonly int BeltDodgeCooldownMax = 5400; + internal static readonly int BrainDodgeCooldownMin = 900; + internal static readonly int BrainDodgeCooldownMax = 5400; + internal static readonly int AmalgamDodgeCooldownMin = 900; + internal static readonly int AmalgamDodgeCooldownMax = 5400; internal static readonly int MirrorDodgeCooldown = 5400; internal static readonly int DaedalusReflectCooldown = 5400; internal static readonly int EvolutionReflectCooldown = 5400; diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index fdd3b7fad8..352dd56117 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -1477,13 +1477,26 @@ namespace CalamityMod.CalPlayer public override bool ConsumableDodge(Player.HurtInfo info) { // Vanilla dodges are gated behind the global dodge cooldown - if (!Player.HasCooldown(GlobalDodge.ID)) + // 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); + if (!Player.HasCooldown(GlobalDodge.ID) && info.Damage >= dodgeDamageGateValue) { + 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((info.Damage - dodgeDamageGateValue) / maxCooldownDurationDamageValue, 0f, 1f); + // Re-implementation of vanilla item Black Belt as a consumable dodge if (Player.whoAmI == Main.myPlayer && Player.blackBelt) { Player.NinjaDodge(); - Player.AddCooldown(GlobalDodge.ID, BalancingConstants.BeltDodgeCooldown); + int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.BeltDodgeCooldownMin, BalancingConstants.BeltDodgeCooldownMax, cooldownDurationScalar); + Player.AddCooldown(GlobalDodge.ID, cooldownDuration); return true; } @@ -1491,7 +1504,9 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer && Player.brainOfConfusionItem != null && !Player.brainOfConfusionItem.IsAir) { Player.BrainOfConfusionDodge(); - int cooldownTime = amalgam ? BalancingConstants.AmalgamDodgeCooldown : BalancingConstants.BrainDodgeCooldown; + 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; } diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index a4741f3604..50f07d75e6 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -405,14 +405,18 @@ namespace CalamityMod.Items // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. #region Guaranteed Dodge Tooltips string beltDodgeLine = "Grants the ability to dodge attacks\n" + - $"The dodge has a {BalancingConstants.BeltDodgeCooldown / 60} second cooldown which is shared with all other dodges and reflects"; + "Attacks that deal less than 5% of your max life in damage will not be dodged\n" + + $"The dodge has a cooldown that ranges between {BalancingConstants.BeltDodgeCooldownMin / 60 } and {BalancingConstants.BeltDodgeCooldownMax / 60} seconds depending on the dodged attack's damage\n" + + "The cooldown is shared with all other dodges and reflects"; if (item.type == ItemID.BlackBelt) EditTooltipByNum(0, (line) => line.Text = beltDodgeLine); if (item.type == ItemID.MasterNinjaGear) EditTooltipByNum(1, (line) => line.Text = beltDodgeLine); string brainDodgeLine = "Grants the ability to dodge attacks\n" + - $"The dodge has a {BalancingConstants.BrainDodgeCooldown / 60} second cooldown which is shared with all other dodges and reflects"; + "Attacks that deal less than 5% of your max life in damage will not be dodged\n" + + $"The dodge has a cooldown that ranges between {BalancingConstants.BrainDodgeCooldownMin / 60} and {BalancingConstants.BrainDodgeCooldownMax / 60} seconds depending on the dodged attack's damage\n" + + "The cooldown is shared with all other dodges and reflects"; if (item.type == ItemID.BrainOfConfusion) EditTooltipByNum(0, (line) => line.Text = brainDodgeLine); #endregion