From e509855524100ea8ad9ecf2aea58f9d842cfc1a7 Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Thu, 30 May 2024 12:27:13 +0000 Subject: [PATCH] - add: Revive 2.0. (#318) --- .../Cult/Runes/Systems/CultSystem.Rune.cs | 67 +++++++++++++++---- .../Locale/ru-RU/_white/cult/entities.ftl | 4 +- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/Content.Server/_White/Cult/Runes/Systems/CultSystem.Rune.cs b/Content.Server/_White/Cult/Runes/Systems/CultSystem.Rune.cs index 40ca051690..3cf9396574 100644 --- a/Content.Server/_White/Cult/Runes/Systems/CultSystem.Rune.cs +++ b/Content.Server/_White/Cult/Runes/Systems/CultSystem.Rune.cs @@ -37,8 +37,10 @@ using Content.Shared._White.Cult.Components; using Content.Shared._White.Cult.Runes; using Content.Shared._White.Cult.UI; using Content.Shared.Cuffs; +using Content.Shared.FixedPoint; using Content.Shared.GameTicking; using Content.Shared.Mindshield.Components; +using Content.Shared.Mobs.Systems; using Content.Shared.Movement.Pulling.Components; using Content.Shared.Movement.Pulling.Systems; using Content.Shared.UserInterface; @@ -74,6 +76,8 @@ public sealed partial class CultSystem : EntitySystem [Dependency] private readonly PullingSystem _pulling = default!; [Dependency] private readonly SharedCuffableSystem _cuffable = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; + [Dependency] private readonly MobStateSystem _mobState = default!; + [Dependency] private readonly MobThresholdSystem _thresholdSystem = default!; public override void Initialize() { @@ -821,8 +825,7 @@ public sealed partial class CultSystem : EntitySystem var targets = _lookup.GetEntitiesInRange(uid, component.RangeTarget, LookupFlags.Dynamic | LookupFlags.Sundries); - targets.RemoveWhere(x => - !_entityManager.HasComponent(x) || !HasComp(x)); + targets.RemoveWhere(x => !_entityManager.HasComponent(x)); if (targets.Count == 0) return; @@ -832,12 +835,7 @@ public sealed partial class CultSystem : EntitySystem if (victim == null) return; - _entityManager.TryGetComponent(victim.Value, out var state); - - if (state == null) - return; - - if (state.CurrentState != MobState.Dead && state.CurrentState != MobState.Critical) + if (_mobState.IsAlive(victim.Value)) { _popupSystem.PopupEntity(Loc.GetString("cult-revive-rune-already-alive"), args.User, args.User); return; @@ -850,15 +848,56 @@ public sealed partial class CultSystem : EntitySystem private bool Revive(EntityUid target, EntityUid user) { - if (CultRuneReviveComponent.ChargesLeft == 0) + if (HasComp(target)) { - _popupSystem.PopupEntity(Loc.GetString("cult-revive-rune-no-charges"), user, user); - return false; + if (CultRuneReviveComponent.ChargesLeft == 0) + { + _popupSystem.PopupEntity(Loc.GetString("cult-revive-rune-no-charges"), user, user); + return false; + } + + CultRuneReviveComponent.ChargesLeft--; + + _entityManager.EventBus.RaiseLocalEvent(target, new RejuvenateEvent()); } + else + { + if (!TryComp(target, out DamageableComponent? damageable) || + !TryComp(target, out MobThresholdsComponent? threshold) || + !TryComp(target, out MobStateComponent? mobState)) + return false; - CultRuneReviveComponent.ChargesLeft--; + if (!_mobState.IsDead(target, mobState)) + return false; - _entityManager.EventBus.RaiseLocalEvent(target, new RejuvenateEvent()); + var airlossGroup = _prototypeManager.Index("Airloss"); + + var deadThreshold = _thresholdSystem.GetThresholdForState(target, MobState.Dead, threshold); + + if (damageable.Damage.TryGetDamageInGroup(airlossGroup, out var toHeal)) + { + var afterHeal = damageable.TotalDamage - toHeal; + if (deadThreshold <= afterHeal) + return false; + + var asphyxType = _prototypeManager.Index("Asphyxiation"); + var bloodlossType = _prototypeManager.Index("Bloodloss"); + + var heal = new Action(type => + { + if (!damageable.Damage.DamageDict.TryGetValue(type.ID, out var damage)) + return; + + _damageableSystem.TryChangeDamage(target, new DamageSpecifier(type, -damage)); + }); + + heal(asphyxType); + heal(bloodlossType); + } + + if (damageable.TotalDamage < deadThreshold) + _mobState.ChangeMobState(target, MobState.Critical, mobState, user); + } EntityUid? transferTo = null; @@ -1383,4 +1422,4 @@ public sealed partial class CultSystem : EntitySystem /* * Helpers End ---- */ -} \ No newline at end of file +} diff --git a/Resources/Locale/ru-RU/_white/cult/entities.ftl b/Resources/Locale/ru-RU/_white/cult/entities.ftl index 0a232fb72f..978a589469 100644 --- a/Resources/Locale/ru-RU/_white/cult/entities.ftl +++ b/Resources/Locale/ru-RU/_white/cult/entities.ftl @@ -1,4 +1,4 @@ -ent-SoulShard = камень душ +ent-SoulShard = камень душ .desc = Мистический светящийся осколок. ent-SoulShardGhost = камень душ @@ -57,7 +57,7 @@ ent-SummoningRune = руна призыва .desc = Эта руна позволяет мгновенно призвать к руне любого несвязанного культиста. Для использования требуются 2 культиста, стоящих вокруг руны. ent-ReviveRune = руна воскрешения - .desc = Каждый раз, когда кого-то приносят в жертву на Руне Преподнесения, этой руне добавляется один глобальный заряд. Размещение трупа культиста на руне и её активация вернет его к жизни, расходуя при этом заряд. + .desc = Каждый раз, когда кого-то приносят в жертву на Руне Преподнесения, этой руне добавляется один глобальный заряд. Размещение трупа культиста на руне и её активация вернет его к жизни, расходуя при этом заряд. Руна воскрешения может воскрешать не культистов, не тратя при этом заряды, но она способна излечить их только от удушения и кровопотери. ent-BarrierRune = руна барьера .desc = При активации на создаёт барьер, блокирующую проход. Может быть повторно активирована, чтобы отменить заклинание.