diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index b95fecfbf8..2927d2a516 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -543,7 +543,6 @@ namespace CalamityMod.CalPlayer public bool voltaicJelly = false; public bool jellyChargedBattery = false; public float summonProjCooldown; - public bool oldDukeScales = false; public bool sandWaifu = false; public bool sandWaifuVanity = false; public bool sandBoobWaifu = false; @@ -1612,7 +1611,6 @@ namespace CalamityMod.CalPlayer thiefsDime = false; dynamoStemCells = false; etherealExtorter = false; - oldDukeScales = false; blazingCore = false; voltaicJelly = false; jellyChargedBattery = false; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 591233a630..22ebb0643c 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3058,33 +3058,6 @@ namespace CalamityMod.CalPlayer Player.npcTypeNoAggro[ModContent.NPCType()] = true; } - if (oldDukeScales) - { - Player.buffImmune[ModContent.BuffType()] = true; - Player.buffImmune[BuffID.Poisoned] = true; - Player.buffImmune[BuffID.Venom] = true; - if (Player.statLife <= (int)(Player.statLifeMax2 * 0.75)) - { - Player.GetDamage() += 0.06f; - Player.GetCritChance() += 3; - } - if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) - { - Player.GetDamage() += 0.06f; - Player.GetCritChance() += 3; - } - if (Player.statLife <= (int)(Player.statLifeMax2 * 0.25)) - { - Player.GetDamage() += 0.06f; - Player.GetCritChance() += 3; - } - if (Player.lifeRegen < 0) - { - Player.GetDamage() += 0.1f; - Player.GetCritChance() += 5; - } - } - if (dArtifact) Player.GetDamage() += 0.25f; diff --git a/Cooldowns/OldDukeScalesFatigue.cs b/Cooldowns/OldDukeScalesFatigue.cs new file mode 100644 index 0000000000..1271028e4e --- /dev/null +++ b/Cooldowns/OldDukeScalesFatigue.cs @@ -0,0 +1,43 @@ +using System; +using CalamityMod.Items.Accessories; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class OldDukeScalesFatigue : CooldownHandler + { + public float CompletionPercentage => MathF.Round(100 - instance.Completion * 100); + private bool IsPlayerTired => instance.player.GetModPlayer().IsTired; + + private float TextXOffset => CompletionPercentage > 99 ? -18 : CompletionPercentage > 9 ? -15 : -12; + private Vector2 TextPosition => new(TextXOffset, 25); + private Color TextColor => IsPlayerTired ? Color.Red : Color.White; + private Color TextBorderColor = Color.Black; + + public static new string ID => "OldDukeScalesFatigue"; + public override bool CanTickDown => false; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override bool ShouldDisplay => instance.player.GetModPlayer().OldDukeScalesOn || IsPlayerTired; + public override string Texture => "CalamityMod/Cooldowns/" + ID; + + public override Color CooldownStartColor => IsPlayerTired ? Color.Red : Color.Lerp(Color.Green, Color.Red, instance.Completion); + public override Color CooldownEndColor => IsPlayerTired ? Color.Red : Color.Lerp(Color.Green, Color.Red, instance.Completion); + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, CompletionPercentage.ToString() + "%", position + TextPosition, TextColor, TextBorderColor); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawCompact(spriteBatch, position, opacity, scale); + + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, CompletionPercentage.ToString() + "%", position + TextPosition, TextColor, TextBorderColor); + } + } +} diff --git a/Cooldowns/OldDukeScalesFatigue.png b/Cooldowns/OldDukeScalesFatigue.png new file mode 100644 index 0000000000..551020e625 Binary files /dev/null and b/Cooldowns/OldDukeScalesFatigue.png differ diff --git a/Cooldowns/OldDukeScalesFatigueOutline.png b/Cooldowns/OldDukeScalesFatigueOutline.png new file mode 100644 index 0000000000..c8845a464c Binary files /dev/null and b/Cooldowns/OldDukeScalesFatigueOutline.png differ diff --git a/Cooldowns/OldDukeScalesFatigueOverlay.png b/Cooldowns/OldDukeScalesFatigueOverlay.png new file mode 100644 index 0000000000..d0528e521b Binary files /dev/null and b/Cooldowns/OldDukeScalesFatigueOverlay.png differ diff --git a/Items/Accessories/OldDukeScales.cs b/Items/Accessories/OldDukeScales.cs index 615d6ea907..0a63f55118 100644 --- a/Items/Accessories/OldDukeScales.cs +++ b/Items/Accessories/OldDukeScales.cs @@ -1,6 +1,8 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Cooldowns; using CalamityMod.Rarities; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -9,6 +11,11 @@ namespace CalamityMod.Items.Accessories public class OldDukeScales : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int RecoverTime = 120; + public static int DashFatigueIncrease = 240; + public static int MaxFatigue = 1200; // This is also the time that it takes the player to recover from the loss of all stamina. + public override void SetDefaults() { Item.width = 28; @@ -20,8 +27,124 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.oldDukeScales = true; + OldDukeScalesPlayer modPlayer = player.GetModPlayer(); + modPlayer.OldDukeScalesOn = true; + } + } + + public class OldDukeScalesPlayer : ModPlayer + { + public bool OldDukeScalesOn = false; + public bool IsTired = false; + public bool HasBoostedDashFirstFrame = false; + private SoundStyle TiredSound => new SoundStyle("CalamityMod/Sounds/Custom/OldDukeHuff") { PitchVariance = .1f, Volume = .8f }; + + public int Fatigue = 0; + public int RecoverTimer = 0; + + public override void PostUpdateMiscEffects() + { + if (OldDukeScalesOn) + { + // Show the bar if the player doesn't have it. + if (!Player.HasCooldown(OldDukeScalesFatigue.ID)) + Player.AddCooldown(OldDukeScalesFatigue.ID, OldDukeScales.MaxFatigue); + + if (!IsTired) + { + // +10% DR. + Player.endurance += 0.1f; + // +10% Max Movement Speed. + Player.maxRunSpeed *= 1.1f; + // +10% Max Acceleration. + Player.accRunSpeed *= 1.1f; + + // If the player has dashed, increase that dash's velocity, + // the fatigue and sets the time before the fatigue can decrease. + if (Player.dashDelay == -1) + { + if (!HasBoostedDashFirstFrame) + { + RecoverTimer = OldDukeScales.RecoverTime; + Fatigue += OldDukeScales.DashFatigueIncrease; + + Player.velocity.X *= 1.25f; + + HasBoostedDashFirstFrame = true; + } + } + else + HasBoostedDashFirstFrame = false; + + // If the player has reached max fatigue, the player becomes tired. + if (Fatigue >= OldDukeScales.MaxFatigue) + { + SoundEngine.PlaySound(TiredSound, Player.Center); + IsTired = true; + } + } + } + + if (IsTired) + { + // -30% Movement Speed. + Player.moveSpeed -= 0.3f; + + // If the player dashes, that dash is 50% slower. + if (Player.dashDelay == -1) + { + if (!HasBoostedDashFirstFrame) + { + Player.velocity.X *= 0.5f; + + HasBoostedDashFirstFrame = true; + } + } + else + HasBoostedDashFirstFrame = false; + + // If the fatigue has worn off, the player is back to normal. + if (Fatigue <= 0) + IsTired = false; + } + + // + // This code below the condition for when the accesory is equipped + // is a prevention to not exploit the item and only get the good bonuses. + // + + // The cooldown doens't act as a normal cooldown, we use the fatigue as the time left of the cooldown. + if (Player.Calamity().cooldowns.TryGetValue(OldDukeScalesFatigue.ID, out var cooldown)) + { + cooldown.timeLeft = Fatigue; + + // The cooldown handler doesn't like values higher than 600 frames. + // So we update the duration to a higher value every frame. + cooldown.duration = OldDukeScales.MaxFatigue; + } + + // If there's any amount of recovery before decreasing the fatigue, decrease this. + if (RecoverTimer > 0) + RecoverTimer--; + + // If the player has recovered, start decreasing the fatigue. + if (Fatigue > 0 && RecoverTimer <= 0) + Fatigue -= Player.StandingStill() ? 2 : 1; + + // The fatigue cannot go higher than the max. + if (Fatigue >= OldDukeScales.MaxFatigue) + Fatigue = OldDukeScales.MaxFatigue; + } + + public override void ResetEffects() + { + OldDukeScalesOn = false; + } + + public override void UpdateDead() + { + Fatigue = 0; + RecoverTimer = 0; } } } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index fc27db08a0..d187bcdd87 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1170,10 +1170,17 @@ OldDukeScales: { DisplayName: Old Duke's Scales Tooltip: ''' - While under the effects of a damaging debuff, you gain 10% increased damage and 5% crit - For every 25% of lost life, you gain 6% increased damage and 3% crit - This will max out at 18% increased damage and 9% crit when under 25% life - Provides immunity to poisoned, venom, and sulphuric poisoning + 15% increased damage reduction + 10% increased max movement speed and acceleration + 25% increased dash velocity and length + Gives you a stamina indicator on the cooldown rack + Using any dash will consume 20% of your stamina + Stamina will gradually recover to 100% after not dashing for 1 second + Stamina recovers faster when you are stationary + If your stamina reaches 0%, you become exhausted + [c/CE0E18:While exhausted, this item's damage reduction and movement bonuses are negated] + [c/CE0E18:Being exhausted reduces movement speed by 30% and dash velocity by 50%] + This debuff lasts until your stamina reaches 100% again ''' } diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 71550e9726..88759dc5b6 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -91,6 +91,7 @@ Cooldowns: { MasterChefShieldDurability: Energy Shield Durability MasterChefShieldRecharge: Energy Shield Recharge NebulousCore: Nebulous Core Cooldown + OldDukeScalesFatigue: Stamina OmegaBlueActive: Abyssal Madness OmegaBlueCooldown: Abyssal Madness Cooldown PermafrostConcoction: Permafrost's Concoction Cooldown