From 7d724339e69129418acb0ad4fda4b211ae4384bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:43:51 +0300 Subject: [PATCH 01/23] =?UTF-8?q?C=D0=B5=D1=80=D0=B4=D0=B5=D1=87=D0=BD?= =?UTF-8?q?=D0=BE-=D0=BB=D1=91=D0=B3=D0=BE=D1=87=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BD=D0=B8=D0=BC=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 83 +++++++++++++++++++ .../ReliveResuscitationComponent.cs | 24 ++++++ .../ReliveResuscitationEvent.cs | 10 +++ .../ADT/Entities/Mobs/Species/Drask.yml | 1 + .../ADT/Entities/Mobs/Species/Tajaran.yml | 1 + .../ADT/Entities/Mobs/Species/Ursus.yml | 1 + .../ADT/Entities/Mobs/Species/Vulpkanin.yml | 1 + .../ADT/Entities/Mobs/Species/demon.yml | 1 + .../ADT/Entities/Mobs/Species/felinid.yml | 1 + .../ADT/Entities/Mobs/Species/kobolt.yml | 1 + .../ADT/Entities/Mobs/Species/moth.yml | 1 + .../ADT/Entities/Mobs/Species/novakid.yml | 1 + .../Entities/Mobs/Species/arachnid.yml | 1 + .../Entities/Mobs/Species/diona.yml | 1 + .../Entities/Mobs/Species/dwarf.yml | 1 + .../Entities/Mobs/Species/human.yml | 1 + .../Entities/Mobs/Species/reptilian.yml | 1 + .../Entities/Mobs/Species/slime.yml | 1 + .../Prototypes/Entities/Mobs/Species/vox.yml | 1 + 19 files changed, 133 insertions(+) create mode 100644 Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs create mode 100644 Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs create mode 100644 Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs new file mode 100644 index 00000000000..310a24b66f7 --- /dev/null +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -0,0 +1,83 @@ +using Content.Shared.Verbs; +using Robust.Shared.Utility; +using Content.Shared.Popups; +using Content.Shared.Electrocution; +using Content.Shared.ADT.ReliveResuscitation; +using Content.Shared.Mobs; +using Content.Shared.Mobs.Components; +using Content.Shared.Damage; +using Content.Shared.Damage.Prototypes; +using Content.Shared.FixedPoint; +using Robust.Shared.Prototypes; + +using Content.Shared.DoAfter; + +namespace Content.Server.ADT.ReliveResuscitation; + +public sealed partial class ReliveResuscitationSystem : EntitySystem +{ + [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly SharedElectrocutionSystem _electrocutionSystem = default!; + [Dependency] private readonly DamageableSystem _damageable = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent>(OnAltVerbs); + //SubscribeLocalEvent(ReliveEvent); + } + + private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) + { + if (TryComp(uid, out var mobState) && TryComp(args.User, out var metaDataUser) && TryComp(uid, out var metaDataTarget)) + { + if (mobState.CurrentState == MobState.Critical) + { + AlternativeVerb verbPersonalize = new() + { + Act = () => Relive(uid, args.User, component, metaDataUser, metaDataTarget), + Text = Loc.GetString("Сердечно-лёгочная реанимация"), + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), + }; + args.Verbs.Add(verbPersonalize); + } + } + } + + private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MetaDataComponent metaDataUser, MetaDataComponent metaDataTarget) + { + _popup.PopupEntity($"{metaDataUser.EntityName} делает сердечно-лёгочную реанимацию {metaDataTarget.EntityName}", uid, user); + + DoRelive(uid, user, component); + } + + private void DoRelive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component) + { + FixedPoint2 asphyxiationHeal = -20; + FixedPoint2 bluntDamage = 5; + + var doAfterEventArgs = + new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) + { + // Didn't break on damage as they may be trying to prevent it and + // not being able to heal your own ticking damage would be frustrating. + NeedHand = true, + BreakOnMove = true, + BreakOnWeightlessMove = false, + + }; + + DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); + DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); + + _damageable.TryChangeDamage(uid, damageAsphyxiation, true); + _damageable.TryChangeDamage(uid, damageBlunt, true); + + _doAfter.TryStartDoAfter(doAfterEventArgs); + //_doAfter.IsRunning(doAfterEventArgs); + + return; + } +} diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs new file mode 100644 index 00000000000..36397637c60 --- /dev/null +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs @@ -0,0 +1,24 @@ +using Robust.Shared.GameStates; +using Content.Shared.DoAfter; + +namespace Content.Shared.ADT.ReliveResuscitation; + +[RegisterComponent, NetworkedComponent] +public sealed partial class ReliveResuscitationComponent : Component +{ + /// + /// How long it takes to apply the damage. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("delay")] + public float Delay = 3f; + + + /// + /// Delay multiplier when healing yourself. + /// + [DataField("selfHealPenaltyMultiplier")] + public float SelfHealPenaltyMultiplier = 3f; + +} + diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs new file mode 100644 index 00000000000..1c674d267d0 --- /dev/null +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; +using Content.Shared.DoAfter; +using Robust.Shared.Serialization; + +namespace Content.Shared.ADT.ReliveResuscitation; + +[Serializable, NetSerializable] +public sealed partial class ReliveDoAfterEvent : SimpleDoAfterEvent +{ +} diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/Drask.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/Drask.yml index 46e282f47fe..99fa58170ad 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/Drask.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/Drask.yml @@ -122,6 +122,7 @@ tallscale: 1.15 short: true shortscale: 1 + - type: ReliveResuscitation - type: entity save: false diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/Tajaran.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/Tajaran.yml index fd28e038444..30466ae0200 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/Tajaran.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/Tajaran.yml @@ -103,6 +103,7 @@ tallscale: 0.95 short: true shortscale: 0.85 + - type: ReliveResuscitation - type: entity save: false diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/Ursus.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/Ursus.yml index 9691c8710eb..1bc2588847a 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/Ursus.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/Ursus.yml @@ -124,6 +124,7 @@ short: true shortscale: 0.98 shortDensity: 0.7 + - type: ReliveResuscitation - type: entity save: false diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/Vulpkanin.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/Vulpkanin.yml index 3ba74a1475f..73ec8f41d73 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/Vulpkanin.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/Vulpkanin.yml @@ -90,6 +90,7 @@ tallscale: 1 short: true shortscale: 0.9 + - type: ReliveResuscitation - type: entity save: false diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/demon.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/demon.yml index 7e07e9abf53..caa801423c1 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/demon.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/demon.yml @@ -74,6 +74,7 @@ tallscale: 1.08 short: true shortscale: 0.92 + - type: ReliveResuscitation - type: entity save: false diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/felinid.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/felinid.yml index 0bc3079d9d5..af44c5bc683 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/felinid.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/felinid.yml @@ -176,6 +176,7 @@ tallscale: 0.95 short: true shortscale: 0.8 + - type: ReliveResuscitation - type: entity save: false diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/kobolt.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/kobolt.yml index 0382e1e7f23..d14707c8e00 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/kobolt.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/kobolt.yml @@ -94,6 +94,7 @@ tallscale: 0.9 short: true shortscale: 0.8 + - type: ReliveResuscitation - type: entity parent: BaseSpeciesDummy diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/moth.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/moth.yml index 44faad9cdec..8b3facc886a 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/moth.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/moth.yml @@ -147,6 +147,7 @@ tallscale: 1 short: true shortscale: 0.85 + - type: ReliveResuscitation - type: entity parent: BaseSpeciesDummy diff --git a/Resources/Prototypes/ADT/Entities/Mobs/Species/novakid.yml b/Resources/Prototypes/ADT/Entities/Mobs/Species/novakid.yml index 41b9e1ae167..ac01e6392d9 100644 --- a/Resources/Prototypes/ADT/Entities/Mobs/Species/novakid.yml +++ b/Resources/Prototypes/ADT/Entities/Mobs/Species/novakid.yml @@ -147,6 +147,7 @@ shortscale: 0.9 - type: BloodCough postingSayDamage: blood-cough-novakid + - type: ReliveResuscitation - type: entity diff --git a/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml b/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml index f39ab14c474..9d93e525975 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/arachnid.yml @@ -138,6 +138,7 @@ tallscale: 1.15 short: true shortscale: 0.98 + - type: ReliveResuscitation #End ADT tweak - type: entity diff --git a/Resources/Prototypes/Entities/Mobs/Species/diona.yml b/Resources/Prototypes/Entities/Mobs/Species/diona.yml index 23b0faa533e..63d43e9f785 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/diona.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/diona.yml @@ -123,6 +123,7 @@ tallscale: 1.08 short: true shortscale: 0.92 + - type: ReliveResuscitation #End ADT tweak - type: entity diff --git a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml index 7411655b82e..da68c79b118 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml @@ -70,6 +70,7 @@ understands: - GalacticCommon - Dwarf + - type: ReliveResuscitation - type: entity parent: BaseSpeciesDummy diff --git a/Resources/Prototypes/Entities/Mobs/Species/human.yml b/Resources/Prototypes/Entities/Mobs/Species/human.yml index 08b28e4b2c2..6690bc4abcd 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/human.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/human.yml @@ -40,6 +40,7 @@ tallscale: 1.08 short: true shortscale: 0.92 + - type: ReliveResuscitation #End ADT tweak diff --git a/Resources/Prototypes/Entities/Mobs/Species/reptilian.yml b/Resources/Prototypes/Entities/Mobs/Species/reptilian.yml index 028dfe40a38..e4f1a7f9213 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/reptilian.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/reptilian.yml @@ -114,6 +114,7 @@ tallscale: 1.12 short: true shortscale: 0.98 + - type: ReliveResuscitation #End ADT tweak - type: entity diff --git a/Resources/Prototypes/Entities/Mobs/Species/slime.yml b/Resources/Prototypes/Entities/Mobs/Species/slime.yml index 3f313d82c64..1d6ae5480b0 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/slime.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/slime.yml @@ -136,6 +136,7 @@ tallscale: 1.05 short: true shortscale: 0.95 + - type: ReliveResuscitation #End ADT tweak - type: entity diff --git a/Resources/Prototypes/Entities/Mobs/Species/vox.yml b/Resources/Prototypes/Entities/Mobs/Species/vox.yml index 5bda0b08dc9..1f354e28ece 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/vox.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/vox.yml @@ -143,6 +143,7 @@ tallscale: 1.05 short: true shortscale: 0.95 + - type: ReliveResuscitation #ADT Tweak end - type: entity From dcaa28de5095885616d5b265c4e5a49968f7c6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:38:55 +0300 Subject: [PATCH 02/23] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 105 +++++++++++++++--- 1 file changed, 87 insertions(+), 18 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 310a24b66f7..c848affc4af 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -9,6 +9,84 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; +using Content.Shared.Actions; +using Content.Shared.Physics; +using Robust.Shared.Physics; +using Content.Shared.ADT.Phantom; +using Content.Shared.ADT.Phantom.Components; +using Content.Shared.Popups; +using Robust.Shared.Map; +using Content.Shared.Movement.Events; +using Content.Server.Power.EntitySystems; +using Content.Shared.Mobs.Systems; +using Robust.Shared.Random; +using Content.Shared.IdentityManagement; +using Content.Shared.Chat; +using Content.Server.Chat; +using System.Linq; +using Content.Shared.Heretic; +using Content.Shared.Alert; +using Robust.Server.GameObjects; +using Content.Server.Chat.Systems; +using Content.Shared.ActionBlocker; +using Content.Shared.StatusEffect; +using Content.Shared.Damage.Systems; +using Content.Shared.Damage.Prototypes; +using Content.Shared.Damage; +using Content.Shared.FixedPoint; +using Content.Shared.Mind; +using Content.Shared.Humanoid; +using Robust.Shared.Containers; +using Content.Shared.DoAfter; +using System.Numerics; +using Robust.Shared.Physics.Systems; +using Robust.Shared.Network; +using Robust.Shared.Player; +using Content.Server.Chat.Managers; +using Robust.Shared.Prototypes; +using Content.Shared.Stunnable; +using Content.Server.Power.Components; +using Content.Shared.Eye.Blinding.Systems; +using Content.Shared.Eye; +using Content.Server.Light.Components; +using Content.Server.Light.EntitySystems; +using Content.Shared.PowerCell.Components; +using Robust.Shared.Timing; +using Content.Shared.Inventory; +using Content.Shared.Interaction.Components; +using Content.Shared.Mindshield.Components; +using Content.Shared.Bible.Components; +using Content.Server.Body.Systems; +using Content.Server.Station.Systems; +using Content.Server.EUI; +using Content.Server.Body.Components; +using Content.Shared.Eye.Blinding.Components; +using Content.Server.ADT.Hallucinations; +using Content.Server.AlertLevel; +using Content.Shared.ADT.Controlled; +using Robust.Shared.Audio.Systems; +using Content.Shared.Weapons.Melee; +using Content.Shared.CombatMode; +using Content.Server.Cuffs; +using Robust.Server.Player; +using Content.Shared.Preferences; +using Content.Shared.Ghost; +using Content.Shared.Tag; +using Content.Server.Hands.Systems; +using Content.Shared.Cuffs.Components; +using Content.Shared.Rejuvenate; +using Content.Shared.ADT.Hallucinations; +using Robust.Shared.Utility; +using Content.Shared.Humanoid.Markings; +using Content.Shared.Projectiles; +using Content.Shared.Throwing; +using Content.Shared.Weapons.Melee.Events; +using Content.Shared.ADT.GhostInteractions; +using Content.Shared.Revenant.Components; +using Content.Shared.Mobs.Components; +using Content.Shared.ADT.Silicon.Components; +using Content.Server.Singularity.Events; +using Content.Server.GameTicking.Rules; using Content.Shared.DoAfter; @@ -26,7 +104,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent>(OnAltVerbs); - //SubscribeLocalEvent(ReliveEvent); + SubscribeLocalEvent(DoRelive); } private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) @@ -48,16 +126,8 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MetaDataComponent metaDataUser, MetaDataComponent metaDataTarget) { + //var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); _popup.PopupEntity($"{metaDataUser.EntityName} делает сердечно-лёгочную реанимацию {metaDataTarget.EntityName}", uid, user); - - DoRelive(uid, user, component); - } - - private void DoRelive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component) - { - FixedPoint2 asphyxiationHeal = -20; - FixedPoint2 bluntDamage = 5; - var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) { @@ -66,18 +136,17 @@ private void DoRelive(EntityUid uid, EntityUid user, ReliveResuscitationComponen NeedHand = true, BreakOnMove = true, BreakOnWeightlessMove = false, - + BreakOnDamage = true, }; - + _doAfter.TryStartDoAfter(doAfterEventArgs); + } + private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent agrs) + { + FixedPoint2 asphyxiationHeal = -20; + FixedPoint2 bluntDamage = 5; DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); - _damageable.TryChangeDamage(uid, damageAsphyxiation, true); _damageable.TryChangeDamage(uid, damageBlunt, true); - - _doAfter.TryStartDoAfter(doAfterEventArgs); - //_doAfter.IsRunning(doAfterEventArgs); - - return; } } From 35d9651e8763bc8fbbd73479e82801112646226f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:40:48 +0300 Subject: [PATCH 03/23] =?UTF-8?q?=D1=83=D0=B1=D0=B8=D1=80=D0=B0=D1=8E=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitation/ReliveResuscitationSystem.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index c848affc4af..6f95e071acb 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -109,13 +109,13 @@ public override void Initialize() private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) { - if (TryComp(uid, out var mobState) && TryComp(args.User, out var metaDataUser) && TryComp(uid, out var metaDataTarget)) + if (TryComp(uid, out var mobState)) { if (mobState.CurrentState == MobState.Critical) { AlternativeVerb verbPersonalize = new() { - Act = () => Relive(uid, args.User, component, metaDataUser, metaDataTarget), + Act = () => Relive(uid, args.User, component), Text = Loc.GetString("Сердечно-лёгочная реанимация"), Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), }; @@ -124,10 +124,10 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G } } - private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MetaDataComponent metaDataUser, MetaDataComponent metaDataTarget) + private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component) { - //var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); - _popup.PopupEntity($"{metaDataUser.EntityName} делает сердечно-лёгочную реанимацию {metaDataTarget.EntityName}", uid, user); + var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); + _popup.PopupEntity(stringLoc, uid, user); var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) { From ee624f2861e5cef8288bc0d6a28d2f613e8cd6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:15:07 +0300 Subject: [PATCH 04/23] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 14 ++++++++++---- .../ReliveResuscitationComponent.cs | 8 -------- .../Locale/ru-RU/ADT/Interaction/relive-popups.ftl | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 6f95e071acb..81186ade424 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -131,8 +131,6 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) { - // Didn't break on damage as they may be trying to prevent it and - // not being able to heal your own ticking damage would be frustrating. NeedHand = true, BreakOnMove = true, BreakOnWeightlessMove = false, @@ -140,13 +138,21 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent }; _doAfter.TryStartDoAfter(doAfterEventArgs); } - private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent agrs) + private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args) { + if (args.Handled || args.Cancelled) + return; + FixedPoint2 asphyxiationHeal = -20; - FixedPoint2 bluntDamage = 5; + FixedPoint2 bluntDamage = 3; DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); _damageable.TryChangeDamage(uid, damageAsphyxiation, true); _damageable.TryChangeDamage(uid, damageBlunt, true); + + args.Handled = true; + + if (args.Used != null) + Relive(uid, args.Used.Value, component); } } diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs index 36397637c60..42d90e12c0b 100644 --- a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs @@ -12,13 +12,5 @@ public sealed partial class ReliveResuscitationComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] public float Delay = 3f; - - - /// - /// Delay multiplier when healing yourself. - /// - [DataField("selfHealPenaltyMultiplier")] - public float SelfHealPenaltyMultiplier = 3f; - } diff --git a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl new file mode 100644 index 00000000000..03e6acb2e62 --- /dev/null +++ b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl @@ -0,0 +1 @@ +relive-start-message = {CAPITALIZE(THE($user))} делает сердечно-лёгочную реанимацю {CAPITALIZE(THE($name))}. From aa4c5bc64cc6bb3d7ddaed16454b7bf429670bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:18:02 +0300 Subject: [PATCH 05/23] =?UTF-8?q?=D0=9B=D0=B8=D1=88=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=8E=D1=81=D0=B8=D0=BD=D0=B3=D0=B8=20=D1=83=D0=B1=D0=B8=D1=80?= =?UTF-8?q?=D0=B0=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 79 ------------------- 1 file changed, 79 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 81186ade424..e3a8a9d6a73 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -1,7 +1,6 @@ using Content.Shared.Verbs; using Robust.Shared.Utility; using Content.Shared.Popups; -using Content.Shared.Electrocution; using Content.Shared.ADT.ReliveResuscitation; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; @@ -9,93 +8,15 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; -using Content.Shared.Actions; -using Content.Shared.Physics; -using Robust.Shared.Physics; -using Content.Shared.ADT.Phantom; -using Content.Shared.ADT.Phantom.Components; -using Content.Shared.Popups; -using Robust.Shared.Map; -using Content.Shared.Movement.Events; -using Content.Server.Power.EntitySystems; -using Content.Shared.Mobs.Systems; -using Robust.Shared.Random; using Content.Shared.IdentityManagement; -using Content.Shared.Chat; -using Content.Server.Chat; -using System.Linq; -using Content.Shared.Heretic; -using Content.Shared.Alert; -using Robust.Server.GameObjects; -using Content.Server.Chat.Systems; -using Content.Shared.ActionBlocker; -using Content.Shared.StatusEffect; -using Content.Shared.Damage.Systems; -using Content.Shared.Damage.Prototypes; -using Content.Shared.Damage; -using Content.Shared.FixedPoint; -using Content.Shared.Mind; -using Content.Shared.Humanoid; -using Robust.Shared.Containers; using Content.Shared.DoAfter; -using System.Numerics; -using Robust.Shared.Physics.Systems; -using Robust.Shared.Network; -using Robust.Shared.Player; -using Content.Server.Chat.Managers; -using Robust.Shared.Prototypes; -using Content.Shared.Stunnable; -using Content.Server.Power.Components; -using Content.Shared.Eye.Blinding.Systems; -using Content.Shared.Eye; -using Content.Server.Light.Components; -using Content.Server.Light.EntitySystems; -using Content.Shared.PowerCell.Components; -using Robust.Shared.Timing; -using Content.Shared.Inventory; -using Content.Shared.Interaction.Components; -using Content.Shared.Mindshield.Components; -using Content.Shared.Bible.Components; -using Content.Server.Body.Systems; -using Content.Server.Station.Systems; -using Content.Server.EUI; -using Content.Server.Body.Components; -using Content.Shared.Eye.Blinding.Components; -using Content.Server.ADT.Hallucinations; -using Content.Server.AlertLevel; -using Content.Shared.ADT.Controlled; -using Robust.Shared.Audio.Systems; -using Content.Shared.Weapons.Melee; -using Content.Shared.CombatMode; -using Content.Server.Cuffs; -using Robust.Server.Player; -using Content.Shared.Preferences; -using Content.Shared.Ghost; -using Content.Shared.Tag; -using Content.Server.Hands.Systems; -using Content.Shared.Cuffs.Components; -using Content.Shared.Rejuvenate; -using Content.Shared.ADT.Hallucinations; -using Robust.Shared.Utility; -using Content.Shared.Humanoid.Markings; -using Content.Shared.Projectiles; -using Content.Shared.Throwing; -using Content.Shared.Weapons.Melee.Events; -using Content.Shared.ADT.GhostInteractions; -using Content.Shared.Revenant.Components; -using Content.Shared.Mobs.Components; -using Content.Shared.ADT.Silicon.Components; -using Content.Server.Singularity.Events; -using Content.Server.GameTicking.Rules; -using Content.Shared.DoAfter; namespace Content.Server.ADT.ReliveResuscitation; public sealed partial class ReliveResuscitationSystem : EntitySystem { [Dependency] private readonly SharedPopupSystem _popup = default!; - [Dependency] private readonly SharedElectrocutionSystem _electrocutionSystem = default!; [Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; From ede0174ff3627b210bc8929b634bd1d042da8640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:24:07 +0300 Subject: [PATCH 06/23] =?UTF-8?q?=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/ReliveResuscitation/ReliveResuscitationComponent.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs index 42d90e12c0b..9be844eba60 100644 --- a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs @@ -1,9 +1,13 @@ using Robust.Shared.GameStates; -using Content.Shared.DoAfter; namespace Content.Shared.ADT.ReliveResuscitation; [RegisterComponent, NetworkedComponent] +/// +/// Этот компонент вешается на сущность, при крит состоянии у неё, можно попробовать провести СЛР(Сердечно-лёгочную реанимацию), +/// и попытаться реанимировать убирая удушение взамен на добавление грубого урона. +/// by Шрёдька <3 (Schrodinger71) +/// public sealed partial class ReliveResuscitationComponent : Component { /// From 163958cc130ef7bbda8daecb869b76808efe83f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:26:38 +0300 Subject: [PATCH 07/23] =?UTF-8?q?=D0=A2=D0=B0=D0=BA=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index e3a8a9d6a73..6fcfec756e4 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -36,7 +36,7 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G { AlternativeVerb verbPersonalize = new() { - Act = () => Relive(uid, args.User, component), + Act = () => Relive(uid, args.User, component, mobState), Text = Loc.GetString("Сердечно-лёгочная реанимация"), Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), }; @@ -45,19 +45,22 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G } } - private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component) + private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) { - var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); - _popup.PopupEntity(stringLoc, uid, user); - var doAfterEventArgs = - new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) - { - NeedHand = true, - BreakOnMove = true, - BreakOnWeightlessMove = false, - BreakOnDamage = true, - }; - _doAfter.TryStartDoAfter(doAfterEventArgs); + if (mobState.CurrentState == MobState.Critical) + { + var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); + _popup.PopupEntity(stringLoc, uid, user); + var doAfterEventArgs = + new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) + { + NeedHand = true, + BreakOnMove = true, + BreakOnWeightlessMove = false, + BreakOnDamage = true, + }; + _doAfter.TryStartDoAfter(doAfterEventArgs); + } } private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args) { @@ -72,8 +75,6 @@ private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref _damageable.TryChangeDamage(uid, damageBlunt, true); args.Handled = true; - - if (args.Used != null) - Relive(uid, args.Used.Value, component); + args.Repeat = true; } } From 2dc9db49d326bffbb7eb3eb959decb8b024b0dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:34:41 +0300 Subject: [PATCH 08/23] =?UTF-8?q?=D0=B4=D0=B0=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 6fcfec756e4..8b8f2cf3360 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -47,34 +47,35 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) { - if (mobState.CurrentState == MobState.Critical) - { - var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); - _popup.PopupEntity(stringLoc, uid, user); - var doAfterEventArgs = - new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) - { - NeedHand = true, - BreakOnMove = true, - BreakOnWeightlessMove = false, - BreakOnDamage = true, - }; - _doAfter.TryStartDoAfter(doAfterEventArgs); - } + var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); + _popup.PopupEntity(stringLoc, uid, user); + var doAfterEventArgs = + new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) + { + NeedHand = true, + BreakOnMove = true, + BreakOnWeightlessMove = false, + BreakOnDamage = true, + }; + + _doAfter.TryStartDoAfter(doAfterEventArgs); } private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args) { - if (args.Handled || args.Cancelled) - return; + if (TryComp(uid, out var mobState) && mobState.CurrentState == MobState.Critical) + { + if (args.Handled || args.Cancelled) + return; - FixedPoint2 asphyxiationHeal = -20; - FixedPoint2 bluntDamage = 3; - DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); - DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); - _damageable.TryChangeDamage(uid, damageAsphyxiation, true); - _damageable.TryChangeDamage(uid, damageBlunt, true); + FixedPoint2 asphyxiationHeal = -20; + FixedPoint2 bluntDamage = 3; + DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); + DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); + _damageable.TryChangeDamage(uid, damageAsphyxiation, true); + _damageable.TryChangeDamage(uid, damageBlunt, true); - args.Handled = true; - args.Repeat = true; + args.Handled = true; + args.Repeat = true; + } } } From 15feff99729d089d1d07c5e06b6ea30fd7b2313c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:41:54 +0300 Subject: [PATCH 09/23] =?UTF-8?q?=D0=94=D0=BE=D0=BA=D1=83=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B1=D0=BB=D1=8F=D1=82?= =?UTF-8?q?=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 22 +++++++++++++++++++ .../ReliveResuscitationComponent.cs | 10 ++++----- .../ReliveResuscitationEvent.cs | 3 +++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 8b8f2cf3360..a5a8b3dfbf0 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -28,6 +28,13 @@ public override void Initialize() SubscribeLocalEvent(DoRelive); } + /// + /// Обрабатывает событие получения альтернативных действий для сущности(ПКМ). + /// Если сущность находится в критическом состоянии, добавляет возможность провести сердечно-лёгочную реанимацию. + /// + /// Идентификатор сущности, на которой выполняется действие. + /// Компонент реанимации, связанный с сущностью. + /// Событие, содержащее информацию о доступных альтернативных действиях. private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) { if (TryComp(uid, out var mobState)) @@ -45,6 +52,13 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G } } + /// + /// Начинает процесс реанимации сущности. Отправляет сообщение пользователю и запускает таймер действия. + /// + /// Идентификатор сущности, которую пытаются реанимировать. + /// Идентификатор пользователя, который проводит реанимацию. + /// Компонент реанимации, связанный с сущностью. + /// Компонент состояния сущности, указывающий текущее состояние. private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) { var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); @@ -60,6 +74,14 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent _doAfter.TryStartDoAfter(doAfterEventArgs); } + + /// + /// Завершает процесс реанимации, нанося урон от удушения и добавляя грубый урон. + /// Проверяет состояние сущности перед применением урона. + /// + /// Идентификатор сущности, которую пытаются реанимировать. + /// Компонент реанимации, связанный с сущностью. + /// Событие, содержащее информацию о выполнении действия. private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args) { if (TryComp(uid, out var mobState) && mobState.CurrentState == MobState.Critical) diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs index 9be844eba60..3d0e9d2664e 100644 --- a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs @@ -2,19 +2,19 @@ namespace Content.Shared.ADT.ReliveResuscitation; -[RegisterComponent, NetworkedComponent] /// -/// Этот компонент вешается на сущность, при крит состоянии у неё, можно попробовать провести СЛР(Сердечно-лёгочную реанимацию), -/// и попытаться реанимировать убирая удушение взамен на добавление грубого урона. +/// Компонент, позволяющий проводить сердечно-лёгочную реанимацию сущности в критическом состоянии. +/// Убирает удушение взамен на добавление грубого урона. /// by Шрёдька <3 (Schrodinger71) /// +[RegisterComponent, NetworkedComponent] public sealed partial class ReliveResuscitationComponent : Component { /// - /// How long it takes to apply the damage. + /// Время проведения реанимации в секундах /// [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] - public float Delay = 3f; + public float Delay = 3.3f; } diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs index 1c674d267d0..0fa7bfdab55 100644 --- a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs @@ -4,6 +4,9 @@ namespace Content.Shared.ADT.ReliveResuscitation; +/// +/// This event is triggered after the ReliveResuscitationComponent has been applied. +/// [Serializable, NetSerializable] public sealed partial class ReliveDoAfterEvent : SimpleDoAfterEvent { From 9d270b829e840271da9c631bf77f0a8376ada098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:43:37 +0300 Subject: [PATCH 10/23] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B8=D0=B9=20=D1=8E=D0=B7=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Server/ADT/BloodCough/BloodCoughSystem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Content.Server/ADT/BloodCough/BloodCoughSystem.cs b/Content.Server/ADT/BloodCough/BloodCoughSystem.cs index 7ba96317f27..79858870c10 100644 --- a/Content.Server/ADT/BloodCough/BloodCoughSystem.cs +++ b/Content.Server/ADT/BloodCough/BloodCoughSystem.cs @@ -8,7 +8,6 @@ using Content.Server.Fluids.EntitySystems; using Content.Shared.Mobs.Systems; using Content.Shared.ADT.Silicon.Components; -using Content.Shared.Damage.Prototypes; using Robust.Shared.Prototypes; From c0bca7e14e0b6cfcb31bb0fd7cb64cce57503cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:52:10 +0300 Subject: [PATCH 11/23] =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Shared/ADT/BloodCough/BloodCoughComponent.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Content.Shared/ADT/BloodCough/BloodCoughComponent.cs b/Content.Shared/ADT/BloodCough/BloodCoughComponent.cs index 5e49d925a76..0af51c7b8ec 100644 --- a/Content.Shared/ADT/BloodCough/BloodCoughComponent.cs +++ b/Content.Shared/ADT/BloodCough/BloodCoughComponent.cs @@ -1,8 +1,12 @@ using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; namespace Content.Shared.ADT.BloodCough; +/// +/// Компонент, который отслеживает состояние сущности и воспроизводит эмоцию о плохом состоянии, если у сущности больше 70 грубого урона. +/// принимает поле postingSayDamage, то сообщение которое будет воспроиводиться эмоцией сущности. +/// by Шрёдька :з (Schrodinger71) +/// [RegisterComponent] [NetworkedComponent] public sealed partial class BloodCoughComponent : Component From 510d2bb0b0f7afefa1116fd893dfd9c69791a79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:54:11 +0300 Subject: [PATCH 12/23] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/ReliveResuscitation/ReliveResuscitationSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index a5a8b3dfbf0..8fcdeae96a6 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -43,7 +43,7 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G { AlternativeVerb verbPersonalize = new() { - Act = () => Relive(uid, args.User, component, mobState), + Act = () => Relive(uid, args.User, component), Text = Loc.GetString("Сердечно-лёгочная реанимация"), Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), }; @@ -59,7 +59,7 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G /// Идентификатор пользователя, который проводит реанимацию. /// Компонент реанимации, связанный с сущностью. /// Компонент состояния сущности, указывающий текущее состояние. - private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) + private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component) { var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); _popup.PopupEntity(stringLoc, uid, user); From fe33478e2968c256787f24cae501bcdbc4cf75be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:17:26 +0300 Subject: [PATCH 13/23] =?UTF-8?q?=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 8fcdeae96a6..379d596c3ab 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -10,6 +10,7 @@ using Robust.Shared.Prototypes; using Content.Shared.IdentityManagement; using Content.Shared.DoAfter; +using Robust.Shared.Toolshed.Commands.Generic.ListGeneration; namespace Content.Server.ADT.ReliveResuscitation; @@ -37,18 +38,15 @@ public override void Initialize() /// Событие, содержащее информацию о доступных альтернативных действиях. private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) { - if (TryComp(uid, out var mobState)) + if (TryComp(uid, out var mobState) && mobState.CurrentState == MobState.Critical) { - if (mobState.CurrentState == MobState.Critical) + AlternativeVerb verbPersonalize = new() { - AlternativeVerb verbPersonalize = new() - { - Act = () => Relive(uid, args.User, component), - Text = Loc.GetString("Сердечно-лёгочная реанимация"), - Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), - }; - args.Verbs.Add(verbPersonalize); - } + Act = () => Relive(uid, args.User, component), + Text = Loc.GetString("Сердечно-лёгочная реанимация"), + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), + }; + args.Verbs.Add(verbPersonalize); } } @@ -84,20 +82,23 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent /// Событие, содержащее информацию о выполнении действия. private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args) { - if (TryComp(uid, out var mobState) && mobState.CurrentState == MobState.Critical) + if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) { - if (args.Handled || args.Cancelled) - return; + args.Repeat = false; + return; + } - FixedPoint2 asphyxiationHeal = -20; - FixedPoint2 bluntDamage = 3; - DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); - DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); - _damageable.TryChangeDamage(uid, damageAsphyxiation, true); - _damageable.TryChangeDamage(uid, damageBlunt, true); + if (args.Handled || args.Cancelled) + return; - args.Handled = true; - args.Repeat = true; - } + FixedPoint2 asphyxiationHeal = -20; + FixedPoint2 bluntDamage = 3; + DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); + DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); + _damageable.TryChangeDamage(uid, damageAsphyxiation, true); + _damageable.TryChangeDamage(uid, damageBlunt, true); + + args.Handled = true; + args.Repeat = true; } } From 29431fdcb38012fb931f4c3bdac0fd31c50f1aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:53:23 +0300 Subject: [PATCH 14/23] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 379d596c3ab..fcf7274a75c 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -38,16 +38,17 @@ public override void Initialize() /// Событие, содержащее информацию о доступных альтернативных действиях. private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) { - if (TryComp(uid, out var mobState) && mobState.CurrentState == MobState.Critical) + if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) + return; + + AlternativeVerb verbPersonalize = new() { - AlternativeVerb verbPersonalize = new() - { - Act = () => Relive(uid, args.User, component), - Text = Loc.GetString("Сердечно-лёгочная реанимация"), - Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), - }; - args.Verbs.Add(verbPersonalize); - } + Act = () => Relive(uid, args.User, component, mobState), + Text = Loc.GetString("Сердечно-лёгочная реанимация"), + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), + }; + + args.Verbs.Add(verbPersonalize); } /// @@ -57,12 +58,15 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G /// Идентификатор пользователя, который проводит реанимацию. /// Компонент реанимации, связанный с сущностью. /// Компонент состояния сущности, указывающий текущее состояние. - private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component) + private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) { + if (mobState.CurrentState != MobState.Critical) + return; + var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); _popup.PopupEntity(stringLoc, uid, user); var doAfterEventArgs = - new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent(), uid, target: uid, used: user) + new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent() {Repeat = true}, uid, target: uid, used: user) { NeedHand = true, BreakOnMove = true, @@ -70,6 +74,7 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent BreakOnDamage = true, }; + _doAfter.TryStartDoAfter(doAfterEventArgs); } @@ -82,15 +87,18 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent /// Событие, содержащее информацию о выполнении действия. private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args) { + if (args.Handled || args.Cancelled) + return; + if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) { + // TODO: Места для супер попапа чтобы прервать. by Mirokko <3 + // . . . + args.Repeat = false; return; } - if (args.Handled || args.Cancelled) - return; - FixedPoint2 asphyxiationHeal = -20; FixedPoint2 bluntDamage = 3; DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); @@ -99,6 +107,5 @@ private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref _damageable.TryChangeDamage(uid, damageBlunt, true); args.Handled = true; - args.Repeat = true; } } From 4d34d0a0eee16a371d4a248dc1f33ced1d26a427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:55:04 +0300 Subject: [PATCH 15/23] =?UTF-8?q?69=20=D0=BA=D1=80=D1=83=D1=82=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BD=D0=BE=D0=BC=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/ReliveResuscitation/ReliveResuscitationSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index fcf7274a75c..dc1a7423eed 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -66,7 +66,7 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); _popup.PopupEntity(stringLoc, uid, user); var doAfterEventArgs = - new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent() {Repeat = true}, uid, target: uid, used: user) + new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent() { Repeat = true }, uid, target: uid, used: user) { NeedHand = true, BreakOnMove = true, From b03b36ad8f0b280f49cc60d0937dc03d9794b72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:21:06 +0300 Subject: [PATCH 16/23] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=D0=BB=20TODO:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitation/ReliveResuscitationSystem.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index dc1a7423eed..d4c969fecb4 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -10,7 +10,7 @@ using Robust.Shared.Prototypes; using Content.Shared.IdentityManagement; using Content.Shared.DoAfter; -using Robust.Shared.Toolshed.Commands.Generic.ListGeneration; +using Content.Server.Body.Components; namespace Content.Server.ADT.ReliveResuscitation; @@ -41,9 +41,14 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) return; + // TODO: Можно конечно всё усложнить с дыханием, и чекать совпадает ли оно... + if (!HasComp(uid) || !HasComp(args.User)) + return; + AlternativeVerb verbPersonalize = new() { Act = () => Relive(uid, args.User, component, mobState), + // TODO: перенести в ftl Text = Loc.GetString("Сердечно-лёгочная реанимация"), Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), }; @@ -92,13 +97,14 @@ private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) { - // TODO: Места для супер попапа чтобы прервать. by Mirokko <3 - // . . . + // TODO: Места для супер попапа чтобы прервать. by Mirokko <3. Мэээъъъъ + // . . . . . args.Repeat = false; return; } + // TODO: Перенести всё в компонент FixedPoint2 asphyxiationHeal = -20; FixedPoint2 bluntDamage = 3; DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); From 32705b0c008fc6295f4dcb938ea106f34d250e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:33:59 +0300 Subject: [PATCH 17/23] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/ReliveResuscitation/ReliveResuscitationSystem.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index d4c969fecb4..88629bb2cf2 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -30,7 +30,7 @@ public override void Initialize() } /// - /// Обрабатывает событие получения альтернативных действий для сущности(ПКМ). + /// Обрабатывает событие получения альтернативных действий для сущности (на ПКМ). /// Если сущность находится в критическом состоянии, добавляет возможность провести сердечно-лёгочную реанимацию. /// /// Идентификатор сущности, на которой выполняется действие. @@ -42,8 +42,9 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G return; // TODO: Можно конечно всё усложнить с дыханием, и чекать совпадает ли оно... - if (!HasComp(uid) || !HasComp(args.User)) - return; + if (!HasComp(uid) || !HasComp(args.User) + || !HasComp(args.User)) return; // Думаю что юзер тоже такой компонент должен иметь... + // проблем в будущем не должно создать AlternativeVerb verbPersonalize = new() { From dc201a80741cfe187657f50e508b8aaa05a440bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:40:06 +0300 Subject: [PATCH 18/23] =?UTF-8?q?todo=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=BE,=20+=20add=20=D1=80=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D0=BE=D0=BC=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitationSystem.cs | 91 +++++++++++-------- .../ReliveResuscitationComponent.cs | 27 ++++++ .../ru-RU/ADT/Interaction/relive-popups.ftl | 4 +- 3 files changed, 83 insertions(+), 39 deletions(-) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs index 88629bb2cf2..ff44fac01b0 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs @@ -1,26 +1,30 @@ -using Content.Shared.Verbs; -using Robust.Shared.Utility; -using Content.Shared.Popups; +using Content.Server.Body.Components; using Content.Shared.ADT.ReliveResuscitation; -using Content.Shared.Mobs; -using Content.Shared.Mobs.Components; using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; -using Content.Shared.FixedPoint; -using Robust.Shared.Prototypes; -using Content.Shared.IdentityManagement; using Content.Shared.DoAfter; -using Content.Server.Body.Components; +using Content.Shared.IdentityManagement; +using Content.Shared.Mobs; +using Content.Shared.Mobs.Components; +using Content.Shared.Popups; +using Content.Shared.Verbs; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; +using Robust.Shared.Utility; +using Robust.Shared.Timing; namespace Content.Server.ADT.ReliveResuscitation; +//SharedReliveResuscitationSystem public sealed partial class ReliveResuscitationSystem : EntitySystem { [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; + [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly IGameTiming _timing = default!; public override void Initialize() { base.Initialize(); @@ -38,23 +42,22 @@ public override void Initialize() /// Событие, содержащее информацию о доступных альтернативных действиях. private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent args) { - if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) - return; - - // TODO: Можно конечно всё усложнить с дыханием, и чекать совпадает ли оно... - if (!HasComp(uid) || !HasComp(args.User) - || !HasComp(args.User)) return; // Думаю что юзер тоже такой компонент должен иметь... - // проблем в будущем не должно создать - - AlternativeVerb verbPersonalize = new() + if (TryComp(uid, out var mobState) && mobState.CurrentState == MobState.Critical) { - Act = () => Relive(uid, args.User, component, mobState), - // TODO: перенести в ftl - Text = Loc.GetString("Сердечно-лёгочная реанимация"), - Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), - }; + // TODO: Можно конечно всё усложнить с дыханием, и чекать совпадает ли оно... + if (!HasComp(args.User)) + return; // Думаю что юзер тоже такой компонент должен иметь... + // проблем в будущем не должно создать - args.Verbs.Add(verbPersonalize); + AlternativeVerb verbPersonalize = new() + { + Act = () => Relive(uid, args.User, component, mobState), + Text = Loc.GetString("relive-resuscitation-verb"), + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")), + }; + + args.Verbs.Add(verbPersonalize); + } } /// @@ -66,11 +69,17 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G /// Компонент состояния сущности, указывающий текущее состояние. private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) { + // if (!_timing.IsFirstTimePredicted) + // return; + if (mobState.CurrentState != MobState.Critical) return; - var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), ("name", Identity.Entity(uid, EntityManager))); - _popup.PopupEntity(stringLoc, uid, user); + var stringLoc = Loc.GetString("relive-start-message", ("user", Identity.Entity(user, EntityManager)), + ("name", Identity.Entity(uid, EntityManager))); + + _popup.PopupEntity(stringLoc, uid, user); // Сообщение о том что начали делать СЛР. (Кто) и (кому) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent() { Repeat = true }, uid, target: uid, used: user) { @@ -96,23 +105,29 @@ private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref if (args.Handled || args.Cancelled) return; - if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) - { - // TODO: Места для супер попапа чтобы прервать. by Mirokko <3. Мэээъъъъ - // . . . . . + var randomDamageAshyxiation = _random.Next(component.MaxAsphyxiationHeal, component.MinAsphyxiationHeal); + var randomDamageBlunt = _random.Next(component.MinBluntDamage, component.MaxBluntDamage); - args.Repeat = false; - return; - } + DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index(component.DamageAsphyxiation), + randomDamageAshyxiation); + DamageSpecifier damageBlunt = new(_prototypeManager.Index(component.DamageBlunt), + randomDamageBlunt); - // TODO: Перенести всё в компонент - FixedPoint2 asphyxiationHeal = -20; - FixedPoint2 bluntDamage = 3; - DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index("Asphyxiation"), asphyxiationHeal); - DamageSpecifier damageBlunt = new(_prototypeManager.Index("Blunt"), bluntDamage); _damageable.TryChangeDamage(uid, damageAsphyxiation, true); _damageable.TryChangeDamage(uid, damageBlunt, true); args.Handled = true; + args.Repeat = true; + + if (!TryComp(uid, out var mobState) || mobState.CurrentState != MobState.Critical) + { + var locReliveAbort = Loc.GetString("relive-abort-message", + ("name", Identity.Entity(uid, EntityManager))); + + _popup.PopupEntity(locReliveAbort, uid, args.User); // by ideas Mirokko :з + + args.Repeat = false; + return; + } } } diff --git a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs index 3d0e9d2664e..23ad5f58801 100644 --- a/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs +++ b/Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationComponent.cs @@ -1,4 +1,7 @@ +using Content.Shared.Damage.Prototypes; +using Content.Shared.FixedPoint; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; namespace Content.Shared.ADT.ReliveResuscitation; @@ -16,5 +19,29 @@ public sealed partial class ReliveResuscitationComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] public float Delay = 3.3f; + + [DataField] + public FixedPoint2 _asphyxiationHeal = -20; + + [DataField] + public FixedPoint2 _bluntDamage = 3; + + [DataField] + public int MinAsphyxiationHeal = -13; + + [DataField] + public int MinBluntDamage = 7; + + [DataField] + public int MaxAsphyxiationHeal = -17; + + [DataField] + public int MaxBluntDamage = 13; + + [DataField] + public ProtoId DamageAsphyxiation = "Asphyxiation"; + + [DataField] + public ProtoId DamageBlunt = "Blunt"; } diff --git a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl index 03e6acb2e62..494049d9847 100644 --- a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl +++ b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl @@ -1 +1,3 @@ -relive-start-message = {CAPITALIZE(THE($user))} делает сердечно-лёгочную реанимацю {CAPITALIZE(THE($name))}. +relive-resuscitation-verb = Сердечно-лёгочная реанимация +relive-start-message = {CAPITALIZE(THE($user))} проводит сердечно-лёгочную реанимацю {CAPITALIZE(THE($name))}. +relive-abort-message = Глаза {CAPITALIZE(THE($name))} широко раскрываются, и он, с хрипом, делает глубокий вдох. From 633a5efe36566a8edd8246170fb716a66ae7b860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:47:21 +0300 Subject: [PATCH 19/23] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=B2=20=D1=88=D0=B5=D0=B9=D1=80=D0=B0=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReliveResuscitation/SharedReliveResuscitationSystem.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs => Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs (96%) diff --git a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs b/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs similarity index 96% rename from Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs rename to Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs index ff44fac01b0..4d62710927c 100644 --- a/Content.Server/ADT/ReliveResuscitation/ReliveResuscitationSystem.cs +++ b/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs @@ -1,5 +1,3 @@ -using Content.Server.Body.Components; -using Content.Shared.ADT.ReliveResuscitation; using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; using Content.Shared.DoAfter; @@ -14,10 +12,9 @@ using Robust.Shared.Timing; -namespace Content.Server.ADT.ReliveResuscitation; +namespace Content.Shared.ADT.ReliveResuscitation; -//SharedReliveResuscitationSystem -public sealed partial class ReliveResuscitationSystem : EntitySystem +public sealed partial class SharedReliveResuscitationSystem : EntitySystem { [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly DamageableSystem _damageable = default!; From ac6ebc82aa066a7ff027b312062211ff3f27149b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:47:40 +0300 Subject: [PATCH 20/23] add predict --- .../ReliveResuscitation/SharedReliveResuscitationSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs b/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs index 4d62710927c..06364e46396 100644 --- a/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs +++ b/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs @@ -66,8 +66,8 @@ private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, G /// Компонент состояния сущности, указывающий текущее состояние. private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent component, MobStateComponent mobState) { - // if (!_timing.IsFirstTimePredicted) - // return; + if (!_timing.IsFirstTimePredicted) + return; if (mobState.CurrentState != MobState.Critical) return; From 8bf773a3b92ff51dc9bf1144fd55250c4f1f8aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:48:59 +0300 Subject: [PATCH 21/23] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs b/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs index 06364e46396..3d63a77e2b6 100644 --- a/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs +++ b/Content.Shared/ADT/ReliveResuscitation/SharedReliveResuscitationSystem.cs @@ -92,7 +92,7 @@ private void Relive(EntityUid uid, EntityUid user, ReliveResuscitationComponent /// /// Завершает процесс реанимации, нанося урон от удушения и добавляя грубый урон. - /// Проверяет состояние сущности перед применением урона. + /// Проверяет состояние если она оживёт, прервать следующую итерацию и вызвать попап. /// /// Идентификатор сущности, которую пытаются реанимировать. /// Компонент реанимации, связанный с сущностью. From 6d4d456d06b6fac4265a9aa7437479eec48fa51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:55:20 +0300 Subject: [PATCH 22/23] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B8=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=8F=D1=82?= =?UTF-8?q?=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl index 494049d9847..b2d35c83de1 100644 --- a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl +++ b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl @@ -1,3 +1,3 @@ relive-resuscitation-verb = Сердечно-лёгочная реанимация relive-start-message = {CAPITALIZE(THE($user))} проводит сердечно-лёгочную реанимацю {CAPITALIZE(THE($name))}. -relive-abort-message = Глаза {CAPITALIZE(THE($name))} широко раскрываются, и он, с хрипом, делает глубокий вдох. +relive-abort-message = Глаза {CAPITALIZE(THE($name))} широко раскрываются, и он с хрипом делает глубокий вдох. From 069c30c2087cf3f170b2c0d0f5529c25ea986016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:59:19 +0300 Subject: [PATCH 23/23] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl index b2d35c83de1..cfab3fe12b7 100644 --- a/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl +++ b/Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl @@ -1,3 +1,3 @@ relive-resuscitation-verb = Сердечно-лёгочная реанимация relive-start-message = {CAPITALIZE(THE($user))} проводит сердечно-лёгочную реанимацю {CAPITALIZE(THE($name))}. -relive-abort-message = Глаза {CAPITALIZE(THE($name))} широко раскрываются, и он с хрипом делает глубокий вдох. +relive-abort-message = Глаза {CAPITALIZE(THE($name))} широко раскрываются. После непродолжительного хрипа слышен глубокий вдох.