Make explosive armor multiplicative and not additive (#9498)
This commit is contained in:
@@ -16,10 +16,10 @@ namespace Content.Server.Explosion.Components;
|
|||||||
public sealed class ExplosionResistanceComponent : Component
|
public sealed class ExplosionResistanceComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
[DataField("resistance")]
|
[DataField("damageCoefficient")]
|
||||||
public float GlobalResistance = 0;
|
public float DamageCoefficient = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Like <see cref="GlobalResistance"/>, but specified specific to each explosion type for more customizability.
|
/// Like <see cref="GlobalResistance"/>, but specified specific to each explosion type for more customizability.
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
var ev = new GetExplosionResistanceEvent(explosionType.ID);
|
var ev = new GetExplosionResistanceEvent(explosionType.ID);
|
||||||
RaiseLocalEvent(uid, ev, false);
|
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);
|
explosionTolerance[index] = (float) ((totalDamageTarget - damageable.TotalDamage) / damagePerIntensity);
|
||||||
|
|||||||
@@ -362,14 +362,16 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
var ev = new GetExplosionResistanceEvent(id);
|
var ev = new GetExplosionResistanceEvent(id);
|
||||||
RaiseLocalEvent(uid, ev, false);
|
RaiseLocalEvent(uid, ev, false);
|
||||||
|
|
||||||
if (ev.Resistance == 0)
|
ev.DamageCoefficient = Math.Max(0, ev.DamageCoefficient);
|
||||||
|
|
||||||
|
if (ev.DamageCoefficient == 1)
|
||||||
{
|
{
|
||||||
// no damage-dict multiplication required.
|
// no damage-dict multiplication required.
|
||||||
_damageableSystem.TryChangeDamage(uid, damage, ignoreResistances: true, damageable: damageable);
|
_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, GetExplosionResistanceEvent args)
|
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))
|
if (component.Resistances.TryGetValue(args.ExplotionPrototype, out var resistance))
|
||||||
args.Resistance += resistance;
|
args.DamageCoefficient *= resistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,10 +11,9 @@ namespace Content.Shared.Explosion;
|
|||||||
public sealed class GetExplosionResistanceEvent : EntityEventArgs, IInventoryRelayEvent
|
public sealed class GetExplosionResistanceEvent : EntityEventArgs, IInventoryRelayEvent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Can be set to whatever, but currently is being additively increased by components & clothing. So think twice
|
/// A coefficient applied to overall explosive damage.
|
||||||
/// before multiplying or directly setting this.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Resistance = 0;
|
public float DamageCoefficient = 1;
|
||||||
|
|
||||||
public readonly string ExplotionPrototype;
|
public readonly string ExplotionPrototype;
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@
|
|||||||
Piercing: 0.9
|
Piercing: 0.9
|
||||||
Heat: 0.9
|
Heat: 0.9
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.9
|
damageCoefficient: 0.9
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
Piercing: 0.4
|
Piercing: 0.4
|
||||||
Heat: 0.9
|
Heat: 0.9
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.8
|
damageCoefficient: 0.8
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
Piercing: 0.6
|
Piercing: 0.6
|
||||||
Heat: 0.5
|
Heat: 0.5
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.65
|
damageCoefficient: 0.65
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
@@ -199,4 +199,4 @@
|
|||||||
walkModifier: 0.7
|
walkModifier: 0.7
|
||||||
sprintModifier: 0.65
|
sprintModifier: 0.65
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.5
|
damageCoefficient: 0.5
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
- type: TemperatureProtection
|
- type: TemperatureProtection
|
||||||
coefficient: 0.001
|
coefficient: 0.001
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.2
|
damageCoefficient: 0.2
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitAtmos
|
clothingPrototype: ClothingHeadHelmetHardsuitAtmos
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
Heat: 0.3
|
Heat: 0.3
|
||||||
Radiation: 0.1
|
Radiation: 0.1
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.5
|
damageCoefficient: 0.5
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitCap
|
clothingPrototype: ClothingHeadHelmetHardsuitCap
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
Heat: 0.2
|
Heat: 0.2
|
||||||
Radiation: 0.2
|
Radiation: 0.2
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.7
|
damageCoefficient: 0.7
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitDeathsquad
|
clothingPrototype: ClothingHeadHelmetHardsuitDeathsquad
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
Heat: 0.7
|
Heat: 0.7
|
||||||
Radiation: 0.35
|
Radiation: 0.35
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.2
|
damageCoefficient: 0.2
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitEngineering
|
clothingPrototype: ClothingHeadHelmetHardsuitEngineering
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
Heat: 0.4
|
Heat: 0.4
|
||||||
Radiation: 0.25
|
Radiation: 0.25
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.2
|
damageCoefficient: 0.2
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitEngineeringWhite
|
clothingPrototype: ClothingHeadHelmetHardsuitEngineeringWhite
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@
|
|||||||
walkModifier: 0.75
|
walkModifier: 0.75
|
||||||
sprintModifier: 0.75
|
sprintModifier: 0.75
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.3
|
damageCoefficient: 0.3
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitRd
|
clothingPrototype: ClothingHeadHelmetHardsuitRd
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
@@ -282,7 +282,7 @@
|
|||||||
Heat: 0.85
|
Heat: 0.85
|
||||||
Radiation: 0.5
|
Radiation: 0.5
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.3
|
damageCoefficient: 0.3
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitSalvage
|
clothingPrototype: ClothingHeadHelmetHardsuitSalvage
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
Heat: 0.8
|
Heat: 0.8
|
||||||
Radiation: 0.25
|
Radiation: 0.25
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.4
|
damageCoefficient: 0.4
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitSecurity
|
clothingPrototype: ClothingHeadHelmetHardsuitSecurity
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@
|
|||||||
Heat: 0.8
|
Heat: 0.8
|
||||||
Radiation: 0.25
|
Radiation: 0.25
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.6
|
damageCoefficient: 0.6
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitSecurityRed
|
clothingPrototype: ClothingHeadHelmetHardsuitSecurityRed
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@
|
|||||||
Heat: 0.4
|
Heat: 0.4
|
||||||
Radiation: 0.20
|
Radiation: 0.20
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.5
|
damageCoefficient: 0.5
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitSyndie
|
clothingPrototype: ClothingHeadHelmetHardsuitSyndie
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@
|
|||||||
Heat: 0.25
|
Heat: 0.25
|
||||||
Radiation: 0.20
|
Radiation: 0.20
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.5
|
damageCoefficient: 0.5
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitWizard
|
clothingPrototype: ClothingHeadHelmetHardsuitWizard
|
||||||
|
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
Heat: 0.5
|
Heat: 0.5
|
||||||
Radiation: 0.3
|
Radiation: 0.3
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.2
|
damageCoefficient: 0.2
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitLing
|
clothingPrototype: ClothingHeadHelmetHardsuitLing
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@
|
|||||||
Heat: 0.35
|
Heat: 0.35
|
||||||
Radiation: 0.1
|
Radiation: 0.1
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.8
|
damageCoefficient: 0.8
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitCybersun
|
clothingPrototype: ClothingHeadHelmetHardsuitCybersun
|
||||||
|
|
||||||
@@ -536,7 +536,7 @@
|
|||||||
Heat: 0.3
|
Heat: 0.3
|
||||||
Radiation: 0.20
|
Radiation: 0.20
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.5
|
damageCoefficient: 0.5
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitSyndieCommander
|
clothingPrototype: ClothingHeadHelmetHardsuitSyndieCommander
|
||||||
|
|
||||||
@@ -567,7 +567,7 @@
|
|||||||
Heat: 0.2
|
Heat: 0.2
|
||||||
Radiation: 0.20
|
Radiation: 0.20
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.3
|
damageCoefficient: 0.3
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetHardsuitSyndieElite
|
clothingPrototype: ClothingHeadHelmetHardsuitSyndieElite
|
||||||
|
|
||||||
@@ -600,7 +600,7 @@
|
|||||||
Shock: 0.1
|
Shock: 0.1
|
||||||
Radiation: 0.1
|
Radiation: 0.1
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.7
|
damageCoefficient: 0.7
|
||||||
- type: ToggleableClothing
|
- type: ToggleableClothing
|
||||||
clothingPrototype: ClothingHeadHelmetCBURN
|
clothingPrototype: ClothingHeadHelmetCBURN
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
Piercing: 0.9
|
Piercing: 0.9
|
||||||
Heat: 0.75
|
Heat: 0.75
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.65 # +0.25 from helmet -> 90%
|
damageCoefficient: 0.65
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterEVASuitBase
|
parent: ClothingOuterEVASuitBase
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
Piercing: 0.5
|
Piercing: 0.5
|
||||||
Heat: 0.9
|
Heat: 0.9
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.9
|
damageCoefficient: 0.9
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterStorageBase
|
parent: ClothingOuterStorageBase
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
Piercing: 0.3
|
Piercing: 0.3
|
||||||
Heat: 0.9
|
Heat: 0.9
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.9
|
damageCoefficient: 0.9
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
Piercing: 0.4
|
Piercing: 0.4
|
||||||
Heat: 0.9
|
Heat: 0.9
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.9
|
damageCoefficient: 0.9
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
Piercing: 0.75
|
Piercing: 0.75
|
||||||
Heat: 0.9
|
Heat: 0.9
|
||||||
- type: ExplosionResistance
|
- type: ExplosionResistance
|
||||||
resistance: 0.9
|
damageCoefficient: 0.9
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingOuterBase
|
parent: ClothingOuterBase
|
||||||
|
|||||||
Reference in New Issue
Block a user