Skip to content

Commit

Permalink
Heat Damage testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tostov authored Sep 7, 2024
1 parent fd8c80c commit a971255
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Source/CombatExtended/CombatExtended/ArmorUtilityCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ public static DamageInfo GetAfterArmorDamage(DamageInfo originalDinfo, Pawn pawn

var dinfo = new DamageInfo(originalDinfo);
var dmgAmount = dinfo.Amount;
var penAmount = originalDinfo.ArmorPenetrationInt; //GetPenetrationValue(originalDinfo);
var involveArmor = dinfo.Def.harmAllLayersUntilOutside || hitPart.depth == BodyPartDepth.Outside;
bool isAmbientDamage = dinfo.IsAmbientDamage();

// In case of ambient damage (fire, electricity) we apply a percentage reduction formula based on the sum of all applicable armor
if (isAmbientDamage)
{
dinfo.SetAmount(Mathf.CeilToInt(GetAmbientPostArmorDamage(dmgAmount, originalDinfo.Def.armorCategory.armorRatingStat, pawn, hitPart)));
dinfo.SetAmount(Mathf.CeilToInt(GetAmbientPostArmorDamage(dmgAmount, penAmount, originalDinfo.Def.armorCategory.armorRatingStat, pawn, hitPart)));
armorDeflected = dinfo.Amount <= 0;
return dinfo;
}
Expand All @@ -73,7 +74,6 @@ public static DamageInfo GetAfterArmorDamage(DamageInfo originalDinfo, Pawn pawn
deflectionComp.deflectedSharp = false;
}

var penAmount = originalDinfo.ArmorPenetrationInt; //GetPenetrationValue(originalDinfo);

// Apply worn armor
if (involveArmor && pawn.apparel != null && !pawn.apparel.WornApparel.NullOrEmpty())
Expand Down Expand Up @@ -419,9 +419,9 @@ private static bool TryDamageArmor(DamageDef def, float penAmount, float armorAm
/// <param name="pawn">The damaged pawn</param>
/// <param name="part">The body part affected</param>
/// <returns>The post-armor damage ranging from 0 to the original amount</returns>
private static float GetAmbientPostArmorDamage(float dmgAmount, StatDef armorRatingStat, Pawn pawn, BodyPartRecord part)
private static float GetAmbientPostArmorDamage(float dmgAmount,float penAmount, StatDef armorRatingStat, Pawn pawn, BodyPartRecord part)
{
var dmgMult = 1f;
var dmgMult = 1f + penAmount;
if (part.IsInGroup(CE_BodyPartGroupDefOf.CoveredByNaturalArmor))
{
dmgMult -= pawn.GetStatValue(armorRatingStat);
Expand All @@ -447,7 +447,10 @@ private static float GetAmbientPostArmorDamage(float dmgAmount, StatDef armorRat
}
}
}

if (dmgMult > 1)
{
dmgMult = 1;
}
var deflectionComp = pawn.TryGetComp<Comp_BurnDamageCalc>();
if (deflectionComp != null)
{
Expand Down

0 comments on commit a971255

Please sign in to comment.