diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 46ccedfca7..32c6f92045 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -907,8 +907,8 @@ namespace CalamityMod.CalPlayer public bool alwaysHoneyRegen = false; public float alwaysHoneyRegenAmount = 0; public bool honeyTurboRegen = false; - public bool honeyDewHalveDebuffs = false; - public bool livingDewHalveDebuffs = false; + public bool honeyDew = false; + public bool livingDew = false; public int jewelBonusDefense = 0; /// /// Counter variable for spawning Toxic Heart's pulses.
@@ -983,7 +983,6 @@ namespace CalamityMod.CalPlayer public bool purity = false; /// If true, reduces the damage of electricity debuffs by 50%. public bool eleResist = false; - public int PurityHealSlowdownFrames = 0; public bool harpyRing = false; public bool angelTreads = false; /// Makes Flesh Knuckles and its upgrades increase the player's max health. @@ -2387,8 +2386,8 @@ namespace CalamityMod.CalPlayer lAmbergris = false; tortShell = false; absorber = false; - honeyDewHalveDebuffs = false; - livingDewHalveDebuffs = false; + honeyDew = false; + livingDew = false; aAmpoule = false; rOoze = false; radiantOozeRegen = 0; @@ -3168,7 +3167,6 @@ namespace CalamityMod.CalPlayer vaporfied = false; banishingFire = false; wither = false; - PurityHealSlowdownFrames = 0; ImmobilityDebuffImmunityTimer = 0; TypelessDebuffMultiplier = new(); HeatDebuffMultiplier = new(); diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 5e61894fbe..f3ac99db4d 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -277,26 +277,6 @@ namespace CalamityMod.CalPlayer bool hasLifeRegenHinderingDebuff = Player.lifeRegenTime == 0; #region Life Regen That Works Even During DoT Debuffs - if (honeyDewHalveDebuffs) - { - // Tick down all sickness debuffs; this makes them expire 2x faster - // Upgrades increase the sets of debuffs which expire faster - for (int l = 0; l < Player.MaxBuffs; ++l) - { - int buffID = Player.buffType[l]; - if (Player.buffTime[l] <= 2 || BuffDatasets.DebuffDataset[buffID] is null) - continue; - bool shouldHalveDuration = BuffDatasets.DebuffDataset[buffID].SicknessDebuffScaling > 0; - if (livingDewHalveDebuffs) - shouldHalveDuration |= BuffDatasets.DebuffDataset[buffID].HeatDebuffScaling > 0; - if (purity) - shouldHalveDuration |= CalamityBuffSets.IsDebuff[buffID]; - - if (shouldHalveDuration) - --Player.buffTime[l]; - } - } - if (divineBless) { if (Player.whoAmI == Main.myPlayer && Player.miscCounter % AngelicAlliance.DivineBlessFramesPerHeal == 0) // Flat 4 health per second @@ -338,60 +318,26 @@ namespace CalamityMod.CalPlayer else if (grandDadHealTimer > 0) grandDadHealTimer--; - // Grant life regen based on missing health for Radiant Ooze, Ambrosial Ampule, and purity - if (rOoze || aAmpoule || purity) - { - float missingLifeRatio = (Player.statLifeMax2 - Player.statLife) / (float)Player.statLifeMax2; - //Ambrosial Ampule and ooze give between 2 and 5 hp/s - int lifeRegenToGive = (int)Math.Round(MathHelper.Lerp(RadiantOoze.MinRegenBoost, RadiantOoze.MaxRegenBoost, missingLifeRatio));//Rounding is needed for it to ever actually give +5 hp/s, as the integer conversion would otherwise floor it. - Player.lifeRegen += lifeRegenToGive; - radiantOozeRegen += lifeRegenToGive / 2f; - purityRegen += lifeRegenToGive / 2f; - } - if (purity) { int intendedPurityDefense = 0; int currentDebuffs = Player.buffType.Count(i => CalamityBuffSets.IsDebuff[i]); if (currentDebuffs > 0) { - // Healing rate is normally 5 HP/s (+1 every 12 frames) - // However, that 12 frames can and will slowly increase if you try to abuse this accessory - int healFrameCadence = 12; + Player.lifeRegen += Radiance.DebuffedRegenBoost; - // Healing slows down after 5 seconds (300 frames) debuffed. For every 15 frames thereafter the cadence slows - // The upper limit to how slow it can get is after 15 seconds (900 frames) - int punishmentFrames = PurityHealSlowdownFrames - 300; - //lowest punishment is a little under a second between the one health heal - if (healFrameCadence < 52) - healFrameCadence += (punishmentFrames < 0) ? 0 : punishmentFrames / 15; - - if (Player.miscCounter % healFrameCadence == healFrameCadence - 1) - Player.Heal(1); - - intendedPurityDefense = 15 + (currentDebuffs - 1) * 5; + intendedPurityDefense = Radiance.DebuffedDefenseBoost + (currentDebuffs - 1) * Radiance.ExtraDebuffDefenseBoost; if (jewelBonusDefense < intendedPurityDefense) jewelBonusDefense = intendedPurityDefense; - // Count up total frames spent healing for slowdown. - if (PurityHealSlowdownFrames < 900) - ++PurityHealSlowdownFrames; - purityRegen += (60 / (float)healFrameCadence); + // Update tooltip + purityRegen += Radiance.DebuffedRegenBoost / 2f; } // If the defense should be ticking down to some lower value, do that. - // Purity loses 1 point of defense every second. - if (Player.miscCounter % 60 == 0 && jewelBonusDefense > intendedPurityDefense) + if (Player.miscCounter % Radiance.FramesToDecayDefense == 0 && jewelBonusDefense > intendedPurityDefense) --jewelBonusDefense; - // If the player is clear of all debuffs then gradually reduce the slowdown frames - if (currentDebuffs <= 0) - { - --PurityHealSlowdownFrames; - if (PurityHealSlowdownFrames < 0) - PurityHealSlowdownFrames = 0; - } - // Actually apply defense bonus Player.statDefense += jewelBonusDefense; } @@ -415,8 +361,7 @@ namespace CalamityMod.CalPlayer } // If the defense should be ticking down to some lower value, do that. - // Infected Jewel loses 1 point of defense every 20 frames. - if (Player.miscCounter % 60 == 0 && jewelBonusDefense > intendedJewelDefense) + if (Player.miscCounter % InfectedJewel.FramesToDecayDefense == 0 && jewelBonusDefense > intendedJewelDefense) --jewelBonusDefense; // Actually apply defense bonus @@ -549,6 +494,21 @@ namespace CalamityMod.CalPlayer if (PinkJellyRegen) Player.lifeRegen += LifeJelly.AuraRegenBoost; + // Grant life regen based on missing health for Radiant Ooze, Ambrosial Ampule, and Radiance + if (rOoze || aAmpoule || purity) + { + float missingLifeRatio = (Player.statLifeMax2 - Player.statLife) / (float)Player.statLifeMax2; + // Rounding is needed to prevent flooring and making the max unreachable + int lifeRegenToGive = (int)Math.Round(MathHelper.Lerp(RadiantOoze.MinRegenBoost, RadiantOoze.MaxRegenBoost, missingLifeRatio)); + Player.lifeRegen += lifeRegenToGive; + // Update tooltips + radiantOozeRegen += lifeRegenToGive / 2f; + purityRegen += lifeRegenToGive / 2f; + } + + if (livingDew) + Player.lifeRegenTime += LivingDew.RegenTimeBoost; + if (GreenJellyRegen) Player.lifeRegen += Items.Accessories.GrandGelatin.AuraRegenBoost; @@ -731,6 +691,10 @@ namespace CalamityMod.CalPlayer public override void NaturalLifeRegen(ref float regen) { + // Honey Dew and its upgrades make natural regen more powerful + if (honeyDew) + regen *= HoneyDew.NaturalRegenPower; + // The Camper counteracts the regen loss while moving horizontally if (camper && (Player.velocity.X != 0 && Player.grappling[0] <= 0)) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e8fe8fde5c..496bd372f8 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1580,7 +1580,7 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) { - Player.HealPlayer(15); + Player.HealPlayer(10); if (profanedCrystal) { diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index 8cd7145e58..ee9f62221b 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static int MaxLifeBoost = 50; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost, RadiantOoze.MinRegenBoost.ToRegenPerSecond(), RadiantOoze.MaxRegenBoost.ToRegenPerSecond()); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost, LivingDew.RegenTimeBoost.ToPercent(), (HoneyDew.NaturalRegenPower - 1f).ToPercent(), RadiantOoze.MinRegenBoost.ToRegenPerSecond(), RadiantOoze.MaxRegenBoost.ToRegenPerSecond()); public override void SetDefaults() { @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Accessories modPlayer.aAmpoule = true; // Inherits all effects of Honey Dew and Living Dew - modPlayer.honeyDewHalveDebuffs = true; - modPlayer.livingDewHalveDebuffs = true; + modPlayer.honeyDew = true; + modPlayer.livingDew = true; // Add light if the other accessories aren't equipped and visibility is turned on if (!(modPlayer.rOoze || modPlayer.purity) && !hideVisual) diff --git a/Items/Accessories/HoneyDew.cs b/Items/Accessories/HoneyDew.cs index cedef67539..ee517c2349 100644 --- a/Items/Accessories/HoneyDew.cs +++ b/Items/Accessories/HoneyDew.cs @@ -1,6 +1,7 @@ using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -8,6 +9,10 @@ namespace CalamityMod.Items.Accessories public class HoneyDew : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int MaxLifeBoost = 10; + public static float NaturalRegenPower = 1.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost, (NaturalRegenPower - 1f).ToPercent()); public override void SetDefaults() { Item.width = 20; @@ -19,11 +24,9 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.statLifeMax2 += 10; - if (!player.HasBuff(BuffID.Honey)) - player.AddBuff(BuffID.Honey, 2); + player.statLifeMax2 += MaxLifeBoost; CalamityPlayer modPlayer = player.Calamity(); - modPlayer.honeyDewHalveDebuffs = true; + modPlayer.honeyDew = true; } public override void AddRecipes() diff --git a/Items/Accessories/InfectedJewel.cs b/Items/Accessories/InfectedJewel.cs index 83a178f4cf..fbd7f2306e 100644 --- a/Items/Accessories/InfectedJewel.cs +++ b/Items/Accessories/InfectedJewel.cs @@ -16,7 +16,8 @@ namespace CalamityMod.Items.Accessories public static int RegenBoost = 2; public static int DebuffedRegenBoost = 3; // Added on top of the baseline regen boost public static int DebuffedDefenseBoost = 8; - public static int ExtraDebuffDefenseBoost = 4; // Per additional debuff + public static int ExtraDebuffDefenseBoost = 3; // Per additional debuff + public static int FramesToDecayDefense = 15; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenBoost.ToRegenPerSecond(), DebuffedDefenseBoost, DebuffedRegenBoost.ToRegenPerSecond(), ExtraDebuffDefenseBoost); public override void SetDefaults() { diff --git a/Items/Accessories/LivingDew.cs b/Items/Accessories/LivingDew.cs index ca84090d44..938341e256 100644 --- a/Items/Accessories/LivingDew.cs +++ b/Items/Accessories/LivingDew.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -9,6 +10,10 @@ namespace CalamityMod.Items.Accessories public class LivingDew : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int MaxLifeBoost = 25; + public static int RegenTimeBoost = 1; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost, RegenTimeBoost.ToPercent(), (HoneyDew.NaturalRegenPower - 1f).ToPercent()); public override void SetDefaults() { Item.width = 34; @@ -20,14 +25,12 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.statLifeMax2 += 25; - if (!player.HasBuff(BuffID.Honey)) - player.AddBuff(BuffID.Honey, 2); + player.statLifeMax2 += MaxLifeBoost; // Inherits all effects of Honey Dew CalamityPlayer modPlayer = player.Calamity(); - modPlayer.honeyDewHalveDebuffs = true; - modPlayer.livingDewHalveDebuffs = true; + modPlayer.honeyDew = true; + modPlayer.livingDew = true; } public override void AddRecipes() diff --git a/Items/Accessories/Radiance.cs b/Items/Accessories/Radiance.cs index 7fbffc9bb8..dcf0f695a2 100644 --- a/Items/Accessories/Radiance.cs +++ b/Items/Accessories/Radiance.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -15,6 +16,15 @@ namespace CalamityMod.Items.Accessories public class Radiance : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Accessories"; + + public static int MaxLifeBoost = 70; + public static int DebuffedRegenBoost = 4; // Added on top of the baseline regen boost + public static int DebuffedDefenseBoost = 9; + public static int ExtraDebuffDefenseBoost = 4; // Per additional debuff + public static int FramesToDecayDefense = 15; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost); + public LocalizedText TooltipExtensionText => this.GetLocalization("HoldShiftTooltip").WithFormatArgs(LivingDew.RegenTimeBoost.ToPercent(), (HoneyDew.NaturalRegenPower - 1f).ToPercent(), + RadiantOoze.MinRegenBoost.ToRegenPerSecond(), RadiantOoze.MaxRegenBoost.ToRegenPerSecond(), DebuffedDefenseBoost, DebuffedRegenBoost.ToRegenPerSecond(), ExtraDebuffDefenseBoost); public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 7)); @@ -25,7 +35,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 18; Item.height = 44; - Item.defense = 5; + Item.defense = 3; Item.accessory = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.rare = ModContent.RarityType(); @@ -34,16 +44,14 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - player.statLifeMax2 += 70; - if (!player.HasBuff(BuffID.Honey)) - player.AddBuff(BuffID.Honey, 2); + player.statLifeMax2 += MaxLifeBoost; - // Abyss light, debuff near-immunity, life regen effects, and massively enhances debuff halving + // Abyss light, debuff near-immunity, and life regen effects modPlayer.purity = true; // Inherits effects from Honey Dew and Living Dew - modPlayer.honeyDewHalveDebuffs = true; - modPlayer.livingDewHalveDebuffs = true; + modPlayer.honeyDew = true; + modPlayer.livingDew = true; // Add light if the other accessories aren't equipped and visibility is turned on if (!(modPlayer.rOoze || modPlayer.aAmpoule) && !hideVisual) diff --git a/Items/Accessories/RadiantOoze.cs b/Items/Accessories/RadiantOoze.cs index 51470995e7..0164304a0d 100644 --- a/Items/Accessories/RadiantOoze.cs +++ b/Items/Accessories/RadiantOoze.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static int MinRegenBoost = 1; - public static int MaxRegenBoost = 4; + public static int MaxRegenBoost = 5; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinRegenBoost.ToRegenPerSecond(), MaxRegenBoost.ToRegenPerSecond()); public override void SetDefaults() diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index ff3204552b..9ab199e038 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -188,7 +188,7 @@ namespace CalamityMod.Items // If holding SHIFT, actually display the extended tooltip. if (holdingShift && firstTooltipIndex != -1) { - string holdShiftText = item.ModItem.GetLocalizedValue(holdShiftItem.TooltipExtensionKey); + string holdShiftText = (holdShiftItem.TooltipExtensionText == LocalizedText.Empty ? item.ModItem.GetLocalizedValue(holdShiftItem.TooltipExtensionKey) : holdShiftItem.TooltipExtensionText.ToString()); TooltipLine holdShiftLine = new TooltipLine(Mod, IHoldShiftTooltipItem.ExtensionTooltipID, holdShiftText); if (holdShiftItem.TooltipExtensionColor is not null) holdShiftLine.OverrideColor = holdShiftItem.TooltipExtensionColor; diff --git a/Items/IHoldShiftTooltipItem.cs b/Items/IHoldShiftTooltipItem.cs index 28938b7a60..69df795e2a 100644 --- a/Items/IHoldShiftTooltipItem.cs +++ b/Items/IHoldShiftTooltipItem.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using Terraria.Localization; namespace CalamityMod.Items { @@ -75,6 +76,11 @@ namespace CalamityMod.Items #endregion #region Tooltip Extension Properties + /// + /// The localization text object itself. Override to allow text to be formatted. + /// + public virtual LocalizedText TooltipExtensionText => LocalizedText.Empty; + /// /// The lang/localization key which this item uses for its tooltip extension. /// diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index f3db981e57..605100e9e8 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -99,8 +99,8 @@ AmbrosialAmpoule: { Tooltip: ''' +{0} max life - Grants +{1} to +{2} HP/s life regen based on missing health - Grants the [cbuffplr:Honey] buff + Natural life regen is {1}% faster and {2}% more potent + Grants +{2} to +{3} HP/s life regen based on missing health Current boost: +[REGEN] HP/s Fire and sickness debuff durations are halved You emit yellow light if visibility is enabled @@ -948,9 +948,8 @@ HoneyDew: { DisplayName: Honey Dew Tooltip: ''' - +10 max life - Grants the [cbuffplr:Honey] buff - Sickness debuff durations are halved + +{0} max life + Natural life regen is {1}% more potent ''' } @@ -979,7 +978,7 @@ InfectedJewel: { ''' Passively grants +{0} HP/s life regen Grants {1} defense and +{2} HP/s life regen while afflicted with any debuff - Granted defense fades away quickly when not afflicted with any debuffs + Granted defense fades away when not afflicted with any debuffs Each debuff beyond the first grants {3} additional defense Nullifies the [cbuffplr:CalamityMod/AstralInfectionDebuff] 'A beautiful gemstone tarnished by spaceborne rot' @@ -1080,9 +1079,8 @@ LivingDew: { DisplayName: Living Dew Tooltip: ''' - +25 max life - Grants the [cbuffplr:Honey] buff - Fire and sickness debuff durations are halved + +{0} max life + Natural life regen is {1}% faster and {2}% more potent ''' } @@ -1392,7 +1390,7 @@ Radiance: { DisplayName: Radiance Tooltip: ''' - +70 max life + +{0} max life Provides greatly improved life regen, increasing with lost health Gain increased defense from debuffs inflicted on you, and greatly reduces their effectiveness Current boosts: +[REGEN] HP/s and [DEFENSE] defense. @@ -1401,13 +1399,11 @@ Radiance: { ''' HoldShiftTooltip: ''' - [c/CDF69C:Grants +0.5 to +2 HP/s life regen based on missing health] - [c/CDF69C:Recover an additional 6 HP/s while inflicted with a debuff] - [c/CDF69C:This eventually slows to 1.33 HP/s when debuffed for an extended time period] - [c/CDF69C:Grants the Honey buff] - [c/CDF69C:Grants 15 defense while afflicted with any debuff] - [c/CDF69C:Each additional debuff grants 5 defense, which slowly decays while not debuffed] - [c/CDF69C:Weak damaging debuffs are harmless and halves the duration of most other debuffs] + [c/CDF69C:Natural life regen is {0}% faster and {1}% more potent] + [c/CDF69C:Grants +{2} to +{3} HP/s life regen based on missing health] + [c/CDF69C:Grants {4} defense and +{5} HP/s life regen while afflicted with any debuff] + [c/CDF69C:Each additional debuff grants {6} defense, which decays while not debuffed] + [c/CDF69C:Causes weak damaging debuffs to be harmless] ''' } diff --git a/Utilities/LocalizationUtils.cs b/Utilities/LocalizationUtils.cs index 10132d352e..58729ababd 100644 --- a/Utilities/LocalizationUtils.cs +++ b/Utilities/LocalizationUtils.cs @@ -97,6 +97,7 @@ namespace CalamityMod public static string GetChanceFromDenominator(this int denominator) => ToPercent(1 / (float)denominator); + public static string ToPercent(this int percent) => (percent * 100).ToString(); public static string ToPercent(this float percent, string precision = "N1") => Round(percent * 100f, precision); public static string ToPercent(this double percent, string precision = "N1") => Round(percent * 100D, precision); // Double-rounded for proper digit cutoffs