diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 9f9fdc2f09..1310c4524d 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -103,6 +103,8 @@ namespace CalamityMod.CalPlayer public int abyssLifeLostAtZeroBreathStat = 0; public int abyssDefenseLossStat = 0; public int stealthStat = 0; + public float standingRegenStat = 0f; + public float movingRegenStat = 0f; // Timer and Counter public int bossRushImmunityFrameCurseTimer = 0; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 2ea6e98c9f..5f9ddd40b9 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -88,7 +88,7 @@ namespace CalamityMod.CalPlayer EnduranceReductions(player, modPlayer); // Stat Meter - StatMeter(player, modPlayer); + UpdateStatMeter(player, modPlayer); // Rogue Mirrors RogueMirrors(player, modPlayer); @@ -3315,7 +3315,7 @@ namespace CalamityMod.CalPlayer #endregion #region Stat Meter - private static void StatMeter(Player player, CalamityPlayer modPlayer) + private static void UpdateStatMeter(Player player, CalamityPlayer modPlayer) { float allDamageStat = player.allDamage - 1f; modPlayer.damageStats[0] = (int)((player.meleeDamage + allDamageStat - 1f) * 100f); @@ -3341,7 +3341,15 @@ namespace CalamityMod.CalPlayer modPlayer.meleeSpeedStat = (int)((1f - player.meleeSpeed) * (100f / player.meleeSpeed)); modPlayer.manaCostStat = (int)(player.manaCost * 100f); modPlayer.rogueVelocityStat = (int)((modPlayer.throwingVelocity - 1f) * 100f); + + // Max stealth 1f is actually "100 stealth", so multiply by 100 to get visual stealth number. modPlayer.stealthStat = (int)(modPlayer.rogueStealthMax * 100f); + // Then divide by 3, because it takes 3 seconds to regen full stealth. + // Divide by 3 again for moving, because it recharges at 1/3 speed (so divide by 9 overall). + // Then multiply by stealthGen variables, which start at 1f and increase proportionally to your boosts. + modPlayer.standingRegenStat = (modPlayer.rogueStealthMax * 100f / 3f) * modPlayer.stealthGenStandstill; + modPlayer.movingRegenStat = (modPlayer.rogueStealthMax * 100f / 9f) * modPlayer.stealthGenMoving * modPlayer.stealthAcceleration; + modPlayer.minionSlotStat = player.maxMinions; modPlayer.manaRegenStat = player.manaRegen; modPlayer.armorPenetrationStat = player.armorPenetration; diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 9f203b244c..36eb6d66b9 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -1,11 +1,10 @@ using CalamityMod.CalPlayer; using CalamityMod.World; +using System; using System.Collections.Generic; +using System.Text; using Terraria; using Terraria.ModLoader; -using Terraria.ModLoader.Config; -using CalamityMod; -using System.Text; namespace CalamityMod.Items.Accessories { @@ -14,8 +13,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Stat Meter"); - Tooltip.SetDefault("Displays info about most of your stats\n" + - "Offensive stats displayed vary with held item"); + Tooltip.SetDefault("Displays almost all player stats"); } public override void SetDefaults() @@ -34,12 +32,18 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); Item heldItem = null; - if (player.selectedItem >= 0 && player.selectedItem < player.inventory.Length) + if (player.selectedItem >= 0 && player.selectedItem < Main.maxInventory) heldItem = player.inventory[player.selectedItem]; - foreach (TooltipLine line2 in list) - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - line2.text = CreateStatMeterTooltip(player, modPlayer, heldItem); + // Replace the vanilla tooltip with a full stat readout + foreach (TooltipLine l in list) + { + if (l.mod == "Terraria" && l.Name == "Tooltip0") + l.text = CreateStatMeterTooltip(player, modPlayer, heldItem); + } + + // To save screen space, favorited tooltips do not exist for the Stat Meter + list.RemoveAll(l => l.mod == "Terraria" && (l.Name == "Favorite" || l.Name == "FavoriteDesc")); } private string CreateStatMeterTooltip(Player player, CalamityPlayer modPlayer, Item heldItem) @@ -53,6 +57,9 @@ namespace CalamityMod.Items.Accessories int ammoConsumption = modPlayer.ammoReductionRanged; int rogueConsumption = modPlayer.ammoReductionRogue; int rogueStealth = modPlayer.stealthStat; + // Format the stealth regen statistics to be accurate to 2 decimal places. + string standingRegen = modPlayer.standingRegenStat.ToString("n2"); + string movingRegen = modPlayer.movingRegenStat.ToString("n2"); int lifeRegen = modPlayer.lifeRegenStat; int manaRegen = modPlayer.manaRegenStat; int armorPenetration = modPlayer.armorPenetrationStat; @@ -65,7 +72,7 @@ namespace CalamityMod.Items.Accessories int defenseLoss = modPlayer.abyssDefenseLossStat; // The notice about held item mattering is always displayed first. - StringBuilder sb = new StringBuilder("Offensive stats displayed vary with held item\n\n", 1024); + StringBuilder sb = new StringBuilder("Displays almost all player stats\nOffensive stats displayed vary with held item\n\n", 1024); // Only append rippers stats in Rev+, if rippers are enabled. if (CalamityWorld.revenge && CalamityMod.CalamityConfig.AdrenalineAndRage) @@ -76,13 +83,13 @@ namespace CalamityMod.Items.Accessories } // Append item stats only if the held item isn't null, and base it off of the item's damage type. - if (heldItem != null) + if (heldItem != null && !heldItem.IsAir) { if (heldItem.melee) { sb.Append("Melee Damage: ").Append(modPlayer.damageStats[0]) .Append("% | Melee Crit Chance: ").Append(modPlayer.critStats[0]) - .Append("%\nMeleeSpeed Boost: ").Append(meleeSpeed).Append("%\n\n"); + .Append("%\nMelee Speed Boost: ").Append(meleeSpeed).Append("%\n\n"); } else if (heldItem.ranged) { @@ -95,20 +102,23 @@ namespace CalamityMod.Items.Accessories sb.Append("Magic Damage: ").Append(modPlayer.damageStats[2]) .Append("% | Magic Crit Chance: ").Append(modPlayer.critStats[2]) .Append("%\nMana Usage: ").Append(manaCost) - .Append("% | Mana Regen").Append(manaRegen).Append("\n\n"); + .Append("% | Mana Regen: ").Append(manaRegen).Append("\n\n"); } else if (heldItem.summon) { sb.Append("Minion Damage: ").Append(modPlayer.damageStats[3]) .Append("% | Minion Slots: ").Append(minionSlots).Append("\n\n"); } - else if (heldItem.Calamity().rogue) + else if (heldItem.Calamity()?.rogue ?? false) { sb.Append("Rogue Damage: ").Append(modPlayer.damageStats[4]) .Append("% | Rogue Crit Chance: ").Append(modPlayer.critStats[3]) .Append("%\nRogue Velocity Boost: ").Append(rogueVelocity) .Append("% | Rogue Weapon Consumption Chance: ").Append(rogueConsumption) - .Append("%\nMax Stealth: ").Append(rogueStealth).Append("\n\n"); + .Append("%\nMax Stealth: ").Append(rogueStealth) + .Append(" | Standing Regen: ").Append(standingRegen).Append(" / sec") + .Append(" | Moving Regen: ").Append(movingRegen).Append(" / sec") + .Append("\n\n"); } } @@ -121,19 +131,17 @@ namespace CalamityMod.Items.Accessories sb.Append(" | Movement Speed Boost: ").Append(moveSpeed).Append("%\n\n"); sb.Append(CalamityWorld.death ? "Abyss/Cave Light Strength: " : "Abyss Light Strength: ").Append(lightLevel).Append("\n\n"); - // Abyss stats always render. - sb.Append("Other Abyss Stats:").Append("\n"); + // Abyss stats only render if the player is in the Abyss. if (modPlayer.ZoneAbyss) { + sb.Append("Other Abyss Stats:").Append("\n"); sb.Append("Breath Lost Per Tick: ").Append(breathLoss); sb.Append(" | Breath Loss Rate: ").Append(breathLossRate).Append("\n"); sb.Append("Life Lost Per Tick at Zero Breath: ").Append(lifeLostAtZeroBreath).Append("\n"); sb.Append("Defense Lost: ").Append(defenseLoss); } else - { - sb.Append("Only displayed while in the Abyss"); - } + sb.Append("Abyss stats only displayed while in the Abyss"); return sb.ToString(); }