From efca114610e07da2d25ab03ae903d62cd1b7979c Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Wed, 26 Feb 2020 17:32:24 -0500 Subject: [PATCH] Cave darkness smoothly fades away as you reach hell --- CalPlayer/CalamityPlayerMiscEffects.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index b2769ab4d2..c163c8913f 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -418,7 +418,15 @@ namespace CalamityMod.CalPlayer double playerUndergroundDepth = point.Y - Main.worldSurface; double depthRatio = playerUndergroundDepth / totalUndergroundDepth; int lightStrength = modPlayer.GetTotalLightStrength(); - float darknessStrength = (float)depthRatio; + + // In the last 50 blocks before hell, the darkness smoothly fades away. + float FadeAwayStart = (float)(1D - 50D / totalUndergroundDepth); + float darknessStrength = (float)(depthRatio / FadeAwayStart); + if (depthRatio > FadeAwayStart) + { + // Varies from 1.0 to 0.0 as depthRatio varies from FadeAwayStart to 1.0. + darknessStrength = (1f - (float)depthRatio) / (1f - FadeAwayStart); + } // Reduce the power of cave darkness based on your light level. 5+ is enough to totally eliminate it. switch (lightStrength)