Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Defs/GameSetupSteps/GameSetupStepDef_DarkShootingCurve.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<GameSetupStepDef>
<defName>CE_DarkShootingCurve</defName>
<order>1000</order>
<setupStep Class="CombatExtended.GameSetupStep_DarkShootingCurve">
<lightingShiftCurve>
<points>
<li>(0.5, 0)</li>
<li>(0.8, 10)</li>
<li>(1, 14)</li>
</points>
</lightingShiftCurve>
</setupStep>
</GameSetupStepDef>

</Defs>
4 changes: 4 additions & 0 deletions Source/CombatExtended/CombatExtended/CE_Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
5 changes: 4 additions & 1 deletion Source/CombatExtended/CombatExtended/LightingTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 9 additions & 1 deletion Source/CombatExtended/CombatExtended/ShiftVecReport.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using RimWorld;
using Verse;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down