Fix pressure damage calculations (#26217)
This commit is contained in:
@@ -224,69 +224,64 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
pressure = MathF.Max(mixture.Pressure, 1f);
|
pressure = MathF.Max(mixture.Pressure, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pressure)
|
pressure = pressure switch
|
||||||
{
|
{
|
||||||
// Low pressure.
|
// Adjust pressure based on equipment. Works differently depending on if it's "high" or "low".
|
||||||
case <= Atmospherics.WarningLowPressure:
|
<= Atmospherics.WarningLowPressure => GetFeltLowPressure(uid, barotrauma, pressure),
|
||||||
pressure = GetFeltLowPressure(uid, barotrauma, pressure);
|
>= Atmospherics.WarningHighPressure => GetFeltHighPressure(uid, barotrauma, pressure),
|
||||||
|
_ => pressure
|
||||||
|
};
|
||||||
|
|
||||||
if (pressure > Atmospherics.WarningLowPressure)
|
if (pressure <= Atmospherics.HazardLowPressure)
|
||||||
goto default;
|
{
|
||||||
|
// Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear.
|
||||||
|
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * Atmospherics.LowPressureDamage, true, false);
|
||||||
|
|
||||||
// Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear.
|
if (!barotrauma.TakingDamage)
|
||||||
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * Atmospherics.LowPressureDamage, true, false);
|
{
|
||||||
|
barotrauma.TakingDamage = true;
|
||||||
|
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} started taking low pressure damage");
|
||||||
|
}
|
||||||
|
|
||||||
if (!barotrauma.TakingDamage)
|
_alertsSystem.ShowAlert(uid, AlertType.LowPressure, 2);
|
||||||
{
|
}
|
||||||
barotrauma.TakingDamage = true;
|
else if (pressure >= Atmospherics.HazardHighPressure)
|
||||||
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} started taking low pressure damage");
|
{
|
||||||
}
|
var damageScale = MathF.Min(((pressure / Atmospherics.HazardHighPressure) - 1) * Atmospherics.PressureDamageCoefficient, Atmospherics.MaxHighPressureDamage);
|
||||||
|
|
||||||
if (pressure <= Atmospherics.HazardLowPressure)
|
// Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear.
|
||||||
{
|
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * damageScale, true, false);
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.LowPressure, 2);
|
|
||||||
|
if (!barotrauma.TakingDamage)
|
||||||
|
{
|
||||||
|
barotrauma.TakingDamage = true;
|
||||||
|
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} started taking high pressure damage");
|
||||||
|
}
|
||||||
|
|
||||||
|
_alertsSystem.ShowAlert(uid, AlertType.HighPressure, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Within safe pressure limits
|
||||||
|
if (barotrauma.TakingDamage)
|
||||||
|
{
|
||||||
|
barotrauma.TakingDamage = false;
|
||||||
|
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} stopped taking pressure damage");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set correct alert.
|
||||||
|
switch (pressure)
|
||||||
|
{
|
||||||
|
case <= Atmospherics.WarningLowPressure:
|
||||||
|
_alertsSystem.ShowAlert(uid, AlertType.LowPressure, 1);
|
||||||
break;
|
break;
|
||||||
}
|
case >= Atmospherics.WarningHighPressure:
|
||||||
|
_alertsSystem.ShowAlert(uid, AlertType.HighPressure, 1);
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.LowPressure, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// High pressure.
|
|
||||||
case >= Atmospherics.WarningHighPressure:
|
|
||||||
pressure = GetFeltHighPressure(uid, barotrauma, pressure);
|
|
||||||
|
|
||||||
if (pressure < Atmospherics.WarningHighPressure)
|
|
||||||
goto default;
|
|
||||||
|
|
||||||
var damageScale = MathF.Min((pressure / Atmospherics.HazardHighPressure) * Atmospherics.PressureDamageCoefficient, Atmospherics.MaxHighPressureDamage);
|
|
||||||
|
|
||||||
// Deal damage and ignore resistances. Resistance to pressure damage should be done via pressure protection gear.
|
|
||||||
_damageableSystem.TryChangeDamage(uid, barotrauma.Damage * damageScale, true, false);
|
|
||||||
|
|
||||||
if (!barotrauma.TakingDamage)
|
|
||||||
{
|
|
||||||
barotrauma.TakingDamage = true;
|
|
||||||
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} started taking high pressure damage");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pressure >= Atmospherics.HazardHighPressure)
|
|
||||||
{
|
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.HighPressure, 2);
|
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
_alertsSystem.ClearAlertCategory(uid, AlertCategory.Pressure);
|
||||||
_alertsSystem.ShowAlert(uid, AlertType.HighPressure, 1);
|
break;
|
||||||
break;
|
}
|
||||||
|
|
||||||
// Normal pressure.
|
|
||||||
default:
|
|
||||||
if (barotrauma.TakingDamage)
|
|
||||||
{
|
|
||||||
barotrauma.TakingDamage = false;
|
|
||||||
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} stopped taking pressure damage");
|
|
||||||
}
|
|
||||||
_alertsSystem.ClearAlertCategory(uid, AlertCategory.Pressure);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ namespace Content.Shared.Atmos
|
|||||||
public const float HazardLowPressure = 20f;
|
public const float HazardLowPressure = 20f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of pressure damage someone takes is equal to (pressure / HAZARD_HIGH_PRESSURE)*PRESSURE_DAMAGE_COEFFICIENT,
|
/// The amount of pressure damage someone takes is equal to ((pressure / HAZARD_HIGH_PRESSURE) - 1)*PRESSURE_DAMAGE_COEFFICIENT,
|
||||||
/// with the maximum of MaxHighPressureDamage.
|
/// with the maximum of MaxHighPressureDamage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float PressureDamageCoefficient = 4;
|
public const float PressureDamageCoefficient = 4;
|
||||||
|
|||||||
@@ -12,13 +12,14 @@
|
|||||||
- type: alarmThreshold
|
- type: alarmThreshold
|
||||||
id: stationPressure
|
id: stationPressure
|
||||||
upperBound: !type:AlarmThresholdSetting
|
upperBound: !type:AlarmThresholdSetting
|
||||||
threshold: 550 # as defined in Atmospherics.cs
|
threshold: 550 # HazardHighPressure from Atmospherics.cs
|
||||||
lowerBound: !type:AlarmThresholdSetting
|
lowerBound: !type:AlarmThresholdSetting
|
||||||
threshold: 20 # as defined in Atmospherics.cs
|
# Actual low pressure damage threshold is at 20 kPa, but below ~85 kPa you can't breathe due to lack of oxygen.
|
||||||
|
threshold: 85
|
||||||
upperWarnAround: !type:AlarmThresholdSetting
|
upperWarnAround: !type:AlarmThresholdSetting
|
||||||
threshold: 0.7
|
threshold: 0.7 # 385 kPa, WarningHighPressure from Atmospherics.cs
|
||||||
lowerWarnAround: !type:AlarmThresholdSetting
|
lowerWarnAround: !type:AlarmThresholdSetting
|
||||||
threshold: 2.5
|
threshold: 1.05 # ~90 kPa
|
||||||
|
|
||||||
# a reminder that all of these are percentages (where 1 is 100%),
|
# a reminder that all of these are percentages (where 1 is 100%),
|
||||||
# so 0.01 is 1%,
|
# so 0.01 is 1%,
|
||||||
|
|||||||
Reference in New Issue
Block a user