Merge branch 'master' into offmed-staging
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.NPC.Prototypes;
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Body.Systems;
|
||||
@@ -10,7 +9,8 @@ using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Armor;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Cloning.Events;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Mind;
|
||||
@@ -119,7 +119,7 @@ namespace Content.Server.Zombies
|
||||
var curTime = _timing.CurTime;
|
||||
|
||||
// Hurt the living infected
|
||||
var query = EntityQueryEnumerator<PendingZombieComponent, DamageableComponent, MobStateComponent>();
|
||||
var query = EntityQueryEnumerator<PendingZombieComponent, Shared.Damage.Components.DamageableComponent, MobStateComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp, out var damage, out var mobState))
|
||||
{
|
||||
// Process only once per second
|
||||
@@ -139,12 +139,12 @@ namespace Content.Server.Zombies
|
||||
? comp.CritDamageMultiplier
|
||||
: 1f;
|
||||
|
||||
_damageable.TryChangeDamage(uid, comp.Damage * multiplier, true, false, damage);
|
||||
_damageable.ChangeDamage((uid, damage), comp.Damage * multiplier, true, false);
|
||||
_brainDamage.TryChangeBrainDamage(uid, multiplier / 2f); // Offbrand
|
||||
}
|
||||
|
||||
// Heal the zombified
|
||||
var zombQuery = EntityQueryEnumerator<ZombieComponent, DamageableComponent, MobStateComponent>();
|
||||
var zombQuery = EntityQueryEnumerator<ZombieComponent, Shared.Damage.Components.DamageableComponent, MobStateComponent>();
|
||||
while (zombQuery.MoveNext(out var uid, out var comp, out var damage, out var mobState))
|
||||
{
|
||||
// Process only once per second
|
||||
@@ -161,7 +161,7 @@ namespace Content.Server.Zombies
|
||||
: 1f;
|
||||
|
||||
// Gradual healing for living zombies.
|
||||
_damageable.TryChangeDamage(uid, comp.PassiveHealing * multiplier, true, false, damage);
|
||||
_damageable.ChangeDamage((uid, damage), comp.PassiveHealing * multiplier, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,25 +238,26 @@ 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;
|
||||
// Don't infect, don't deal damage, do not heal from bites, don't pass go!
|
||||
args.Handled = true;
|
||||
continue;
|
||||
}
|
||||
else if (!HasComp<WoundableComponent>(entity)) // Offbrand
|
||||
{
|
||||
@@ -267,14 +268,25 @@ namespace Content.Server.Zombies
|
||||
}
|
||||
}
|
||||
|
||||
if (_mobState.IsIncapacitated(entity, mobState) && !HasComp<ZombieComponent>(entity) && !HasComp<ZombieImmuneComponent>(entity) && !HasComp<WoundableComponent>(entity)) // Offbrand
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user