mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +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>
209 lines
8.5 KiB
C#
209 lines
8.5 KiB
C#
using Content.Shared.CCVar;
|
|
using Content.Shared.Chemistry.Events;
|
|
using Content.Shared.Climbing.Components;
|
|
using Content.Shared.Climbing.Events;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Medical;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Random.Helpers;
|
|
using Content.Shared.Stunnable;
|
|
using Content.Shared.Throwing;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.Clumsy;
|
|
|
|
public sealed class ClumsySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedStunSystem _stun = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly INetManager _net = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<ClumsyComponent, SelfBeforeInjectEvent>(BeforeHyposprayEvent);
|
|
SubscribeLocalEvent<ClumsyComponent, SelfBeforeDefibrillatorZapsEvent>(BeforeDefibrillatorZapsEvent);
|
|
SubscribeLocalEvent<ClumsyComponent, SelfBeforeGunShotEvent>(BeforeGunShotEvent);
|
|
SubscribeLocalEvent<ClumsyComponent, CatchAttemptEvent>(OnCatchAttempt);
|
|
SubscribeLocalEvent<ClumsyComponent, SelfBeforeClimbEvent>(OnBeforeClimbEvent);
|
|
}
|
|
|
|
// If you add more clumsy interactions add them in this section!
|
|
#region Clumsy interaction events
|
|
private void BeforeHyposprayEvent(Entity<ClumsyComponent> ent, ref SelfBeforeInjectEvent args)
|
|
{
|
|
// Clumsy people sometimes inject themselves! Apparently syringes are clumsy proof...
|
|
|
|
// checks if ClumsyHypo is false, if so, skips.
|
|
if (!ent.Comp.ClumsyHypo)
|
|
return;
|
|
|
|
// TODO: Replace with RandomPredicted once the engine PR is merged
|
|
var seed = SharedRandomExtensions.HashCodeCombine((int)_timing.CurTick.Value, GetNetEntity(ent).Id);
|
|
var rand = new System.Random(seed);
|
|
if (!rand.Prob(ent.Comp.ClumsyDefaultCheck))
|
|
return;
|
|
|
|
args.TargetGettingInjected = args.EntityUsingInjector;
|
|
args.OverrideMessage = Loc.GetString(ent.Comp.HypoFailedMessage);
|
|
_audio.PlayPredicted(ent.Comp.ClumsySound, ent, args.EntityUsingInjector);
|
|
}
|
|
|
|
private void BeforeDefibrillatorZapsEvent(Entity<ClumsyComponent> ent, ref SelfBeforeDefibrillatorZapsEvent args)
|
|
{
|
|
// Clumsy people sometimes defib themselves!
|
|
|
|
// checks if ClumsyDefib is false, if so, skips.
|
|
if (!ent.Comp.ClumsyDefib)
|
|
return;
|
|
|
|
// TODO: Replace with RandomPredicted once the engine PR is merged
|
|
var seed = SharedRandomExtensions.HashCodeCombine((int)_timing.CurTick.Value, GetNetEntity(ent).Id);
|
|
var rand = new System.Random(seed);
|
|
if (!rand.Prob(ent.Comp.ClumsyDefaultCheck))
|
|
return;
|
|
|
|
args.DefibTarget = args.EntityUsingDefib;
|
|
_audio.PlayPvs(ent.Comp.ClumsySound, ent);
|
|
|
|
}
|
|
|
|
private void OnCatchAttempt(Entity<ClumsyComponent> ent, ref CatchAttemptEvent args)
|
|
{
|
|
// Clumsy people sometimes fail to catch items!
|
|
|
|
// checks if ClumsyCatching is false, if so, skips.
|
|
if (!ent.Comp.ClumsyCatching)
|
|
return;
|
|
|
|
// TODO: Replace with RandomPredicted once the engine PR is merged
|
|
var seed = SharedRandomExtensions.HashCodeCombine((int)_timing.CurTick.Value, GetNetEntity(args.Item).Id);
|
|
var rand = new System.Random(seed);
|
|
if (!rand.Prob(ent.Comp.ClumsyDefaultCheck))
|
|
return;
|
|
|
|
args.Cancelled = true; // fail to catch
|
|
|
|
if (ent.Comp.CatchingFailDamage != null)
|
|
_damageable.ChangeDamage(ent.Owner, ent.Comp.CatchingFailDamage, origin: args.Item);
|
|
|
|
// Collisions don't work properly with PopupPredicted or PlayPredicted.
|
|
// So we make this server only.
|
|
if (_net.IsClient)
|
|
return;
|
|
|
|
var selfMessage = Loc.GetString(ent.Comp.CatchingFailedMessageSelf, ("item", ent.Owner), ("catcher", Identity.Entity(ent.Owner, EntityManager)));
|
|
var othersMessage = Loc.GetString(ent.Comp.CatchingFailedMessageOthers, ("item", ent.Owner), ("catcher", Identity.Entity(ent.Owner, EntityManager)));
|
|
_popup.PopupEntity(selfMessage, ent.Owner, ent.Owner);
|
|
_popup.PopupEntity(othersMessage, ent.Owner, Filter.PvsExcept(ent.Owner), true);
|
|
_audio.PlayPvs(ent.Comp.ClumsySound, ent);
|
|
}
|
|
|
|
private void BeforeGunShotEvent(Entity<ClumsyComponent> ent, ref SelfBeforeGunShotEvent args)
|
|
{
|
|
// Clumsy people sometimes can't shoot :(
|
|
|
|
// checks if ClumsyGuns is false, if so, skips.
|
|
if (!ent.Comp.ClumsyGuns)
|
|
return;
|
|
|
|
if (args.Gun.Comp.ClumsyProof)
|
|
return;
|
|
|
|
// TODO: Replace with RandomPredicted once the engine PR is merged
|
|
var seed = SharedRandomExtensions.HashCodeCombine((int)_timing.CurTick.Value, GetNetEntity(args.Gun).Id);
|
|
var rand = new System.Random(seed);
|
|
if (!rand.Prob(ent.Comp.ClumsyGunShootCheck)) // DeltaV change from default to gun check
|
|
return;
|
|
|
|
if (ent.Comp.GunShootFailDamage != null)
|
|
_damageable.ChangeDamage(ent.Owner, ent.Comp.GunShootFailDamage, origin: ent);
|
|
|
|
_stun.TryUpdateParalyzeDuration(ent, ent.Comp.GunShootFailStunTime);
|
|
|
|
// Apply salt to the wound ("Honk!") (No idea what this comment means)
|
|
_audio.PlayPvs(ent.Comp.GunShootFailSound, ent);
|
|
_audio.PlayPvs(ent.Comp.ClumsySound, ent);
|
|
|
|
_popup.PopupEntity(Loc.GetString(ent.Comp.GunFailedMessage), ent, ent);
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnBeforeClimbEvent(Entity<ClumsyComponent> ent, ref SelfBeforeClimbEvent args)
|
|
{
|
|
// checks if ClumsyVaulting is false, if so, skips.
|
|
if (!ent.Comp.ClumsyVaulting || args.PuttingOnTable != ent.Owner) // DeltaV - don't bonk if someone else vaults/biomasses you
|
|
return;
|
|
|
|
// TODO: Replace with RandomPredicted once the engine PR is merged
|
|
var seed = SharedRandomExtensions.HashCodeCombine((int)_timing.CurTick.Value, GetNetEntity(ent).Id);
|
|
var rand = new System.Random(seed);
|
|
if (!_cfg.GetCVar(CCVars.GameTableBonk) && !rand.Prob(ent.Comp.ClumsyDefaultCheck))
|
|
return;
|
|
|
|
HitHeadClumsy(ent, args.BeingClimbedOn);
|
|
|
|
_audio.PlayPredicted(ent.Comp.ClumsySound, ent, ent);
|
|
|
|
_audio.PlayPredicted(ent.Comp.TableBonkSound, ent, ent);
|
|
|
|
var gettingPutOnTableName = Identity.Entity(args.GettingPutOnTable, EntityManager);
|
|
var puttingOnTableName = Identity.Entity(args.PuttingOnTable, EntityManager);
|
|
|
|
if (args.PuttingOnTable == ent.Owner)
|
|
{
|
|
// You are slamming yourself onto the table.
|
|
_popup.PopupPredicted(
|
|
Loc.GetString(ent.Comp.VaulingFailedMessageSelf, ("bonkable", args.BeingClimbedOn)),
|
|
Loc.GetString(ent.Comp.VaulingFailedMessageOthers, ("victim", gettingPutOnTableName), ("bonkable", args.BeingClimbedOn)),
|
|
ent,
|
|
ent);
|
|
}
|
|
else
|
|
{
|
|
// Someone else slamed you onto the table.
|
|
// This is only run in server so you need to use popup entity.
|
|
_popup.PopupPredicted(
|
|
Loc.GetString(ent.Comp.VaulingFailedMessageForced,
|
|
("bonker", puttingOnTableName),
|
|
("victim", gettingPutOnTableName),
|
|
("bonkable", args.BeingClimbedOn)),
|
|
ent,
|
|
null);
|
|
}
|
|
|
|
args.Cancel();
|
|
}
|
|
#endregion
|
|
|
|
#region Helper functions
|
|
/// <summary>
|
|
/// "Hits" an entites head against the given table.
|
|
/// </summary>
|
|
// Oh this fucntion is public le- NO!! This is only public for the one admin command if you use this anywhere else I will cry.
|
|
public void HitHeadClumsy(Entity<ClumsyComponent> target, EntityUid table)
|
|
{
|
|
var stunTime = target.Comp.ClumsyDefaultStunTime;
|
|
|
|
if (TryComp<BonkableComponent>(table, out var bonkComp))
|
|
{
|
|
stunTime = bonkComp.BonkTime;
|
|
if (bonkComp.BonkDamage != null)
|
|
_damageable.ChangeDamage(target.Owner, bonkComp.BonkDamage, true);
|
|
}
|
|
|
|
_stun.TryUpdateParalyzeDuration(target, stunTime);
|
|
}
|
|
#endregion
|
|
}
|