Make explosive armor multiplicative and not additive (#9498)

This commit is contained in:
Nemanja
2022-07-06 23:15:20 -04:00
committed by GitHub
parent 458d05b29b
commit 3bedfb1cbf
9 changed files with 38 additions and 37 deletions

View File

@@ -16,10 +16,10 @@ namespace Content.Server.Explosion.Components;
public sealed class ExplosionResistanceComponent : Component
{
/// <summary>
/// The resistance values for this component, This fraction is added to the total resistance.
/// The explosive resistance coefficient, This fraction is multiplied into the total resistance.
/// </summary>
[DataField("resistance")]
public float GlobalResistance = 0;
[DataField("damageCoefficient")]
public float DamageCoefficient = 1;
/// <summary>
/// Like <see cref="GlobalResistance"/>, but specified specific to each explosion type for more customizability.

View File

@@ -155,7 +155,7 @@ public sealed partial class ExplosionSystem : EntitySystem
var ev = new GetExplosionResistanceEvent(explosionType.ID);
RaiseLocalEvent(uid, ev, false);
damagePerIntensity += value * Math.Clamp(0, 1 - ev.Resistance, 1);
damagePerIntensity += value * Math.Max(0, ev.DamageCoefficient);
}
explosionTolerance[index] = (float) ((totalDamageTarget - damageable.TotalDamage) / damagePerIntensity);

View File

@@ -362,14 +362,16 @@ public sealed partial class ExplosionSystem : EntitySystem
var ev = new GetExplosionResistanceEvent(id);
RaiseLocalEvent(uid, ev, false);
if (ev.Resistance == 0)
ev.DamageCoefficient = Math.Max(0, ev.DamageCoefficient);
if (ev.DamageCoefficient == 1)
{
// no damage-dict multiplication required.
_damageableSystem.TryChangeDamage(uid, damage, ignoreResistances: true, damageable: damageable);
}
else if (ev.Resistance < 1)
else
{
_damageableSystem.TryChangeDamage(uid, damage * (1 - ev.Resistance), ignoreResistances: true, damageable: damageable);
_damageableSystem.TryChangeDamage(uid, damage * ev.DamageCoefficient, ignoreResistances: true, damageable: damageable);
}
}

View File

@@ -93,9 +93,9 @@ public sealed partial class ExplosionSystem : EntitySystem
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, GetExplosionResistanceEvent args)
{
args.Resistance += component.GlobalResistance;
args.DamageCoefficient *= component.DamageCoefficient;
if (component.Resistances.TryGetValue(args.ExplotionPrototype, out var resistance))
args.Resistance += resistance;
args.DamageCoefficient *= resistance;
}
/// <summary>

View File

@@ -11,10 +11,9 @@ namespace Content.Shared.Explosion;
public sealed class GetExplosionResistanceEvent : EntityEventArgs, IInventoryRelayEvent
{
/// <summary>
/// Can be set to whatever, but currently is being additively increased by components & clothing. So think twice
/// before multiplying or directly setting this.
/// A coefficient applied to overall explosive damage.
/// </summary>
public float Resistance = 0;
public float DamageCoefficient = 1;
public readonly string ExplotionPrototype;

View File

@@ -135,7 +135,7 @@
Piercing: 0.9
Heat: 0.9
- type: ExplosionResistance
resistance: 0.9
damageCoefficient: 0.9
- type: entity
parent: ClothingOuterBase
@@ -155,7 +155,7 @@
Piercing: 0.4
Heat: 0.9
- type: ExplosionResistance
resistance: 0.8
damageCoefficient: 0.8
- type: entity
parent: ClothingOuterBase
@@ -175,7 +175,7 @@
Piercing: 0.6
Heat: 0.5
- type: ExplosionResistance
resistance: 0.65
damageCoefficient: 0.65
- type: entity
parent: ClothingOuterBase
@@ -199,4 +199,4 @@
walkModifier: 0.7
sprintModifier: 0.65
- type: ExplosionResistance
resistance: 0.5
damageCoefficient: 0.5

View File

@@ -25,7 +25,7 @@
- type: TemperatureProtection
coefficient: 0.001
- type: ExplosionResistance
resistance: 0.2
damageCoefficient: 0.2
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitAtmos
@@ -54,7 +54,7 @@
Heat: 0.3
Radiation: 0.1
- type: ExplosionResistance
resistance: 0.5
damageCoefficient: 0.5
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitCap
@@ -83,7 +83,7 @@
Heat: 0.2
Radiation: 0.2
- type: ExplosionResistance
resistance: 0.7
damageCoefficient: 0.7
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitDeathsquad
@@ -112,7 +112,7 @@
Heat: 0.7
Radiation: 0.35
- type: ExplosionResistance
resistance: 0.2
damageCoefficient: 0.2
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitEngineering
@@ -141,7 +141,7 @@
Heat: 0.4
Radiation: 0.25
- type: ExplosionResistance
resistance: 0.2
damageCoefficient: 0.2
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitEngineeringWhite
@@ -251,7 +251,7 @@
walkModifier: 0.75
sprintModifier: 0.75
- type: ExplosionResistance
resistance: 0.3
damageCoefficient: 0.3
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitRd
- type: StaticPrice
@@ -282,7 +282,7 @@
Heat: 0.85
Radiation: 0.5
- type: ExplosionResistance
resistance: 0.3
damageCoefficient: 0.3
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSalvage
@@ -308,7 +308,7 @@
Heat: 0.8
Radiation: 0.25
- type: ExplosionResistance
resistance: 0.4
damageCoefficient: 0.4
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSecurity
@@ -337,7 +337,7 @@
Heat: 0.8
Radiation: 0.25
- type: ExplosionResistance
resistance: 0.6
damageCoefficient: 0.6
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSecurityRed
@@ -366,7 +366,7 @@
Heat: 0.4
Radiation: 0.20
- type: ExplosionResistance
resistance: 0.5
damageCoefficient: 0.5
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndie
@@ -395,7 +395,7 @@
Heat: 0.25
Radiation: 0.20
- type: ExplosionResistance
resistance: 0.5
damageCoefficient: 0.5
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitWizard
@@ -424,7 +424,7 @@
Heat: 0.5
Radiation: 0.3
- type: ExplosionResistance
resistance: 0.2
damageCoefficient: 0.2
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitLing
@@ -507,7 +507,7 @@
Heat: 0.35
Radiation: 0.1
- type: ExplosionResistance
resistance: 0.8
damageCoefficient: 0.8
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitCybersun
@@ -536,7 +536,7 @@
Heat: 0.3
Radiation: 0.20
- type: ExplosionResistance
resistance: 0.5
damageCoefficient: 0.5
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndieCommander
@@ -567,7 +567,7 @@
Heat: 0.2
Radiation: 0.20
- type: ExplosionResistance
resistance: 0.3
damageCoefficient: 0.3
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetHardsuitSyndieElite
@@ -600,7 +600,7 @@
Shock: 0.1
Radiation: 0.1
- type: ExplosionResistance
resistance: 0.7
damageCoefficient: 0.7
- type: ToggleableClothing
clothingPrototype: ClothingHeadHelmetCBURN

View File

@@ -16,7 +16,7 @@
Piercing: 0.9
Heat: 0.75
- type: ExplosionResistance
resistance: 0.65 # +0.25 from helmet -> 90%
damageCoefficient: 0.65
- type: entity
parent: ClothingOuterEVASuitBase

View File

@@ -16,7 +16,7 @@
Piercing: 0.5
Heat: 0.9
- type: ExplosionResistance
resistance: 0.9
damageCoefficient: 0.9
- type: entity
parent: ClothingOuterStorageBase
@@ -36,7 +36,7 @@
Piercing: 0.3
Heat: 0.9
- type: ExplosionResistance
resistance: 0.9
damageCoefficient: 0.9
- type: entity
parent: ClothingOuterBase
@@ -56,7 +56,7 @@
Piercing: 0.4
Heat: 0.9
- type: ExplosionResistance
resistance: 0.9
damageCoefficient: 0.9
- type: entity
parent: ClothingOuterBase
@@ -76,7 +76,7 @@
Piercing: 0.75
Heat: 0.9
- type: ExplosionResistance
resistance: 0.9
damageCoefficient: 0.9
- type: entity
parent: ClothingOuterBase