Предкрит (#13)

* add precrit

* minifix tags
This commit is contained in:
Zekins
2024-12-05 12:52:30 +03:00
committed by GitHub
parent d2f8fa7f47
commit 2fc4b454c0
9 changed files with 61 additions and 6 deletions

View File

@@ -167,7 +167,7 @@ namespace Content.Server.Ghost
if (!_minds.TryGetMind(uid, out var mindId, out var mind) || mind.IsVisitingEntity)
return;
if (component.MustBeDead && (_mobState.IsAlive(uid) || _mobState.IsCritical(uid)))
if (component.MustBeDead && (_mobState.IsAlive(uid) || _mobState.IsCritical(uid) || _mobState.IsPreCritical(uid))) // Corvax-Wega-PreCritical
return;
OnGhostAttempt(mindId, component.CanReturn, mind: mind);

View File

@@ -26,6 +26,7 @@ namespace Content.Shared.Mobs.Components
public HashSet<MobState> AllowedStates = new()
{
MobState.Alive,
MobState.PreCritical, // Corvax-Wega-PreCritical
MobState.Critical,
MobState.Dead
};

View File

@@ -28,6 +28,7 @@ public sealed partial class MobThresholdsComponent : Component
public Dictionary<MobState, ProtoId<AlertPrototype>> StateAlertDict = new()
{
{MobState.Alive, "HumanHealth"},
{MobState.PreCritical, "HumanCrit"}, // Corvax-Wega-PreCritical
{MobState.Critical, "HumanCrit"},
{MobState.Dead, "HumanDead"},
};

View File

@@ -15,8 +15,11 @@ public enum MobState : byte
{
Invalid = 0,
Alive = 1,
Critical = 2,
Dead = 3
// Corvax-Wega-PreCritical-change-start
PreCritical = 2,
Critical = 3,
Dead = 4
// Corvax-Wega-PreCritical-change-end
}
/// <summary>

View File

@@ -1,10 +1,13 @@
using Content.Shared.Database;
using Content.Shared.Mobs.Components;
using Content.Shared.Speech.EntitySystems; // Corvax-Wega-PreCritical
namespace Content.Shared.Mobs.Systems;
public partial class MobStateSystem
{
[Dependency] private readonly SharedStutteringSystem _stutteringSystem = default!; // Corvax-Wega-PreCritical
#region Public API
/// <summary>
@@ -66,6 +69,13 @@ public partial class MobStateSystem
protected virtual void OnEnterState(EntityUid entity, MobStateComponent component, MobState state)
{
OnStateEnteredSubscribers(entity, component, state);
// Corvax-Wega-PreCritical-start
if (state == MobState.PreCritical)
ApplyStutteringEffect(entity);
else
RemoveStutteringEffect(entity);
// Corvax-Wega-PreCritical-end
}
/// <summary>
@@ -116,6 +126,20 @@ public partial class MobStateSystem
}
#endregion
// Corvax-Wega-PreCritical-start
#region PreCritical Effect
private void ApplyStutteringEffect(EntityUid target)
{
_stutteringSystem.DoStutter(target, TimeSpan.FromSeconds(5), refresh: true);
}
private void RemoveStutteringEffect(EntityUid target)
{
_stutteringSystem.DoRemoveStutterTime(target, 5);
}
#endregion
// Corvax-Wega-PreCritical-end
}
/// <summary>

View File

@@ -77,6 +77,11 @@ public partial class MobStateSystem
case MobState.Alive:
//unused
break;
// Corvax-Wega-PreCritical-start
case MobState.PreCritical:
//unused
break;
// Corvax-Wega-PreCritical-end
case MobState.Critical:
_standing.Stand(target);
break;
@@ -106,6 +111,12 @@ public partial class MobStateSystem
_standing.Stand(target);
_appearance.SetData(target, MobStateVisuals.State, MobState.Alive);
break;
// Corvax-Wega-PreCritical-start
case MobState.PreCritical:
_standing.Stand(target);
_appearance.SetData(target, MobStateVisuals.State, MobState.Critical);
break;
// Corvax-Wega-PreCritical-end
case MobState.Critical:
_standing.Down(target);
_appearance.SetData(target, MobStateVisuals.State, MobState.Critical);
@@ -142,10 +153,14 @@ public partial class MobStateSystem
private void OnGettingStripped(EntityUid target, MobStateComponent component, BeforeGettingStrippedEvent args)
{
// Incapacitated or dead targets get stripped two or three times as fast. Makes stripping corpses less tedious.
// Corvax-Wega-PreCritical-change-start
if (IsDead(target, component))
args.Multiplier /= 3;
args.Multiplier /= 4;
else if (IsCritical(target, component))
args.Multiplier /= 3;
else if (IsPreCritical(target, component))
args.Multiplier /= 2;
// Corvax-Wega-PreCritical-change-end
}
private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAttemptEvent args)

View File

@@ -43,6 +43,15 @@ public partial class MobStateSystem : EntitySystem
return component.CurrentState == MobState.Alive;
}
// Corvax-Wega-PreCritical-start
public bool IsPreCritical(EntityUid target, MobStateComponent? component = null)
{
if (!_mobStateQuery.Resolve(target, ref component, false))
return false;
return component.CurrentState == MobState.PreCritical;
}
// Corvax-Wega-PreCritical-end
/// <summary>
/// Check if a Mob is Critical
/// </summary>

View File

@@ -89,7 +89,8 @@
- type: MobThresholds
thresholds:
0: Alive
100: Critical
100: PreCritical # Corvax-Wega-PreCritical
125: Critical # Corvax-Wega-PreCritical
200: Dead
- type: MobStateActions
actions:

View File

@@ -49,7 +49,8 @@
- type: MobThresholds
thresholds:
0: Alive
80: Critical
80: PreCritical
100: Critical
160: Dead
- type: Butcherable
butcheringType: Spike