v1.1.19.3 (Treacherous Tides Hotfix 2)
This commit is contained in:
@@ -130,10 +130,17 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// When set to true, the explosion don't deal less damage when the target is behind a solid object.
|
||||
/// </summary>
|
||||
public bool IgnoreCover
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public bool IgnoreCover { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Does the damage from the explosion decrease with distance from the origin of the explosion?
|
||||
/// </summary>
|
||||
public bool DistanceFalloff { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Structures that don't count as "cover" that reduces damage from the explosion. Only relevant if IgnoreCover is set to false.
|
||||
/// </summary>
|
||||
public IEnumerable<Structure> IgnoredCover;
|
||||
|
||||
/// <summary>
|
||||
/// How long the light source created by the explosion lasts.
|
||||
@@ -311,12 +318,15 @@ namespace Barotrauma
|
||||
|
||||
if (!MathUtils.NearlyEqual(Attack.GetStructureDamage(1.0f), 0.0f) || !MathUtils.NearlyEqual(Attack.GetLevelWallDamage(1.0f), 0.0f))
|
||||
{
|
||||
RangedStructureDamage(worldPosition, displayRange, Attack.GetStructureDamage(1.0f), Attack.GetLevelWallDamage(1.0f), attacker, IgnoredSubmarines, Attack.EmitStructureDamageParticles);
|
||||
RangedStructureDamage(worldPosition, displayRange, Attack.GetStructureDamage(1.0f), Attack.GetLevelWallDamage(1.0f), attacker,
|
||||
IgnoredSubmarines,
|
||||
Attack.EmitStructureDamageParticles,
|
||||
DistanceFalloff);
|
||||
}
|
||||
|
||||
if (BallastFloraDamage > 0.0f)
|
||||
{
|
||||
RangedBallastFloraDamage(worldPosition, displayRange, BallastFloraDamage, attacker);
|
||||
RangedBallastFloraDamage(worldPosition, displayRange, BallastFloraDamage, attacker, DistanceFalloff);
|
||||
}
|
||||
|
||||
if (EmpStrength > 0.0f)
|
||||
@@ -326,7 +336,7 @@ namespace Barotrauma
|
||||
{
|
||||
float distSqr = Vector2.DistanceSquared(item.WorldPosition, worldPosition);
|
||||
if (distSqr > displayRangeSqr) { continue; }
|
||||
float distFactor = CalculateDistanceFactor(distSqr, displayRange);
|
||||
float distFactor = DistanceFalloff ? CalculateDistanceFactor(distSqr, displayRange) : 1.0f;
|
||||
|
||||
//damage repairable power-consuming items
|
||||
var powered = item.GetComponent<Powered>();
|
||||
@@ -362,7 +372,10 @@ namespace Barotrauma
|
||||
float distSqr = Vector2.DistanceSquared(item.WorldPosition, worldPosition);
|
||||
if (distSqr > displayRangeSqr) { continue; }
|
||||
|
||||
float distFactor = 1.0f - (float)Math.Sqrt(distSqr) / displayRange;
|
||||
float distFactor =
|
||||
DistanceFalloff ?
|
||||
1.0f - (float)Math.Sqrt(distSqr) / displayRange :
|
||||
1.0f;
|
||||
//repair repairable items
|
||||
if (item.Repairables.Any())
|
||||
{
|
||||
@@ -415,13 +428,16 @@ namespace Barotrauma
|
||||
|
||||
if (item.Prefab.DamagedByExplosions && !item.Indestructible)
|
||||
{
|
||||
float distFactor = 1.0f - dist / displayRange;
|
||||
float distFactor =
|
||||
DistanceFalloff ?
|
||||
1.0f - dist / displayRange :
|
||||
1.0f;
|
||||
float damageAmount = Attack.GetItemDamage(1.0f, item.Prefab.ExplosionDamageMultiplier);
|
||||
|
||||
Vector2 explosionPos = worldPosition;
|
||||
if (item.Submarine != null) { explosionPos -= item.Submarine.Position; }
|
||||
|
||||
damageAmount *= GetObstacleDamageMultiplier(ConvertUnits.ToSimUnits(explosionPos), worldPosition, item.SimPosition);
|
||||
damageAmount *= GetObstacleDamageMultiplier(ConvertUnits.ToSimUnits(explosionPos), worldPosition, item.SimPosition, IgnoredCover);
|
||||
item.Condition -= damageAmount * distFactor;
|
||||
}
|
||||
}
|
||||
@@ -482,12 +498,15 @@ namespace Barotrauma
|
||||
|
||||
if (dist > attack.Range) { continue; }
|
||||
|
||||
float distFactor = 1.0f - dist / attack.Range;
|
||||
float distFactor =
|
||||
DistanceFalloff ?
|
||||
1.0f - dist / attack.Range :
|
||||
1.0f;
|
||||
|
||||
//solid obstacles between the explosion and the limb reduce the effect of the explosion
|
||||
if (!IgnoreCover)
|
||||
{
|
||||
distFactor *= GetObstacleDamageMultiplier(explosionPos, worldPosition, limb.SimPosition);
|
||||
distFactor *= GetObstacleDamageMultiplier(explosionPos, worldPosition, limb.SimPosition, IgnoredCover);
|
||||
}
|
||||
if (distFactor > 0)
|
||||
{
|
||||
@@ -602,7 +621,8 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Returns a dictionary where the keys are the structures that took damage and the values are the amount of damage taken
|
||||
/// </summary>
|
||||
public static Dictionary<Structure, float> RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage, float levelWallDamage, Character attacker = null, IEnumerable<Submarine> ignoredSubmarines = null, bool emitWallDamageParticles = true)
|
||||
public static Dictionary<Structure, float> RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage, float levelWallDamage, Character attacker = null, IEnumerable<Submarine> ignoredSubmarines = null,
|
||||
bool emitWallDamageParticles = true, bool distanceFalloff = true)
|
||||
{
|
||||
float dist = 600.0f;
|
||||
damagedStructures.Clear();
|
||||
@@ -616,7 +636,10 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < structure.SectionCount; i++)
|
||||
{
|
||||
float distFactor = 1.0f - (Vector2.Distance(structure.SectionPosition(i, true), worldPosition) / worldRange);
|
||||
float distFactor =
|
||||
distanceFalloff ?
|
||||
1.0f - (Vector2.Distance(structure.SectionPosition(i, true), worldPosition) / worldRange) :
|
||||
1.0f;
|
||||
if (distFactor <= 0.0f) { continue; }
|
||||
|
||||
structure.AddDamage(i, damage * distFactor, attacker, emitParticles: emitWallDamageParticles);
|
||||
@@ -680,7 +703,7 @@ namespace Barotrauma
|
||||
return damagedStructures;
|
||||
}
|
||||
|
||||
public static void RangedBallastFloraDamage(Vector2 worldPosition, float worldRange, float damage, Character attacker = null)
|
||||
public static void RangedBallastFloraDamage(Vector2 worldPosition, float worldRange, float damage, Character attacker = null, bool distanceFalloff = true)
|
||||
{
|
||||
List<BallastFloraBehavior> ballastFlorae = new List<BallastFloraBehavior>();
|
||||
|
||||
@@ -698,7 +721,10 @@ namespace Barotrauma
|
||||
float branchDist = Vector2.Distance(branchWorldPos, worldPosition);
|
||||
if (branchDist < worldRange)
|
||||
{
|
||||
float distFactor = 1.0f - (branchDist / worldRange);
|
||||
float distFactor =
|
||||
distanceFalloff ?
|
||||
1.0f - (branchDist / worldRange) :
|
||||
1.0f;
|
||||
if (distFactor <= 0.0f) { return; }
|
||||
|
||||
Vector2 explosionPos = worldPosition;
|
||||
@@ -715,7 +741,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetObstacleDamageMultiplier(Vector2 explosionSimPos, Vector2 explosionWorldPos, Vector2 targetSimPos)
|
||||
private static float GetObstacleDamageMultiplier(Vector2 explosionSimPos, Vector2 explosionWorldPos, Vector2 targetSimPos, IEnumerable<Structure> ignoredCover = null)
|
||||
{
|
||||
float damageMultiplier = 1.0f;
|
||||
var obstacles = Submarine.PickBodies(targetSimPos, explosionSimPos, collisionCategory: Physics.CollisionItem | Physics.CollisionItemBlocking | Physics.CollisionWall);
|
||||
@@ -728,6 +754,10 @@ namespace Barotrauma
|
||||
}
|
||||
else if (body.UserData is Structure structure)
|
||||
{
|
||||
if (ignoredCover != null)
|
||||
{
|
||||
if (ignoredCover.Contains(structure)) { continue; }
|
||||
}
|
||||
int sectionIndex = structure.FindSectionIndex(explosionWorldPos, world: true, clamp: true);
|
||||
if (structure.SectionBodyDisabled(sectionIndex))
|
||||
{
|
||||
|
||||
@@ -109,6 +109,8 @@ namespace Barotrauma
|
||||
|
||||
public float Size => IsHorizontal ? Rect.Height : Rect.Width;
|
||||
|
||||
public float PressureDistributionSpeed => Size / 100.0f * open;
|
||||
|
||||
private Door connectedDoor;
|
||||
public Door ConnectedDoor
|
||||
{
|
||||
@@ -427,11 +429,9 @@ namespace Barotrauma
|
||||
|
||||
if (hull1.WaterVolume <= 0.0 && hull2.WaterVolume <= 0.0) { return; }
|
||||
|
||||
float size = IsHorizontal ? rect.Height : rect.Width;
|
||||
|
||||
//a variable affecting the water flow through the gap
|
||||
//the larger the gap is, the faster the water flows
|
||||
float sizeModifier = size / 100.0f * open;
|
||||
float sizeModifier = Size / 100.0f * open;
|
||||
|
||||
//horizontal gap (such as a regular door)
|
||||
if (IsHorizontal)
|
||||
@@ -440,7 +440,7 @@ namespace Barotrauma
|
||||
float delta = 0.0f;
|
||||
|
||||
//water level is above the lower boundary of the gap
|
||||
if (Math.Max(hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface + subOffset.Y + hull2.WaveY[0]) > rect.Y - size)
|
||||
if (Math.Max(hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface + subOffset.Y + hull2.WaveY[0]) > rect.Y - Size)
|
||||
{
|
||||
int dir = (hull1.Pressure > hull2.Pressure + subOffset.Y) ? 1 : -1;
|
||||
|
||||
@@ -569,27 +569,35 @@ namespace Barotrauma
|
||||
|
||||
if (open > 0.0f)
|
||||
{
|
||||
if (hull1.WaterVolume > hull1.Volume / Hull.MaxCompress && hull2.WaterVolume > hull2.Volume / Hull.MaxCompress)
|
||||
if (hull1.WaterVolume > hull1.Volume / Hull.MaxCompress &&
|
||||
hull2.WaterVolume > hull2.Volume / Hull.MaxCompress)
|
||||
{
|
||||
//both hulls full -> distribute pressure
|
||||
float avgLethality = (hull1.LethalPressure + hull2.LethalPressure) / 2.0f;
|
||||
hull1.LethalPressure = avgLethality;
|
||||
hull2.LethalPressure = avgLethality;
|
||||
changePressure(hull1, avgLethality, PressureDistributionSpeed, deltaTime);
|
||||
changePressure(hull2, avgLethality, PressureDistributionSpeed, deltaTime);
|
||||
|
||||
static void changePressure(Hull hull, float target, float speed, float deltaTime)
|
||||
{
|
||||
float diff = target - hull.LethalPressure;
|
||||
float maxChange = Hull.PressureBuildUpSpeed * speed * deltaTime;
|
||||
hull.LethalPressure += MathHelper.Clamp(diff, -maxChange, maxChange);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hull1.LethalPressure -= Hull.PressureDropSpeed * deltaTime;
|
||||
hull2.LethalPressure -= Hull.PressureDropSpeed * deltaTime;
|
||||
//either hull not full -> pressure drops
|
||||
hull1.LethalPressure -= Hull.PressureDropSpeed * PressureDistributionSpeed * deltaTime;
|
||||
hull2.LethalPressure -= Hull.PressureDropSpeed * PressureDistributionSpeed * deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateRoomToOut(float deltaTime, Hull hull1)
|
||||
{
|
||||
float size = IsHorizontal ? rect.Height : rect.Width;
|
||||
|
||||
//a variable affecting the water flow through the gap
|
||||
//the larger the gap is, the faster the water flows
|
||||
float sizeModifier = size * open * open;
|
||||
float sizeModifier = Size * open * open;
|
||||
|
||||
float delta = 500.0f * sizeModifier * deltaTime;
|
||||
|
||||
@@ -642,7 +650,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * deltaTime;
|
||||
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * PressureDistributionSpeed * deltaTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -657,7 +665,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (hull1.WaterVolume >= hull1.Volume / Hull.MaxCompress)
|
||||
{
|
||||
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * deltaTime;
|
||||
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * PressureDistributionSpeed * deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1016,7 +1016,11 @@ namespace Barotrauma
|
||||
|
||||
if (waterVolume < Volume)
|
||||
{
|
||||
LethalPressure -= PressureDropSpeed * deltaTime;
|
||||
//pressure drop speed is inversely proportionate to water percentage
|
||||
//= pressure drops very fast if the hull is nowhere near full
|
||||
float waterVolumeFactor = Math.Max((100.0f - WaterPercentage) / 10.0f, 1.0f);
|
||||
LethalPressure -=
|
||||
PressureDropSpeed * waterVolumeFactor * deltaTime;
|
||||
if (WaterVolume <= 0.0f)
|
||||
{
|
||||
#if CLIENT
|
||||
|
||||
@@ -365,7 +365,7 @@ namespace Barotrauma
|
||||
if (FinishedEvents.Any())
|
||||
{
|
||||
var finishedEventsElement = new XElement(nameof(FinishedEvents));
|
||||
foreach (var (set, count) in FinishedEvents.DistinctBy(f => f.Key.Identifier))
|
||||
foreach (var (set, count) in FinishedEvents)
|
||||
{
|
||||
var element = new XElement(nameof(FinishedEvents),
|
||||
new XAttribute("set", set.Identifier),
|
||||
|
||||
@@ -1245,7 +1245,7 @@ namespace Barotrauma
|
||||
|
||||
private static void CreateWallDamageExplosion(Gap gap, Character attacker)
|
||||
{
|
||||
const float explosionRange = 750.0f;
|
||||
const float explosionRange = 500.0f;
|
||||
float explosionStrength = gap.Open;
|
||||
|
||||
var linkedHull = gap.linkedTo.FirstOrDefault() as Hull;
|
||||
@@ -1264,20 +1264,22 @@ namespace Barotrauma
|
||||
|
||||
if (explosionOnBroken == null)
|
||||
{
|
||||
explosionOnBroken = new Explosion(explosionRange, force: 10.0f, damage: 0.0f, structureDamage: 0.0f, itemDamage: 0.0f);
|
||||
explosionOnBroken = new Explosion(explosionRange, force: 5.0f, damage: 0.0f, structureDamage: 0.0f, itemDamage: 0.0f);
|
||||
if (AfflictionPrefab.Prefabs.TryGet("lacerations".ToIdentifier(), out AfflictionPrefab lacerations))
|
||||
{
|
||||
explosionOnBroken.Attack.Afflictions.Add(lacerations.Instantiate(3.0f), null);
|
||||
explosionOnBroken.Attack.Afflictions.Add(lacerations.Instantiate(5.0f), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
explosionOnBroken.Attack.Afflictions.Add(AfflictionPrefab.InternalDamage.Instantiate(3.0f), null);
|
||||
explosionOnBroken.Attack.Afflictions.Add(AfflictionPrefab.InternalDamage.Instantiate(5.0f), null);
|
||||
}
|
||||
explosionOnBroken.IgnoreCover = true;
|
||||
explosionOnBroken.IgnoreCover = false;
|
||||
explosionOnBroken.OnlyInside = true;
|
||||
explosionOnBroken.DistanceFalloff = false;
|
||||
explosionOnBroken.DisableParticles();
|
||||
}
|
||||
|
||||
explosionOnBroken.IgnoredCover = gap.ConnectedWall?.ToEnumerable();
|
||||
explosionOnBroken.Attack.Range = explosionRange * gap.Open;
|
||||
explosionOnBroken.Attack.DamageMultiplier = explosionStrength;
|
||||
explosionOnBroken.Attack.Stun = MathHelper.Clamp(explosionStrength, 0.5f, 1.0f);
|
||||
|
||||
Reference in New Issue
Block a user