]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Zombies can't hurt II. (#41007)
authorPrincess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
Mon, 20 Oct 2025 17:55:34 +0000 (10:55 -0700)
committerGitHub <noreply@github.com>
Mon, 20 Oct 2025 17:55:34 +0000 (17:55 +0000)
* Make zombie system not fard

* Actually who cares if our owner is not a zombie, let melee weapons be zombies that's funny as fuck

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Content.Server/Zombies/ZombieSystem.cs

index b8f2bd56ed5b3bc8d01a1e3d60861e0319da4071..d4f86fa96cb4e7dcb76f36ff17892ba6ca0cbda9 100644 (file)
@@ -236,43 +236,47 @@ namespace Content.Server.Zombies
             return MathF.Max(chance, zombieComponent.MinZombieInfectionChance);
         }
 
-        private void OnMeleeHit(EntityUid uid, ZombieComponent component, MeleeHitEvent args)
+        private void OnMeleeHit(Entity<ZombieComponent> entity, ref MeleeHitEvent args)
         {
-            if (!TryComp<ZombieComponent>(args.User, out _))
+            if (!args.IsHit)
                 return;
 
-            if (!args.HitEntities.Any())
-                return;
+            var cannotSpread = HasComp<NonSpreaderZombieComponent>(args.User);
 
-            foreach (var entity in args.HitEntities)
+            foreach (var uid in args.HitEntities)
             {
-                if (args.User == entity)
+                if (args.User == uid)
                     continue;
 
-                if (!TryComp<MobStateComponent>(entity, out var mobState))
+                if (!TryComp<MobStateComponent>(uid, out var mobState))
                     continue;
 
-                if (HasComp<ZombieComponent>(entity))
+                if (HasComp<ZombieComponent>(uid) || HasComp<IncurableZombieComponent>(uid))
                 {
-                    args.BonusDamage = -args.BaseDamage;
-                }
-                else
-                {
-                    if (!HasComp<ZombieImmuneComponent>(entity) && !HasComp<NonSpreaderZombieComponent>(args.User) && _random.Prob(GetZombieInfectionChance(entity, component)))
-                    {
-                        EnsureComp<PendingZombieComponent>(entity);
-                        EnsureComp<ZombifyOnDeathComponent>(entity);
-                    }
+                    // Don't infect, don't deal damage, do not heal from bites, don't pass go!
+                    args.Handled = true;
+                    continue;
                 }
 
-                if (_mobState.IsIncapacitated(entity, mobState) && !HasComp<ZombieComponent>(entity) && !HasComp<ZombieImmuneComponent>(entity) && !HasComp<NonSpreaderZombieComponent>(args.User))
+                if (_mobState.IsAlive(uid, mobState))
                 {
-                    ZombifyEntity(entity);
-                    args.BonusDamage = -args.BaseDamage;
+                    _damageable.TryChangeDamage(args.User, entity.Comp.HealingOnBite, true, false);
+
+                    // If we cannot infect the living target, the zed will just heal itself.
+                    if (HasComp<ZombieImmuneComponent>(uid) || cannotSpread || _random.Prob(GetZombieInfectionChance(uid, entity.Comp)))
+                        continue;
+
+                    EnsureComp<PendingZombieComponent>(uid);
+                    EnsureComp<ZombifyOnDeathComponent>(uid);
                 }
-                else if (mobState.CurrentState == MobState.Alive) //heals when zombies bite live entities
+                else
                 {
-                    _damageable.TryChangeDamage(uid, component.HealingOnBite, true, false);
+                    if (HasComp<ZombieImmuneComponent>(uid) || cannotSpread)
+                        continue;
+
+                    // If the target is dead and can be infected, infect.
+                    ZombifyEntity(uid);
+                    args.Handled = true;
                 }
             }
         }