mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-02 00:57:26 +00:00
* Reapply "Nubody Merge" (#5807) This reverts commitd62f7cef10. * Revert "Nubody Merge (#5670)" This reverts commitb465cfb3fd. * Revert "IPC fibers (#4968)" This reverts commitc2b42211f0. * Revert "IPC Polymorph fix (#4545)" This reverts commitfa03d8c655. * Revert "fix IPC not having humanoid emotes (#4445)" This reverts commit216fdf999f. * Revert "ipc heat/cold (#4306)" This reverts commitfafd5cf816. * Revert "ipc cables (#4283)" This reverts commit54958039a1. * Revert "feat: ipcs now have dynamic power draw based off movement speed (#3917)" This reverts commit71e8b7e64b. * Revert "fix ipcs not being able to disarm (#3374)" This reverts commit764c4dcf54. * Revert "make steel heal caustic for ipcs (#3206)" This reverts commit450ac82550. * Revert "add missing ipc survival boxes (#3065)" This reverts commit888c9cdb00. * Revert "make borgs use ipc repairing (#3064)" This reverts commitf77a49dd0b. * Revert "Update hud.yml to add ipcs to diagnostic hud (#3019)" This reverts commit7220643531. * Revert "Tweak IPCs (#2979)" This reverts commit98b47476de. * Revert "fix nukies ipc test fail (#2957)" This reverts commit4a1acbf863. * Revert "fix ipc nukies not getting comms (#2884)" This reverts commit8a2254770e. * Revert "fix ipc encryption key mispredict (#2879)" This reverts commitf08726efc1. * Revert "Merge pull request #2800 from Spielern/port-ipc" This reverts commit822fa4312c, reversing changes made tofe4c23c702. * Remove and Fix rest of IPC Hangons causing crashes * Integration test Errors * Expand migration file with removed IPC stuff * IPC Leg was found and migrated to naught * Revert "Merge pull request #2542 from deltanedas/shitmed-ops" This reverts commit83a8002922, reversing changes made tobaa89b0052. * Revert "Set up surgical augments infrastructure & add tool panel augments (#3059)" This reverts commita40f0be6fd. * Revert "Psionic Prosthetics (#4689)" This reverts commit2679bb238a. * Revert "Add surgical cleanliness and sanitation (#2847)" This reverts commit64565ba4f7. * Remove unremoved mentions * Revert "Add autoclave to easily sanitize large amounts of items and faster (#2933)" This reverts commitd0da90fa2e. * Shit Med Removed * Remove _ShitMed Folders and fix Errors in Console * Add OrganAnimalBrain into the mirgraiton file * Heads no Input Mover * Monke * Full migration file I guess * oops * shiv state fix * Restore accidental deleted recipe * Forgot one flt mention * Fix more issues * Comment out Damage Visual for motorkind for now * Motorkind... * Commenting stuff out for now * thought there'd be more of this to gut --------- Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
298 lines
12 KiB
C#
298 lines
12 KiB
C#
// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
|
|
// SPDX-FileCopyrightText: 2025 Solstice <solsticeofthewinter@gmail.com>
|
|
// SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
using System.Text.RegularExpressions;
|
|
using Content.Shared._Goobstation.Religion;
|
|
using Content.Server._Goobstation.Devil.Condemned;
|
|
using Content.Server._Goobstation.Devil.Contract;
|
|
using Content.Server._Goobstation.Devil.Objectives.Components;
|
|
using Content.Server._Goobstation.Possession;
|
|
using Content.Shared._Goobstation.CheatDeath;
|
|
using Content.Shared._Goobstation.CrematorImmune;
|
|
using Content.Shared._Goobstation.Devil;
|
|
using Content.Shared._Goobstation.Devil.Condemned;
|
|
using Content.Shared._Goobstation.Exorcism;
|
|
using Content.Server.Actions;
|
|
using Content.Shared.Administration.Systems;
|
|
using Content.Server.Antag.Components;
|
|
using Content.Server.Atmos.Components;
|
|
using Content.Server.Body.Systems;
|
|
using Content.Server.Destructible;
|
|
using Content.Server.Hands.Systems;
|
|
using Content.Server.Jittering;
|
|
using Content.Server.Mind;
|
|
using Content.Server.Polymorph.Systems;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.Speech;
|
|
using Content.Shared.Speech.Components;
|
|
using Content.Server.Stunnable;
|
|
using Content.Server.Temperature.Components;
|
|
using Content.Shared.Zombies;
|
|
using Content.Shared._Lavaland.Chasm;
|
|
using Content.Shared.Actions;
|
|
using Content.Shared.CombatMode;
|
|
using Content.Shared.Damage.Components;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.IdentityManagement.Components;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Nutrition.Components;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Shuttles.Components;
|
|
using Content.Shared.Temperature.Components;
|
|
using Robust.Server.Containers;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
using Content.Shared.Body.Part;
|
|
using Content.Server.Bible.Components;
|
|
|
|
namespace Content.Server._Goobstation.Devil;
|
|
|
|
public sealed partial class DevilSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly HandsSystem _hands = default!;
|
|
[Dependency] private readonly ActionsSystem _actions = default!;
|
|
[Dependency] private readonly PolymorphSystem _poly = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly StunSystem _stun = default!;
|
|
[Dependency] private readonly PopupSystem _popup = default!;
|
|
[Dependency] private readonly MindSystem _mind = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
|
[Dependency] private readonly RejuvenateSystem _rejuvenate = default!;
|
|
[Dependency] private readonly DevilContractSystem _contract = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly PossessionSystem _possession = default!;
|
|
[Dependency] private readonly CondemnedSystem _condemned = default!;
|
|
[Dependency] private readonly MobStateSystem _state = default!;
|
|
[Dependency] private readonly JitteringSystem _jittering = default!;
|
|
[Dependency] private readonly BodySystem _body = default!;
|
|
[Dependency] private readonly ContainerSystem _container = default!;
|
|
|
|
private static readonly Regex WhitespaceAndNonWordRegex = new(@"[\s\W]+", RegexOptions.Compiled);
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<DevilComponent, MapInitEvent>(OnStartup);
|
|
SubscribeLocalEvent<DevilComponent, ExaminedEvent>(OnExamined);
|
|
SubscribeLocalEvent<DevilComponent, ListenEvent>(OnListen);
|
|
SubscribeLocalEvent<DevilComponent, SoulAmountChangedEvent>(OnSoulAmountChanged);
|
|
SubscribeLocalEvent<DevilComponent, PowerLevelChangedEvent>(OnPowerLevelChanged);
|
|
SubscribeLocalEvent<DevilComponent, ExorcismDoAfterEvent>(OnExorcismDoAfter);
|
|
|
|
SubscribeLocalEvent<IdentityBlockerComponent, InventoryRelayedEvent<IsEyesCoveredCheckEvent>>(OnEyesCoveredCheckEvent);
|
|
|
|
InitializeHandshakeSystem();
|
|
SubscribeAbilities();
|
|
}
|
|
|
|
#region Startup & Remove
|
|
|
|
private void OnStartup(Entity<DevilComponent> devil, ref MapInitEvent args)
|
|
{
|
|
// Remove human components.
|
|
RemComp<CombatModeComponent>(devil);
|
|
RemComp<HungerComponent>(devil);
|
|
RemComp<ThirstComponent>(devil);
|
|
RemComp<TemperatureComponent>(devil);
|
|
RemComp<TemperatureSpeedComponent>(devil);
|
|
RemComp<CondemnedComponent>(devil);
|
|
RemComp<DestructibleComponent>(devil);
|
|
|
|
// Adjust stats
|
|
EnsureComp<ZombieImmuneComponent>(devil);
|
|
EnsureComp<PressureImmunityComponent>(devil);
|
|
EnsureComp<ActiveListenerComponent>(devil);
|
|
EnsureComp<WeakToHolyComponent>(devil).AlwaysTakeHoly = true;
|
|
EnsureComp<CrematoriumImmuneComponent>(devil);
|
|
EnsureComp<AntagImmuneComponent>(devil);
|
|
EnsureComp<PreventChasmFallingComponent>(devil).DeleteOnUse = false;
|
|
EnsureComp<FTLSmashImmuneComponent>(devil);
|
|
|
|
// Allow infinite revival
|
|
var revival = EnsureComp<CheatDeathComponent>(devil);
|
|
revival.InfiniteRevives = true;
|
|
revival.CanCheatStanding = true;
|
|
|
|
// Change damage modifier
|
|
_damageable.SetDamageModifierSetId(devil.Owner, devil.Comp.DevilDamageModifierSet);
|
|
|
|
// No decapitating the devil
|
|
foreach (var part in _body.GetBodyChildren(devil))
|
|
{
|
|
if (!TryComp(part.Id, out BodyPartComponent? woundable)) // DeltaV - Use Bodypart instead of woundable.
|
|
continue;
|
|
|
|
Dirty(part.Id, woundable);
|
|
}
|
|
|
|
// Add base actions
|
|
foreach (var actionId in devil.Comp.BaseDevilActions)
|
|
_actions.AddAction(devil, actionId);
|
|
|
|
// Self Explanatory
|
|
GenerateTrueName(devil);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Event Listeners
|
|
|
|
private void OnSoulAmountChanged(Entity<DevilComponent> devil, ref SoulAmountChangedEvent args)
|
|
{
|
|
if (!_mind.TryGetMind(args.User, out var mindId, out var mind))
|
|
return;
|
|
|
|
devil.Comp.Souls += args.Amount;
|
|
_popup.PopupEntity(Loc.GetString("contract-soul-added"), args.User, args.User, PopupType.MediumCaution);
|
|
|
|
if (devil.Comp.Souls is > 1 and < 7 && devil.Comp.Souls % 2 == 0)
|
|
{
|
|
devil.Comp.PowerLevel = (DevilPowerLevel)(devil.Comp.Souls / 2); // malicious casting to enum
|
|
|
|
// Raise event
|
|
var ev = new PowerLevelChangedEvent(args.User, devil.Comp.PowerLevel);
|
|
RaiseLocalEvent(args.User, ref ev);
|
|
}
|
|
|
|
if (_mind.TryGetObjectiveComp<SignContractConditionComponent>(mindId, out var objectiveComp, mind))
|
|
objectiveComp.ContractsSigned += args.Amount;
|
|
}
|
|
|
|
private void OnPowerLevelChanged(Entity<DevilComponent> devil, ref PowerLevelChangedEvent args)
|
|
{
|
|
var popup = Loc.GetString($"devil-power-level-increase-{args.NewLevel.ToString().ToLowerInvariant()}");
|
|
_popup.PopupEntity(popup, args.User, args.User, PopupType.Large);
|
|
|
|
if (!_prototype.TryIndex(devil.Comp.DevilBranchPrototype, out var proto))
|
|
return;
|
|
|
|
foreach (var ability in proto.PowerActions)
|
|
{
|
|
if (args.NewLevel < ability.Key) // DeltaV - Just incase of admin shenanigans
|
|
continue;
|
|
|
|
foreach (var actionId in ability.Value)
|
|
_actions.AddAction(devil, actionId);
|
|
}
|
|
}
|
|
|
|
private void OnExamined(Entity<DevilComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
if (!args.IsInDetailsRange || ent.Comp.PowerLevel < DevilPowerLevel.Weak)
|
|
return;
|
|
|
|
var ev = new IsEyesCoveredCheckEvent();
|
|
RaiseLocalEvent(ent, ev);
|
|
|
|
if (ev.IsEyesProtected)
|
|
return;
|
|
|
|
args.PushMarkup(Loc.GetString("devil-component-examined", ("target", Identity.Entity(ent, EntityManager))));
|
|
}
|
|
|
|
private void OnEyesCoveredCheckEvent(Entity<IdentityBlockerComponent> ent, ref InventoryRelayedEvent<IsEyesCoveredCheckEvent> args)
|
|
{
|
|
if (ent.Comp.Enabled)
|
|
args.Args.IsEyesProtected = true;
|
|
}
|
|
private void OnListen(Entity<DevilComponent> devil, ref ListenEvent args)
|
|
{
|
|
// Other Devils and entities without souls have no authority over you.
|
|
if (HasComp<DevilComponent>(args.Source)
|
|
|| HasComp<CondemnedComponent>(args.Source)
|
|
|| args.Source == devil.Owner)
|
|
return;
|
|
|
|
var message = WhitespaceAndNonWordRegex.Replace(args.Message.ToLowerInvariant(), "");
|
|
var trueName = WhitespaceAndNonWordRegex.Replace(devil.Comp.TrueName.ToLowerInvariant(), "");
|
|
|
|
if (!message.Contains(trueName))
|
|
return;
|
|
|
|
// hardcoded, but this is just flavor so who cares :godo:
|
|
_jittering.DoJitter(devil, TimeSpan.FromSeconds(4), true);
|
|
|
|
if (_timing.CurTime < devil.Comp.LastTriggeredTime + devil.Comp.CooldownDuration)
|
|
return;
|
|
|
|
devil.Comp.LastTriggeredTime = _timing.CurTime;
|
|
|
|
if (HasComp<BibleUserComponent>(args.Source))
|
|
{
|
|
_damageable.TryChangeDamage(devil.Owner, devil.Comp.DamageOnTrueName * devil.Comp.BibleUserDamageMultiplier, true);
|
|
_stun.TryAddParalyzeDuration(devil, devil.Comp.ParalyzeDurationOnTrueName * devil.Comp.BibleUserDamageMultiplier);
|
|
|
|
var popup = Loc.GetString("devil-true-name-heard-chaplain", ("speaker", args.Source), ("target", devil));
|
|
_popup.PopupEntity(popup, devil, PopupType.LargeCaution);
|
|
}
|
|
else
|
|
{
|
|
_stun.TryAddParalyzeDuration(devil, devil.Comp.ParalyzeDurationOnTrueName);
|
|
_damageable.TryChangeDamage(devil.Owner, devil.Comp.DamageOnTrueName, true);
|
|
|
|
var popup = Loc.GetString("devil-true-name-heard", ("speaker", args.Source), ("target", devil));
|
|
_popup.PopupEntity(popup, devil, PopupType.LargeCaution);
|
|
}
|
|
}
|
|
|
|
private void OnExorcismDoAfter(Entity<DevilComponent> devil, ref ExorcismDoAfterEvent args)
|
|
{
|
|
if (args.Target is not { } target
|
|
|| args.Cancelled
|
|
|| args.Handled)
|
|
return;
|
|
|
|
_popup.PopupEntity(Loc.GetString("devil-exorcised", ("target", Name(devil))), devil, PopupType.LargeCaution);
|
|
_condemned.StartCondemnation(target, behavior: CondemnedBehavior.Banish, doFlavor: false);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Helper Methods
|
|
|
|
private static bool TryUseAbility(BaseActionEvent action)
|
|
{
|
|
if (action.Handled)
|
|
return false;
|
|
|
|
action.Handled = true;
|
|
return true;
|
|
}
|
|
private void PlayFwooshSound(EntityUid uid, DevilComponent? comp = null)
|
|
{
|
|
if (!Resolve(uid, ref comp))
|
|
return;
|
|
|
|
_audio.PlayPvs(comp.FwooshPath, uid, new AudioParams(-2f, 1f, SharedAudioSystem.DefaultSoundRange, 1f, false, 0f));
|
|
}
|
|
|
|
private void DoContractFlavor(EntityUid devil, string name)
|
|
{
|
|
var flavor = Loc.GetString("contract-summon-flavor", ("name", name));
|
|
_popup.PopupEntity(flavor, devil, PopupType.Medium);
|
|
}
|
|
private void GenerateTrueName(DevilComponent comp)
|
|
{
|
|
// Generate true name.
|
|
var firstNameOptions = _prototype.Index(comp.FirstNameTrue);
|
|
var lastNameOptions = _prototype.Index(comp.LastNameTrue);
|
|
|
|
comp.TrueName = string.Concat(_random.Pick(firstNameOptions.Values), " ", _random.Pick(lastNameOptions.Values));
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|