From 4df35cff847c52779ebbac802ab71802dddca90d Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 5 Nov 2025 17:51:36 -0600 Subject: [PATCH 01/22] spooky! --- CalPlayer/CalamityPlayer.cs | 27 ++++- CalPlayer/CalamityPlayerMiscEffects.cs | 59 +--------- Effects/CalamityShaders.cs | 8 ++ Effects/DozeLightingShader.fx | 15 +++ Effects/DozeLightingShader.xnb | Bin 0 -> 784 bytes Graphics/EnhancedDarknessSystem.cs | 103 ++++++++++++++++++ Items/Accessories/StatMeter.cs | 4 +- .../Mods.CalamityMod.Items.Accessories.hjson | 8 +- ModSupport/ModCalls.cs | 18 ++- Projectiles/Pets/BabyGhostBell.cs | 3 + Projectiles/Pets/OceanSpirit.cs | 3 + Systems/Graphic/LightingEffectsSystem.cs | 21 ---- Utilities/PlayerUtils.cs | 90 +++++---------- 13 files changed, 204 insertions(+), 155 deletions(-) create mode 100644 Effects/DozeLightingShader.fx create mode 100644 Effects/DozeLightingShader.xnb create mode 100644 Graphics/EnhancedDarknessSystem.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c7a64e729e..8c52399b6a 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -13,6 +13,7 @@ using CalamityMod.DataStructures; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.FluidSimulation; +using CalamityMod.Graphics; using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; @@ -222,7 +223,6 @@ namespace CalamityMod.CalPlayer #endregion #region External variables -- Not used by Calamity, only via Mod.Call or reflection - public int externalAbyssLight = 0; public float externalBreathTickBoost = 0f; public float externalFlightTimeMultBoost = 0f; @@ -709,6 +709,12 @@ namespace CalamityMod.CalPlayer public int abyssLifeLostAtZeroBreathStat = 0; /// The amount which defense is reduced while in the Abyss. public int abyssDefenseLossStat = 0; + + //These stats are for the abyss darkness system. + public float abyssDarkness = 0f; + public float abyssPlayerGlowMultiplier = 1f; + public float abyssFlashlightWidthMultiplier = 1f; + public float darknessIntensity = 0; #endregion #region Permanent Buff @@ -2068,7 +2074,6 @@ namespace CalamityMod.CalPlayer DashID = string.Empty; - externalAbyssLight = 0; externalBreathTickBoost = 0f; externalFlightTimeMultBoost = 0f; externalRageEnabled = externalAdrenalineEnabled = null; @@ -2796,6 +2801,14 @@ namespace CalamityMod.CalPlayer disablePerfCystSpawns = false; disableVoodooSpawns = false; + + #region Abyss + abyssDarkness = 0; + abyssPlayerGlowMultiplier = 1; + abyssFlashlightWidthMultiplier = 1; + darknessIntensity = 0; + #endregion + EnchantHeldItemEffects(Player, Player.Calamity(), Player.ActiveItem()); } #endregion @@ -2924,7 +2937,6 @@ namespace CalamityMod.CalPlayer rOfResilienceEffect = 0; demonSwordKillMode = false; - externalAbyssLight = 0; externalBreathTickBoost = 0f; externalFlightTimeMultBoost = 0f; externalColdImmunity = externalHeatImmunity = false; @@ -4526,7 +4538,16 @@ namespace CalamityMod.CalPlayer public override void PostUpdate() { + if (ZoneAbyss && Main.netMode != NetmodeID.Server) + { + //Main aura + EnhancedDarknessSystem.lights.Add(new() { center = Player.Center, rotation = 0, scale = 4 * abyssPlayerGlowMultiplier, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); + + //Flashlight + EnhancedDarknessSystem.lights.Add(new() { center = Player.Center + Player.DirectionTo(mouseWorld) * 750f, rotation = Player.DirectionTo(Main.MouseWorld).ToRotation() - MathHelper.PiOver2, vectorScale = new Vector2(0.75f * abyssFlashlightWidthMultiplier, 0.75f), texture = Request("CalamityMod/Particles/BloomLineFade") }); + } + if (subtitletext != null) { if (!subtitletext.active) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 9dfd0ab0f6..7e09581eb2 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3040,7 +3040,7 @@ namespace CalamityMod.CalPlayer #region Abyss Effects private void AbyssEffects() { - int lightStrength = Player.GetCurrentAbyssLightLevel(); + Player.SetAbyssLightLevels(); if (ZoneAbyss) { @@ -3058,42 +3058,7 @@ namespace CalamityMod.CalPlayer double depthRatioFromAbyssLayer1 = playerAbyssDepthFromLayer1 / totalAbyssDepthFromLayer1; // Darkness strength scales smoothly with how deep you are. - float darknessStrength = (float)depthRatio; - - // Reduce the power of abyss darkness based on your light level. - float multiplier = 1f; - switch (lightStrength) - { - case 0: - break; - case 1: - multiplier = 0.85f; - break; - case 2: - multiplier = 0.7f; - break; - case 3: - multiplier = 0.55f; - break; - case 4: - multiplier = 0.4f; - break; - case 5: - multiplier = 0.25f; - break; - case 6: - multiplier = 0.15f; - break; - case 7: - multiplier = 0.1f; - break; - default: - multiplier = 0.05f; - break; - } - - // Modify darkness variable - caveDarkness = darknessStrength * multiplier; + darknessIntensity = abyssDarkness + (float)depthRatio * 3; // Nebula Headcrab darkness effect if (!Player.headcovered) @@ -3233,26 +3198,6 @@ namespace CalamityMod.CalPlayer // Reduce the power of Signus darkness based on your light level. float multiplier = 1f; - switch (Main.LocalPlayer.GetCurrentAbyssLightLevel()) - { - case 0: - break; - case 1: - case 2: - multiplier = 0.75f; - break; - case 3: - case 4: - multiplier = 0.5f; - break; - case 5: - case 6: - multiplier = 0.25f; - break; - default: - multiplier = 0f; - break; - } float signusDarkness = signusLifeRatio * multiplier; darkRatio = MathHelper.Clamp(signusDarkness, 0f, 1f); diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 83d6559fb6..2cd7e2f594 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -213,6 +213,11 @@ namespace CalamityMod.Effects #endregion #region Doze's Shaders + /// + /// The shader used for Abyss's custom light system. + /// Basically works by turning textures into an opacity mask + /// + internal static Effect DozeLightingShader; internal static Effect FlipScreenShader; #endregion @@ -456,6 +461,9 @@ namespace CalamityMod.Effects #endregion #region Loading Doze's Shaders + DozeLightingShader = LoadShader("DozeLightingShader"); + RegisterMiscShader(DozeLightingShader, "ShadowPass", "DozeLightingShader"); + FlipScreenShader = LoadShader("ScreenShaders/FlipScreen"); RegisterScreenShader(FlipScreenShader, "FlipTheScreen", "FlipScreen",EffectPriority.VeryHigh); #endregion diff --git a/Effects/DozeLightingShader.fx b/Effects/DozeLightingShader.fx new file mode 100644 index 0000000000..21375981f2 --- /dev/null +++ b/Effects/DozeLightingShader.fx @@ -0,0 +1,15 @@ +sampler uImage0 : register(s0); +float uOpacity; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 baseColor = tex2D(uImage0, coords); + return float4(0, 0, 0, (1 - baseColor.x) * uOpacity); +} +technique Technique1 +{ + pass ShadowPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/DozeLightingShader.xnb b/Effects/DozeLightingShader.xnb new file mode 100644 index 0000000000000000000000000000000000000000..5016f55158b8f81de7c2d1e438d8a5e3318387f1 GIT binary patch literal 784 zcmZ`%!A{#i5S;}gOsNzO9C|?N9;p;riAk#D5LF~CP1Ure5Ks=4(Bf>cMPj>aTY+1+ z^#-Uv;Cn87K>wjX!3XpUaA%x#lnY~x-+QyOJF}zhe{D?)Y-<&O-Lo&Qt^Cj*MrPj= z=7ADpIq}t{+4j9idXf2IIFxpDB*j3g5`QlHqY{DR+F^;GN)@`k*Q}al`bxYVkD^$~ zrYGY_iBX9k#^)o~{w%M1{-yMq^{QnL>*umEkhOBHwg+U)SpoRF`R~tGCg(r4kv`pN z{Q_|feMjpY3?%WVvAB?Bzzb&9(MZ6w6W>6OzXif}qifQ%Rz#mrg-jl6FM`4xITw>5Z)x%AC#F{9aRMkg(= z>68To;hA+-hQ&MKyGL($r+eJxG(o9&+aCw+2uZ`V-kOb?Wm@%W6}|%$7!(tn&b!57 zNM6s|oMPPv&F{b{CavsBMT|c_fbp2%UFbcdh8yfVDP-CpO`c#3Q`V;pPUhUm_D*S{ F{{i=zgfRdB literal 0 HcmV?d00001 diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs new file mode 100644 index 0000000000..b06bbf4e84 --- /dev/null +++ b/Graphics/EnhancedDarknessSystem.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Graphics.Light; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics +{ + public class EnhancedDarknessSystem : ModSystem + { + public class LightSource + { + public Asset texture; + public float scale = 1; + public Vector2 vectorScale = Vector2.One; + public Vector2 center = Main.LocalPlayer.Center; + public float rotation = 0; + } + ManagedRenderTarget rt = null; + + public static List lights = new(); + public override void OnModLoad() + { + On_Main.DrawInterface += DrawShadows; + On_LightingEngine.UpdateLightDecay += AdjustTransmissiveness; + RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; + rt = new ManagedRenderTarget(true, ManagedRenderTarget.CreateScreenSizedTarget); + } + + private void AdjustTransmissiveness(On_LightingEngine.orig_UpdateLightDecay orig, LightingEngine self) + { + orig(self); + FieldInfo field = typeof(LightingEngine).GetField("_workingLightMap", BindingFlags.Instance | BindingFlags.NonPublic); + + if (field != null) + { + var mp = Main.LocalPlayer.Calamity(); + var map = (LightMap)field.GetValue(self); + if (mp.ZoneAbyss) + { + //This converts the light decay amount from the amount it normally is in water into the amount it normally is in air, depending on the intensity of the abyss darkness. + //This is to offset the abyss darkness system to make the parts that are supposed to be visible easier to see. + //Dividing by 0.91 brings the water back to 100% transmissiveness with the original color + map.LightDecayThroughWater = Vector3.Lerp(map.LightDecayThroughWater, (map.LightDecayThroughWater / 0.91f) * 0.95f, MathHelper.Clamp(mp.darknessIntensity, 0, 1)); + } + } + } + + private void PrepareTargets() + { + //This system works by drawing all the light sources additively onto a plain black RenderTarget. + //The shader then uses this as an opacity mask, where black = opaque and white = transparent. + var gd = Main.instance.GraphicsDevice; + gd.SetRenderTarget(rt); + gd.Clear(Color.Black); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + foreach (var item in lights) + { + Main.spriteBatch.Draw(item.texture.Value, item.center - Main.screenPosition, null, Color.White, item.rotation, item.texture.Size() * 0.5f, item.vectorScale * item.scale, SpriteEffects.None, 0); + } + Main.spriteBatch.End(); + gd.SetRenderTarget(null); + } + private void DrawShadows(On_Main.orig_DrawInterface orig, Main self, GameTime gameTime) + { + var mp = Main.LocalPlayer.Calamity(); + if (mp.darknessIntensity <= 0) + { + orig(self, gameTime); + return; + } + var gd = Main.graphics.GraphicsDevice; + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.EnterShaderRegion(); + var shader = GameShaders.Misc["CalamityMod:DozeLightingShader"]; + var abyssDarkness = Utils.Remap(Main.LocalPlayer.Center.Y, (float)Main.rockLayer * 16f, Main.UnderworldLayer * 16f, 0, 3, true); + shader.UseOpacity(mp.darknessIntensity); + shader.Apply(); + Main.spriteBatch.Draw(rt, Main.screenLastPosition - Main.screenPosition, Color.White); + Main.spriteBatch.ExitShaderRegion(); + Main.spriteBatch.End(); + orig(self, gameTime); + } + + public override void OnWorldUnload() + { + lights.Clear(); + } + + public override void PreUpdateEntities() + { + //Every frame, the light sources are determined by what was added on that frame only. Therefore, we reset the light list every frame. + lights.Clear(); + } + + } +} diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 10edb5b418..24e0269642 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -222,7 +222,9 @@ namespace CalamityMod.Items.Accessories // Detailed Abyss stats only render if the player is in the Abyss. string stats4 = "\n" + (!modPlayer.ZoneAbyss ? this.GetLocalizedValue("AbyssStatsHidden") : this.GetLocalization("AbyssStats").Format( - player.GetCurrentAbyssLightLevel(), + modPlayer.abyssDarkness, + modPlayer.abyssPlayerGlowMultiplier, + modPlayer.abyssFlashlightWidthMultiplier, TwoPlaces(modPlayer.abyssBreathLossRateStat), modPlayer.abyssLifeLostAtZeroBreathStat, modPlayer.abyssDefenseLossStat)); diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 60b3c0f0b4..1e8d4dc1a2 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1821,10 +1821,10 @@ StatMeter: { MiscStats: Aggro: {0} | Luck: {1}% AbyssStats: ''' - Abyss Light Strength: {0} - Breath Loss Rate: {1} - Life Lost Per Tick at Zero Breath: {2} - Defense Lost From Pressure: {3} + Abyss Darkness: {0} | Player Glow: {1}x | Flashlight: {2}x + Breath Loss Rate: {3} + Life Lost Per Tick at Zero Breath: {4} + Defense Lost From Pressure: {5} ''' AbyssStatsHidden: Abyss stats are only displayed while in the Abyss } diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 9d2985bac3..49bee82e11 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -663,12 +663,17 @@ namespace CalamityMod #endregion #region Other Player Stats - public static int GetLightStrength(Player p) => p?.GetCurrentAbyssLightLevel() ?? 0; - - public static void AddAbyssLightStrength(Player p, int add) + public static float GetDarknessIntensity(Player p) { if (p != null) - p.Calamity().externalAbyssLight += add; + return p.Calamity().darknessIntensity; + return 0; + } + + public static void AddAbyssLightStrength(Player p, float add) + { + if (p != null) + p.Calamity().abyssDarkness -= add; } public static void AddBreathTick(Player p, float add) @@ -1206,11 +1211,14 @@ namespace CalamityMod case "GetAbyssLight": case "GetAbyssLightLevel": case "GetAbyssLightStrength": + case "GetDarkness": + case "GetAbyssDarkness": + case "GetDarknessIntensity": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int."); - return GetLightStrength(castPlayer(args[1])); + return GetDarknessIntensity(castPlayer(args[1])); case "AddLight": case "AddLightLevel": diff --git a/Projectiles/Pets/BabyGhostBell.cs b/Projectiles/Pets/BabyGhostBell.cs index ec696d2407..4556e2a2a7 100644 --- a/Projectiles/Pets/BabyGhostBell.cs +++ b/Projectiles/Pets/BabyGhostBell.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.Graphics; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -46,6 +48,7 @@ namespace CalamityMod.Projectiles.Pets underwater = Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); if (underwater) { + EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 3, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); Lighting.AddLight(Projectile.Center, 0.3f, 0.9f, 1.5f); } else diff --git a/Projectiles/Pets/OceanSpirit.cs b/Projectiles/Pets/OceanSpirit.cs index 233fb80d29..600d1cf18d 100644 --- a/Projectiles/Pets/OceanSpirit.cs +++ b/Projectiles/Pets/OceanSpirit.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; +using CalamityMod.Graphics; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -76,6 +78,7 @@ namespace CalamityMod.Projectiles.Pets underwater = player.IsUnderwater(); if (underwater) { + EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 6, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); if (Projectile.frame == 16) Projectile.frame = 0; if (sleepyTimer > 0) diff --git a/Systems/Graphic/LightingEffectsSystem.cs b/Systems/Graphic/LightingEffectsSystem.cs index 1bc1a1631b..8f4c75e59f 100644 --- a/Systems/Graphic/LightingEffectsSystem.cs +++ b/Systems/Graphic/LightingEffectsSystem.cs @@ -36,28 +36,7 @@ namespace CalamityMod.Systems { float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax); - // Reduce the power of Signus darkness based on your light level. float multiplier = 1f; - switch (Main.LocalPlayer.GetCurrentAbyssLightLevel()) - { - case 0: - break; - case 1: - case 2: - multiplier = 0.75f; - break; - case 3: - case 4: - multiplier = 0.5f; - break; - case 5: - case 6: - multiplier = 0.25f; - break; - default: - multiplier = 0f; - break; - } // Total darkness float signusDarkness = signusLifeRatio * multiplier; diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 44011b1330..d5df797029 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -170,82 +170,44 @@ namespace CalamityMod /// Calculates and returns the player's total light strength. This is used for Abyss darkness, among other things.
/// The Stat Meter also reports this stat. /// - /// The player's total light strength. - public static int GetCurrentAbyssLightLevel(this Player player) + public static void SetAbyssLightLevels(this Player player) { CalamityPlayer mp = player.Calamity(); - int light = mp.externalAbyssLight; bool underwater = player.IsUnderwater(); bool miningHelmet = player.head == ArmorIDs.Head.MiningHelmet || player.head == ArmorIDs.Head.UltraBrightHelmet; - - // The campfire bonus does not apply while in the Abyss. - if (!mp.ZoneAbyss && (player.HasBuff(BuffID.Campfire) || Main.SceneMetrics.HasCampfire)) - light += 1; - if (mp.camper) // inherits Campfire so it is +2 in practice - light += 1; + //Things that include darkness multipliers + if (mp.camper) + mp.abyssPlayerGlowMultiplier += Utils.Remap(player.velocity.Length(), 0, 5, 1, 0); if (miningHelmet) - light += 1; - if (player.hasMagiluminescence) - light += 1; - if (player.lightOrb) - light += 1; - if (player.crimsonHeart) - light += 1; - if (player.magicLantern) - light += 1; + mp.abyssPlayerGlowMultiplier += 0.2f; + if (player.nightVision) + mp.abyssDarkness -= 0.4f; if (mp.giantPearl) - light += 1; - if (mp.radiator) - light += 1; - if (mp.bendyPet) - light += 1; - if (mp.sparks) - light += 1; - if (mp.thiefsDime) - light += 1; + mp.abyssPlayerGlowMultiplier += 0.2f; if (mp.fathomSwarmerVisage) - light += 1; + { + mp.abyssDarkness -= 0.2f; + mp.abyssPlayerGlowMultiplier += 0.2f; + mp.abyssFlashlightWidthMultiplier += 0.5f; + } if (mp.aquaticHeart) - light += 1; - if (mp.purity) // does not stack with downgrades - light += 2; - else if (mp.rOoze || mp.aAmpoule) // the two "yellow lights" do not stack with each other - light += 1; - if (mp.aquaticEmblem && underwater) - light += 1; - if (player.arcticDivingGear && underwater) // inherited by abyssal diving gear/suit. jellyfish necklace is inherited so arctic diving gear is really +2 - light += 1; + mp.abyssDarkness -= 0.1f; if (mp.jellyfishNecklace && underwater) // inherited by jellyfish diving gear and higher - light += 1; + mp.abyssPlayerGlowMultiplier += 0.2f; if (mp.reaverExplore) - light += 2; + { + mp.abyssDarkness -= 0.2f; + mp.abyssPlayerGlowMultiplier += 0.2f; + mp.abyssFlashlightWidthMultiplier += 0.5f; + } if (mp.shine) - light += 2; - if (mp.blazingCore) - light += 2; - if (player.redFairy || player.greenFairy || player.blueFairy) - light += 2; - if (mp.babyGhostBell) - light += underwater ? 2 : 1; - if (player.petFlagDD2Ghost) - light += 2; - if (mp.sirenPet) - light += underwater ? 3 : 1; - if (player.petFlagPumpkingPet) - light += 3; - if (player.petFlagGolemPet) - light += 3; - if (player.petFlagFairyQueenPet) - light += 3; - if (player.wisp) - light += 3; - if (player.suspiciouslookingTentacle) - light += 3; + mp.abyssPlayerGlowMultiplier += 0.2f; + if (mp.babyGhostBell && underwater) + mp.abyssDarkness -= 0.1f; + if (mp.sirenPet && underwater) + mp.abyssDarkness -= 0.2f; if (mp.littleLightPet) - light += 3; - if (mp.profanedCrystalBuffs && !mp.ZoneAbyss) - light += (Main.dayTime || player.lavaWet) ? 2 : 1; // not sure how you'd be in lava in the abyss but go ham I guess - return light; + mp.abyssDarkness -= 0.4f; } /// From 31589436fbacf22e145c6b9301e4c8d88413a149 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 12 Nov 2025 19:39:19 -0600 Subject: [PATCH 02/22] hiding ui no longer hides the darkness, light pets glow --- Graphics/EnhancedDarknessSystem.cs | 50 ++++++++++++++----------- Projectiles/CalamityGlobalProjectile.cs | 4 ++ 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs index b06bbf4e84..3db07f8239 100644 --- a/Graphics/EnhancedDarknessSystem.cs +++ b/Graphics/EnhancedDarknessSystem.cs @@ -1,11 +1,10 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Reflection; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.Graphics.Effects; using Terraria.Graphics.Light; using Terraria.Graphics.Shaders; using Terraria.ModLoader; @@ -27,12 +26,38 @@ namespace CalamityMod.Graphics public static List lights = new(); public override void OnModLoad() { - On_Main.DrawInterface += DrawShadows; + On_OverlayManager.Draw += DrawShadowOverlay; On_LightingEngine.UpdateLightDecay += AdjustTransmissiveness; RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; rt = new ManagedRenderTarget(true, ManagedRenderTarget.CreateScreenSizedTarget); } + private void DrawShadowOverlay(On_OverlayManager.orig_Draw orig, OverlayManager self, SpriteBatch spriteBatch, RenderLayers layer, bool beginSpriteBatch) + { + orig(self, spriteBatch, layer, beginSpriteBatch); + + //This ensures that the shadows only draw + // - In the world + // - Right before UI is drawn (and right before the hideUI check), as that's where RenderLayers.All is drawn + // - + if (Main.gameMenu || layer != RenderLayers.All || Main.LocalPlayer.Calamity().darknessIntensity <= 0) + return; + var mp = Main.LocalPlayer.Calamity(); + + var gd = Main.graphics.GraphicsDevice; + Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () => + { + Main.spriteBatch.EnterShaderRegion(); + var shader = GameShaders.Misc["CalamityMod:DozeLightingShader"]; + var abyssDarkness = Utils.Remap(Main.LocalPlayer.Center.Y, (float)Main.rockLayer * 16f, Main.UnderworldLayer * 16f, 0, 3, true); + shader.UseOpacity(mp.darknessIntensity); + shader.Apply(); + Main.spriteBatch.Draw(rt, Main.screenLastPosition - Main.screenPosition, Color.White); + Main.spriteBatch.ExitShaderRegion(); + }); + } + + private void AdjustTransmissiveness(On_LightingEngine.orig_UpdateLightDecay orig, LightingEngine self) { orig(self); @@ -69,23 +94,6 @@ namespace CalamityMod.Graphics } private void DrawShadows(On_Main.orig_DrawInterface orig, Main self, GameTime gameTime) { - var mp = Main.LocalPlayer.Calamity(); - if (mp.darknessIntensity <= 0) - { - orig(self, gameTime); - return; - } - var gd = Main.graphics.GraphicsDevice; - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - Main.spriteBatch.EnterShaderRegion(); - var shader = GameShaders.Misc["CalamityMod:DozeLightingShader"]; - var abyssDarkness = Utils.Remap(Main.LocalPlayer.Center.Y, (float)Main.rockLayer * 16f, Main.UnderworldLayer * 16f, 0, 3, true); - shader.UseOpacity(mp.darknessIntensity); - shader.Apply(); - Main.spriteBatch.Draw(rt, Main.screenLastPosition - Main.screenPosition, Color.White); - Main.spriteBatch.ExitShaderRegion(); - Main.spriteBatch.End(); - orig(self, gameTime); } public override void OnWorldUnload() diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 622057199c..d9547530f7 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -54,6 +54,7 @@ using Terraria.Utilities; using Terraria.WorldBuilding; using static Terraria.ModLoader.ModContent; using NanotechProjectile = CalamityMod.Projectiles.Typeless.Nanotech; +using CalamityMod.Graphics; namespace CalamityMod.Projectiles { @@ -375,6 +376,9 @@ namespace CalamityMod.Projectiles #region Pre AI public override bool PreAI(Projectile projectile) { + if (ProjectileID.Sets.LightPet[projectile.type]) + EnhancedDarknessSystem.lights.Add(new() { center = projectile.Center, texture = ModContent.Request("CalamityMod/Particles/BloomCircle"), scale = 1 }); + if (projectile.bobber && projectile.type != ModContent.ProjectileType() && RunFishingMinigames(projectile)) return false; //Reset the Homing Target immediately before AI can re-set it on applicable projectiles From a0e3915d441a4dd6bbc790229a5aee64b1400baf Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 26 Nov 2025 21:04:29 -0600 Subject: [PATCH 03/22] limiting lights to the abyss & some cleanup --- CalPlayer/CalamityPlayer.cs | 4 ++-- Graphics/EnhancedDarknessSystem.cs | 14 +++++++++++--- Projectiles/CalamityGlobalProjectile.cs | 4 +++- Projectiles/Pets/BabyGhostBell.cs | 3 ++- Projectiles/Pets/OceanSpirit.cs | 3 ++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 9c9a9d81fb..eed27cd808 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4532,10 +4532,10 @@ namespace CalamityMod.CalPlayer if (ZoneAbyss && Main.netMode != NetmodeID.Server) { //Main aura - EnhancedDarknessSystem.lights.Add(new() { center = Player.Center, rotation = 0, scale = 4 * abyssPlayerGlowMultiplier, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); + EnhancedDarknessSystem.lights.Add(new(center: Player.Center, scale: 4 * abyssPlayerGlowMultiplier)); //Flashlight - EnhancedDarknessSystem.lights.Add(new() { center = Player.Center + Player.DirectionTo(mouseWorld) * 750f, rotation = Player.DirectionTo(Main.MouseWorld).ToRotation() - MathHelper.PiOver2, vectorScale = new Vector2(0.75f * abyssFlashlightWidthMultiplier, 0.75f), texture = Request("CalamityMod/Particles/BloomLineFade") }); + EnhancedDarknessSystem.lights.Add(new(center: Player.Center + Player.DirectionTo(mouseWorld) * 750f, rotation: Player.DirectionTo(Main.MouseWorld).ToRotation() - MathHelper.PiOver2, vectorScale: new Vector2(0.75f * abyssFlashlightWidthMultiplier, 0.75f), texture: Request("CalamityMod/Particles/BloomLineFade") )); } diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs index 3db07f8239..d8b8d0c166 100644 --- a/Graphics/EnhancedDarknessSystem.cs +++ b/Graphics/EnhancedDarknessSystem.cs @@ -20,6 +20,17 @@ namespace CalamityMod.Graphics public Vector2 vectorScale = Vector2.One; public Vector2 center = Main.LocalPlayer.Center; public float rotation = 0; + + public LightSource() { } + + public LightSource(Vector2? center = null, Asset texture = null, float scale = 1, float rotation = 0, Vector2? vectorScale = null) + { + this.texture = texture ?? ModContent.Request("CalamityMod/Particles/BloomCircle"); + this.scale = scale; + this.vectorScale = vectorScale ?? Vector2.One; + this.center = center ?? Main.LocalPlayer.Center; + this.rotation = rotation; + } } ManagedRenderTarget rt = null; @@ -92,9 +103,6 @@ namespace CalamityMod.Graphics Main.spriteBatch.End(); gd.SetRenderTarget(null); } - private void DrawShadows(On_Main.orig_DrawInterface orig, Main self, GameTime gameTime) - { - } public override void OnWorldUnload() { diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 0f646d0f38..31ae117ded 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -377,7 +377,9 @@ namespace CalamityMod.Projectiles #region Pre AI public override bool PreAI(Projectile projectile) { - if (ProjectileID.Sets.LightPet[projectile.type]) + //Light Pets will add light to the abyss darkness. + //This uses local player on purpose, as the abyss darkness system is entirely client side. + if (ProjectileID.Sets.LightPet[projectile.type] && Main.LocalPlayer.Calamity().ZoneAbyss) EnhancedDarknessSystem.lights.Add(new() { center = projectile.Center, texture = ModContent.Request("CalamityMod/Particles/BloomCircle"), scale = 1 }); if (projectile.bobber && projectile.type != ModContent.ProjectileType() && RunFishingMinigames(projectile)) diff --git a/Projectiles/Pets/BabyGhostBell.cs b/Projectiles/Pets/BabyGhostBell.cs index 4556e2a2a7..00ba8afe34 100644 --- a/Projectiles/Pets/BabyGhostBell.cs +++ b/Projectiles/Pets/BabyGhostBell.cs @@ -48,7 +48,8 @@ namespace CalamityMod.Projectiles.Pets underwater = Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); if (underwater) { - EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 3, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); + if (Main.LocalPlayer.Calamity().ZoneAbyss) + EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 3, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); Lighting.AddLight(Projectile.Center, 0.3f, 0.9f, 1.5f); } else diff --git a/Projectiles/Pets/OceanSpirit.cs b/Projectiles/Pets/OceanSpirit.cs index 600d1cf18d..6bdf7cbef1 100644 --- a/Projectiles/Pets/OceanSpirit.cs +++ b/Projectiles/Pets/OceanSpirit.cs @@ -78,7 +78,8 @@ namespace CalamityMod.Projectiles.Pets underwater = player.IsUnderwater(); if (underwater) { - EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 6, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); + if (Main.LocalPlayer.Calamity().ZoneAbyss) + EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 6, texture = ModContent.Request("CalamityMod/Particles/BloomCircle") }); if (Projectile.frame == 16) Projectile.frame = 0; if (sleepyTimer > 0) From 9826377820c52394a3e493ae26162efe0aa3b067 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 26 Nov 2025 21:53:14 -0600 Subject: [PATCH 04/22] tooltips and more cleanup --- Graphics/EnhancedDarknessSystem.cs | 1 - Items/CalamityGlobalItemTooltip.cs | 18 +++++------------- .../en-US/Mods.CalamityMod.Common.hjson | 6 +++--- .../Mods.CalamityMod.Items.Accessories.hjson | 7 +++---- ...Mods.CalamityMod.Items.Armor.Hardmode.hjson | 3 ++- .../en-US/Mods.CalamityMod.Items.Fishing.hjson | 3 ++- .../en-US/Mods.CalamityMod.Items.Pets.hjson | 9 ++------- 7 files changed, 17 insertions(+), 30 deletions(-) diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs index d8b8d0c166..2a6fc1d5c9 100644 --- a/Graphics/EnhancedDarknessSystem.cs +++ b/Graphics/EnhancedDarknessSystem.cs @@ -60,7 +60,6 @@ namespace CalamityMod.Graphics { Main.spriteBatch.EnterShaderRegion(); var shader = GameShaders.Misc["CalamityMod:DozeLightingShader"]; - var abyssDarkness = Utils.Remap(Main.LocalPlayer.Center.Y, (float)Main.rockLayer * 16f, Main.UnderworldLayer * 16f, 0, 3, true); shader.UseOpacity(mp.darknessIntensity); shader.Apply(); Main.spriteBatch.Draw(rt, Main.screenLastPosition - Main.screenPosition, Color.White); diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index ac63b0d935..08b829f388 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -608,23 +608,15 @@ namespace CalamityMod.Items // Applies to various item categories which carry their light/breath effects into the Abyss #region Abyss Light/Breath // +1 to Abyss light level - if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace || + if (item.type == ItemID.JellyfishNecklace || item.type == ItemID.MiningHelmet || item.type == ItemID.UltrabrightHelmet) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel1")); - if (item.type == ItemID.JellyfishDivingGear || item.type == ItemID.Magiluminescence) - EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel1")); + EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssGlow")); + if (item.type == ItemID.JellyfishDivingGear) + EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssGlow")); // +2 to Abyss light level if (item.type == ItemID.ShinePotion) - EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel2")); - if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel2")); - - // +3 to Abyss light level - if (item.type == ItemID.WispinaBottle || item.type == ItemID.PumpkingPetItem || item.type == ItemID.GolemPetItem || item.type == ItemID.FairyQueenPetItem) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel3")); - if (item.type == ItemID.SuspiciousLookingTentacle) - EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel3")); + EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssGlow")); // Moderate breath boost if (item.type == ItemID.DivingHelmet) diff --git a/Localization/en-US/Mods.CalamityMod.Common.hjson b/Localization/en-US/Mods.CalamityMod.Common.hjson index de36dce08e..f3363486be 100644 --- a/Localization/en-US/Mods.CalamityMod.Common.hjson +++ b/Localization/en-US/Mods.CalamityMod.Common.hjson @@ -13,9 +13,9 @@ DoubleTapDown: Double tap {0} AggroBoost: Enemies are more likely to target you AggroReduction: Enemies are less likely to target you KnockbackImmunity: Grants immunity to knockback -AbyssLightLevel1: Provides a small amount of light in the abyss -AbyssLightLevel2: Provides a moderate amount of light in the abyss -AbyssLightLevel3: Provides a large amount of light in the abyss +AbyssLightLevel: Reduces the darkness intensity of the abyss +AbyssFlashlight: Increases flashlight width in the abyss +AbyssGlow: Increases visibily range in the abyss AbyssBreathLevel1: Slightly reduces breath loss in the abyss AbyssBreathLevel2: Moderately reduces breath loss in the abyss AbyssBreathLevel3: Greatly reduces breath loss in the abyss diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 54c7dad151..b8e0853797 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -181,7 +181,7 @@ AquaticHeart: { ''' Wow, you can swim now! Being underwater increases max speed and acceleration by {0}% - Greatly reduces breath loss and provides a small amount of light in the abyss + Greatly reduces breath loss and reduces the darkness intensity in the abyss Attackers are inflicted with [cbuff:CalamityMod/GlacialState] Gain a fragile ice barrier that grants {1}% damage reduction for one hit The ice shield regenerates after {2} seconds @@ -300,7 +300,6 @@ BlazingCore: { Upon shattering, holy stars spiral outwards and damage taken is negated After shattering, this damage reduction effect goes on cooldown Damage parried whilst on cooldown summons additional healing stars, and will not be reduced - {$Common.AbyssLightLevel2} ''' } @@ -852,7 +851,7 @@ GiantPearl: { You have a light aura around you Enemies within the aura are slowed down Enemies that remain within the aura are bombarded by homing prism shards - {$Common.AbyssLightLevel1} + {$Common.AbyssGlow} ''' } @@ -1902,7 +1901,7 @@ TheCamper: { You deal 50% less damage unless stationary Standing still grants buffs depending on held item, and creates a damaging aura around you While moving, you regenerate health as if standing still - {$Common.AbyssLightLevel1} + {$Common.AbyssGlow} when standing still 'In rest may we find victory' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 132f7b301e..8a48f4a9fc 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -166,6 +166,7 @@ FathomSwarmerVisage: { {$CommonItemTooltip.IncreasesMaxMinionsBy} {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Provides breathing and light underwater + Greatly enhances visibility in the abyss ''' SetBonus: ''' @@ -445,7 +446,7 @@ ReaverHeadExplore: { ''' Emits light and shows the location of treasure and ore {$Common.AggroReduction} and grants underwater breathing - These have a moderate effect while in the Abyss + Greatly enhances visibility in the abyss Increased block placement & tool range by {0} Increases pickup range for items ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index 5340c86c1f..fdee2da02d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -171,8 +171,9 @@ RustedJingleBell: { DisplayName: Rusted Jingle Bell Tooltip: ''' - Summons a baby ghost bell light pet + Summons a baby ghost bell to light the way for you Provides a moderate amount of light while underwater + {$Common.AbyssLightLevel} ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson index f19502c196..fd9a313a46 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson @@ -36,7 +36,6 @@ ChromaticOrb: { Tooltip: ''' Summons an ancient dragon light pet that highlights nearby enemies and danger sources - {$Common.AbyssLightLevel1} 'It glows warmly in your hand' ''' } @@ -56,7 +55,6 @@ EnchantedButterfly: { Tooltip: ''' Summons a mysterious dragonfly light pet - {$Common.AbyssLightLevel1} 'Feed him butterflies to keep him strong!' ''' } @@ -80,7 +78,6 @@ FrostyBatBottle: { Tooltip: ''' Summons an icy bat to light your way that flies towards your cursor when you dash - {$Common.AbyssLightLevel1} [c/6ECAC3:'All the world's bats are prime to squeak!'] ''' } @@ -116,7 +113,7 @@ LittleLight: { Tooltip: ''' Summons a small construct that follows you and provides a great amount of light - {$Common.AbyssLightLevel3} + {$Common.AbyssLightLevel} 'It's been looking for you for a long time' ''' } @@ -146,7 +143,6 @@ RadiatingCrystal: { Tooltip: ''' Summons a radiator light pet - {$Common.AbyssLightLevel1} 'The crystal contains traces of holothurin' ''' } @@ -167,6 +163,7 @@ StrangeOrb: { ''' Summons a miniature Ocean Spirit light pet Provides a large amount of light while underwater + {$Common.AbyssLightLevel} ''' } @@ -194,7 +191,6 @@ ThiefsDime: { Tooltip: ''' Summons Goldie the rogue coin to collect nearby coins and light your way - {$Common.AbyssLightLevel1} 'Once worthless treasure, now a relic of a thief's companionship' ''' } @@ -204,7 +200,6 @@ ToastyBatBottle: { Tooltip: ''' Summons a fiery bat to light your way that leaves a trail of glowing embers - {$Common.AbyssLightLevel1} [c/CF6454:'Guaranteed to NOT knock you off your hellbridge'] ''' } From 563ceaebac6355467b23964bcf4a6e7ba4b4c344 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 26 Nov 2025 23:56:40 -0600 Subject: [PATCH 05/22] fastfield cacheing --- Graphics/EnhancedDarknessSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs index 2a6fc1d5c9..9ffd832862 100644 --- a/Graphics/EnhancedDarknessSystem.cs +++ b/Graphics/EnhancedDarknessSystem.cs @@ -66,17 +66,17 @@ namespace CalamityMod.Graphics Main.spriteBatch.ExitShaderRegion(); }); } + private static readonly FastField Fld_WorkingLightMap = new("_workingLightMap", BindingFlags.Instance | BindingFlags.NonPublic); private void AdjustTransmissiveness(On_LightingEngine.orig_UpdateLightDecay orig, LightingEngine self) { orig(self); - FieldInfo field = typeof(LightingEngine).GetField("_workingLightMap", BindingFlags.Instance | BindingFlags.NonPublic); - if (field != null) + if (Fld_WorkingLightMap != null) { var mp = Main.LocalPlayer.Calamity(); - var map = (LightMap)field.GetValue(self); + LightMap map = Fld_WorkingLightMap.Get(self); if (mp.ZoneAbyss) { //This converts the light decay amount from the amount it normally is in water into the amount it normally is in air, depending on the intensity of the abyss darkness. From afad90cdd348e1dade11f664f1694c77477c83fc Mon Sep 17 00:00:00 2001 From: Flowaria Date: Tue, 30 Dec 2025 18:27:38 +0900 Subject: [PATCH 06/22] Moved width, height update from FindFrame to AI --- NPCs/HiveMind/HiveMind.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 9bf9925929..e05c2ed981 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.HiveMind { string normalIconPath = "CalamityMod/NPCs/HiveMind/HiveMind_Head_Boss"; string phase2IconPath = "CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"; - + normalIconIndex = CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } @@ -277,10 +277,6 @@ namespace CalamityMod.NPCs.HiveMind frameHeight = frameHeight_P2; } - // Update NPC Size accordingly - NPC.width = frameWidth; - NPC.height = frameHeight - 2; //Phase 1 Sprite have 2 pixel margin - NPC.frameCounter += 1.0; // Update each 6 ticks if (NPC.frameCounter >= 6.0) { @@ -416,6 +412,10 @@ namespace CalamityMod.NPCs.HiveMind public override void AI() { + // Update NPC Size according to Phase Changes + NPC.width = frameWidth; + NPC.height = frameHeight - 2; //Phase 1 Sprite have 2 pixel margin + // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); From 12f1c0ddb1d7fa795d244089238dc76c05caf92c Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Tue, 30 Dec 2025 14:50:50 -0500 Subject: [PATCH 07/22] 1 - Vanilla bosses no longer have Rev+ health multipliers applied during Boss Rush 2 - Fixed EoW Boss Rush health buff from a while ago mysteriously disappearing --- NPCs/CalamityGlobalNPC.cs | 204 ++++++++++++++----------- Systems/Collections/CalamityNPCSets.cs | 6 +- 2 files changed, 121 insertions(+), 89 deletions(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index d3597de092..5cf1a9e0e6 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1270,112 +1270,150 @@ namespace CalamityMod.NPCs #region Revengeance and Death Mode Stat Changes private void RevDeathStatChanges(NPC npc, Mod mod) { + // Health changes (disabled in Boss Rush) + if (!BossRushEvent.BossRushActive) + { + switch (npc.type) + { + case NPCID.KingSlime: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); + break; + case NPCID.EyeofCthulhu: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); + break; + case NPCID.ServantofCthulhu: + npc.lifeMax *= 4; + break; + case NPCID.BrainofCthulhu: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.75); + break; + case NPCID.Creeper: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.1); + break; + case NPCID.QueenBee: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); + break; + case NPCID.Bee: + case NPCID.BeeSmall: + if (CalamityPlayer.areThereAnyDamnBosses) + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); + break; + case NPCID.Deerclops: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); + break; + case NPCID.SkeletronHand: + npc.lifeMax = (int)Math.Round(npc.lifeMax * (CalamityWorld.death ? 0.5 : 0.75)); + break; + case NPCID.WallofFlesh: + case NPCID.WallofFleshEye: + npc.lifeMax *= 2; + break; + case NPCID.QueenSlimeBoss: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); + break; + case NPCID.Retinazer: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); + break; + case NPCID.Spazmatism: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.3); + break; + case NPCID.Probe: + if (CalamityWorld.death) + npc.lifeMax *= 2; + break; + case NPCID.SkeletronPrime: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); + break; + case NPCID.PrimeCannon: + case NPCID.PrimeSaw: + case NPCID.PrimeVice: + case NPCID.PrimeLaser: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.65); + break; + case NPCID.Plantera: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.85); + break; + case NPCID.PlanterasTentacle: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); + break; + case NPCID.Golem: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 3.2); + break; + case NPCID.GolemHead: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.28); + break; + case NPCID.GolemFistLeft: + case NPCID.GolemFistRight: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.75); + break; + case NPCID.DukeFishron: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.3); + break; + case NPCID.Sharkron: + case NPCID.Sharkron2: + npc.lifeMax *= 5; + break; + case NPCID.HallowBoss: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.7); + break; + case NPCID.CultistBoss: + npc.lifeMax *= 3; + break; + case NPCID.AncientCultistSquidhead: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); + break; + case NPCID.MoonLordCore: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.2); + break; + case NPCID.MoonLordHand: + case NPCID.MoonLordHead: + case NPCID.MoonLordLeechBlob: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); + break; + } + + if (npc.type >= NPCID.CultistDragonHead && npc.type <= NPCID.CultistDragonTail) + { + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.4); + } + else if (CalamityNPCTypeSets.Destroyer.Contains(npc.type)) + { + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.25); + } + else if (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type)) + { + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); + } + } + + // Other stat changes switch (npc.type) { case NPCID.KingSlime: npc.scale = CalamityWorld.death ? (Main.getGoodWorld ? 6f : 2.5f) : (Main.getGoodWorld ? 3f : 1.5f); - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); - break; - case NPCID.EyeofCthulhu: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); - break; - case NPCID.ServantofCthulhu: - npc.lifeMax *= 4; - break; - case NPCID.BrainofCthulhu: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.75); - break; - case NPCID.Creeper: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.1); break; case NPCID.QueenBee: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); npc.defense = 14; npc.defDefense = npc.defense; break; case NPCID.Bee: case NPCID.BeeSmall: if (CalamityPlayer.areThereAnyDamnBosses) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); npc.scale *= 1.25f; - } - break; - case NPCID.Deerclops: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); - break; - case NPCID.SkeletronHand: - npc.lifeMax = (int)Math.Round(npc.lifeMax * (CalamityWorld.death ? 0.5 : 0.75)); - break; - case NPCID.WallofFlesh: - case NPCID.WallofFleshEye: - npc.lifeMax *= 2; - break; - case NPCID.QueenSlimeBoss: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); - break; - case NPCID.Retinazer: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); - break; - case NPCID.Spazmatism: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.3); break; case NPCID.Probe: - if (CalamityWorld.death) - npc.lifeMax *= 2; npc.scale *= Main.zenithWorld ? 2f : 1.2f; break; - case NPCID.SkeletronPrime: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - break; case NPCID.PrimeCannon: case NPCID.PrimeSaw: case NPCID.PrimeVice: case NPCID.PrimeLaser: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.65); npc.scale *= 1.15f; break; - case NPCID.Plantera: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.85); - break; - case NPCID.PlanterasTentacle: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); - break; - case NPCID.Golem: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 3.2); - break; - case NPCID.GolemHead: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.28); - break; case NPCID.GolemFistLeft: case NPCID.GolemFistRight: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.75); npc.scale *= 1.15f; break; - case NPCID.DukeFishron: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.3); - break; - case NPCID.Sharkron: - case NPCID.Sharkron2: - npc.lifeMax *= 5; - break; - case NPCID.HallowBoss: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.7); - break; - case NPCID.CultistBoss: - npc.lifeMax *= 3; - break; - case NPCID.AncientCultistSquidhead: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); - break; - case NPCID.MoonLordCore: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.2); - break; - case NPCID.MoonLordHand: - case NPCID.MoonLordHead: - case NPCID.MoonLordLeechBlob: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - break; case NPCID.Mothron: npc.scale *= 1.25f; break; @@ -1391,18 +1429,12 @@ namespace CalamityMod.NPCs break; } - if (npc.type >= NPCID.CultistDragonHead && npc.type <= NPCID.CultistDragonTail) + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type)) { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.4); - } - else if (CalamityNPCTypeSets.Destroyer.Contains(npc.type)) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.25); npc.scale *= Main.zenithWorld ? 2f : 1.2f; } else if (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type)) { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); if (CalamityWorld.death) npc.scale *= 1.1f; } diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs index 10209c6308..e16ef7e0aa 100644 --- a/Systems/Collections/CalamityNPCSets.cs +++ b/Systems/Collections/CalamityNPCSets.cs @@ -235,9 +235,9 @@ namespace CalamityMod.Systems.Collections { NPCType(), 21000 }, { NPCID.EyeofCthulhu, 450000 }, // 30 seconds { NPCID.ServantofCthulhu, 6000 }, - { NPCID.EaterofWorldsHead, 10000 }, // 30 seconds + immunity timer at start - { NPCID.EaterofWorldsBody, 10000 }, - { NPCID.EaterofWorldsTail, 10000 }, + { NPCID.EaterofWorldsHead, 15000 }, // 30 seconds + immunity timer at start + { NPCID.EaterofWorldsBody, 15000 }, + { NPCID.EaterofWorldsTail, 15000 }, { NPCID.BrainofCthulhu, 100000 }, // 30 seconds with creepers { NPCID.Creeper, 10000 }, { NPCID.QueenBee, 315000 }, // 30 seconds From f0fd4db44d1b589c34542b340d4f78af769a4ca7 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Tue, 30 Dec 2025 15:39:39 -0500 Subject: [PATCH 08/22] MOAB allows holding UP to fly faster --- Items/Accessories/Wings/MOAB.cs | 17 +++++++++++++++++ ...ds.CalamityMod.Items.Accessories.Wings.hjson | 1 + 2 files changed, 18 insertions(+) diff --git a/Items/Accessories/Wings/MOAB.cs b/Items/Accessories/Wings/MOAB.cs index 997d77ee74..4603a286db 100644 --- a/Items/Accessories/Wings/MOAB.cs +++ b/Items/Accessories/Wings/MOAB.cs @@ -22,6 +22,9 @@ namespace CalamityMod.Items.Accessories.Wings public override float BaseAscent => 0.125f; public static int wingSlot = 0; + // How powerful the acceleration increase is while pressing UP + // This also affects the flight time tick rate + public static float BoostPower = 2f; public override void SetStaticDefaults() { ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(75, 6.5f, 1f); @@ -153,6 +156,20 @@ namespace CalamityMod.Items.Accessories.Wings // Mirrors the +5% luck from Lucky Horseshoe (vanilla behavior). player.Calamity().calamityBonusLuck += 0.05f; } + + public override void AdditionalFlightMovement(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) + { + if (player.TryingToHoverUp) + { + ascentWhenFalling *= BoostPower; + ascentWhenRising *= BoostPower; + maxCanAscendMultiplier *= BoostPower; + maxAscentMultiplier *= BoostPower; + constantAscend *= BoostPower; + player.wingTime -= BoostPower - 1f; + } + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson index c39f19ab3a..100e290574 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson @@ -51,6 +51,7 @@ MOAB: { Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} + {$CommonItemTooltip.PressUpToBooster} 32% increased jump speed and allows auto-jump Grants the player cloud, blizzard, and sandstorm mid-air jumps [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:Jetpack] [c/aaaaaa:jetpack] From 258336d5339a9b8f80efd0fb074e7967b54bfe04 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Wed, 31 Dec 2025 06:50:45 +0900 Subject: [PATCH 09/22] Updated DialogueGroup key --- NPCs/DevourerofGods/DevourerofGodsHead.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index cd2714ad1d..4a19347ddb 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -2822,7 +2822,7 @@ namespace CalamityMod.NPCs.DevourerofGods int DialogueIndex; if (target.statLife - hurtInfo.Damage <= 0) { - DialogueGroup = "DevourerOfGods.Death"; + DialogueGroup = "Mods.CalamityMod.DevourerOfGods.Death"; if (counter == 0) if (NPC.GetLifePercent() <= 0.25f) DialogueIndex = 4;// text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath5"; //All that running just to die to a single touch? @@ -2841,7 +2841,7 @@ namespace CalamityMod.NPCs.DevourerofGods { if (counter == 0 && Phase2Started) { - DialogueGroup = "DevourerOfGods.Running"; + DialogueGroup = "Mods.CalamityMod.DevourerOfGods.Running"; if (NPC.GetLifePercent() <= 0.25f) DialogueIndex = 1;// text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning2"; //WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! else @@ -2849,7 +2849,7 @@ namespace CalamityMod.NPCs.DevourerofGods } else { - DialogueGroup = "DevourerOfGods.Head"; + DialogueGroup = "Mods.CalamityMod.DevourerOfGods.Head"; if (counter > 9) DialogueIndex = Main.rand.Next(10, 13);// text = headHitKeys[Main.rand.Next(10, 13)]; //DogHead11-13 else if (counter == 9) From e51ed36e9093ae94befd7c7c4c47db139bbe717e Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Tue, 30 Dec 2025 18:28:10 -0500 Subject: [PATCH 10/22] Updated some vanilla bestiary entry changes --- .../en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson index 269038422a..6eb062ab99 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson @@ -1,7 +1,7 @@ // Put their internal name here NPCName: { Guide: Once tasked with shepherding the Wall of Flesh, the Guide is a godlike figure in Demon folklore. However, the former warlock apprentice now savors a humble life, mentoring adventurers with his sharp intuition. - Dryad: Dryads practice the art of Life Magic, pioneered by Silva. She is connected with nature and can analyze its purity worldwide. She sells seeds, too! + Dryad: The Dryad practices the art of Life Magic, pioneered by Silva. She is connected with nature and can analyze its purity worldwide. She sells seeds, too! Mechanic: The Mechanic was imprisoned for sticking her nose where she shouldn't. She sells wiring and tools for putting together anything imaginable. EmpressButterfly: These familiars conjured by the Empress draw power from their surroundings and later bring it to their master. They remind her of a lost loved one, and should one perish in the chaos of night, she shall unleash her full fury upon the attacker. DemonEye: "{$CommonEntries.DemonEye}" @@ -58,7 +58,7 @@ NPCName: { DungeonGuardian: The Old Man is cursed to never leave nor enter the Dungeon, much less die. Whoever crosses paths with him and dares to descend into those halls shall not pass! BoneSerpentHead: Mighty serpentine beasts ruled hell since before history, later led by the exiled Flame Dragon. For said alliance, their obsidian scales were turned to Ash shortly after his demise. Now their skeletal husks remain, forced to protect the demonic territory using stolen Azafurian spells. Demon: Despite being a primitive civilization, demons populate most of the underworld. Unlike their lesser brothers, they cast shadow magic rather than hell magic. - VoodooDemon: Demons have several religious practices, specially sacrifices. They worship the Wall of Flesh ever since it started roaming the underworld, using offerings to draw it closer. + VoodooDemon: Demons have several religious practices, especially sacrifices. They worship the Wall of Flesh ever since it started roaming the underworld, using offerings to draw it closer. RedDevil: Conjuring potent spears of dark magic, these elite demons look after the adventurer that destroyed their perceived deity. WyvernHead: Deeply in tune with the magic of the world, these serpentine dragons guard the skyward ruins of Chrysadia on behalf of the Storm Dragon. Now, their duty calls louder as divine essence surges through the land. Harpy: Winged, demi-human creatures from distant southward mountains who came to inhabit Chrysadia after its tragic downfall. They defend their new territory fiercely against invaders with their razor-sharp feathers. @@ -73,7 +73,7 @@ NPCName: { PirateCaptain: A pirate captain's love for riches is only rivaled by his desire to explore! Word that the Crusade had seemingly ended spread fast across the world, and abundances to plunder in this continent attracted this sea dweller and his motley crew. MartianSaucerCore: Following the destruction of their planet by otherworldly creatures, the Martians' military evolved at an unprecedented rate. They were prepared to fight back any future threats, and also pillage any other worlds they could find. TorchGod: An unknown entity responsible for a torch's eternal flicker, however easily angered by the unsightly, ungrateful abuse of torch placement. - EyeofCthulhu: A gargantuan monster of unknown origins, responsible for plaguing the night with Demon Eyes. It was given the title of "Cthulhu", which means "Great Beast" in the language of dragons. + EyeofCthulhu: A gargantuan monster of unknown origins, responsible for plaguing the night with Demon Eyes. Beasts of such caliber are often given the title of "Cthulhu", a word that meant "great beast" in the language of dragons. BrainofCthulhu: The death of a god often birthed great monsters due to the volatile nature of godly essence. The culling of such abominations used to be cause for songs and festivities, but now, they only give birth to disappointments. SkeletronHead: A demonic construct that bursts out of the Old Man when necessary and the most dangerous part of the curse laid by the Dragon Cult. They hoped to stop all intruders with it, but one was too cunning even for them. WallofFlesh: Originally created by Azafurian mages as a gambit to seal away godly essence, the towering wall broke free after the city's destruction. Its existence was problematic, but its demise has ushered even greater instability upon the world. @@ -100,7 +100,7 @@ CommonEntries: { SandShark: Sand Sharks lived in the shallow waters of Ilmeris, hiding beneath the sand. They were thankfully well equipped to deal with the fallout of the Incineration. AngryBones: Cursed with undeath, the former prisoners of the Dungeon roam endlessly through its halls, seeking a victim for their unending fury. BlueArmoredBones: Mercenaries hired by Yharim to guard the Dungeon, the Marching Blues were disciplined and relentless, sundering any escapees that decided to rise against their jailors. - HellArmoredBones: Mercenaries hired by Yharim to guard the Dungeon hailing from Azafure, the fiery glow of the Molten Legion is unmistakable. If anyone ever tried to hide, their red-hot armaments would melt the hideout immediately. + HellArmoredBones: Mercenaries hired by Yharim to guard the Dungeon hailing from Azafure, the fiery glow of the Molten Legion is unmistakable. When the halls of the Dungeon lit up, every prisoner knew hell would be let loose. RustyArmoredBones: Mercenaries hired by Yharim to guard the Dungeon hailing from Underground factions, the Rusted Company's weapons are jagged and rough through use and neglect. The brutality they employed on the field was enough to make many prisoners give up on freedom. Diabolist: Mages of Azafure who bear the Diabolic Sigil, a certificate of their prowess, wielding flames as intense as any in the underworld. They were effective at blocking passageways and at making prisoners talk. Necromancer: These sorcerers were trained in Azafure and bore the Necromantic Sign, a certificate of their prowess. Much like they terrorized prisoners with the bodies of their friends, so do they terrorize the Dungeon now. From 4522c31130a555d5d01f3f52601c0596529249de Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Tue, 30 Dec 2025 18:17:17 -0600 Subject: [PATCH 11/22] Updating to new render systems + pr comments --- CalPlayer/CalamityPlayer.cs | 9 ++- Graphics/EnhancedDarknessSystem.cs | 70 +++++++++---------- .../Mods.CalamityMod.Items.Accessories.hjson | 2 +- ModSupport/ModCalls.cs | 6 -- 4 files changed, 41 insertions(+), 46 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 8d20d73e4d..37ae440100 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -250,6 +250,9 @@ namespace CalamityMod.CalPlayer #endregion #region External variables -- Not used by Calamity, only via Mod.Call or reflection + [Obsolete("No longer does anything in the new abyss light system")] + public int externalAbyssLight = 0; + public float externalBreathTickBoost = 0f; public float externalFlightTimeMultBoost = 0f; @@ -4940,9 +4943,11 @@ namespace CalamityMod.CalPlayer { //Main aura EnhancedDarknessSystem.lights.Add(new(center: Player.Center, scale: 4 * abyssPlayerGlowMultiplier)); - + //Flashlight - EnhancedDarknessSystem.lights.Add(new(center: Player.Center + Player.DirectionTo(mouseWorld) * 750f, rotation: Player.DirectionTo(Main.MouseWorld).ToRotation() - MathHelper.PiOver2, vectorScale: new Vector2(0.75f * abyssFlashlightWidthMultiplier, 0.75f), texture: Request("CalamityMod/Particles/BloomLineFade") )); + //Due to being in postUpdate we need to adjust the mousepos for the player's movement that will have happened + var mouseworld = Main.MouseWorld + Player.position - Player.oldPosition; + EnhancedDarknessSystem.lights.Add(new(center: Player.Center + Player.DirectionTo(mouseworld) * 750f, rotation: Player.DirectionTo(mouseworld).ToRotation() - MathHelper.PiOver2, vectorScale: new Vector2(0.75f * abyssFlashlightWidthMultiplier, 0.75f), texture: Request("CalamityMod/Particles/BloomLineFade"))); } diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs index 9ffd832862..93278dfc28 100644 --- a/Graphics/EnhancedDarknessSystem.cs +++ b/Graphics/EnhancedDarknessSystem.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; -using System.Reflection; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -32,15 +33,12 @@ namespace CalamityMod.Graphics this.rotation = rotation; } } - ManagedRenderTarget rt = null; public static List lights = new(); public override void OnModLoad() { On_OverlayManager.Draw += DrawShadowOverlay; On_LightingEngine.UpdateLightDecay += AdjustTransmissiveness; - RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; - rt = new ManagedRenderTarget(true, ManagedRenderTarget.CreateScreenSizedTarget); } private void DrawShadowOverlay(On_OverlayManager.orig_Draw orig, OverlayManager self, SpriteBatch spriteBatch, RenderLayers layer, bool beginSpriteBatch) @@ -55,54 +53,52 @@ namespace CalamityMod.Graphics return; var mp = Main.LocalPlayer.Calamity(); - var gd = Main.graphics.GraphicsDevice; - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Main.GameViewMatrix.TransformationMatrix, () => + var device = Main.instance.GraphicsDevice; + using var lease = RenderTargetPool.Shared.Rent( + device, + Main.screenWidth / 2, + Main.screenHeight / 2, + RenderTargetDescriptor.Default + ); + + using (lease.Scope(clearColor: Color.Black)) { - Main.spriteBatch.EnterShaderRegion(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + foreach (var item in lights) + { + Main.spriteBatch.Draw(item.texture.Value, (item.center - Main.screenPosition) * 0.5f, null, Color.White, item.rotation, item.texture.Size() * 0.5f, item.vectorScale * item.scale * 0.5f, SpriteEffects.None, 0); + } + Main.spriteBatch.End(); + } + + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); var shader = GameShaders.Misc["CalamityMod:DozeLightingShader"]; shader.UseOpacity(mp.darknessIntensity); shader.Apply(); - Main.spriteBatch.Draw(rt, Main.screenLastPosition - Main.screenPosition, Color.White); - Main.spriteBatch.ExitShaderRegion(); - }); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 2, 0, 0); + spriteBatch.End(); + } } - private static readonly FastField Fld_WorkingLightMap = new("_workingLightMap", BindingFlags.Instance | BindingFlags.NonPublic); + private const float VanillaWaterLightMult = 0.91f; //Vanilla water light multiplier. private void AdjustTransmissiveness(On_LightingEngine.orig_UpdateLightDecay orig, LightingEngine self) { orig(self); - if (Fld_WorkingLightMap != null) + var mp = Main.LocalPlayer.Calamity(); + LightMap map = self._workingLightMap; + if (mp.ZoneAbyss) { - var mp = Main.LocalPlayer.Calamity(); - LightMap map = Fld_WorkingLightMap.Get(self); - if (mp.ZoneAbyss) - { - //This converts the light decay amount from the amount it normally is in water into the amount it normally is in air, depending on the intensity of the abyss darkness. - //This is to offset the abyss darkness system to make the parts that are supposed to be visible easier to see. - //Dividing by 0.91 brings the water back to 100% transmissiveness with the original color - map.LightDecayThroughWater = Vector3.Lerp(map.LightDecayThroughWater, (map.LightDecayThroughWater / 0.91f) * 0.95f, MathHelper.Clamp(mp.darknessIntensity, 0, 1)); - } + //This converts the light decay amount from the amount it normally is in water into the amount it normally is in air, depending on the intensity of the abyss darkness. + //This is to offset the abyss darkness system to make the parts that are supposed to be visible easier to see. + //Dividing by 0.91 brings the water back to 100% transmissiveness with the original color + map.LightDecayThroughWater = Vector3.Lerp(map.LightDecayThroughWater, (map.LightDecayThroughWater / VanillaWaterLightMult) * 0.95f, MathHelper.Clamp(mp.darknessIntensity, 0, 1)); } } - private void PrepareTargets() - { - //This system works by drawing all the light sources additively onto a plain black RenderTarget. - //The shader then uses this as an opacity mask, where black = opaque and white = transparent. - var gd = Main.instance.GraphicsDevice; - gd.SetRenderTarget(rt); - gd.Clear(Color.Black); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); - foreach (var item in lights) - { - Main.spriteBatch.Draw(item.texture.Value, item.center - Main.screenPosition, null, Color.White, item.rotation, item.texture.Size() * 0.5f, item.vectorScale * item.scale, SpriteEffects.None, 0); - } - Main.spriteBatch.End(); - gd.SetRenderTarget(null); - } - public override void OnWorldUnload() { lights.Clear(); diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index a202b069e7..74e6f2bac0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1827,7 +1827,7 @@ StatMeter: { MiscStats: Aggro: {0} | Luck: {1}% AbyssStats: ''' - Abyss Darkness: {0} | Player Glow: {1}x | Flashlight: {2}x + Abyss Darkness: {0} | Player Glow: {1}x | Flashlight Width: {2}x Breath Loss Rate: {3} Life Lost Per Tick at Zero Breath: {4} Defense Lost From Pressure: {5} diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index ef78a5cc20..e6291dce60 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -1200,12 +1200,6 @@ namespace CalamityMod return null; } - case "GetLight": - case "GetLightLevel": - case "GetLightStrength": - case "GetAbyssLight": - case "GetAbyssLightLevel": - case "GetAbyssLightStrength": case "GetDarkness": case "GetAbyssDarkness": case "GetDarknessIntensity": From 3b37bf077a5a3a7c2ba3540a53fc81496e34f53e Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Tue, 30 Dec 2025 19:19:01 -0600 Subject: [PATCH 12/22] deerclops now uses the darkness system --- CalPlayer/CalamityPlayer.cs | 33 +++++- Effects/CalamityShaders.cs | 4 - .../ScreenShaders/DeerclopsShadowShader.fx | 52 ---------- .../ScreenShaders/DeerclopsShadowShader.xnb | Bin 2440 -> 0 bytes Graphics/EnhancedDarknessSystem.cs | 6 +- NPCs/CalamityGlobalNPC.cs | 4 - .../Bosses/DeerclopsAI.cs | 95 ++---------------- 7 files changed, 40 insertions(+), 154 deletions(-) delete mode 100644 Effects/ScreenShaders/DeerclopsShadowShader.fx delete mode 100644 Effects/ScreenShaders/DeerclopsShadowShader.xnb diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 37ae440100..39e59b0c62 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -55,6 +55,7 @@ using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Boss; @@ -745,7 +746,13 @@ namespace CalamityMod.CalPlayer public float abyssDarkness = 0f; public float abyssPlayerGlowMultiplier = 1f; public float abyssFlashlightWidthMultiplier = 1f; + + #endregion + + #region Light System public float darknessIntensity = 0; + + public Vector2? lastDeerclopsPosition; #endregion #region Permanent Buff @@ -2922,10 +2929,10 @@ namespace CalamityMod.CalPlayer abyssDarkness = 0; abyssPlayerGlowMultiplier = 1; abyssFlashlightWidthMultiplier = 1; - darknessIntensity = 0; + darknessIntensity = MathHelper.Max(darknessIntensity-0.05f,0); #endregion - EnchantHeldItemEffects(Player, Player.Calamity(), Player.HeldItem); + EnchantHeldItemEffects(Player, Player.Calamity(), Player.HeldItem); } #endregion @@ -4950,7 +4957,27 @@ namespace CalamityMod.CalPlayer EnhancedDarknessSystem.lights.Add(new(center: Player.Center + Player.DirectionTo(mouseworld) * 750f, rotation: Player.DirectionTo(mouseworld).ToRotation() - MathHelper.PiOver2, vectorScale: new Vector2(0.75f * abyssFlashlightWidthMultiplier, 0.75f), texture: Request("CalamityMod/Particles/BloomLineFade"))); } - + if (lastDeerclopsPosition.HasValue) + { + //While deer is alive and the player is nearby, make it dark + if (Main.npc.Any(x => x.active && x.type == NPCID.Deerclops) && Player.DistanceSQ(lastDeerclopsPosition.Value) < 10240000) //3200^2, or 00 tiles + { + darknessIntensity = MathHelper.Min(Main.LocalPlayer.Calamity().darknessIntensity + 0.06f, 1f); ; + } + + //Add the main light circle for the arena + DeerclopsAI.ArenaTex ??= ModContent.Request(DeerclopsAI.ArenaTexPath); + EnhancedDarknessSystem.lights.Add(new(lastDeerclopsPosition.Value, scale: DeerclopsAI.borderScale, texture: DeerclopsAI.ArenaTex)); + + //we draw light around the player when far away so they have some visibility, although very small. This is especially nice in multiplayer. we scale opacity with distance bc it looks better + EnhancedDarknessSystem.lights.Add(new EnhancedDarknessSystem.LightSource(scale: 0.75f, opacity: MathHelper.Clamp(Main.LocalPlayer.DistanceSQ(lastDeerclopsPosition.Value) / (409600 /*640^2*/), 0, 1))); + + if (darknessIntensity == 0) + { + lastDeerclopsPosition = null; + } + } + //reset the stored Y value for red wine's increased vertical speed if (redWine && (redWineStoredY > 0.2f || redWineStoredY < -0.2f) && (Player.velocity.Y > 0.2f || Player.velocity.Y < -0.2f)) { diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 4678e95e35..5dd18a0419 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -204,7 +204,6 @@ namespace CalamityMod.Effects #region Amber's Shaders internal static Asset PrimitiveClearShader; internal static Asset HolyInfernoShader; - internal static Asset DeerclopsShadowShader; #endregion #region YuH's Shaders @@ -465,9 +464,6 @@ namespace CalamityMod.Effects HolyInfernoShader = LoadShader("ScreenShaders/HolyInfernoShader"); RegisterMiscShader(HolyInfernoShader, "InfernoPass", "HolyInfernoShader"); - DeerclopsShadowShader = LoadShader("ScreenShaders/DeerclopsShadowShader"); - RegisterMiscShader(DeerclopsShadowShader, "ShadowPass", "DeerclopsShadowShader"); - #endregion #region Loading YuH's Shaders diff --git a/Effects/ScreenShaders/DeerclopsShadowShader.fx b/Effects/ScreenShaders/DeerclopsShadowShader.fx deleted file mode 100644 index 47273956fe..0000000000 --- a/Effects/ScreenShaders/DeerclopsShadowShader.fx +++ /dev/null @@ -1,52 +0,0 @@ -float minRadius; -float maxRadius; -float maxOpacity; - -float2 screenPosition; -float2 screenSize; -float2 anchorPoint; - -float InverseLerp(float a, float b, float t) -{ - return saturate((t - a) / (b - a)); -} - -float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 uv : TEXCOORD0) : COLOR0 -{ - float2 worldUV = screenPosition + screenSize * uv; - float2 deerclopsUV = anchorPoint / screenSize; - float worldDistance = distance(worldUV, anchorPoint); - - // Get the distance to the pixel from Deerclops - float distToDeerclops = distance(anchorPoint, worldUV); - // And get the correct opacity based on it. - float opacity = InverseLerp(0, maxRadius, distToDeerclops); - - // Define the border and mix the shadow and light for a smoother transition - bool border = worldDistance < minRadius && opacity > 0; - float colorMult = 1; - - if (worldDistance > minRadius && worldDistance < maxRadius) - opacity = lerp(opacity, maxOpacity, InverseLerp(minRadius, maxRadius, distToDeerclops)); - - opacity = clamp(opacity, 0, maxOpacity); - - if (border) - { - colorMult = InverseLerp(minRadius * 0.94, minRadius, worldDistance); - } - - // If the color multi has not been changed (not border pixel) and opacity is 0 OR it's within - if (colorMult == 1 && (opacity == 0 || worldDistance < minRadius)) - return sampleColor; - - return float4(0, 0, 0, 1) * colorMult * opacity; -} - -technique Technique1 -{ - pass ShadowPass - { - PixelShader = compile ps_2_0 PixelShaderFunction(); - } -} \ No newline at end of file diff --git a/Effects/ScreenShaders/DeerclopsShadowShader.xnb b/Effects/ScreenShaders/DeerclopsShadowShader.xnb deleted file mode 100644 index 8703cff4497586ea5e65484d26272b8c1a9eb9d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2440 zcmbtVUuz>(6hC*;+BUn8?$Re&bRPCWp@cT3OZTCyZfw`ZsM-9HAPehkGNr?&GjWp8 z?&8A~6nqd|(GM_1pHf)*xDSH+0R+E*4+=p9LHY?Y{?5H~Gn14GvM0HjbAIP{{@uBg zX?}S7U|xK+L?pfyA2==F>v_BVeABh^JHEAVA9((we93eBw%gBd@9x^Ie$}?xw!dm# z#J=NO-94w(TQxtn{hs5wTgChue^$-Xpwl1t_Lgf8`o7g!H7kRM9jEoa{kZNuvfZuC zVxhIW`Osc(+Z$^e8*dSd_R{6R1^Az8JuKQs)ht+HOw(VBDp3}!Jk>I|V zbB3j5HjZnlxSI3CPHJ6GC7+GCj2O#p?RkF1bKJhH!S&~Kk@(8FYkOAPJE&MaY!usd zyS3*!pAGDFqE}#Z8P3m(<4r6rMJN?*;M&FtQug=IPgC|U(Em!=ocvm9j{C9BmvTz~ zE{@p*R!reKRRq!ckKD8oMdPSSrTRO!ufe>+F~HcxHpI*VV{VB1zDeO#Q3sd>HF@qMTu<3h~fzObBP|r!~oSpF97xJTM@Wp2~IqfrN zEOm6cy$6K{YczR^%{QuVn(visWs}cqPk_pdq z`-lI3s&RA~Gu7^BMbO(J$FXRP^>i-AIbXV##+b`K<*!U~ z>74B6{_wXgg?X$Cx|oX>kQCj|Y~9!`Yw~`dL2?j&((e(?XDJsdPQZH?;QRCIY9#2n zr-`09MQ>;|6D-mwL~r!>Tp|GQ+*w!4_$Dha;p<@EPUqbYaFvcjr|H?#H zTq6+3&nw{?;5K5e(zz~DOB_ud&rAENvNU1MG{c$8%uGez`XLQ4cofJp=OHAg{b8_BDuA~kfsamqWA!q^ddVh1^5^9cc9X-W< M;Wfb6DBv^vFB`ySUH||9 diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs index 93278dfc28..e6636e92b3 100644 --- a/Graphics/EnhancedDarknessSystem.cs +++ b/Graphics/EnhancedDarknessSystem.cs @@ -21,16 +21,18 @@ namespace CalamityMod.Graphics public Vector2 vectorScale = Vector2.One; public Vector2 center = Main.LocalPlayer.Center; public float rotation = 0; + public float opacity = 1; public LightSource() { } - public LightSource(Vector2? center = null, Asset texture = null, float scale = 1, float rotation = 0, Vector2? vectorScale = null) + public LightSource(Vector2? center = null, Asset texture = null, float scale = 1, float rotation = 0, Vector2? vectorScale = null, float opacity = 1) { this.texture = texture ?? ModContent.Request("CalamityMod/Particles/BloomCircle"); this.scale = scale; this.vectorScale = vectorScale ?? Vector2.One; this.center = center ?? Main.LocalPlayer.Center; this.rotation = rotation; + this.opacity = opacity; } } @@ -66,7 +68,7 @@ namespace CalamityMod.Graphics Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); foreach (var item in lights) { - Main.spriteBatch.Draw(item.texture.Value, (item.center - Main.screenPosition) * 0.5f, null, Color.White, item.rotation, item.texture.Size() * 0.5f, item.vectorScale * item.scale * 0.5f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(item.texture.Value, (item.center - Main.screenPosition) * 0.5f, null, Color.White * item.opacity, item.rotation, item.texture.Size() * 0.5f, item.vectorScale * item.scale * 0.5f, SpriteEffects.None, 0); } Main.spriteBatch.End(); } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 5cf1a9e0e6..0397a4b12b 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4813,10 +4813,6 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.Deerclops) { DeerclopsAI.hasTargetBeenInRange = false; - DeerclopsAI.borderDelay = 7f * 60f; - DeerclopsAI.borderScalar = 0f; - DeerclopsAI.innerBorder = DeerclopsAI.MaxDRIncreaseDistance * 5f; - DeerclopsAI.outerBorder = DeerclopsAI.MaxDRIncreaseDistance * 5f; } // Despawn Blazing Wheels and Spike Balls when a boss spawns so they're not annoying and stay in the arena diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs index 44d52c8a76..b776aab1fb 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs @@ -1,9 +1,11 @@ using System; using CalamityMod.Events; +using CalamityMod.Graphics; using CalamityMod.Systems.Graphic; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -18,15 +20,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { public class DeerclopsAI : VanillaAIOverride { - public static bool shouldDrawEnrageBorder = true; public static bool hasTargetBeenInRange = true; public const float IncreaseDRTriggerDistance = 750f; public const float MaxDRIncreaseDistance = 1200f; - public static float borderDelay = 10f * 60f; - public static float innerBorder = 750f; - public static float outerBorder = 1200f; - public static float borderScalar = 0f; - public static Vector2 lastDeerclopsPosition; + public static float borderScale = 5f; + public static string ArenaTexPath = "CalamityMod/Particles/LargeBloom"; // Vanilla values public static int DebrisDamage = 18; // 72 @@ -35,66 +33,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int IceSpikeDamage = 16; // 64 (buffed from 52) public static int HandDamage = 13; // 52 (buffed from 40) - public override void Load() - { - GeneralDrawLayerSystem.OnAfterEverything += DrawDeerclopsShadow; - } - - public override void Unload() - { - GeneralDrawLayerSystem.OnAfterEverything -= DrawDeerclopsShadow; - } - - private static void DrawDeerclopsShadow() - { - if (Main.gameMenu) - return; - - bool shouldDraw; - var deerclopsInactive = false; - if (NPC.deerclopsBoss >= 0 && NPC.deerclopsBoss.WithinBounds(Main.npc.Length)) - { - shouldDraw = Main.npc[NPC.deerclopsBoss].HasValidTarget; - } - else - { - shouldDraw = borderScalar > 0f; - deerclopsInactive = true; - } - - if (shouldDraw) - { - var minRadius = innerBorder; - var maxRadius = outerBorder; - - // Begin drawing the shadow - var blackTile = TextureAssets.MagicPixel; - - var shader = GameShaders.Misc["CalamityMod:DeerclopsShadowShader"].Shader; - shader.Parameters["minRadius"].SetValue(minRadius); - shader.Parameters["maxRadius"].SetValue(maxRadius); - shader.Parameters["anchorPoint"].SetValue(lastDeerclopsPosition); - shader.Parameters["screenPosition"].SetValue(Main.screenPosition); - shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); - shader.Parameters["maxOpacity"].SetValue(borderScalar); - - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Main.Transform); - - Rectangle rekt = new(Main.screenWidth / 2, Main.screenHeight / 2, Main.screenWidth, Main.screenHeight); - Main.spriteBatch.Draw(blackTile.Value, rekt, null, default, 0f, blackTile.Value.Size() * 0.5f, 0, 0f); - - // Shadow drawing complete - Main.spriteBatch.End(); - } - - if (deerclopsInactive) - { - // Push the border away and fade out when deerclops is deadge - borderScalar = MathHelper.Clamp(borderScalar - 0.015f, 0f, 1f); - innerBorder += 30f; - outerBorder += 30f; - } - } + public static Asset ArenaTex; public override bool AI(Mod mod) { @@ -116,7 +55,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (NPC.target.WithinBounds(Main.player.Length) && Main.player[NPC.target].dead) { hasTargetBeenInRange = false; - borderScalar = 0.9f; } // Target data @@ -134,8 +72,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float dustAndDRScalar = Utils.Remap(NPC.localAI[3], 0f, 30f, 0f, 1f); calamityGlobalNPC.DR = MathHelper.Lerp(0f, 0.9f, dustAndDRScalar); - if (borderDelay > 0f) - borderDelay -= 1f; if (dustAndDRScalar > 0f) { @@ -150,29 +86,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Target entered the border for the first time hasTargetBeenInRange = true; - if (borderDelay > 120f) - borderDelay = 120f; } - if (innerBorder != IncreaseDRTriggerDistance || MaxDRIncreaseDistance != outerBorder) - { - // Adjust the border IF the new value is lower (helps prevent jumping if you enter the border early while it's on screen but not finished zooming in) - var LerpValue = Utils.GetLerpValue(hasTargetBeenInRange ? 120f : 180f, 0f, borderDelay, true); - var newInner = MathHelper.Lerp(MaxDRIncreaseDistance * 5f, IncreaseDRTriggerDistance, LerpValue); - if (newInner < innerBorder) - innerBorder = newInner; - var newOuter = MathHelper.Lerp(MaxDRIncreaseDistance * 5f, MaxDRIncreaseDistance, LerpValue); - if (newOuter < outerBorder) - outerBorder = newOuter; - } - if ((hasTargetBeenInRange && borderScalar < 1f) || borderDelay > 0f) - { - // Fade in, with full opacity only available after being inside the border for the first time - borderScalar = MathHelper.Clamp(borderScalar + 0.015f, 0f, hasTargetBeenInRange ? 1f : 0.9f); - } - shouldDrawEnrageBorder = CalamityWorld.revenge || CalamityWorld.death; // Set the last deerclops position (used only for post-death border shenanigans) - lastDeerclopsPosition = NPC.Center; + Main.LocalPlayer.Calamity().lastDeerclopsPosition = NPC.Center; // Spawn settings if (NPC.homeTileX == -1 && NPC.homeTileY == -1) From 581e7ebfa85f6c12a518090734046f7c90b83202 Mon Sep 17 00:00:00 2001 From: Big E Date: Tue, 30 Dec 2025 22:14:39 -0500 Subject: [PATCH 13/22] + Main.dedServ check in BaseRenderer --- Graphics/Renderers/BaseRenderer.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Graphics/Renderers/BaseRenderer.cs b/Graphics/Renderers/BaseRenderer.cs index 99e1994015..0d570acfd5 100644 --- a/Graphics/Renderers/BaseRenderer.cs +++ b/Graphics/Renderers/BaseRenderer.cs @@ -51,10 +51,13 @@ public abstract class BaseRenderer : ModType public sealed override void SetStaticDefaults() { - Main.QueueMainThreadAction(() => + if (!Main.dedServ) { - MainTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); - }); + Main.QueueMainThreadAction(() => + { + MainTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); + }); + } } /// From c23fa7534b2f94c51b1f4d31cfb4312c6b0740a8 Mon Sep 17 00:00:00 2001 From: Big E Date: Tue, 30 Dec 2025 00:06:33 -0500 Subject: [PATCH 14/22] + Added excludedPlayers to CalamityTargetingParameters --- Utilities/NPCUtils.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 5d5e1b672e..11683436f8 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -89,6 +89,9 @@ namespace CalamityMod // Generally this doesn't need to be set to true, as bosses will never have collideX or collideY set to true. public bool forceNetUpdate = false; + // Player indexes put into this list will not be considered for targetting. + public int[] excludedPlayers = []; + public CalamityTargetingParameters() { } @@ -410,9 +413,10 @@ namespace CalamityMod continue; // ForceSwitch targeting. If the same player from last time is iterated over, just ignore them. + // Player exclusion. If the player is to be excluded, do not consider them. bool sameTargetAsLastTime = p.whoAmI == npc.oldTarget; bool notSinglePlayer = Main.netMode != NetmodeID.SinglePlayer; - if (options.targetType == NPCTargetType.ForceSwitch && notSinglePlayer && sameTargetAsLastTime) + if (notSinglePlayer && (options.excludedPlayers.Contains(p.whoAmI) || (options.targetType == NPCTargetType.ForceSwitch && sameTargetAsLastTime))) continue; // @@ -455,7 +459,7 @@ namespace CalamityMod // If either targeting method succeeded, then this target is being engaged. bool engageThisTarget = preferSameFound || standardTargetingRequirementsMet; - if (engageThisTarget) + if (engageThisTarget && !targetShouldBeExcluded) { anyTargetAvailable = true; tankMinionProjectileID = -1; // Reset any Stardust Guardian aggro because a real player was found. From beafb883e48cb4cb0830ce53275da19242520e80 Mon Sep 17 00:00:00 2001 From: Big E Date: Tue, 30 Dec 2025 11:02:07 -0500 Subject: [PATCH 15/22] + Switched to HashSet --- Utilities/NPCUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 11683436f8..c360a2d7ea 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using CalamityMod.Balancing; @@ -90,7 +91,7 @@ namespace CalamityMod public bool forceNetUpdate = false; // Player indexes put into this list will not be considered for targetting. - public int[] excludedPlayers = []; + public HashSet excludedPlayers = []; public CalamityTargetingParameters() { @@ -459,7 +460,7 @@ namespace CalamityMod // If either targeting method succeeded, then this target is being engaged. bool engageThisTarget = preferSameFound || standardTargetingRequirementsMet; - if (engageThisTarget && !targetShouldBeExcluded) + if (engageThisTarget) { anyTargetAvailable = true; tankMinionProjectileID = -1; // Reset any Stardust Guardian aggro because a real player was found. From adf4570cc7539801cda52b260cd1e26efc6b4f71 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 31 Dec 2025 00:00:49 -0600 Subject: [PATCH 16/22] some underwater effect fixes --- CalPlayer/CalamityPlayerMiscEffects.cs | 13 +++++++------ Items/Accessories/AquaticEmblem.cs | 2 +- Items/Armor/Victide/VictideHeadBurrow.cs | 2 +- Projectiles/Pets/OceanSpirit.cs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e421a926cd..35f572c889 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3253,7 +3253,7 @@ namespace CalamityMod.CalPlayer // Aquatic Emblem bonus if (aquaticEmblem) { - if (countsAsAnyWet && !Player.lavaWet && !Player.honeyWet && !Player.mount.Active) + if (countsAsAnyWet && !Player.lavaWet && !Player.honeyWet) { if (aquaticBoost < AquaticEmblem.TimeToReachMaxBoost) { @@ -3271,12 +3271,13 @@ namespace CalamityMod.CalPlayer aquaticBoost--; if (aquaticBoost <= 0f) aquaticBoost = 0f; - if (Player.mount.Active) - aquaticBoost = 0f; } - - Player.statDefense += (int)Utils.Remap(aquaticBoost, 0, AquaticEmblem.TimeToReachMaxBoost, 0, AquaticEmblem.MaxDefenseBoost); - Player.moveSpeed -= Utils.Remap(aquaticBoost, 0, AquaticEmblem.TimeToReachMaxBoost, 0, AquaticEmblem.MaxMoveSpeedReduction); + //Because mounts are unchanged by move speed we also don'y let them have the defense. + if (!Player.mount.Active) + { + Player.statDefense += (int)Utils.Remap(aquaticBoost, 0, AquaticEmblem.TimeToReachMaxBoost, 0, AquaticEmblem.MaxDefenseBoost); + Player.moveSpeed -= Utils.Remap(aquaticBoost, 0, AquaticEmblem.TimeToReachMaxBoost, 0, AquaticEmblem.MaxMoveSpeedReduction); + } } else aquaticBoost = 0f; diff --git a/Items/Accessories/AquaticEmblem.cs b/Items/Accessories/AquaticEmblem.cs index 760c5ba1ef..dbe9935d5d 100644 --- a/Items/Accessories/AquaticEmblem.cs +++ b/Items/Accessories/AquaticEmblem.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories player.npcTypeNoAggro[NPCID.PinkJellyfish] = true; player.npcTypeNoAggro[NPCID.Crab] = true; player.npcTypeNoAggro[NPCID.Squid] = true; - if (player.IsUnderwater()) + if (player.Calamity().countsAsAnyWet) player.gills = true; } } diff --git a/Items/Armor/Victide/VictideHeadBurrow.cs b/Items/Armor/Victide/VictideHeadBurrow.cs index d2e3cbe413..5618cd3570 100644 --- a/Items/Armor/Victide/VictideHeadBurrow.cs +++ b/Items/Armor/Victide/VictideHeadBurrow.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Armor.Victide { player.Calamity().victideBurrowHead = true; player.moveSpeed += MoveSpeedAccelerationBoost; - if (player.IsUnderwater()) + if (player.Calamity().countsAsAnyWet) player.gills = true; } diff --git a/Projectiles/Pets/OceanSpirit.cs b/Projectiles/Pets/OceanSpirit.cs index 6bdf7cbef1..e67d58d68d 100644 --- a/Projectiles/Pets/OceanSpirit.cs +++ b/Projectiles/Pets/OceanSpirit.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Pets Projectile.frame = sleepy ? 16 : 8; } } - underwater = player.IsUnderwater(); + underwater = player.Calamity().countsAsAnyWet; if (underwater) { if (Main.LocalPlayer.Calamity().ZoneAbyss) From 163166646787bd2dc1a62950f156ad454989f662 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 31 Dec 2025 00:17:01 -0600 Subject: [PATCH 17/22] blood pact buff blood pact was mathematically much worse than Charm of Myths. This brings the potion heal per second value between the two to be exactly the same, while leaving the difference in +1hp/s vs 25% max hp --- Items/Accessories/BloodPact.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Accessories/BloodPact.cs b/Items/Accessories/BloodPact.cs index 739dbe82c0..dd97b8121d 100644 --- a/Items/Accessories/BloodPact.cs +++ b/Items/Accessories/BloodPact.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.bloodPact = true; // This applies the +25% health boost. - modPlayer.healingPotionMultiplier += 0.25f; + modPlayer.healingPotionMultiplier += 0.33f; //Grants immunity to most Bleeding debuffs player.buffImmune[BuffID.Bleeding] = true; player.buffImmune[ModContent.BuffType()] = true; From 5dbf7261983d8826d8f1e8af5630ec45f6977fe5 Mon Sep 17 00:00:00 2001 From: doze-zoze Date: Wed, 31 Dec 2025 00:18:32 -0600 Subject: [PATCH 18/22] forgot local --- Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 74e6f2bac0..f85719aee0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -318,7 +318,7 @@ BloodPact: { ''' Increases max HP by 25% Grants immunity to Bleeding, Burning Blood and Heavy Bleeding - Healing Potions are 25% more effective + Healing Potions are 33% more effective ''' } From 94e1d5a2fe3fc4c96f25b10ac9dcd2c81026e1af Mon Sep 17 00:00:00 2001 From: Flowaria Date: Wed, 31 Dec 2025 19:40:18 +0900 Subject: [PATCH 19/22] Optimized ChaliceBleed and ManaBurn UI Bar --- UI/ResourceSets/CalamityResourceOverlay.cs | 83 ++++++++-------------- 1 file changed, 30 insertions(+), 53 deletions(-) diff --git a/UI/ResourceSets/CalamityResourceOverlay.cs b/UI/ResourceSets/CalamityResourceOverlay.cs index 294f8f3e82..2bf13689b0 100644 --- a/UI/ResourceSets/CalamityResourceOverlay.cs +++ b/UI/ResourceSets/CalamityResourceOverlay.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using CalamityMod.CalPlayer; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -147,35 +148,27 @@ namespace CalamityMod.UI.ResourceSets } if (drawType == 0) //bars { + int width = snapshot.AmountOfLifeHearts * 12; + float pixelsPerLife = 12f / snapshot.LifePerSegment; + int deadPixels = (int)MathF.Floor((snapshot.LifeMax - snapshot.Life) * pixelsPerLife); + int bleedPixels = (int)MathF.Ceiling((float)bleed * pixelsPerLife); + bleedPixels = Math.Min(bleedPixels, width - deadPixels); - // This works by dynamically creating a texture that it then draws over the life bar. - int width = 12 * snapshot.AmountOfLifeHearts; - GraphicsDevice _graphicsDevice = Main.graphics.GraphicsDevice; - var barOverlay = new Texture2D(_graphicsDevice, width, 12); - Color[] barTextureData = new Color[12 * 12]; - CalamityUIResourceSets.HPChaliceBleed.Bar.Value.GetData(barTextureData); - var pixelsPerLife = 12f / snapshot.LifePerSegment; - int deadPixels = (int)Math.Floor((snapshot.LifeMax - snapshot.Life) * pixelsPerLife); - var bleedPixels = Math.Round(bleed * pixelsPerLife); + if (bleedPixels < 0) + return; - Color[] textureData = new Color[width * 12]; + int barMaxStatX = (int)position.X - width; + int drawX = barMaxStatX + deadPixels; - // doze 19MAR2025 - I don't know if I could optimize this any further without switching to shaders. - // I don't expect performance issues, but at some point might be worth adding a config to disable the indicator in case of lag or accessibility concerns - for (int i = 0; i < textureData.Length; i++) - { - var i_MOD_width = i % width; //minor optimization, calculated here once instead of twice in the loop. - var bleedCol = Color.Transparent; - if ((i_MOD_width < bleedPixels + deadPixels) && !(i_MOD_width < deadPixels)) - { - bleedCol = barTextureData[((i % 12) + (i / width) * 12)]; - } - textureData[i] = bleedCol; - - } - - barOverlay.SetData(textureData); - Main.spriteBatch.Draw(barOverlay, position, null, Color.White, 0, new Vector2(width, 0), 1, SpriteEffects.None, 1); + using (Main.spriteBatch.Scope()) + { + var bleedDrawPos = new Vector2(drawX, position.Y); + var bleedDrawRect = new Rectangle(deadPixels % 12, 0, bleedPixels, 12); + var bleedDrawOrigin = new Vector2(0, 0); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix); + Main.spriteBatch.Draw(CalamityUIResourceSets.HPChaliceBleed.Bar.Value, bleedDrawPos, bleedDrawRect, Color.White, 0, bleedDrawOrigin, 1, SpriteEffects.None, 1); + Main.spriteBatch.End(); + } } else if (drawType == 1) //default heart { @@ -244,37 +237,21 @@ namespace CalamityMod.UI.ResourceSets } if (drawType == 0) //bars { + float pixelsPerStar = 12f / snapshot.ManaPerSegment; + int bleedPixels = (int)MathF.Ceiling((float)mana * pixelsPerStar); - // This works by dynamically creating a texture that it then draws over the life bar. - int width = 12 * stars; - if (width < 1) - width = 1; - GraphicsDevice _graphicsDevice = Main.graphics.GraphicsDevice; - var barOverlay = new Texture2D(_graphicsDevice, width, 12); - Color[] barTextureData = new Color[12 * 12]; - manaSet.Bar.Value.GetData(barTextureData); - var pixelsPerLife = 12f / snapshot.ManaPerSegment; - int deadPixels = (int)Math.Floor((snapshot.ManaMax + snapshot.Mana) * pixelsPerLife); - var bleedPixels = Math.Round(mana * pixelsPerLife); + if (bleedPixels < 0) + return; - Color[] textureData = new Color[width * 12]; - - // doze 19MAR2025 - I don't know if I could optimize this any further without switching to shaders. - // I don't expect performance issues, but at some point might be worth adding a config to disable the indicator in case of lag or accessibility concerns - for (int i = 0; i < textureData.Length; i++) + using (Main.spriteBatch.Scope()) { - var i_MOD_width = i % width; //minor optimization, calculated here once instead of twice in the loop. - var bleedCol = Color.Transparent; - if ((i_MOD_width < bleedPixels + deadPixels) && !(i_MOD_width < deadPixels)) - { - bleedCol = barTextureData[((i % 12) + (i / width) * 12)]; - } - textureData[i] = bleedCol; - + var bleedDrawPos = new Vector2(position.X, position.Y); + var bleedDrawRect = new Rectangle(-(bleedPixels % 12), 0, bleedPixels, 12); + var bleedDrawOrigin = new Vector2(bleedPixels, 0); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix); + Main.spriteBatch.Draw(CalamityUIResourceSets.MPManaBurn.Bar.Value, bleedDrawPos, bleedDrawRect, Color.White, 0, bleedDrawOrigin, 1, SpriteEffects.None, 1); + Main.spriteBatch.End(); } - - barOverlay.SetData(textureData); - Main.spriteBatch.Draw(barOverlay, position, null, Color.White, 0, new Vector2(width, 0), 1, SpriteEffects.None, 1); } else if (drawType == 1) //default heart { From 4abecb3ef767dde74a53fed7f820e7ba7543e72b Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Wed, 31 Dec 2025 11:14:58 -0500 Subject: [PATCH 20/22] Added donor name "Tequila" for Witch Doctor --- NPCs/CalamityGlobalTownNPC.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 1c1f3e6717..ac140bfe71 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -293,6 +293,7 @@ namespace CalamityMod.NPCs "Aeroni", // <@!348174404984766465> (aeroni) (previously: toxin) "Mixcoatl", // <@!284775927294984203> (.sharzz) "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) + "Tequila", // <@!889175547744239677> (thecrispistofnuggets) ]; private static readonly string[] WizardNames = [ From 9de1768cbc4954dfbe242719b4c28479e20c7cf0 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Wed, 31 Dec 2025 13:36:10 -0500 Subject: [PATCH 21/22] Hive Mind idle timer no longer speeds up when too close in Death Mode --- NPCs/HiveMind/HiveMind.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index e05c2ed981..c3da3cc0f7 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -803,10 +803,6 @@ namespace CalamityMod.NPCs.HiveMind // Use an attack sooner if being hit if (NPC.justHit) phase2timer -= 4; - - // Use an attack sooner if target is close - if (NPC.Distance(player.Center) < 160f) - phase2timer -= 2; } if (phase2timer <= -180) // No stalling drift mode forever From ca13073196efb7a8af716d8cecc69a31698c63db Mon Sep 17 00:00:00 2001 From: Dreitone Date: Wed, 31 Dec 2025 15:34:02 -0600 Subject: [PATCH 22/22] main thread wrap window titles --- UI/WindowTitles.cs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/UI/WindowTitles.cs b/UI/WindowTitles.cs index dd92747966..843587fe36 100644 --- a/UI/WindowTitles.cs +++ b/UI/WindowTitles.cs @@ -18,33 +18,38 @@ namespace CalamityMod.UI if (Main.dedServ) return; - // the other method involving some terraria intrinsic function didn't work, so i'm just ignoring it - var vanillaTitles = Language.FindAll(new Regex("^GameTitle\\.")).ToList(); - var customTitles = Language.FindAll(new Regex("^Mods\\.CalamityMod\\.UI\\.WindowTitle\\.")).ToList(); + Main.QueueMainThreadAction(() => + { + // the other method involving some terraria intrinsic function didn't work, so i'm just ignoring it + var vanillaTitles = Language.FindAll(new Regex("^GameTitle\\.")).ToList(); + var customTitles = Language.FindAll(new Regex("^Mods\\.CalamityMod\\.UI\\.WindowTitle\\.")).ToList(); - var allTitles = new List(); - allTitles.AddRange(vanillaTitles); - allTitles.AddRange(customTitles); - - _calamityModifiedText ??= allTitles[Main.rand.Next(allTitles.Count)]; - - // this is what vanilla terraria does to set it's title, so i'm replicating that here - Platform.Get().SetUnicodeTitle(Main.instance.Window, _calamityModifiedText.Value); - Platform.Get().SetIcon(Main.instance.Window); + var allTitles = new List(); + allTitles.AddRange(vanillaTitles); + allTitles.AddRange(customTitles); - loaded = true; + _calamityModifiedText ??= allTitles[Main.rand.Next(allTitles.Count)]; + + // this is what vanilla terraria does to set it's title, so i'm replicating that here + Platform.Get().SetUnicodeTitle(Main.instance.Window, _calamityModifiedText.Value); + Platform.Get().SetIcon(Main.instance.Window); + + loaded = true; + }); } public override void Unload() { if (Main.dedServ) return; - + Main.QueueMainThreadAction(() => + { Platform.Get().SetUnicodeTitle(Main.instance.Window, Lang.GetRandomGameTitle()); Platform.Get().SetIcon(Main.instance.Window); _calamityModifiedText = null; loaded = false; + }); base.Unload(); } }