Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[АРХИВ] Relive old #22

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7d72433
Cердечно-лёгочная реанимация
Schrodinger71 Oct 15, 2024
dcaa28d
Правки
Schrodinger71 Oct 15, 2024
35d9651
убираю лишнее
Schrodinger71 Oct 15, 2024
ee624f2
финальные правки
Schrodinger71 Oct 15, 2024
aa4c5bc
Лишнии юсинги убираю
Schrodinger71 Oct 15, 2024
ede0174
основа документации
Schrodinger71 Oct 15, 2024
163958c
Так?
Schrodinger71 Oct 15, 2024
2dc9db4
да?
Schrodinger71 Oct 15, 2024
15feff9
Документация блять
Schrodinger71 Oct 15, 2024
9d270b8
убрал лишний юзинг
Schrodinger71 Oct 15, 2024
c0bca7e
докум
Schrodinger71 Oct 15, 2024
510d2bb
убрал лишнее
Schrodinger71 Oct 15, 2024
d58cbf3
Merge branch 'master' into relive
Schrodinger71 Oct 15, 2024
fe33478
да
Schrodinger71 Oct 15, 2024
0ead8fa
Merge branch 'relive' of https://github.com/AdventureTimeSS14/space_s…
Schrodinger71 Oct 15, 2024
29431fd
правки
Schrodinger71 Oct 15, 2024
4d34d0a
69 крутой номер
Schrodinger71 Oct 15, 2024
b03b36a
прописал TODO:
Schrodinger71 Oct 15, 2024
32705b0
Мелкие правки
Schrodinger71 Oct 15, 2024
c2cccf5
Merge branch 'master' into relive
Schrodinger71 Oct 16, 2024
dc201a8
todo выполнено, + add рандомизация
Schrodinger71 Oct 16, 2024
24a025d
Merge branch 'relive' of https://github.com/AdventureTimeSS14/space_s…
Schrodinger71 Oct 16, 2024
633a5ef
Перенос в шейрад
Schrodinger71 Oct 16, 2024
ac6ebc8
add predict
Schrodinger71 Oct 16, 2024
8bf773a
правки описания
Schrodinger71 Oct 16, 2024
6d4d456
убрал лишнии запятые
Schrodinger71 Oct 16, 2024
069c30c
правка перевода
Schrodinger71 Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Content.Server/ADT/BloodCough/BloodCoughSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/ADT/BloodCough/BloodCoughComponent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.ADT.BloodCough;

/// <summary>
/// Компонент, который отслеживает состояние сущности и воспроизводит эмоцию о плохом состоянии, если у сущности больше 70 грубого урона.
/// принимает поле postingSayDamage, то сообщение которое будет воспроиводиться эмоцией сущности.
/// by Шрёдька :з (Schrodinger71)
/// </summary>
[RegisterComponent]
[NetworkedComponent]
public sealed partial class BloodCoughComponent : Component
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.ADT.ReliveResuscitation;

/// <summary>
/// Компонент, позволяющий проводить сердечно-лёгочную реанимацию сущности в критическом состоянии.
/// Убирает удушение взамен на добавление грубого урона.
/// by Шрёдька <3 (Schrodinger71)
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class ReliveResuscitationComponent : Component
{
/// <summary>
/// Время проведения реанимации в секундах
/// </summary>
[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<DamageTypePrototype> DamageAsphyxiation = "Asphyxiation";

[DataField]
public ProtoId<DamageTypePrototype> DamageBlunt = "Blunt";
}

13 changes: 13 additions & 0 deletions Content.Shared/ADT/ReliveResuscitation/ReliveResuscitationEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Robust.Shared.GameStates;
using Content.Shared.DoAfter;
using Robust.Shared.Serialization;

namespace Content.Shared.ADT.ReliveResuscitation;

/// <summary>
/// This event is triggered after the ReliveResuscitationComponent has been applied.
/// </summary>
[Serializable, NetSerializable]
public sealed partial class ReliveDoAfterEvent : SimpleDoAfterEvent
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.DoAfter;
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.Shared.ADT.ReliveResuscitation;

public sealed partial class SharedReliveResuscitationSystem : 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();

SubscribeLocalEvent<ReliveResuscitationComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerbs);
SubscribeLocalEvent<ReliveResuscitationComponent, ReliveDoAfterEvent>(DoRelive);
}

/// <summary>
/// Обрабатывает событие получения альтернативных действий для сущности (на ПКМ).
/// Если сущность находится в критическом состоянии, добавляет возможность провести сердечно-лёгочную реанимацию.
/// </summary>
/// <param name="uid">Идентификатор сущности, на которой выполняется действие.</param>
/// <param name="component">Компонент реанимации, связанный с сущностью.</param>
/// <param name="args">Событие, содержащее информацию о доступных альтернативных действиях.</param>
private void OnAltVerbs(EntityUid uid, ReliveResuscitationComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (TryComp<MobStateComponent>(uid, out var mobState) && mobState.CurrentState == MobState.Critical)
{
// TODO: Можно конечно всё усложнить с дыханием, и чекать совпадает ли оно...
if (!HasComp<ReliveResuscitationComponent>(args.User))
return; // Думаю что юзер тоже такой компонент должен иметь...
// проблем в будущем не должно создать

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);
}
}

/// <summary>
/// Начинает процесс реанимации сущности. Отправляет сообщение пользователю и запускает таймер действия.
/// </summary>
/// <param name="uid">Идентификатор сущности, которую пытаются реанимировать.</param>
/// <param name="user">Идентификатор пользователя, который проводит реанимацию.</param>
/// <param name="component">Компонент реанимации, связанный с сущностью.</param>
/// <param name="mobState">Компонент состояния сущности, указывающий текущее состояние.</param>
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 doAfterEventArgs =
new DoAfterArgs(EntityManager, user, component.Delay, new ReliveDoAfterEvent() { Repeat = true }, uid, target: uid, used: user)
{
NeedHand = true,
BreakOnMove = true,
BreakOnWeightlessMove = false,
BreakOnDamage = true,
};


_doAfter.TryStartDoAfter(doAfterEventArgs);
}

/// <summary>
/// Завершает процесс реанимации, нанося урон от удушения и добавляя грубый урон.
/// Проверяет состояние если она оживёт, прервать следующую итерацию и вызвать попап.
/// </summary>
/// <param name="uid">Идентификатор сущности, которую пытаются реанимировать.</param>
/// <param name="component">Компонент реанимации, связанный с сущностью.</param>
/// <param name="args">Событие, содержащее информацию о выполнении действия.</param>
private void DoRelive(EntityUid uid, ReliveResuscitationComponent component, ref ReliveDoAfterEvent args)
{
if (args.Handled || args.Cancelled)
return;

var randomDamageAshyxiation = _random.Next(component.MaxAsphyxiationHeal, component.MinAsphyxiationHeal);
var randomDamageBlunt = _random.Next(component.MinBluntDamage, component.MaxBluntDamage);

DamageSpecifier damageAsphyxiation = new(_prototypeManager.Index<DamageTypePrototype>(component.DamageAsphyxiation),
randomDamageAshyxiation);
DamageSpecifier damageBlunt = new(_prototypeManager.Index<DamageTypePrototype>(component.DamageBlunt),
randomDamageBlunt);

_damageable.TryChangeDamage(uid, damageAsphyxiation, true);
_damageable.TryChangeDamage(uid, damageBlunt, true);

args.Handled = true;
args.Repeat = true;

if (!TryComp<MobStateComponent>(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;
}
}
}
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/ADT/Interaction/relive-popups.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
relive-resuscitation-verb = Сердечно-лёгочная реанимация
relive-start-message = {CAPITALIZE(THE($user))} проводит сердечно-лёгочную реанимацю {CAPITALIZE(THE($name))}.
relive-abort-message = Глаза {CAPITALIZE(THE($name))} широко раскрываются. После непродолжительного хрипа слышен глубокий вдох.
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/Drask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
tallscale: 1.15
short: true
shortscale: 1
- type: ReliveResuscitation

- type: entity
save: false
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/Tajaran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
tallscale: 0.95
short: true
shortscale: 0.85
- type: ReliveResuscitation

- type: entity
save: false
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/Ursus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
short: true
shortscale: 0.98
shortDensity: 0.7
- type: ReliveResuscitation

- type: entity
save: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
tallscale: 1
short: true
shortscale: 0.9
- type: ReliveResuscitation

- type: entity
save: false
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/demon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
tallscale: 1.08
short: true
shortscale: 0.92
- type: ReliveResuscitation

- type: entity
save: false
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/felinid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
tallscale: 0.95
short: true
shortscale: 0.8
- type: ReliveResuscitation

- type: entity
save: false
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/kobolt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
tallscale: 0.9
short: true
shortscale: 0.8
- type: ReliveResuscitation

- type: entity
parent: BaseSpeciesDummy
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
tallscale: 1
short: true
shortscale: 0.85
- type: ReliveResuscitation

- type: entity
parent: BaseSpeciesDummy
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Species/novakid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
shortscale: 0.9
- type: BloodCough
postingSayDamage: blood-cough-novakid
- type: ReliveResuscitation


- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/arachnid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
tallscale: 1.15
short: true
shortscale: 0.98
- type: ReliveResuscitation
#End ADT tweak

- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
tallscale: 1.08
short: true
shortscale: 0.92
- type: ReliveResuscitation
#End ADT tweak

- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/dwarf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
understands:
- GalacticCommon
- Dwarf
- type: ReliveResuscitation

- type: entity
parent: BaseSpeciesDummy
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/human.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
tallscale: 1.08
short: true
shortscale: 0.92
- type: ReliveResuscitation
#End ADT tweak


Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/reptilian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
tallscale: 1.12
short: true
shortscale: 0.98
- type: ReliveResuscitation
#End ADT tweak

- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/slime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
tallscale: 1.05
short: true
shortscale: 0.95
- type: ReliveResuscitation
#End ADT tweak

- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/vox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
tallscale: 1.05
short: true
shortscale: 0.95
- type: ReliveResuscitation
#ADT Tweak end

- type: entity
Expand Down