Hristov & .60 changes - Hristov Rework, Part 2 (#31662)

* Initial commit

* Updated values to reflect new resistances

* Review fixes

* Review fixes

* LINQ BEGONETH
This commit is contained in:
SlamBamActionman
2025-02-04 22:55:09 +01:00
committed by GitHub
parent 87fa6a3b74
commit e58d031300
7 changed files with 140 additions and 12 deletions

View File

@@ -1,9 +1,11 @@
using Content.Server.Administration.Logs;
using Content.Server.Destructible;
using Content.Server.Effects;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Camera;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Projectiles;
using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
@@ -15,6 +17,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ColorFlashEffectSystem _color = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly DestructibleSystem _destructibleSystem = default!;
[Dependency] private readonly GunSystem _guns = default!;
[Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!;
@@ -28,7 +31,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem
{
// This is so entities that shouldn't get a collision are ignored.
if (args.OurFixtureId != ProjectileFixture || !args.OtherFixture.Hard
|| component.DamagedEntity || component is { Weapon: null, OnlyCollideWhenShot: true })
|| component.ProjectileSpent || component is { Weapon: null, OnlyCollideWhenShot: true })
return;
var target = args.OtherEntity;
@@ -45,7 +48,13 @@ public sealed class ProjectileSystem : SharedProjectileSystem
RaiseLocalEvent(uid, ref ev);
var otherName = ToPrettyString(target);
var modifiedDamage = _damageableSystem.TryChangeDamage(target, ev.Damage, component.IgnoreResistances, origin: component.Shooter);
var damageRequired = _destructibleSystem.DestroyedAt(target);
if (TryComp<DamageableComponent>(target, out var damageableComponent))
{
damageRequired -= damageableComponent.TotalDamage;
damageRequired = FixedPoint2.Max(damageRequired, FixedPoint2.Zero);
}
var modifiedDamage = _damageableSystem.TryChangeDamage(target, ev.Damage, component.IgnoreResistances, damageable: damageableComponent, origin: component.Shooter);
var deleted = Deleted(target);
if (modifiedDamage is not null && EntityManager.EntityExists(component.Shooter))
@@ -60,6 +69,46 @@ public sealed class ProjectileSystem : SharedProjectileSystem
$"Projectile {ToPrettyString(uid):projectile} shot by {ToPrettyString(component.Shooter!.Value):user} hit {otherName:target} and dealt {modifiedDamage.GetTotal():damage} damage");
}
// If penetration is to be considered, we need to do some checks to see if the projectile should stop.
if (modifiedDamage is not null && component.PenetrationThreshold != 0)
{
// If a damage type is required, stop the bullet if the hit entity doesn't have that type.
if (component.PenetrationDamageTypeRequirement != null)
{
var stopPenetration = false;
foreach (var requiredDamageType in component.PenetrationDamageTypeRequirement)
{
if (!modifiedDamage.DamageDict.Keys.Contains(requiredDamageType))
{
stopPenetration = true;
break;
}
}
if (stopPenetration)
component.ProjectileSpent = true;
}
// If the object won't be destroyed, it "tanks" the penetration hit.
if (modifiedDamage.GetTotal() < damageRequired)
{
component.ProjectileSpent = true;
}
if (!component.ProjectileSpent)
{
component.PenetrationAmount += damageRequired;
// The projectile has dealt enough damage to be spent.
if (component.PenetrationAmount >= component.PenetrationThreshold)
{
component.ProjectileSpent = true;
}
}
}
else
{
component.ProjectileSpent = true;
}
if (!deleted)
{
_guns.PlayImpactSound(target, modifiedDamage, component.SoundHit, component.ForceSound);
@@ -68,9 +117,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem
_sharedCameraRecoil.KickCamera(target, args.OurBody.LinearVelocity.Normalized());
}
component.DamagedEntity = true;
if (component.DeleteOnCollide)
if (component.DeleteOnCollide && component.ProjectileSpent)
QueueDel(uid);
if (component.ImpactEffect != null && TryComp(uid, out TransformComponent? xform))