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
84 changes: 84 additions & 0 deletions Defs/Stats/Stats_Concealment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<!-- ================================== Pawn's stat =======================================-->

<StatDef>
<defName>ConcealmentEfficiency</defName>
<label>concealment efficiency</label>
<description>A measure of the creature's overall ability to conceal themselves and blend into surroundings, increasing visibility and range errors against them based on apparel, implants, and their natural abilities.</description>
<category>PawnCombat</category>
<defaultBaseValue>1</defaultBaseValue>
<displayPriorityInCategory>70</displayPriorityInCategory>
<toStringStyle>PercentZero</toStringStyle>
<showIfUndefined>true</showIfUndefined>
<minValue>0</minValue>
<maxValue>10.0</maxValue>
<parts>
<li Class="StatPart_Stuff">
<priority>100</priority>
<stuffPowerStat>StuffPower_ConcealmentEfficiency</stuffPowerStat>
<multiplierStat>StuffEffectMultiplierConcealment</multiplierStat>
</li>
<li Class="StatPart_GearStatOffset">
<apparelStat>ConcealmentEfficiency_Apparel</apparelStat>
</li>
</parts>
</StatDef>

<!-- how much this apparel by itself and by its stuff increases concealment -->
<StatDef>
<defName>ConcealmentEfficiency_Apparel</defName>
<label>apparel concealment offset</label>
<description>The effect of apparel items on a creature's ability to conceal themselves and blend into surroundings, increasing visibility and range errors against them.</description>
<category>Apparel</category>
<minValue>0</minValue>
<maxValue>10.0</maxValue>
<hideAtValue>0</hideAtValue>
<defaultBaseValue>0</defaultBaseValue>
<toStringStyle>PercentZero</toStringStyle>
<showIfUndefined>false</showIfUndefined>
<parts>
<li Class="StatPart_Quality">
<factorAwful>0.70</factorAwful>
<factorPoor>0.85</factorPoor>
<factorNormal>1</factorNormal>
<factorGood>1.05</factorGood>
<factorExcellent>1.1</factorExcellent>
<factorMasterwork>1.15</factorMasterwork>
<factorLegendary>1.25</factorLegendary>
</li>
<li Class="StatPart_Stuff">
<priority>100</priority>
<stuffPowerStat>StuffPower_ConcealmentEfficiency</stuffPowerStat>
<multiplierStat>StuffEffectMultiplierConcealment</multiplierStat>
</li>
</parts>
</StatDef>

<!-- how much this material improves apparel concealment -->
<StatDef>
<defName>StuffPower_ConcealmentEfficiency</defName>
<label>Concealment Efficiency</label>
<description>How much an apparel made of this material improves a wearer's ability to conceal themselves and blend into surroundings.</description>
<category>StuffStatFactors</category>
<defaultBaseValue>0</defaultBaseValue>
<hideAtValue>1</hideAtValue>
<minValue>0</minValue>
<toStringStyle>PercentZero</toStringStyle>
<showIfUndefined>false</showIfUndefined>
<displayPriorityInCategory>79</displayPriorityInCategory>
</StatDef>

<!-- how much this armor increases the power of stuff's concealment bonus -->
<StatDef>
<defName>StuffEffectMultiplierConcealment</defName>
<label>Concealment - Material effect multiplier</label>
<category>Apparel</category>
<defaultBaseValue>1</defaultBaseValue>
<minValue>0</minValue>
<alwaysHide>true</alwaysHide>
<displayPriorityInCategory>1</displayPriorityInCategory>
</StatDef>

</Defs>
1 change: 1 addition & 0 deletions Languages/English/Keyed/Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<CE_CoverHeight>Cover height</CE_CoverHeight>
<CE_TargetHeight>Target height</CE_TargetHeight>
<CE_TargetWidth>Target width</CE_TargetWidth>
<CE_Concealment>Concealment</CE_Concealment>

<CE_EstimatedHitChance>Estimated hit chance</CE_EstimatedHitChance>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static CE_StatDefOf()
public static StatDef BodyPartBluntArmor;
public static StatDef AverageSharpArmor;
public static StatDef NightVisionEfficiency;
public static StatDef ConcealmentEfficiency;

public static StatDef SmokeSensitivity;

Expand Down
21 changes: 19 additions & 2 deletions Source/CombatExtended/CombatExtended/ShiftVecReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,25 @@ public float visibilityShift
{
se = 0.02f;
}
visibilityShiftInt = environmentShift * (shotDist / 50 / se) * (2 - aimingAccuracy);
visibilityShiftInt = environmentShift * (shotDist / 50 / se) * (2 - aimingAccuracy) * concealmentFactor;
}
return visibilityShiftInt;
}
}

public float concealmentFactor
{
get
{
if (targetPawn != null)
{
return targetPawn.GetStatValue(CE_StatDefOf.ConcealmentEfficiency);
}

return 1f;
}
}

// Leading variables
public float shotSpeed = 0f;
private bool targetIsMoving
Expand Down Expand Up @@ -169,7 +182,7 @@ public float distShift
{
get
{
return shotDist * (shotDist / Math.Max(maxRange, 20)) * Mathf.Min(accuracyFactor * 0.5f, 0.8f);
return shotDist * (shotDist / Math.Max(maxRange, 20)) * Mathf.Min(accuracyFactor * 0.5f, 0.8f) * concealmentFactor;
}
}

Expand Down Expand Up @@ -283,6 +296,10 @@ public string GetTextReadout()
{
stringBuilder.AppendLine(" " + "CE_RangeError".Translate() + "\t" + GenText.ToStringByStyle(distShift, ToStringStyle.FloatTwo) + " " + "CE_cells".Translate());
}
if ((visibilityShift > 0 || distShift > 0) && !Mathf.Approximately(concealmentFactor, 1f))
{
stringBuilder.AppendLine(" " + "CE_Concealment".Translate() + "\t" + AsPercent(concealmentFactor));
}
if (swayDegrees > 0)
{
stringBuilder.AppendLine(" " + "CE_Sway".Translate() + "\t\t" + GenText.ToStringByStyle(swayDegrees, ToStringStyle.FloatTwo) + "CE_degrees".Translate());
Expand Down
Loading