mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-02 00:57:26 +00:00
* Nubody (#42419) * Nubody * fix test fails * gibbing * lung test returns * doc comment * hand organ test * giblet test * yaml formatting * returning * relocate * trimming * re-smite * oops thusd tweak * arachnids have slower metabolism i guess * never mind the old behaviour is bad actually * rider whyyy * style changes and allat * fix collision --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * C# files done * Visual nubody (humanoid appearance refactor) (#42476) * initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Let vox eat trash again (#42503) * C# complete port * Getting closer * Harpy Nubody Port * Port Feroxi, Kitsune. Fix some yml typos and remove ipcs stuff * Port Oni * Port Rest, except Motorkind * Port Motorkind * Remove more surgery, restore too much deleted stuff * Fix Typos and change some organ names. Need to split eyes next * Harpy HAve Wings again * Some fixes, More Surgeyr Removal, Copying of eye organs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use correct Body imports * Markings Refactoring, Harpy Layering * Motorkind doesn't crash anymore. Some layer remappings. * Allow Organs to have Markings Displacements again. (#43604) * first shtep * readd markings support --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix STalk eyes and several layerings * Fix sexed organs (#42554) * Fix markings for several species, fit them for sexed organs and rename some files to fit them for it * Additional IPC-related removals * Vulpkanin eyes are now correct again * Fix Subtle Cultist Marks on species * Fix Asakim Sprites (sexed) and make CD imports work * Migration, error fixes, and Height * Fix humanoid profile voice being broken (#42550) Fix humanoid appearance voice being broken * Change Kitsune SexChanged Event to with ref * Fix asakim issue, Respirator fix * Simplify hands UI code (#42534) * Simplify hands UI code * i remembered about SortedHands in the component * minor cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Set size of Analyzer back to 350, Kitsune can't gib themselves no more. Migration * yml linter errors and an rudimentary onAdd Organ Functionality * Fixing it trying to remove nothing * midpoint migration * Why do you put so many organs everywhere * More missing prototypes * Migration of more organs * Forgot lungs * Move character preview handling into a specialized control (#41252) * Move character preview handling into a specialized control Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> * Restore job name that I accidentally removed from character picker buttons * Just resolve dependencies the standard way --------- Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> * Drop ICharacterProfile/ICharacterAppearance interfaces (#42661) * Ensure profile loading only returns valid species (#42842) (Stable merge) (#42865) Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * Changes to make it work for us. * No more bald Harpy * OperatingTables instead of null * Adding Delta V Comments, commenting out instead of deleting * Fix broken Height Scale. * Remove HumanoidSilicon Mention * Did an error. Readded, uncommented. * Clean up Marking data structure, add tests for Zombie transformation (#42756) * Clean up Marking data structure, add tests for Zombie transformation * empty * AAAAAAAAAAAAAAAA --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix markings colour setting (#42771) * Fix: Markings Color For Downstream * Comment out A Leg. Remove Todo * Revert to original hidden species code --------- Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: Absotively <jen@jenpollock.ca> Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Myra <vasilis@pikachu.systems>
325 lines
13 KiB
C#
325 lines
13 KiB
C#
using Content.Shared.NPC.Prototypes;
|
|
using Content.Server.Actions;
|
|
using Content.Server.Body.Systems;
|
|
using Content.Server.Chat;
|
|
using Content.Server.Chat.Systems;
|
|
using Content.Server.Emoting.Systems;
|
|
using Content.Server.Speech.EntitySystems;
|
|
using Content.Shared.Anomaly.Components;
|
|
using Content.Shared.Armor;
|
|
using Content.Shared.Bed.Sleep;
|
|
using Content.Shared.Cloning.Events;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Mind.Components;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.Roles.Components;
|
|
using Content.Shared.Weapons.Melee.Events;
|
|
using Content.Shared.Zombies;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server.Zombies
|
|
{
|
|
public sealed partial class ZombieSystem : SharedZombieSystem
|
|
{
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
|
[Dependency] private readonly ChatSystem _chat = default!;
|
|
[Dependency] private readonly ActionsSystem _actions = default!;
|
|
[Dependency] private readonly AutoEmoteSystem _autoEmote = default!;
|
|
[Dependency] private readonly EmoteOnDamageSystem _emoteOnDamage = default!;
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly SharedRoleSystem _role = default!;
|
|
|
|
public readonly ProtoId<NpcFactionPrototype> Faction = "Zombie";
|
|
|
|
public const SlotFlags ProtectiveSlots =
|
|
SlotFlags.FEET |
|
|
SlotFlags.HEAD |
|
|
SlotFlags.EYES |
|
|
SlotFlags.GLOVES |
|
|
SlotFlags.MASK |
|
|
SlotFlags.NECK |
|
|
SlotFlags.INNERCLOTHING |
|
|
SlotFlags.OUTERCLOTHING;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ZombieComponent, EmoteEvent>(OnEmote, before:
|
|
new[] { typeof(VocalSystem), typeof(BodyEmotesSystem) });
|
|
|
|
SubscribeLocalEvent<ZombieComponent, MeleeHitEvent>(OnMeleeHit);
|
|
SubscribeLocalEvent<ZombieComponent, MobStateChangedEvent>(OnMobState);
|
|
SubscribeLocalEvent<ZombieComponent, CloningEvent>(OnZombieCloning);
|
|
SubscribeLocalEvent<ZombieComponent, TryingToSleepEvent>(OnSleepAttempt);
|
|
SubscribeLocalEvent<ZombieComponent, GetCharactedDeadIcEvent>(OnGetCharacterDeadIC);
|
|
SubscribeLocalEvent<ZombieComponent, GetCharacterUnrevivableIcEvent>(OnGetCharacterUnrevivableIC);
|
|
SubscribeLocalEvent<ZombieComponent, MindAddedMessage>(OnMindAdded);
|
|
SubscribeLocalEvent<ZombieComponent, MindRemovedMessage>(OnMindRemoved);
|
|
|
|
SubscribeLocalEvent<PendingZombieComponent, MapInitEvent>(OnPendingMapInit);
|
|
SubscribeLocalEvent<PendingZombieComponent, BeforeRemoveAnomalyOnDeathEvent>(OnBeforeRemoveAnomalyOnDeath);
|
|
|
|
SubscribeLocalEvent<IncurableZombieComponent, MapInitEvent>(OnPendingMapInit);
|
|
|
|
SubscribeLocalEvent<ZombifyOnDeathComponent, MobStateChangedEvent>(OnDamageChanged);
|
|
}
|
|
|
|
private void OnBeforeRemoveAnomalyOnDeath(Entity<PendingZombieComponent> ent, ref BeforeRemoveAnomalyOnDeathEvent args)
|
|
{
|
|
// Pending zombies (e.g. infected non-zombies) do not remove their hosted anomaly on death.
|
|
// Current zombies DO remove the anomaly on death.
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnPendingMapInit(EntityUid uid, IncurableZombieComponent component, MapInitEvent args)
|
|
{
|
|
_actions.AddAction(uid, ref component.Action, component.ZombifySelfActionPrototype);
|
|
_faction.AddFaction(uid, Faction);
|
|
|
|
if (HasComp<ZombieComponent>(uid) || HasComp<ZombieImmuneComponent>(uid))
|
|
return;
|
|
|
|
EnsureComp<PendingZombieComponent>(uid, out PendingZombieComponent pendingComp);
|
|
|
|
pendingComp.GracePeriod = _random.Next(pendingComp.MinInitialInfectedGrace, pendingComp.MaxInitialInfectedGrace);
|
|
}
|
|
|
|
private void OnPendingMapInit(EntityUid uid, PendingZombieComponent component, MapInitEvent args)
|
|
{
|
|
if (_mobState.IsDead(uid))
|
|
{
|
|
ZombifyEntity(uid);
|
|
return;
|
|
}
|
|
|
|
component.NextTick = _timing.CurTime + TimeSpan.FromSeconds(1f);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
var curTime = _timing.CurTime;
|
|
|
|
// Hurt the living infected
|
|
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
|
|
if (comp.NextTick > curTime)
|
|
continue;
|
|
|
|
comp.NextTick = curTime + TimeSpan.FromSeconds(1f);
|
|
|
|
comp.GracePeriod -= TimeSpan.FromSeconds(1f);
|
|
if (comp.GracePeriod > TimeSpan.Zero)
|
|
continue;
|
|
|
|
if (_random.Prob(comp.InfectionWarningChance))
|
|
_popup.PopupEntity(Loc.GetString(_random.Pick(comp.InfectionWarnings)), uid, uid);
|
|
|
|
var multiplier = _mobState.IsCritical(uid, mobState)
|
|
? comp.CritDamageMultiplier
|
|
: 1f;
|
|
|
|
_damageable.ChangeDamage((uid, damage), comp.Damage * multiplier, true, false);
|
|
}
|
|
|
|
// Heal the zombified
|
|
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
|
|
if (comp.NextTick + TimeSpan.FromSeconds(1) > curTime)
|
|
continue;
|
|
|
|
comp.NextTick = curTime;
|
|
|
|
if (_mobState.IsDead(uid, mobState))
|
|
continue;
|
|
|
|
var multiplier = _mobState.IsCritical(uid, mobState)
|
|
? comp.PassiveHealingCritMultiplier
|
|
: 1f;
|
|
|
|
// Gradual healing for living zombies.
|
|
_damageable.ChangeDamage((uid, damage), comp.PassiveHealing * multiplier, true, false);
|
|
}
|
|
}
|
|
|
|
private void OnSleepAttempt(EntityUid uid, ZombieComponent component, ref TryingToSleepEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnGetCharacterDeadIC(EntityUid uid, ZombieComponent component, ref GetCharactedDeadIcEvent args)
|
|
{
|
|
args.Dead = true;
|
|
}
|
|
|
|
private void OnGetCharacterUnrevivableIC(EntityUid uid, ZombieComponent component, ref GetCharacterUnrevivableIcEvent args)
|
|
{
|
|
args.Unrevivable = true;
|
|
}
|
|
|
|
private void OnEmote(EntityUid uid, ZombieComponent component, ref EmoteEvent args)
|
|
{
|
|
// always play zombie emote sounds and ignore others
|
|
if (args.Handled)
|
|
return;
|
|
|
|
_protoManager.Resolve(component.EmoteSoundsId, out var sounds);
|
|
|
|
args.Handled = _chat.TryPlayEmoteSound(uid, sounds, args.Emote);
|
|
}
|
|
|
|
private void OnMobState(EntityUid uid, ZombieComponent component, MobStateChangedEvent args)
|
|
{
|
|
if (args.NewMobState == MobState.Alive)
|
|
{
|
|
// Groaning when damaged
|
|
EnsureComp<EmoteOnDamageComponent>(uid);
|
|
_emoteOnDamage.AddEmote(uid, "Scream");
|
|
|
|
// Random groaning
|
|
EnsureComp<AutoEmoteComponent>(uid);
|
|
_autoEmote.AddEmote(uid, "ZombieGroan");
|
|
}
|
|
else
|
|
{
|
|
// Stop groaning when damaged
|
|
_emoteOnDamage.RemoveEmote(uid, "Scream");
|
|
|
|
// Stop random groaning
|
|
_autoEmote.RemoveEmote(uid, "ZombieGroan");
|
|
}
|
|
}
|
|
|
|
private float GetZombieInfectionChance(EntityUid uid, ZombieComponent zombieComponent)
|
|
{
|
|
var chance = zombieComponent.BaseZombieInfectionChance;
|
|
|
|
var armorEv = new CoefficientQueryEvent(ProtectiveSlots);
|
|
RaiseLocalEvent(uid, armorEv);
|
|
foreach (var resistanceEffectiveness in zombieComponent.ResistanceEffectiveness.DamageDict)
|
|
{
|
|
if (armorEv.DamageModifiers.Coefficients.TryGetValue(resistanceEffectiveness.Key, out var coefficient))
|
|
{
|
|
// Scale the coefficient by the resistance effectiveness, very descriptive I know
|
|
// For example. With 30% slash resist (0.7 coeff), but only a 60% resistance effectiveness for slash,
|
|
// you'll end up with 1 - (0.3 * 0.6) = 0.82 coefficient, or a 18% resistance
|
|
var adjustedCoefficient = 1 - ((1 - coefficient) * resistanceEffectiveness.Value.Float());
|
|
chance *= adjustedCoefficient;
|
|
}
|
|
}
|
|
|
|
var zombificationResistanceEv = new ZombificationResistanceQueryEvent(ProtectiveSlots);
|
|
RaiseLocalEvent(uid, zombificationResistanceEv);
|
|
chance *= zombificationResistanceEv.TotalCoefficient;
|
|
|
|
return MathF.Max(chance, zombieComponent.MinZombieInfectionChance);
|
|
}
|
|
|
|
private void OnMeleeHit(Entity<ZombieComponent> entity, ref MeleeHitEvent args)
|
|
{
|
|
if (!args.IsHit)
|
|
return;
|
|
|
|
var cannotSpread = HasComp<NonSpreaderZombieComponent>(args.User);
|
|
|
|
foreach (var uid in args.HitEntities)
|
|
{
|
|
if (args.User == uid)
|
|
continue;
|
|
|
|
if (!TryComp<MobStateComponent>(uid, out var mobState))
|
|
continue;
|
|
|
|
if (HasComp<ZombieComponent>(uid) || HasComp<IncurableZombieComponent>(uid))
|
|
{
|
|
// Don't infect, don't deal damage, do not heal from bites, don't pass go!
|
|
args.Handled = true;
|
|
continue;
|
|
}
|
|
|
|
if (_mobState.IsAlive(uid, mobState))
|
|
{
|
|
_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 (HasComp<ZombieImmuneComponent>(uid) || cannotSpread)
|
|
continue;
|
|
|
|
// If the target is dead and can be infected, infect.
|
|
ZombifyEntity(uid);
|
|
args.Handled = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// This is the function to call if you want to unzombify an entity.
|
|
/// </summary>
|
|
/// <param name="source">the entity having the ZombieComponent</param>
|
|
/// <param name="target">the entity you want to unzombify (different from source in case of cloning, for example)</param>
|
|
/// <param name="zombiecomp"></param>
|
|
/// <remarks>
|
|
/// this currently only restore the skin/eye color from before zombified
|
|
/// TODO: completely rethink how zombies are done to allow reversal.
|
|
/// </remarks>
|
|
public bool UnZombify(EntityUid source, EntityUid target, ZombieComponent? zombiecomp)
|
|
{
|
|
if (!Resolve(source, ref zombiecomp))
|
|
return false;
|
|
|
|
_visualBody.ApplyProfiles(target, zombiecomp.BeforeZombifiedProfiles);
|
|
_visualBody.ApplyMarkings(target, zombiecomp.BeforeZombifiedMarkings);
|
|
|
|
_bloodstream.ChangeBloodReagents(target, zombiecomp.BeforeZombifiedBloodReagents);
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnZombieCloning(Entity<ZombieComponent> ent, ref CloningEvent args)
|
|
{
|
|
UnZombify(ent.Owner, args.CloneUid, ent.Comp);
|
|
}
|
|
|
|
// Make sure players that enter a zombie (for example via a ghost role or the mind swap spell) count as an antagonist.
|
|
private void OnMindAdded(Entity<ZombieComponent> ent, ref MindAddedMessage args)
|
|
{
|
|
if (!_role.MindHasRole<ZombieRoleComponent>(args.Mind))
|
|
_role.MindAddRole(args.Mind, "MindRoleZombie", mind: args.Mind.Comp);
|
|
}
|
|
|
|
// Remove the role when getting cloned, getting gibbed and borged, or leaving the body via any other method.
|
|
private void OnMindRemoved(Entity<ZombieComponent> ent, ref MindRemovedMessage args)
|
|
{
|
|
_role.MindRemoveRole<ZombieRoleComponent>((args.Mind.Owner, args.Mind.Comp));
|
|
}
|
|
}
|
|
}
|