diff --git a/Buffs/StatBuffs/BossZen.cs b/Buffs/StatBuffs/BossZen.cs index 92165336db..3ebab98238 100644 --- a/Buffs/StatBuffs/BossZen.cs +++ b/Buffs/StatBuffs/BossZen.cs @@ -1,3 +1,4 @@ +using System.Text; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,16 +19,22 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { - player.Calamity().bossZen = true; + // TODO -- This bool does nothing except enable boss zen config. All other effects are hardcoded. + // Is this intended? + player.Calamity().isNearbyBoss = true; } public override void ModifyBuffTip(ref string tip, ref int rare) { - tip = "The nearby boss is:\n" + - "Greatly reducing enemy spawn rates\n" + - "Disabling teleportation effects\n" + - "Increasing Nurse healing cost by 400%\n" + - "Disabling Target and Super Dummy hitboxes"; + StringBuilder sb = new StringBuilder(512); + sb.Append("The nearby boss is:\n"); + if (CalamityConfig.Instance.BossZen) + sb.Append("Greatly reducing enemy spawn rates\n"); + sb.Append("Disabling teleportation effects\n"); + sb.Append("Increasing Nurse healing cost by 400%\n"); + sb.Append("Disabling Target and Super Dummy hitboxes"); + + tip = sb.ToString(); } } } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 2b24b44148..471cfdf861 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -821,7 +821,7 @@ namespace CalamityMod.CalPlayer public bool omniscience = false; public bool zerg = false; public bool zen = false; - public bool bossZen = false; + public bool isNearbyBoss = false; public bool yPower = false; public bool aWeapon = false; public bool tScale = false; @@ -1905,7 +1905,7 @@ namespace CalamityMod.CalPlayer omniscience = false; zerg = false; zen = false; - bossZen = false; + isNearbyBoss = false; permafrostsConcoction = false; armorCrumbling = false; armorShattering = false; @@ -2145,7 +2145,7 @@ namespace CalamityMod.CalPlayer #region Screen Position Movements public override void ModifyScreenPosition() { - if (CalamityConfig.Instance.DisableScreenShakes) + if (!CalamityConfig.Instance.Screenshake) return; if (GeneralScreenShakePower > 0f) @@ -2327,7 +2327,7 @@ namespace CalamityMod.CalPlayer omniscience = false; zerg = false; zen = false; - bossZen = false; + isNearbyBoss = false; permafrostsConcoction = false; armorCrumbling = false; armorShattering = false; @@ -3437,15 +3437,7 @@ namespace CalamityMod.CalPlayer Player.buffImmune[BuffID.WindPushed] = true; } - if (CalamityConfig.Instance.BossHealthBar) - { - drawBossHPBar = true; - } - else - { - drawBossHPBar = false; - } - + // TODO -- why is boss health bar code in Player.UpdateEquips and not a ModSystem CalamityConfig.Instance.BossHealthBarExtraInfo = shouldDrawSmallText; // Increase tile placement speed to speed up early game a bit and make building more fun @@ -6382,7 +6374,7 @@ namespace CalamityMod.CalPlayer else Player.GiveIFrames(Player.immuneTime + iFramesToAdd, true); - if (BossRushEvent.BossRushActive && CalamityConfig.Instance.BossRushImmunityFrameCurse) + if (BossRushEvent.BossRushActive && CalamityConfig.Instance.BossRushIFrameCurse) bossRushImmunityFrameCurseTimer = 180 + Player.immuneTime; if (aeroSet && damage > 25) diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 7d1caf1c15..4107529d97 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -67,6 +67,7 @@ namespace CalamityMod.CalPlayer if (Player.Calamity().andromedaState != AndromedaPlayerState.Inactive) AndromedaMechLayer.DrawTheStupidFuckingRobot(ref drawInfo); + // TODO -- Why is the Speedrun Timer not its own UI file? Why is this in CalamityPlayer? CalamityPlayer calamityPlayer = Player.Calamity(); if (Main.myPlayer == Player.whoAmI && !Main.gameMenu && CalamityConfig.Instance.SpeedrunTimer) { @@ -350,8 +351,8 @@ namespace CalamityMod.CalPlayer } } - bool noRogueStealth = calamityPlayer.rogueStealth == 0f || Player.townNPCs > 2f || !CalamityConfig.Instance.StealthInvisbility; - if (calamityPlayer.rogueStealth > 0f && calamityPlayer.rogueStealthMax > 0f && Player.townNPCs < 3f && CalamityConfig.Instance.StealthInvisbility) + bool noRogueStealth = calamityPlayer.rogueStealth == 0f || Player.townNPCs > 2f || !CalamityConfig.Instance.StealthInvisibility; + if (calamityPlayer.rogueStealth > 0f && calamityPlayer.rogueStealthMax > 0f && Player.townNPCs < 3f && CalamityConfig.Instance.StealthInvisibility) { // A translucent orchid color, the rogue class color float colorValue = calamityPlayer.rogueStealth / calamityPlayer.rogueStealthMax * 0.9f; //0 to 0.9 diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index c128ed481b..e4e688b5ec 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -980,18 +980,15 @@ namespace CalamityMod.CalPlayer } } - if (BossRushEvent.BossRushActive) + if (BossRushEvent.BossRushActive && CalamityConfig.Instance.BossRushRegenCurse) { - if (CalamityConfig.Instance.BossRushHealthCurse) - { - if (Player.lifeRegen > 0) - Player.lifeRegen = 0; + if (Player.lifeRegen > 0) + Player.lifeRegen = 0; - Player.lifeRegenTime = 0; + Player.lifeRegenTime = 0; - if (Player.lifeRegenCount > 0) - Player.lifeRegenCount = 0; - } + if (Player.lifeRegenCount > 0) + Player.lifeRegenCount = 0; } } #endregion diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index da14ef9581..bc9ea8ca85 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -77,12 +77,17 @@ namespace CalamityMod.CalPlayer if (fearmongerRegenFrames > 0) fearmongerRegenFrames--; - // Reduce the expert debuff time multiplier to the normal mode multiplier + // Reduce the expert+ debuff time multiplier to the normal mode multiplier + // TODO -- This should be a ModSystem, why is this in CalamityPlayer if (CalamityConfig.Instance.NerfExpertDebuffs) { var copy = Main.RegisteredGameModes[GameModeID.Expert]; copy.DebuffTimeMultiplier = 1f; Main.RegisteredGameModes[GameModeID.Expert] = copy; + + copy = Main.RegisteredGameModes[GameModeID.Master]; + copy.DebuffTimeMultiplier = 1f; + Main.RegisteredGameModes[GameModeID.Master] = copy; } // Go through the old positions for the player. @@ -745,7 +750,7 @@ namespace CalamityMod.CalPlayer { Player.buffImmune[ModContent.BuffType()] = true; } - if (CalamityConfig.Instance.ReworkChilledWater) + if (CalamityConfig.Instance.ChilledWaterRework) { if (Main.expertMode && Player.ZoneSnow && Player.wet && !Player.lavaWet && !Player.honeyWet) { diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 4ebedaf07e..6a91c9601e 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -1,380 +1,399 @@ -using CalamityMod.UI; +using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.DifficultyItems; +using CalamityMod.Items.DraedonMisc; +using CalamityMod.Items.Dyes.HairDye; +using CalamityMod.Items.Potions; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.UI; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.Config; namespace CalamityMod { - [Label("Config")] + [Label("$Mods.CalamityMod.Config.MainTitle")] [BackgroundColor(49, 32, 36, 216)] public class CalamityConfig : ModConfig { public static CalamityConfig Instance; + + // TODO -- Not all Calamity config settings should be considered client side. + // There are many configs which are server side and should stay that way. public override ConfigScope Mode => ConfigScope.ClientSide; + public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message) => true; // Clamps values that would cause ugly problems if loaded directly without sanitization. [OnDeserialized] internal void ClampValues(StreamingContext context) { BossHealthBoost = Utils.Clamp(BossHealthBoost, MinBossHealthBoost, MaxBossHealthBoost); - MeterShake = Utils.Clamp(MeterShake, MinMeterShake, MaxMeterShake); + RipperMeterShake = Utils.Clamp(RipperMeterShake, MinMeterShake, MaxMeterShake); } - [Header("Graphics Changes")] + #region Graphics Changes + [Header("$Mods.CalamityMod.Config.SectionTitle.Graphics")] - [Label("Afterimages")] + [Label("$Mods.CalamityMod.Config.EntryTitle.Afterimages")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Enables rendering afterimages for Calamity NPCs, projectiles, etc.\nDisable to improve performance.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.Afterimages")] public bool Afterimages { get; set; } - [Label("MaxParticles")] + [Label("$Mods.CalamityMod.Config.EntryTitle.ParticleLimit")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] [Range(0, 1000)] [DefaultValue(500)] - [Tooltip("Sets the maximum of particle effects that can exist at once.\nParticles are separate from dust and gores.\nTurn down to improve performance.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ParticleLimit")] public int ParticleLimit { get; set; } - [Label("ScreenshakeOff")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Disables all screen-shaking effects.")] - public bool DisableScreenShakes { get; set; } - - [Label("StealthInvisibility")] + [Label("$Mods.CalamityMod.Config.EntryTitle.Screenshake")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Enables players gradually turning invisible as their Rogue Stealth increases.\nThis effect is visually similar to Shroomite armor's stealth.")] - public bool StealthInvisbility { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.Screenshake")] + public bool Screenshake { get; set; } - [Label("ShopAlert")] + [Label("$Mods.CalamityMod.Config.EntryTitle.StealthInvisibility")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Adds an icon that appears over Town NPCs when they have new items in their shops.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.StealthInvisibility")] + public bool StealthInvisibility { get; set; } + + [Label("$Mods.CalamityMod.Config.EntryTitle.ShopNewAlert")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ShopNewAlert")] public bool ShopNewAlert { get; set; } + #endregion - [Header("UI Changes")] + #region UI Changes + [Header("$Mods.CalamityMod.Config.SectionTitle.UI")] - [Label("BossHealthBar")] + [Label("$Mods.CalamityMod.Config.EntryTitle.BossHealthBarExtraInfo")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Enables Calamity's boss health bar in the bottom right corner of the screen.")] - public bool BossHealthBar { get; set; } - - [Label("BossHealthBarExtra")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Adds extra info to the Calamity boss health bar.\nThis displays either the boss's exact health or number of remaining parts or segments.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.BossHealthBarExtraInfo")] public bool BossHealthBarExtraInfo { get; set; } - [Label("DebuffDisplay")] + [Label("$Mods.CalamityMod.Config.EntryTitle.DebuffDisplay")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Adds an array of debuff icons above all bosses and minibosses.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.DebuffDisplay")] public bool DebuffDisplay { get; set; } - [Label("CooldownDisplay")] + [Label("$Mods.CalamityMod.Config.EntryTitle.CooldownDisplay")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f,2f)] + [Range(0f, 2f)] [DefaultValue(2f)] [Increment(1f)] [DrawTicks] - [Tooltip("Displays all the important cooldowns on your UI under your buffs and debuffs. Set this to 1 to have it display in a more compact way, and to 0 to entirely disable the UI")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.CooldownDisplay")] public float CooldownDisplay { get; set; } - [Label("VanillaCooldownDisplay")] + [Label("$Mods.CalamityMod.Config.EntryTitle.VanillaCooldownDisplay")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Adds custom cooldown displays for Chaos State and Potion Sickness.\nThis doesn't remove them from your buff list, but can help with visibility nontheless")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.VanillaCooldownDisplay")] public bool VanillaCooldownDisplay { get; set; } [BackgroundColor(192, 54, 64, 192)] - [Label("MeterLock")] + [Label("$Mods.CalamityMod.Config.EntryTitle.MeterPosLock")] [DefaultValue(true)] - [Tooltip("Prevents clicking on the Stealth, Charge, Rage, and Adrenaline Meters.\nThis stops them from being dragged around with the mouse.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.MeterPosLock")] public bool MeterPosLock { get; set; } - [Label("StealthMeter")] + [Label("$Mods.CalamityMod.Config.EntryTitle.StealthMeter")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Enables the Stealth Meter UI, which shows the player's current stealth level.\nThe Stealth Meter is always hidden if not wearing Rogue armor.")] - public bool StealthBar { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.StealthMeter")] + public bool StealthMeter { get; set; } - [Label("StealthMeterX")] + [Label("$Mods.CalamityMod.Config.EntryTitle.StealthMeterPosX")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] - [DefaultValue(820f)] - [Tooltip("The X position of the Stealth Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Range(0f, 100f)] + [DefaultValue(StealthUI.DefaultStealthPosX)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.StealthMeterPosX")] public float StealthMeterPosX { get; set; } - [Label("StealthMeterY")] + [Label("$Mods.CalamityMod.Config.EntryTitle.StealthMeterPosY")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] - [DefaultValue(43f)] - [Tooltip("The Y position of the Stealth Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Range(0f, 100f)] + [DefaultValue(StealthUI.DefaultStealthPosY)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.StealthMeterPosY")] public float StealthMeterPosY { get; set; } - [Label("ChargeMeter")] + [Label("$Mods.CalamityMod.Config.EntryTitle.ChargeMeter")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Enables the Charge Meter UI, which shows the charge level of the player's currently held Arsenal item.\nThe Charge Meter is always hidden if not holding a chargable arsenal item.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ChargeMeter")] public bool ChargeMeter { get; set; } - [Label("ChargeMeterX")] + [Label("$Mods.CalamityMod.Config.EntryTitle.ChargeMeterPosX")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] - [DefaultValue(950f)] - [Tooltip("The X position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Range(0f, 100f)] + [DefaultValue(49.47917f)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ChargeMeterPosX")] public float ChargeMeterPosX { get; set; } - [Label("ChargeMeterY")] + [Label("$Mods.CalamityMod.Config.EntryTitle.ChargeMeterPosY")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] + [Range(0f, 100f)] [DefaultValue(43f)] - [Tooltip("The Y position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ChargeMeterPosY")] public float ChargeMeterPosY { get; set; } - [Label("SpeedrunTimer")] + [Label("$Mods.CalamityMod.Config.EntryTitle.SpeedrunTimer")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(false)] - [Tooltip("Enables a Speedrun Timer.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.SpeedrunTimer")] public bool SpeedrunTimer { get; set; } - [Label("SpeedrunTimerX")] + [Label("$Mods.CalamityMod.Config.EntryTitle.SpeedrunTimerPosX")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(-800f, 800f)] - [DefaultValue(68f)] - [Tooltip("The X position of the Speedrun Timer.")] + [Range(0f, 100f)] + [DefaultValue(53.5417f)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.SpeedrunTimerPosX")] public float SpeedrunTimerPosX { get; set; } - [Label("SpeedrunTimerY")] + [Label("$Mods.CalamityMod.Config.EntryTitle.SpeedrunTimerPosY")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(16f, 1000f)] - [DefaultValue(16f)] - [Tooltip("The Y position of the Speedrun Timer.")] + [Range(0f, 100f)] + [DefaultValue(0.01481f)] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.SpeedrunTimerPosY")] public float SpeedrunTimerPosY { get; set; } + #endregion - [Header("General Gameplay Changes")] + #region General Gameplay Changes + [Header("$Mods.CalamityMod.Config.SectionTitle.Gameplay")] - [Label("EarlyHMRework")] + [Label("$Mods.CalamityMod.Config.EntryTitle.EarlyHardmodeProgressionRework")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Demon Altars no longer spawn ores and crimson/corruption blocks when broken.\n" + - "Wall of Flesh spawns Cobalt and Palladium ore on first kill.\n" + - "The first mech boss you fight has 20% less HP and damage and spawns Mythril and Orichalcum ore on first kill.\n" + - "The second mech boss you fight has 10% less HP and damage and spawns Adamantite and Titanium ore on first kill.\n" + - "The third mech boss spawns Hallowed Ore on first kill")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.EarlyHardmodeProgressionRework")] public bool EarlyHardmodeProgressionRework { get; set; } - [Label("Proficiency")] + [Label("$Mods.CalamityMod.Config.EntryTitle.Proficiency")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Enables the Proficiency system which allows the player to gain slight stat bonuses by persistently using one damage class.\nDisabling the system does not remove levels players already have, but disables their stat bonuses and prevents experience gain.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.Proficiency")] public bool Proficiency { get; set; } - [Label("BossZen")] + [Label("$Mods.CalamityMod.Config.EntryTitle.BossZen")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("While a boss is alive, all players near a boss receive the Boss Effects buff, which drastically reduces enemy spawn rates.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.BossZen")] public bool BossZen { get; set; } - [Label("NPCNightSpawn")] + [Label("$Mods.CalamityMod.Config.EntryTitle.TownNPCsSpawnAtNight")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(false)] - [Tooltip("Allows you to determine if town NPCs (including the Old Man) can spawn at night.")] - public bool CanTownNPCsSpawnAtNight { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.TownNPCsSpawnAtNight")] + public bool TownNPCsSpawnAtNight { get; set; } private const int MinTownNPCSpawnMultiplier = 1; private const int MaxTownNPCSpawnMultiplier = 10; - [Label("NPCExtraSpawn")] + [Label("$Mods.CalamityMod.Config.EntryTitle.TownNPCSpawnRateMultiplier")] [BackgroundColor(192, 54, 64, 192)] [Range(MinTownNPCSpawnMultiplier, MaxTownNPCSpawnMultiplier)] [Increment(1)] [DrawTicks] [DefaultValue(MinTownNPCSpawnMultiplier)] - [Tooltip("Makes town NPCs spawn more quickly, the higher this value is.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.TownNPCSpawnRateMultiplier")] public int TownNPCSpawnRateMultiplier { get; set; } private const float MinBossHealthBoost = 0f; private const float MaxBossHealthBoost = 900f; - [Label("BossHPBoost")] + [Label("$Mods.CalamityMod.Config.EntryTitle.BossHealthBoost")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] [Range(MinBossHealthBoost, MaxBossHealthBoost)] - [Increment(50f)] + [Increment(25f)] [DrawTicks] [DefaultValue(MinBossHealthBoost)] - [Tooltip("Globally boosts the health of all bosses.\nDoes not affect bosses that are already spawned.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.BossHealthBoost")] public float BossHealthBoost { get; set; } + #endregion - [Header("Expert Mode Changes")] + #region Expert and Master Mode Changes + [Header("$Mods.CalamityMod.Config.SectionTitle.ExpertMaster")] - [Label("ExpertDebuffReduction")] + [Label("$Mods.CalamityMod.Config.EntryTitle.NerfExpertDebuffs")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("Disables Expert Mode doubling the duration of all debuffs inflicted on the player.\nCalamity is balanced with the assumption that this setting is enabled.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.NerfExpertDebuffs")] public bool NerfExpertDebuffs { get; set; } - [Label("ChillWaterRework")] + [Label("$Mods.CalamityMod.Config.EntryTitle.ChilledWaterRework")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - [Tooltip("When enabled, water in the Snow and Ice biomes will rapidly drain the player's breath instead of inflicting Chilled.")] - public bool ReworkChilledWater { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ChilledWaterRework")] + public bool ChilledWaterRework { get; set; } - [Label("ExpertSafeTowns")] + [Label("$Mods.CalamityMod.Config.EntryTitle.ForceTownSafety")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(false)] - [Tooltip("Counteracts Expert Mode allowing enemies to spawn near towns by vastly decreasing spawn rates.\nThis can have unintended side effects such as making critters difficult to find.")] - public bool DisableExpertTownSpawns { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.ForceTownSafety")] + public bool ForceTownSafety { get; set; } + #endregion - [Header("Revengeance Mode Changes")] + #region Revengeance Mode Changes + [Header("$Mods.CalamityMod.Config.SectionTitle.Revengeance")] private const float MinMeterShake = 0f; private const float MaxMeterShake = 4f; - [Label("RipperBarShake")] + [Label("$Mods.CalamityMod.Config.EntryTitle.RipperMeterShake")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] [Range(MinMeterShake, MaxMeterShake)] [Increment(1f)] [DrawTicks] [DefaultValue(2f)] - [Tooltip("How much the Rage and Adrenaline Meters shake while in use.\nSet to zero to disable the shaking entirely.")] - public float MeterShake { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.RipperMeterShake")] + public float RipperMeterShake { get; set; } - [Label("RageX")] + [Label("$Mods.CalamityMod.Config.EntryTitle.RageMeterPosX")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] + [Range(0f, 100f)] [DefaultValue(RipperUI.DefaultRagePosX)] - [Tooltip("The X position of the Rage Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.RageMeterPosX")] public float RageMeterPosX { get; set; } - [Label("RageY")] + [Label("$Mods.CalamityMod.Config.EntryTitle.RageMeterPosY")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] + [Range(0f, 100f)] [DefaultValue(RipperUI.DefaultRagePosY)] - [Tooltip("The Y position of the Rage Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.RageMeterPosY")] public float RageMeterPosY { get; set; } - [Label("AdrenalineX")] + [Label("$Mods.CalamityMod.Config.EntryTitle.AdrenalineMeterPosX")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] + [Range(0f, 100f)] [DefaultValue(RipperUI.DefaultAdrenPosX)] - [Tooltip("The X position of the Adrenaline Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.AdrenalineMeterPosX")] public float AdrenalineMeterPosX { get; set; } - [Label("AdrenalineY")] + [Label("$Mods.CalamityMod.Config.EntryTitle.AdrenalineMeterPosY")] [BackgroundColor(192, 54, 64, 192)] [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] + [Range(0f, 100f)] [DefaultValue(RipperUI.DefaultAdrenPosY)] - [Tooltip("The Y position of the Adrenaline Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.AdrenalineMeterPosY")] public float AdrenalineMeterPosY { get; set; } + #endregion - [Header("Boss Rush Curses")] + #region Boss Rush Curses + [Header("$Mods.CalamityMod.Config.SectionTitle.BossRushCurses")] - [Label("BRCurseAccessory")] + [Label("$Mods.CalamityMod.Config.EntryTitle.BossRushRegenCurse")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(false)] - [Tooltip("Limits the player to five accessories during the Boss Rush.")] - public bool BossRushAccessoryCurse { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.BossRushRegenCurse")] + public bool BossRushRegenCurse { get; set; } - [Label("BRCurseHealth")] + [Label("$Mods.CalamityMod.Config.EntryTitle.BossRushDashCurse")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(false)] - [Tooltip("Disables all health regeneration during the Boss Rush.")] - public bool BossRushHealthCurse { get; set; } - - [Label("BRCurseDash")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Disables all dashes during the Boss Rush.")] + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.BossRushDashCurse")] public bool BossRushDashCurse { get; set; } - [Label("BRCurseImmunity")] + [Label("$Mods.CalamityMod.Config.EntryTitle.BossRushIFrameCurse")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(false)] - [Tooltip("During the Boss Rush, being hit twice within three seconds will cause instant death.\nThis effect ignores revives.")] - public bool BossRushImmunityFrameCurse { get; set; } + [Tooltip("$Mods.CalamityMod.Config.EntryTooltip.BossRushIFrameCurse")] + public bool BossRushIFrameCurse { get; set; } + #endregion - public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message) => true; - - - - - public static void LoadConfigLabels(Mod instance) + #region Dynamic Localization (Item Icon Injection) + + // Because it is impossible to know the item IDs of Calamity items until runtime, + // and we have many config titles which use embedded Calamity items, + // we need to dynamically declare those items and inject them as dynamic localization. + // + // TODO -- this doesn't work, see CalamityMod for more info + // if you do fix this, you will need to add _ in front of all entry title keys above + // or alternatively change the mechanism via which the dynamic localizations are injected + // You are not allowed to get registered mod translations in any way + internal static void RegisterDynamicLocalization() { - string[][] _configLabels = new[] + static string EmbedItem(int itemID, string suffix = "") => $"[i:{itemID}] {suffix}"; + + var configLabelItemEmbeds = new KeyValuePair[] { - new [] { "Afterimages", ItemID.SteampunkGoggles.ToString(), "Afterimages" }, - new [] { "MaxParticles", ItemID.FragmentStardust.ToString(), "Maximum particles" }, - new [] { "ScreenshakeOff", instance.Find("WavePounder").Type.ToString(), "Disable Screenshakes" }, - new [] { "StealthInvisibility", instance.Find("StealthHairDye").Type.ToString(), "Stealth Invisibility" }, - new [] { "ShopAlert", ItemID.GoldChest.ToString(), "New Shop Inventory Alert" }, + new("Afterimages", ItemID.SteampunkGoggles), + new("Screenshake", ModContent.ItemType()), + new("ParticleLimit", ItemID.FragmentStardust), + new("StealthInvisibility", ModContent.ItemType()), + new("ShopNewAlert", ItemID.GoldChest), - new [] { "BossHealthBar", instance.Find("BloodOrange").Type.ToString(), "Boss Health Bars" }, - new [] { "BossHealthBarExtra", instance.Find("EncryptedSchematicPlanetoid").Type.ToString(), "Boss Health Bar Extra Info" }, - new [] { "DebuffDisplay", ItemID.FlaskofIchor.ToString(), "Boss and Miniboss Debuff Display" }, - new [] { "CooldownDisplay", instance.Find("NebulousCore").Type.ToString(), "Cooldown Display" }, - new [] { "VanillaCooldownDisplay", ItemID.HealingPotion.ToString(), "Vanilla Cooldowns Display" }, - new [] { "MeterLock", ItemID.GemLockTopaz.ToString(), "Lock Meter Positions" }, + new("BossHealthBarExtraInfo", ModContent.ItemType()), + new("DebuffDisplay", ItemID.FlaskofIchor), + new("CooldownDisplay", ModContent.ItemType()), + new("VanillaCooldownDisplay", ItemID.HealingPotion), + new("MeterPosLock", ItemID.GemLockTopaz), - new [] { "StealthMeter", instance.Find("EclipseMirror").Type.ToString(), "Stealth Meter" }, - new [] { "StealthMeterX", ItemID.LaserRuler.ToString(), "Stealth Meter X Position" }, - new [] { "StealthMeterY", ItemID.LaserRuler.ToString(), "Stealth Meter Y Position" }, + new("StealthMeter", ModContent.ItemType()), + new("StealthMeterPosX", ItemID.LaserRuler), + new("StealthMeterPosY", ItemID.LaserRuler), - new [] { "ChargeMeter", instance.Find("PowerCell").Type.ToString(), "Charge Meter" }, - new [] { "ChargeMeterX", ItemID.LaserRuler.ToString(), "Charge Meter X Position" }, - new [] { "ChargeMeterY", ItemID.LaserRuler.ToString(), "Charge Meter Y Position" }, + new("ChargeMeter", ModContent.ItemType()), + new("ChargeMeterPosX", ItemID.LaserRuler), + new("ChargeMeterPosY", ItemID.LaserRuler), - new [] { "SpeedrunTimer", ItemID.Stopwatch.ToString(), "Speedrun Timer" }, - new [] { "SpeedrunTimerX", ItemID.LaserRuler.ToString(), "Speedrun Timer X Position" }, - new [] { "SpeedrunTimerY", ItemID.LaserRuler.ToString(), "Speedrun Timer Y Position" }, + new("SpeedrunTimer", ItemID.Stopwatch), + new("SpeedrunTimerPosX", ItemID.LaserRuler), + new("SpeedrunTimerPosY", ItemID.LaserRuler), - new [] { "EarlyHMRework", ItemID.Pwnhammer.ToString(), "Early Hardmode Progression Rework" }, - new [] { "Proficiency", instance.Find("MagicLevelMeter").Type.ToString(), "Proficiency" }, - new [] { "BossZen", instance.Find("ZenPotion").Type.ToString(), "Boss Zen" }, - new [] { "NPCNightSpawn", ItemID.ClothierVoodooDoll.ToString(), "Let Town NPCs spawn at night" }, - new [] { "NPCExtraSpawn", ItemID.GuideVoodooDoll.ToString(), "Town NPC Spawn Rate Multiplier" }, - new [] { "BossHPBoost", ItemID.LifeCrystal.ToString(), "Boss Health Percentage Boost" }, + new("EarlyHardmodeProgressionRework", ItemID.Pwnhammer), + new("Proficiency", ModContent.ItemType()), + new("BossZen", ModContent.ItemType()), + new("TownNPCsSpawnAtNight", ItemID.ClothierVoodooDoll), + new("TownNPCSpawnRateMultiplier", ItemID.GuideVoodooDoll), + new("BossHealthBoost", ItemID.LifeCrystal), - new [] { "ExpertDebuffReduction", ItemID.AnkhCharm.ToString(), "Reduce Expert Debuff Durations" }, - new [] { "ChillWaterRework", ItemID.ArcticDivingGear.ToString(), "Rework Chilled Water" }, - new [] { "ExpertSafeTowns", ItemID.Sunflower.ToString(), "Disable Expert Enemy Spawns in Towns" }, - new [] { "RipperBarShake", instance.Find("Revenge").Type.ToString(), "Rage and Adrenaline Meter Shake" }, - new [] { "RageX", ItemID.LaserRuler.ToString(), "Rage Meter X Position" }, - new [] { "RageY", ItemID.LaserRuler.ToString(), "Rage Meter Y Position" }, - new [] { "AdrenalineX", ItemID.LaserRuler.ToString(), "Adrenaline Meter X Position" }, - new [] { "AdrenalineY", ItemID.LaserRuler.ToString(), "Adrenaline Meter Y Position" }, + new("NerfExpertDebuffs", ItemID.AnkhCharm), + new("ChilledWaterRework", ItemID.ArcticDivingGear), + new("ForceTownSafety", ItemID.Sunflower), - new [] { "BRCurseAccessory", ItemID.Shackle.ToString(), "Accessory Curse" }, - new [] { "BRCurseHealth", ItemID.Shackle.ToString(), "Health Curse" }, - new [] { "BRCurseDash", ItemID.Shackle.ToString(), "Dash Curse" }, - new [] { "BRCurseImmunity", ItemID.Shackle.ToString(), "Immunity Frame Curse" } + new("RipperMeterShake", ModContent.ItemType()), + new("RageMeterPosX", ItemID.LaserRuler), + new("RageMeterPosY", ItemID.LaserRuler), + new("AdrenalineMeterPosX", ItemID.LaserRuler), + new("AdrenalineMeterPosY", ItemID.LaserRuler), + + new("BossRushRegenCurse", ItemID.Shackle), + new("BossRushDashCurse", ItemID.Shackle), + new("BossRushIFrameCurse", ItemID.Shackle), }; - foreach (string[] label in _configLabels) + Mod cal = CalamityMod.Instance; + foreach (KeyValuePair kv in configLabelItemEmbeds) { - ModTranslation text = LocalizationLoader.CreateTranslation(label[0]); - text.SetDefault($"[i:" + label[1] + "] "+ label[2]); - LocalizationLoader.AddTranslation(text); + string localizationKey = $"Mods.CalamityMod.Config.EntryTitle.{kv.Key}"; + string baseTooltip = Language.GetText(localizationKey).Value; + string dynamicKey = $"Config.EntryTitle._{kv.Key}"; + ModTranslation newDynTrans = LocalizationLoader.CreateTranslation(cal, dynamicKey); + newDynTrans.SetDefault(EmbedItem(kv.Value, baseTooltip)); + LocalizationLoader.AddTranslation(newDynTrans); } } + #endregion } } diff --git a/CalamityMod.cs b/CalamityMod.cs index cee496e12a..b87506e1b6 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -207,7 +207,10 @@ namespace CalamityMod SetupBossKillTimes(); SetupBossVelocityScalingValues(); CalamityLocalization.AddLocalizations(); - CalamityConfig.LoadConfigLabels(ModContent.GetInstance()); + // TODO -- Item icons are not visible in config tooltips. + // You cannot inject localizations and then RefreshModLanguage without crashing the game instantly. + // You cannot display Calamity items in static localizations because their IDs could change. + // CalamityConfig.RegisterDynamicLocalization(); SchematicManager.Load(); CustomLavaManagement.Load(); Attunement.Load(); diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index c3487d60e1..91380988f1 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -253,7 +253,7 @@ namespace CalamityMod.ILEditing { // A cached delegate is used here instead of direct reflection for performance reasons // since UpdateTime is called every frame. - if (Main.dayTime || CalamityConfig.Instance.CanTownNPCsSpawnAtNight) + if (Main.dayTime || CalamityConfig.Instance.TownNPCsSpawnAtNight) VanillaSpawnTownNPCs(); }); diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index 28d48ed182..a901c3a44d 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -102,7 +102,7 @@ namespace CalamityMod.ILEditing #region Prevention of Slime Rain Spawns When Near Bosses private static void PreventBossSlimeRainSpawns(On.Terraria.NPC.orig_SlimeRainSpawns orig, int plr) { - if (!Main.player[plr].Calamity().bossZen) + if (!Main.player[plr].Calamity().isNearbyBoss && CalamityConfig.Instance.BossZen) orig(plr); } #endregion Prevention of Slime Rain Spawns When Near Bosses diff --git a/Localization/enUS.hjson b/Localization/enUS.hjson index d0b5594cc7..f414705079 100644 --- a/Localization/enUS.hjson +++ b/Localization/enUS.hjson @@ -2,10 +2,105 @@ { CalamityMod: { + Config: + { + MainTitle: "Main Config", + + SectionTitle: + { + "BossRushCurses": "Boss Rush Curses", + "ExpertMaster": "Expert and Master Mode Changes", + "Gameplay": "General Gameplay Changes", + "Graphics": "Graphics Changes", + "Revengeance": "Revengeance Mode Changes", + "UI": "UI Changes", + } + + EntryTitle: + { + "AdrenalineMeterPosX": "Adrenaline Meter X Position", + "AdrenalineMeterPosY": "Adrenaline Meter Y Position", + "Afterimages": "Afterimages", + "BossHealthBarExtraInfo": "Boss Health Bar Extra Info", + "BossHealthBoost": "Boss Health Boost Percentage", + "BossRushDashCurse": "Dashes", + "BossRushIFrameCurse": "Immunity Frames", + "BossRushRegenCurse": "Regeneration", + "BossZen": "Bosses Drastically Reduce Spawn Rates", + "ChargeMeter": "Display Charge Meter", + "ChargeMeterPosX": "Charge Meter X Position", + "ChargeMeterPosY": "Charge Meter Y Position", + "ChilledWaterRework": "Chilled Water Rework", + "CooldownDisplay": "Cooldown Rack Display Mode", + "DebuffDisplay": "Display Enemy Debuffs", + "EarlyHardmodeProgressionRework": "Early Hardmode Progression Rework", + "ForceTownSafety": "Force Town Safety", + "MeterPosLock": "Lock Meter Positions", + "NerfExpertDebuffs": "Remove Increased Debuff Duration", + "ParticleLimit": "Max Particle Limit", + "Proficiency": "Proficiency", + "RageMeterPosX": "Rage Meter X Position", + "RageMeterPosY": "Rage Meter Y Position", + "RipperMeterShake": "Rage and Adrenaline Meter Shake", + "Screenshake": "Screenshake", + "ShopNewAlert": "New Shop Inventory Alerts", + "SpeedrunTimer": "Display Speedrun Timer", + "SpeedrunTimerPosX": "Speedrun Timer X Position", + "SpeedrunTimerPosY": "Speedrun Timer Y Position", + "StealthInvisibility": "Stealth Invisibility", + "StealthMeter": "Display Stealth Meter", + "StealthMeterPosX": "Stealth Meter X Position", + "StealthMeterPosY": "Stealth Meter Y Position", + "TownNPCSpawnRateMultiplier": "Town NPC Spawn Rate Multiplier", + "TownNPCsSpawnAtNight": "Town NPCs Spawn at Night", + "VanillaCooldownDisplay": "Display Vanilla Cooldowns", + } + + EntryTooltip: + { + "AdrenalineMeterPosX": "The X position of the Adrenaline Meter, measured as a % of your screen width.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "AdrenalineMeterPosY": "The Y position of the Adrenaline Meter, measured as a % of your screen height.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "Afterimages": "Enables rendering afterimages for Calamity NPCs, projectiles, etc.\nDisable to improve performance.", + "BossHealthBarExtraInfo": "Adds extra info to Calamity's boss health bar.\nThis displays either the boss's exact health or number of remaining parts or segments.", + "BossHealthBoost": "Globally boosts the health of all bosses by the specified percentage.\nThis stacks with multiplayer boss health boosts.\nDoes not affect bosses that are already spawned.", + "BossRushDashCurse": "Disables all dashes during the Boss Rush.", + "BossRushIFrameCurse": "During the Boss Rush, being hit twice within three seconds will cause instant death.\nThis effect ignores revives.", + "BossRushRegenCurse": "Disables all health regeneration during the Boss Rush.", + "BossZen": "All living bosses will drastically reduce the spawn rates of regular enemies.\nThis also prevents Slime Rain from occurring while a boss is alive.", + "ChargeMeter": "Enables the Charge Meter UI, which displays the current charge of the player's held weapon.\nThe Charge Meter is always hidden if not holding a weapon which requires charge.", + "ChargeMeterPosX": "The X position of the Charge Meter, measured as a % of your screen width.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "ChargeMeterPosY": "The Y position of the Charge Meter, measured as a % of your screen height.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "ChilledWaterRework": "When enabled, water in the Snow and Ice biomes will rapidly drain the player's breath instead of inflicting Chilled.", + "CooldownDisplay": "Adds the Cooldown Rack which displays all important cooldowns right underneath buffs and debuffs.\nSet this to 1 to display the Cooldown Rack in compact mode, and to 0 to hide it entirely.", + "DebuffDisplay": "Adds an array of debuff icons above all bosses and minibosses.", + "EarlyHardmodeProgressionRework": "Demon Altars no longer spawn ores and crimson/corruption blocks when broken.\nWall of Flesh spawns Cobalt and Palladium ore on first kill.\nThe first mech boss you fight has 20% less HP and damage and spawns Mythril and Orichalcum ore on first kill.\nThe second mech boss you fight has 10% less HP and damage and spawns Adamantite and Titanium ore on first kill.\nThe third mech boss spawns Hallowed Ore on first kill", + "ForceTownSafety": "Counteracts Expert and Master Mode allowing enemies to spawn near towns by vastly decreasing spawn rates.\nThis can have unintended side effects such as making critters difficult to find.", + "MeterPosLock": "Prevents clicking on the Stealth, Charge, Rage, and Adrenaline Meters.\nThis stops them from being dragged around with the mouse.", + "NerfExpertDebuffs": "Disables Expert Mode doubling (and Master Mode tripling) the duration of debuffs on the player.\nCalamity is balanced around this setting being enabled.", + "ParticleLimit": "Sets the maximum of particle effects that can exist at once.\nParticles are separate from dust and gores.\nTurn down to improve performance.", + "Proficiency": "Enables the Proficiency system which allows the player to gain slight stat bonuses by persistently using one damage class.\nDisabling the system does not remove levels players already have, but disables their stat bonuses and prevents experience gain.", + "RageMeterPosX": "The X position of the Rage Meter, measured as a % of your screen width.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "RageMeterPosY": "The Y position of the Rage Meter, measured as a % of your screen height.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "RipperMeterShake": "How much the Rage and Adrenaline Meters shake while in use.\nSet to zero to disable the shaking entirely.", + "Screenshake": "Enable or disable all screen-shaking effects.", + "ShopNewAlert": "Adds an icon that appears over Town NPCs when they have new items in their shops.", + "SpeedrunTimer": "Enables an in-game speedrun timer which shows in-game time down to the millisecond.\nA second line displays the time of your most recent boss kill.\nThe time is tracked per player and only counts time while loaded into a world.", + "SpeedrunTimerPosX": "The X position of the Speedrun Timer, measured as a % of your screen width.\nThis must be set manually and cannot be dragged around.", + "SpeedrunTimerPosY": "The Y position of the Speedrun Timer, measured as a % of your screen height.\nThis must be set manually and cannot be dragged around.", + "StealthInvisibility": "Enables players gradually turning invisible as their Rogue Stealth increases.\nThis effect is visually similar to Shroomite armor's stealth.", + "StealthMeter": "Enables the Stealth Meter UI, which shows the player's current stealth level.\nThe Stealth Meter is always hidden if not wearing Rogue armor.", + "StealthMeterPosX": "The X position of the Stealth Meter, measured as a % of your screen width.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "StealthMeterPosY": "The Y position of the Stealth Meter, measured as a % of your screen height.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.", + "TownNPCSpawnRateMultiplier": "Directly multiply the rate at which town NPCs spawn and respawn.\nThis reduces waiting times if a boss or event wipes your whole town.", + "TownNPCsSpawnAtNight": "When enabled, town NPCs can spawn and respawn at night.\nThis includes the Old Man.", + "VanillaCooldownDisplay": "Adds the vanilla debuffs Potion Sickness and Chaos State to the Cooldown Rack.\nThis doesn't remove them from your buff list, but can help with visibility nontheless", + } + } + DamageClassName: { - "RogueDamageClass": "rogue damage", - "AverageDamageClass": "average damage", + RogueDamageClass: "rogue damage", + AverageDamageClass: "average damage", } } } \ No newline at end of file diff --git a/MainMenu/MenuBackground.png b/MainMenu/MenuBackground.png index 6085dbc75b..b05a5e6c1d 100644 Binary files a/MainMenu/MenuBackground.png and b/MainMenu/MenuBackground.png differ diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 7c9dc6e8f8..2ad2489fba 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4604,12 +4604,12 @@ namespace CalamityMod.NPCs spawnRate = (int)(spawnRate * 1.4); maxSpawns = (int)(maxSpawns * 0.4f); } - if (player.Calamity().zen || (CalamityConfig.Instance.DisableExpertTownSpawns && player.townNPCs > 1f && Main.expertMode)) + if (player.Calamity().zen || (CalamityConfig.Instance.ForceTownSafety && player.townNPCs > 1f && Main.expertMode)) { spawnRate = (int)(spawnRate * 2.5); maxSpawns = (int)(maxSpawns * 0.3f); } - if (player.Calamity().bossZen && CalamityConfig.Instance.BossZen) + if (player.Calamity().isNearbyBoss && CalamityConfig.Instance.BossZen) { spawnRate *= 5; maxSpawns = (int)(maxSpawns * 0.001f); diff --git a/Systems/WorldMiscUpdateSystem.cs b/Systems/WorldMiscUpdateSystem.cs index e63ff0e210..d27192e7b7 100644 --- a/Systems/WorldMiscUpdateSystem.cs +++ b/Systems/WorldMiscUpdateSystem.cs @@ -367,9 +367,9 @@ namespace CalamityMod.Systems if (Main.SceneMetrics.WaterCandleCount > 0) spawnRate *= 0.8D; - if (modPlayer.bossZen) + if (modPlayer.isNearbyBoss && CalamityConfig.Instance.BossZen) spawnRate *= 50D; - if (modPlayer.zen || (CalamityConfig.Instance.DisableExpertTownSpawns && player.townNPCs > 1f && Main.expertMode)) + if (modPlayer.zen || (CalamityConfig.Instance.ForceTownSafety && player.townNPCs > 1f && Main.expertMode)) spawnRate *= 2D; if (modPlayer.tranquilityCandle) spawnRate *= 1.67D; diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index c402cc3185..cbe23b7c3a 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -1,11 +1,10 @@ -using CalamityMod.CalPlayer; -using CalamityMod.World; +using System.Collections.Generic; +using System.Text; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using ReLogic.Content; -using System.Collections.Generic; -using System.Text; using Terraria; using Terraria.ModLoader; @@ -13,18 +12,19 @@ namespace CalamityMod.UI { public static class RipperUI { - public const float DefaultRagePosX = 500f; - public const float DefaultRagePosY = 30f; - public const float DefaultAdrenPosX = 650f; - public const float DefaultAdrenPosY = 30f; + public const float DefaultRagePosX = 26.04167f; + public const float DefaultRagePosY = 3f; + public const float DefaultAdrenPosX = 33.8542f; + public const float DefaultAdrenPosY = 3f; + private const float MouseDragEpsilon = 0.05f; // 0.05% private const int RageAnimFrameDelay = 6; private const int RageAnimFrames = 10; private const int AdrenAnimFrameDelay = 5; private const int AdrenAnimFrames = 10; - public static Vector2 rageDrawPos = new Vector2(DefaultRagePosX, DefaultRagePosY); - public static Vector2 adrenDrawPos = new Vector2(DefaultAdrenPosX, DefaultAdrenPosY); + private static Vector2 rageDrawPos; + private static Vector2 adrenDrawPos; private static Vector2? rageDragOffset = null; private static Vector2? adrenDragOffset = null; private static Vector2 pearlOffsetLeft = Vector2.Zero; @@ -353,7 +353,7 @@ namespace CalamityMod.UI private static Vector2 GetShakeOffset() { - float shake = CalamityConfig.Instance.MeterShake; + float shake = CalamityConfig.Instance.RipperMeterShake; float shakeX = Main.rand.NextFloat(-shake, shake); float shakeY = Main.rand.NextFloat(-shake, shake); return new Vector2(shakeX, shakeY); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 5b7c8105ef..dfdc9cd07d 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; +using System; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; -using System; using Terraria; using Terraria.ModLoader; @@ -10,88 +10,135 @@ namespace CalamityMod.UI { public class StealthUI { - public static Vector2 DrawPosition = new Vector2(CalamityConfig.Instance.StealthMeterPosX, CalamityConfig.Instance.StealthMeterPosY); - public static Vector2 Offset = DrawPosition; + internal const float DefaultStealthPosX = 42.7083f; + internal const float DefaultStealthPosY = 56.0000f; + private const float MouseDragEpsilon = 0.05f; // 0.05% + + private static Vector2? dragOffset = null; + private static Texture2D edgeTexture, indicatorTexture, barTexture, fullBarTexture; + + internal static void Load() + { + edgeTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeter").Value; + indicatorTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator").Value; + barTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeterBar").Value; + fullBarTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeterBarFull").Value; + + Reset(); + } + + internal static void Unload() + { + Reset(); + edgeTexture = indicatorTexture = barTexture = fullBarTexture = null; + } + + private static void Reset() + { + dragOffset = null; + } + public static void Draw(SpriteBatch spriteBatch, Player player) { - if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) - { - DrawPosition.X = Main.screenWidth / 2f; - DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; - } + // Sanity check the planned position before drawing + Vector2 screenRatioPosition = new Vector2(CalamityConfig.Instance.StealthMeterPosX, CalamityConfig.Instance.StealthMeterPosY); + if (screenRatioPosition.X < 0f || screenRatioPosition.X > 100f) + screenRatioPosition.X = DefaultStealthPosX; + if (screenRatioPosition.Y < 0f || screenRatioPosition.Y > 100f) + screenRatioPosition.Y = DefaultStealthPosY; + + // Convert the screen ratio position to an absolute position in pixels + // Cast to integer to prevent blurriness which results from decimal pixel positions + float uiScale = Main.UIScale; + Vector2 screenPos = screenRatioPosition; + screenPos.X = (int)(screenPos.X * 0.01f * Main.screenWidth); + screenPos.Y = (int)(screenPos.Y * 0.01f * Main.screenHeight); + CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.stealthUIAlpha <= 0f || !CalamityConfig.Instance.StealthBar || modPlayer.rogueStealthMax <= 0f || !modPlayer.wearingRogueArmor) + + // If not drawing the stealth meter, save its latest position to config and leave. + if (modPlayer.stealthUIAlpha <= 0f || !CalamityConfig.Instance.StealthMeter || modPlayer.rogueStealthMax <= 0f || !modPlayer.wearingRogueArmor) { - if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) + if (CalamityConfig.Instance.StealthMeterPosX != screenRatioPosition.X) { - CalamityConfig.Instance.StealthMeterPosX = DrawPosition.X; + CalamityConfig.Instance.StealthMeterPosX = screenRatioPosition.X; CalamityMod.SaveConfig(CalamityConfig.Instance); } - if (CalamityConfig.Instance.StealthMeterPosY != DrawPosition.Y) + if (CalamityConfig.Instance.StealthMeterPosY != screenRatioPosition.Y) { - CalamityConfig.Instance.StealthMeterPosY = DrawPosition.Y; + CalamityConfig.Instance.StealthMeterPosY = screenRatioPosition.Y; CalamityMod.SaveConfig(CalamityConfig.Instance); } return; } - Texture2D edgeTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeter").Value; - Texture2D indicatorTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator").Value; - Texture2D barTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeterBar").Value; - Texture2D fullBarTexture = ModContent.Request("CalamityMod/ExtraTextures/UI/StealthMeterBarFull").Value; - float uiScale = Main.UIScale; - float offset = (edgeTexture.Width - barTexture.Width) * 0.5f; - spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + + float offset = (edgeTexture.Width - barTexture.Width) * 0.5f; + spriteBatch.Draw(edgeTexture, screenPos, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + + // If SS is available, display the explicit indication thereof if (modPlayer.StealthStrikeAvailable()) - { - spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - } + spriteBatch.Draw(indicatorTexture, screenPos, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); float completionRatio = modPlayer.rogueStealth / modPlayer.rogueStealthMax; Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; - spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition + new Vector2(offset * uiScale, 0), barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + spriteBatch.Draw(full ? fullBarTexture : barTexture, screenPos + new Vector2(offset * uiScale, 0), barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); - Rectangle stealthBar = Utils.CenteredRectangle(DrawPosition, edgeTexture.Size() * uiScale); + Rectangle mouseHitbox = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); + Rectangle stealthBar = Utils.CenteredRectangle(screenPos, edgeTexture.Size() * uiScale); - if (stealthBar.Intersects(mouse)) + // If the mouse is on top of the meter, show the player's exact numeric stealth. + if (stealthBar.Intersects(mouseHitbox)) { if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) { Main.LocalPlayer.mouseInterface = true; - int stealthInt = (int)Math.Round(modPlayer.rogueStealth * 100f); - int maxStealthInt = (int)Math.Round(modPlayer.rogueStealthMax * 100f); + string stealthStr = (100f * modPlayer.rogueStealth).ToString("n2"); + string maxStealthStr = (100f * modPlayer.rogueStealthMax).ToString("n2"); //only way I got this to show up consistently, otherwise it fucked up and showed up anywhere onscreen lol. - Main.instance.MouseText("Stealth: " + stealthInt + "/" + maxStealthInt + "", 0, 0, -1, -1, -1, -1); + Main.instance.MouseText($"Stealth: {stealthStr}/{maxStealthStr}", 0, 0, -1, -1, -1, -1); modPlayer.stealthUIAlpha = MathHelper.Lerp(modPlayer.stealthUIAlpha, 0.25f, 0.035f); } } + + // Handle mouse dagging if (!CalamityConfig.Instance.MeterPosLock) { - if (stealthBar.Intersects(mouse)) + Vector2 newScreenRatioPosition = screenRatioPosition; + if (stealthBar.Intersects(mouseHitbox)) { - if (Mouse.GetState().LeftButton == ButtonState.Pressed) - { - Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - if (Mouse.GetState().LeftButton == ButtonState.Released) - { - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - } + MouseState ms = Mouse.GetState(); + Vector2 mousePos = new Vector2(ms.X, ms.Y); - if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) - { - CalamityConfig.Instance.StealthMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - if (CalamityConfig.Instance.StealthMeterPosY != DrawPosition.Y) - { - CalamityConfig.Instance.StealthMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityConfig.Instance); + // As long as the mouse button is held down, drag the meter along with an offset. + if (ms.LeftButton == ButtonState.Pressed) + { + // If the drag offset doesn't exist yet, create it. + if (!dragOffset.HasValue) + dragOffset = mousePos - screenPos; + + // Given the mouse's absolute current position, compute where the corner of the stealth bar should be based on the original drag offset. + Vector2 newCorner = mousePos - dragOffset.GetValueOrDefault(Vector2.Zero); + + // Convert the new corner position into a screen ratio position. + newScreenRatioPosition.X = (100f * newCorner.X) / Main.screenWidth; + newScreenRatioPosition.Y = (100f * newCorner.Y) / Main.screenHeight; + } + + // Compute the change in position. If it is large enough, actually move the meter + Vector2 delta = newScreenRatioPosition - screenRatioPosition; + if (Math.Abs(delta.X) >= MouseDragEpsilon || Math.Abs(delta.Y) >= MouseDragEpsilon) + { + CalamityConfig.Instance.StealthMeterPosX = newScreenRatioPosition.X; + CalamityConfig.Instance.StealthMeterPosY = newScreenRatioPosition.Y; + } + + // When the mouse is released, save the config and destroy the drag offset. + if (ms.LeftButton == ButtonState.Released) + { + dragOffset = null; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } } } }