NonSpreaderZombieComponent prevents infection of crit mobs (#40857)

prevent the most critical bug in the history of station space 14
This commit is contained in:
GitHubUser53123 2025-10-13 05:13:30 +04:00 committed by Vanessa
parent f5a69c4ca8
commit 04015f18bc
1 changed files with 14 additions and 6 deletions

View File

@ -237,10 +237,12 @@ namespace Content.Server.Zombies
private void OnMeleeHit(EntityUid uid, ZombieComponent component, MeleeHitEvent args)
{
// this prevents a player using a zombie mouse as a weapon to infect people
if (!TryComp<ZombieComponent>(args.User, out _))
return;
if (!args.HitEntities.Any())
return;
foreach (var entity in args.HitEntities)
{
if (args.User == entity)
@ -249,14 +251,20 @@ namespace Content.Server.Zombies
if (!TryComp<MobStateComponent>(entity, out var mobState))
continue;
var canZombify = !HasComp<ZombieComponent>(entity) && !HasComp<ZombieImmuneComponent>(entity);
if (canZombify && !HasComp<NonSpreaderZombieComponent>(args.User) && _random.Prob(GetZombieInfectionChance(entity, component)))
if (HasComp<ZombieComponent>(entity))
{
EnsureComp<PendingZombieComponent>(entity);
EnsureComp<ZombifyOnDeathComponent>(entity);
args.BonusDamage = -args.BaseDamage;
}
else
{
if (!HasComp<ZombieImmuneComponent>(entity) && !HasComp<NonSpreaderZombieComponent>(args.User) && _random.Prob(GetZombieInfectionChance(entity, component)))
{
EnsureComp<PendingZombieComponent>(entity);
EnsureComp<ZombifyOnDeathComponent>(entity);
}
}
if (_mobState.IsIncapacitated(entity, mobState) && canZombify)
if (_mobState.IsIncapacitated(entity, mobState) && !HasComp<ZombieComponent>(entity) && !HasComp<ZombieImmuneComponent>(entity) && !HasComp<NonSpreaderZombieComponent>(args.User))
{
ZombifyEntity(entity);
args.BonusDamage = -args.BaseDamage;