Unstable v0.1300.0.0 (February 19th 2021)

This commit is contained in:
Joonas Rikkonen
2021-02-25 13:44:23 +02:00
parent b772654326
commit 24cbef485a
441 changed files with 21343 additions and 8562 deletions
@@ -1,4 +1,5 @@
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Collision;
@@ -446,21 +447,24 @@ namespace Barotrauma
private void UpdateDepthDamage(float deltaTime)
{
#if CLIENT
if (GameMain.GameSession.GameMode is TestGameMode) { return; }
if (GameMain.GameSession?.GameMode is TestGameMode) { return; }
#endif
if (Level.Loaded == null) { return; }
float submarineDepth = submarine.RealWorldDepth;
if (submarineDepth < Level.Loaded.RealWorldCrushDepth) { return; }
if (!Submarine.AtDamageDepth) { return; }
depthDamageTimer -= deltaTime;
if (depthDamageTimer > 0.0f) { return; }
foreach (Structure wall in Structure.WallList)
{
if (wall.Submarine != submarine || wall.CrushDepth > submarineDepth) { continue; }
if (wall.Submarine != submarine) { continue; }
float pastCrushDepth = submarineDepth - wall.CrushDepth;
Explosion.RangedStructureDamage(wall.WorldPosition, 100.0f, pastCrushDepth * 0.1f);
float wallCrushDepth = wall.CrushDepth;
if (submarine.Info.SubmarineClass == SubmarineClass.DeepDiver) { wallCrushDepth *= 1.2f; }
float pastCrushDepth = submarine.RealWorldDepth - wallCrushDepth;
if (pastCrushDepth < 0) { return; }
Explosion.RangedStructureDamage(wall.WorldPosition, 100.0f, pastCrushDepth * 0.1f, levelWallDamage: 0.0f);
if (Character.Controlled != null && Character.Controlled.Submarine == submarine)
{
GameMain.GameScreen.Cam.Shake = Math.Max(GameMain.GameScreen.Cam.Shake, Math.Min(pastCrushDepth * 0.001f, 50.0f));
@@ -555,19 +559,29 @@ namespace Barotrauma
{
if (limb?.body?.FarseerBody == null || limb.character == null) { return; }
if (limb.Mass > MinImpactLimbMass)
float impactMass = limb.Mass;
var enemyAI = limb.character.AIController as EnemyAIController;
float attackMultiplier = 1.0f;
if (enemyAI?.ActiveAttack != null)
{
impactMass = Math.Max(Math.Max(limb.Mass, limb.character.AnimController.MainLimb.Mass), limb.character.AnimController.Collider.Mass);
attackMultiplier = enemyAI.ActiveAttack.SubmarineImpactMultiplier;
}
if (impactMass * attackMultiplier > MinImpactLimbMass)
{
Vector2 normal =
Vector2.DistanceSquared(Body.SimPosition, limb.SimPosition) < 0.0001f ?
Vector2.UnitY :
Vector2.Normalize(Body.SimPosition - limb.SimPosition);
float impact = Math.Min(Vector2.Dot(collision.Velocity, -normal), 50.0f) * Math.Min(limb.Mass / 100.0f, 1);
float impact = Math.Min(Vector2.Dot(collision.Velocity, -normal), 50.0f) * Math.Min(impactMass / 300.0f, 1);
impact *= attackMultiplier;
ApplyImpact(impact, -normal, collision.ImpactPos, applyDamage: false);
ApplyImpact(impact, normal, collision.ImpactPos, applyDamage: false);
foreach (Submarine dockedSub in submarine.DockedTo)
{
dockedSub.SubBody.ApplyImpact(impact, -normal, collision.ImpactPos, applyDamage: false);
dockedSub.SubBody.ApplyImpact(impact, normal, collision.ImpactPos, applyDamage: false);
}
}
@@ -663,7 +677,7 @@ namespace Barotrauma
dockedSub.SubBody.ApplyImpact(wallImpact, -impact.Normal, impact.ImpactPos);
}
if (cell != null && wallImpact > 0.0f)
if (cell != null && cell.IsDestructible && wallImpact > 0.0f)
{
var hitWall = Level.Loaded?.ExtraWalls.Find(w => w.Cells.Contains(cell));
if (hitWall != null && hitWall.WallDamageOnTouch > 0.0f)
@@ -672,7 +686,7 @@ namespace Barotrauma
ConvertUnits.ToDisplayUnits(impact.ImpactPos),
500.0f,
hitWall.WallDamageOnTouch,
damageLevelWalls: false);
levelWallDamage: 0.0f);
#if CLIENT
PlayDamageSounds(damagedStructures, impact.ImpactPos, wallImpact, "StructureSlash");
#endif
@@ -800,7 +814,7 @@ namespace Barotrauma
#if CLIENT
if (Character.Controlled != null && Character.Controlled.Submarine == submarine)
{
GameMain.GameScreen.Cam.Shake = impact * 2.0f;
GameMain.GameScreen.Cam.Shake = impact * 10.0f;
if (submarine.Info.Type == SubmarineType.Player && !submarine.DockedTo.Any(s => s.Info.Type != SubmarineType.Player))
{
float angularVelocity =
@@ -814,25 +828,32 @@ namespace Barotrauma
foreach (Character c in Character.CharacterList)
{
if (c.Submarine != submarine) { continue; }
if (c.KnockbackCooldownTimer > 0.0f) { continue; }
c.KnockbackCooldownTimer = Character.KnockbackCooldown;
foreach (Limb limb in c.AnimController.Limbs)
{
if (limb.IsSevered) { continue; }
limb.body.ApplyLinearImpulse(limb.Mass * impulse, 10.0f);
}
c.AnimController.Collider.ApplyLinearImpulse(c.AnimController.Collider.Mass * impulse, 10.0f);
bool holdingOntoSomething = false;
if (c.SelectedConstruction != null)
{
var controller = c.SelectedConstruction.GetComponent<Items.Components.Controller>();
holdingOntoSomething = controller != null && controller.LimbPositions.Any();
holdingOntoSomething =
c.SelectedConstruction.GetComponent<Ladder>() != null ||
(c.SelectedConstruction.GetComponent<Controller>()?.LimbPositions.Any() ?? false);
}
//stun for up to 1 second if the impact equal or higher to the maximum impact
if (impact >= MaxCollisionImpact && !holdingOntoSomething)
if (!holdingOntoSomething)
{
c.SetStun(Math.Min(impulse.Length() * 0.2f, 1.0f));
c.AnimController.Collider.ApplyLinearImpulse(c.AnimController.Collider.Mass * impulse, 10.0f);
//stun for up to 2 second if the impact equal or higher to the maximum impact
if (impact >= MaxCollisionImpact)
{
c.AddDamage(impactPos, AfflictionPrefab.ImpactDamage.Instantiate(3.0f).ToEnumerable(), stun: Math.Min(impulse.Length() * 0.2f, 2.0f), playSound: true);
}
}
}
@@ -843,11 +864,12 @@ namespace Barotrauma
item.body.ApplyLinearImpulse(item.body.Mass * impulse, 10.0f);
}
float dmg = applyDamage ? impact * ImpactDamageMultiplier : 0.0f;
var damagedStructures = Explosion.RangedStructureDamage(
ConvertUnits.ToDisplayUnits(impactPos),
impact * 50.0f,
applyDamage ? impact * ImpactDamageMultiplier : 0.0f);
impact * 50.0f,
dmg, dmg);
#if CLIENT
PlayDamageSounds(damagedStructures, impactPos, impact, "StructureBlunt");