diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index cf85506a16..36cc882eba 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4774,13 +4774,22 @@ namespace CalamityMod.CalPlayer { float baseRecoveryRate = Main.expertMode ? BalancingConstants.LifeStealRecoveryRate_Expert : BalancingConstants.LifeStealRecoveryRate_Classic; float lifeStealRecoveryRateReduction = Main.expertMode ? BalancingConstants.LifeStealRecoveryRateReduction_Expert : BalancingConstants.LifeStealRecoveryRateReduction_Classic; + float lifeStealCap = Main.expertMode ? BalancingConstants.LifeStealCap_Expert: BalancingConstants.LifeStealCap_Classic; float lifeStealRecoveryRate = baseRecoveryRate - lifeStealRecoveryRateReduction; - if (Player.lifeSteal < -lifeStealRecoveryRate) + + if (Player.lifeSteal < lifeStealCap) { - int duration = (int)Math.Ceiling(Math.Abs(Player.lifeSteal) / lifeStealRecoveryRate); - if (!Player.HasCooldown(LifeSteal.ID) || (cooldowns[LifeSteal.ID].duration < duration)) - Player.AddCooldown(LifeSteal.ID, duration); + + if (Player.Calamity().cooldowns.TryGetValue(LifeSteal.ID, out var cooldown)) + { + cooldown.timeLeft = (int)Math.Max(0,(lifeStealCap-Math.Abs(Player.lifeSteal))); + } + else + { + Player.AddCooldown(LifeSteal.ID, (int)lifeStealCap) + .timeLeft = (int)Math.Max(0, (lifeStealCap - Math.Abs(Player.lifeSteal))); + } } } if (moonshine) diff --git a/Cooldowns/LifeSteal.cs b/Cooldowns/LifeSteal.cs index 560e78b220..d7126d4ae0 100644 --- a/Cooldowns/LifeSteal.cs +++ b/Cooldowns/LifeSteal.cs @@ -1,4 +1,9 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Balancing; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; using Terraria.Localization; namespace CalamityMod.Cooldowns @@ -6,11 +11,44 @@ namespace CalamityMod.Cooldowns public class LifeSteal : CooldownHandler { public static new string ID => "LifeSteal"; - public override bool ShouldDisplay => instance.player.lifeSteal < 0f; + + private float lifeStealCap => Main.expertMode ? BalancingConstants.LifeStealCap_Expert : BalancingConstants.LifeStealCap_Classic; + public override bool ShouldDisplay => instance.player.lifeSteal < lifeStealCap; public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); public override string Texture => "CalamityMod/Cooldowns/LifeSteal"; - public override Color OutlineColor => new Color(255, 142, 165); - public override Color CooldownStartColor => Color.Lerp(new Color(255, 216, 216), new Color(255, 117, 117), instance.Completion); - public override Color CooldownEndColor => Color.Lerp(new Color(255, 216, 216), new Color(255, 117, 117), instance.Completion); + + public override bool CanTickDown => false; + public override Color OutlineColor => instance.player!.lifeSteal < 0 + ? new Color(255, 142, 165) + : new Color(255, 142, 165); + public override Color CooldownStartColor => instance.player!.lifeSteal < 0 + ? new Color(145, 59, 59) + : new Color(255, 181, 181); + public override Color CooldownEndColor => CooldownStartColor; + private Color TextColor => Color.White; + private Color TextBorderColor => new Color(40, 0, 0); + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + var value = instance.player.lifeSteal; + bool negate = value < 0; + var valueToMeasure = Math.Abs(value); + float Xoffset = valueToMeasure > 9 ? valueToMeasure > 99 ? -12.5f : -10f : -5; + if (negate) + Xoffset -= 8; + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (value).ToString("#"), position + new Vector2(Xoffset, 8) * scale, TextColor, TextBorderColor, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawCompact(spriteBatch, position, opacity, scale); + var value = instance.player.lifeSteal; + bool negate = value < 0; + var valueToMeasure = Math.Abs(value); + float Xoffset = valueToMeasure > 9 ? valueToMeasure > 99 ? -12.5f : -10f : -5; + if (negate) + Xoffset -= 8; + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (value).ToString("#"), position + new Vector2(Xoffset, 8) * scale, TextColor, TextBorderColor, scale); + } } } diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 57aa927d58..c912701a81 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -123,7 +123,7 @@ Cooldowns: { InkBomb: Ink Bomb Cooldown KillModeActive: Kill Mode Active KillModeCooldown: Kill Mode Cooldown - LifeSteal: Life Steal Cooldown + LifeSteal: Life Steal Remaining LionHeartShield: Energy Shell Cooldown M1GarandShots: Chambered Rounds MasterChefShieldDurability: MJOLNIR Shield Level