diff --git a/Defs/GameSetupSteps/GameSetupStepDef_DarkShootingCurve.xml b/Defs/GameSetupSteps/GameSetupStepDef_DarkShootingCurve.xml new file mode 100644 index 0000000000..b059cbfdc7 --- /dev/null +++ b/Defs/GameSetupSteps/GameSetupStepDef_DarkShootingCurve.xml @@ -0,0 +1,18 @@ + + + + + CE_DarkShootingCurve + 1000 + + + +
  • (0.5, 0)
  • +
  • (0.8, 10)
  • +
  • (1, 14)
  • +
    +
    +
    +
    + +
    \ No newline at end of file diff --git a/Source/CombatExtended/CombatExtended/CE_Utility.cs b/Source/CombatExtended/CombatExtended/CE_Utility.cs index a890c2d924..8fdceca200 100644 --- a/Source/CombatExtended/CombatExtended/CE_Utility.cs +++ b/Source/CombatExtended/CombatExtended/CE_Utility.cs @@ -503,6 +503,10 @@ public static float GetMoveSpeed(Pawn pawn) public static float GetLightingShift(Thing caster, float glowAtTarget) { + if (glowAtTarget >= 0.5f) + { + return 0f; + } return Mathf.Max((1.0f - glowAtTarget) * (1.0f - caster.GetStatValue(CE_StatDefOf.NightVisionEfficiency)), 0f); } diff --git a/Source/CombatExtended/CombatExtended/GameSetupSteps/GameSetupStep_DarkShootingCurve.cs b/Source/CombatExtended/CombatExtended/GameSetupSteps/GameSetupStep_DarkShootingCurve.cs new file mode 100644 index 0000000000..aab423995e --- /dev/null +++ b/Source/CombatExtended/CombatExtended/GameSetupSteps/GameSetupStep_DarkShootingCurve.cs @@ -0,0 +1,21 @@ +using Verse; + +namespace CombatExtended +{ + public class GameSetupStep_DarkShootingCurve : GameSetupStep + { + public SimpleCurve lightingShiftCurve; + + public override int SeedPart => 58224853; // unused, but required + + public override void GenerateFresh() + { + ShiftVecReport.LightingShiftCurve = lightingShiftCurve; + } + + public override void GenerateFromScribe() + { + ShiftVecReport.LightingShiftCurve = lightingShiftCurve; + } + } +} diff --git a/Source/CombatExtended/CombatExtended/LightingTracker.cs b/Source/CombatExtended/CombatExtended/LightingTracker.cs index c6af9f14c9..fda4688529 100644 --- a/Source/CombatExtended/CombatExtended/LightingTracker.cs +++ b/Source/CombatExtended/CombatExtended/LightingTracker.cs @@ -238,9 +238,12 @@ public void Notify_ShotsFiredAt(IntVec3 position, float intensity = 0.8f) public float CombatGlowAt(IntVec3 position) { float result = 0f; + float centerGlow = GetGlowForCell(position); for (int i = 0; i < 9; i++) { - result += AdjWeights[i] * GetGlowForCell(position + AdjCells[i]) / WEIGHTSSUM; + var newPosition = position + AdjCells[i]; + float glow = newPosition.Impassable(map) ? centerGlow : GetGlowForCell(newPosition); + result += AdjWeights[i] * glow / WEIGHTSSUM; } return Mathf.Min(result, IsNight ? 0.5f : 1.0f); } diff --git a/Source/CombatExtended/CombatExtended/ShiftVecReport.cs b/Source/CombatExtended/CombatExtended/ShiftVecReport.cs index 5d53b95963..4144013141 100644 --- a/Source/CombatExtended/CombatExtended/ShiftVecReport.cs +++ b/Source/CombatExtended/CombatExtended/ShiftVecReport.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using RimWorld; using Verse; @@ -44,14 +45,17 @@ public float accuracyFactor public float lightingShift = 0f; public float weatherShift = 0f; + internal static SimpleCurve LightingShiftCurve = []; + private float enviromentShiftInt = -1; + public float enviromentShift { get { if (enviromentShiftInt < 0) { - enviromentShiftInt = ((blindFiring ? 1 : lightingShift) * 7f + weatherShift * 1.5f) * CE_Utility.LightingRangeMultiplier(shotDist) + smokeDensity; + enviromentShiftInt = LightingShiftCurve.Evaluate(((blindFiring ? 1 : lightingShift)) + weatherShift * 1.5f) * CE_Utility.LightingRangeMultiplier(shotDist) + smokeDensity; } return enviromentShiftInt; } @@ -71,6 +75,10 @@ public float visibilityShift se = 0.02f; } visibilityShiftInt = enviromentShift * (shotDist / 50 / se) * (2 - aimingAccuracy); + if (lightingShift >= 1f) + { + visibilityShiftInt += 1.5f; + } } return visibilityShiftInt; }