]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix for thrown items dealing damage twice to first target (#30115)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Fri, 19 Jul 2024 01:08:52 +0000 (18:08 -0700)
committerGitHub <noreply@github.com>
Fri, 19 Jul 2024 01:08:52 +0000 (21:08 -0400)
* FUCK YOU

* fine

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs

index ff4d1cabe98a9abbe0be9a6a8b12a99ad79ca7d1..8a7b3df0b2481af3d261e8f4ee20cbdf9fd84c04 100644 (file)
@@ -32,31 +32,25 @@ namespace Content.Server.Damage.Systems
 
         private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
         {
-            if (!TerminatingOrDeleted(args.Target))
-            {
-                var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
+            if (TerminatingOrDeleted(args.Target))
+                return;
 
-                // Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
-                if (dmg != null && HasComp<MobStateComponent>(args.Target))
-                    _adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.GetTotal():damage} damage from collision");
+            var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
 
-                if (dmg is { Empty: false })
-                {
-                    _color.RaiseEffect(Color.Red, new List<EntityUid>() { args.Target }, Filter.Pvs(args.Target, entityManager: EntityManager));
-                }
+            // Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
+            if (dmg != null && HasComp<MobStateComponent>(args.Target))
+                _adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.GetTotal():damage} damage from collision");
 
-                _guns.PlayImpactSound(args.Target, dmg, null, false);
-                if (TryComp<PhysicsComponent>(uid, out var body) && body.LinearVelocity.LengthSquared() > 0f)
-                {
-                    var direction = body.LinearVelocity.Normalized();
-                    _sharedCameraRecoil.KickCamera(args.Target, direction);
-                }
+            if (dmg is { Empty: false })
+            {
+                _color.RaiseEffect(Color.Red, new List<EntityUid>() { args.Target }, Filter.Pvs(args.Target, entityManager: EntityManager));
             }
 
-            // TODO: If more stuff touches this then handle it after.
-            if (TryComp<PhysicsComponent>(uid, out var physics))
+            _guns.PlayImpactSound(args.Target, dmg, null, false);
+            if (TryComp<PhysicsComponent>(uid, out var body) && body.LinearVelocity.LengthSquared() > 0f)
             {
-                _thrownItem.LandComponent(args.Thrown, args.Component, physics, false);
+                var direction = body.LinearVelocity.Normalized();
+                _sharedCameraRecoil.KickCamera(args.Target, direction);
             }
         }