Skip to content

Commit

Permalink
Merge branch 'master' into showers
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyScarecrow committed Aug 6, 2024
2 parents 8cca382 + bc3ffaf commit ff25f38
Show file tree
Hide file tree
Showing 19 changed files with 242 additions and 35 deletions.
15 changes: 14 additions & 1 deletion Content.Server/Body/Components/BloodstreamComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Traits.Assorted;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Damage;
Expand All @@ -11,7 +12,7 @@

namespace Content.Server.Body.Components
{
[RegisterComponent, Access(typeof(BloodstreamSystem), typeof(ReactionMixerSystem))]
[RegisterComponent, Access(typeof(BloodstreamSystem), typeof(ReactionMixerSystem), typeof(BloodDeficiencySystem))]
public sealed partial class BloodstreamComponent : Component
{
public static string DefaultChemicalsSolutionName = "chemicals";
Expand Down Expand Up @@ -171,5 +172,17 @@ public sealed partial class BloodstreamComponent : Component
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan StatusTime;

/// <summary>
/// If this is true, the entity will not passively regenerate blood,
/// and instead will slowly lose blood.
/// </summary>
public bool HasBloodDeficiency = false;

/// <summary>
/// How much reagent of blood should be removed with blood deficiency in each update interval?
/// </summary>
[DataField]
public FixedPoint2 BloodDeficiencyLossAmount;
}
}
25 changes: 20 additions & 5 deletions Content.Server/Body/Systems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,14 @@ public override void Update(float frameTime)
if (!_solutionContainerSystem.ResolveSolution(uid, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution))
continue;

// Adds blood to their blood level if it is below the maximum; Blood regeneration. Must be alive.
if (bloodSolution.Volume < bloodSolution.MaxVolume && !_mobStateSystem.IsDead(uid))
{
TryModifyBloodLevel(uid, bloodstream.BloodRefreshAmount, bloodstream);
}
// Removes blood for Blood Deficiency constantly.
if (bloodstream.HasBloodDeficiency)
if (!_mobStateSystem.IsDead(uid))
RemoveBlood(uid, bloodstream.BloodDeficiencyLossAmount, bloodstream);
// Adds blood to their blood level if it is below the maximum.
else if (bloodSolution.Volume < bloodSolution.MaxVolume)
if (!_mobStateSystem.IsDead(uid))
TryModifyBloodLevel(uid, bloodstream.BloodRefreshAmount, bloodstream);

// Removes blood from the bloodstream based on bleed amount (bleed rate)
// as well as stop their bleeding to a certain extent.
Expand Down Expand Up @@ -472,4 +475,16 @@ public void ChangeBloodReagent(EntityUid uid, string reagent, BloodstreamCompone
if (currentVolume > 0)
_solutionContainerSystem.TryAddReagent(component.BloodSolution.Value, component.BloodReagent, currentVolume, out _);
}

/// <summary>
/// Remove blood from an entity, without spilling it.
/// </summary>
private void RemoveBlood(EntityUid uid, FixedPoint2 amount, BloodstreamComponent? component = null)
{
if (!Resolve(uid, ref component, logMissing: false)
|| !_solutionContainerSystem.ResolveSolution(uid, component.BloodSolutionName, ref component.BloodSolution, out var bloodSolution))
return;

bloodSolution.RemoveReagent(component.BloodReagent, amount);
}
}
4 changes: 2 additions & 2 deletions Content.Server/Nyanotrasen/Abilities/Boxer/BoxingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<BoxerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<BoxerComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<BoxingGlovesComponent, StaminaMeleeHitEvent>(OnStamHit);
SubscribeLocalEvent<BoxingGlovesComponent, TakeStaminaDamageEvent>(OnStamHit);
}

private void OnInit(EntityUid uid, BoxerComponent component, ComponentInit args)
Expand All @@ -27,7 +27,7 @@ private void OnMeleeHit(EntityUid uid, BoxerComponent component, MeleeHitEvent a
args.ModifiersList.Add(component.UnarmedModifiers);
}

private void OnStamHit(EntityUid uid, BoxingGlovesComponent component, StaminaMeleeHitEvent args)
private void OnStamHit(EntityUid uid, BoxingGlovesComponent component, TakeStaminaDamageEvent args)
{
if (!_containerSystem.TryGetContainingContainer(uid, out var equipee))
return;
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Nyanotrasen/Abilities/Oni/OniSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Initialize()
SubscribeLocalEvent<OniComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
SubscribeLocalEvent<OniComponent, MeleeHitEvent>(OnOniMeleeHit);
SubscribeLocalEvent<HeldByOniComponent, MeleeHitEvent>(OnHeldMeleeHit);
SubscribeLocalEvent<HeldByOniComponent, StaminaMeleeHitEvent>(OnStamHit);
SubscribeLocalEvent<HeldByOniComponent, TakeStaminaDamageEvent>(OnStamHit);
}

private void OnEntInserted(EntityUid uid, OniComponent component, EntInsertedIntoContainerMessage args)
Expand Down Expand Up @@ -68,7 +68,7 @@ private void OnHeldMeleeHit(EntityUid uid, HeldByOniComponent component, MeleeHi
args.ModifiersList.Add(oni.MeleeModifiers);
}

private void OnStamHit(EntityUid uid, HeldByOniComponent component, StaminaMeleeHitEvent args)
private void OnStamHit(EntityUid uid, HeldByOniComponent component, TakeStaminaDamageEvent args)
{
if (!TryComp<OniComponent>(component.Holder, out var oni))
return;
Expand Down
12 changes: 5 additions & 7 deletions Content.Server/Nyanotrasen/Psionics/PsionicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<PotentialPsionicComponent, MapInitEvent>(OnStartup);
SubscribeLocalEvent<AntiPsionicWeaponComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<AntiPsionicWeaponComponent, StaminaMeleeHitEvent>(OnStamHit);
SubscribeLocalEvent<AntiPsionicWeaponComponent, TakeStaminaDamageEvent>(OnStamHit);

SubscribeLocalEvent<PsionicComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<PsionicComponent, ComponentRemove>(OnRemove);
Expand Down Expand Up @@ -110,14 +110,12 @@ private void OnRemove(EntityUid uid, PsionicComponent component, ComponentRemove
_npcFactonSystem.RemoveFaction(uid, "PsionicInterloper");
}

private void OnStamHit(EntityUid uid, AntiPsionicWeaponComponent component, StaminaMeleeHitEvent args)
private void OnStamHit(EntityUid uid, AntiPsionicWeaponComponent component, TakeStaminaDamageEvent args)
{
var bonus = false;
foreach (var stam in args.HitList)
{
if (HasComp<PsionicComponent>(stam.Entity))
bonus = true;
}

if (HasComp<PsionicComponent>(args.Target))
bonus = true;

if (!bonus)
return;
Expand Down
14 changes: 14 additions & 0 deletions Content.Server/Traits/BloodDeficiencyComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Server.Traits.Assorted;

/// <summary>
/// This is used for the Blood Deficiency trait.
/// </summary>
[RegisterComponent]
public sealed partial class BloodDeficiencyComponent : Component
{
// <summary>
// How much reagent of blood should be removed in each update interval?
// </summary>
[DataField(required: true)]
public float BloodLossAmount;
}
23 changes: 23 additions & 0 deletions Content.Server/Traits/BloodDeficiencySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Server.Body.Systems;
using Content.Server.Body.Components;
using Content.Shared.Damage;

namespace Content.Server.Traits.Assorted;

public sealed class BloodDeficiencySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BloodDeficiencyComponent, ComponentStartup>(OnStartup);
}

private void OnStartup(EntityUid uid, BloodDeficiencyComponent component, ComponentStartup args)
{
if (!TryComp<BloodstreamComponent>(uid, out var bloodstream))
return;

bloodstream.HasBloodDeficiency = true;
bloodstream.BloodDeficiencyLossAmount = component.BloodLossAmount;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
using Content.Shared.Damage.Components;
using Robust.Shared.Collections;
using Content.Shared.Inventory;

namespace Content.Shared.Damage.Events;

/// <summary>
/// The components in the list are going to be hit,
/// give opportunities to change the damage or other stuff.
/// </summary>
public sealed class StaminaMeleeHitEvent : HandledEntityEventArgs
public sealed class TakeStaminaDamageEvent : HandledEntityEventArgs, IInventoryRelayEvent
{
public SlotFlags TargetSlots { get; } = ~SlotFlags.POCKET;

/// <summary>
/// List of hit stamina components.
/// </summary>
public List<(EntityUid Entity, StaminaComponent Component)> HitList;
public EntityUid Target;

/// <summary>
/// The multiplier. Generally, try to use *= or /= instead of overwriting.
Expand All @@ -24,8 +26,8 @@ public sealed class StaminaMeleeHitEvent : HandledEntityEventArgs
/// </summary>
public float FlatModifier = 0;

public StaminaMeleeHitEvent(List<(EntityUid Entity, StaminaComponent Component)> hitList)
public TakeStaminaDamageEvent(EntityUid target)
{
HitList = hitList;
Target = target;
}
}
35 changes: 25 additions & 10 deletions Content.Shared/Damage/Systems/StaminaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,20 @@ private void OnMeleeHit(EntityUid uid, StaminaDamageOnHitComponent component, Me
toHit.Add((ent, stam));
}

var hitEvent = new StaminaMeleeHitEvent(toHit);
RaiseLocalEvent(uid, hitEvent);
foreach (var (ent, comp) in toHit)
{
var hitEvent = new TakeStaminaDamageEvent(ent);
RaiseLocalEvent(uid, hitEvent);

if (hitEvent.Handled)
return;
if (hitEvent.Handled)
return;

var damage = component.Damage;
var damage = component.Damage;

damage *= hitEvent.Multiplier;
damage *= hitEvent.Multiplier;

damage += hitEvent.FlatModifier;
damage += hitEvent.FlatModifier;

foreach (var (ent, comp) in toHit)
{
TakeStaminaDamage(ent, damage / toHit.Count, comp, source: args.User, with: args.Weapon, sound: component.Sound);
}
}
Expand All @@ -204,12 +204,27 @@ private void OnThrowHit(EntityUid uid, StaminaDamageOnCollideComponent component

private void OnCollide(EntityUid uid, StaminaDamageOnCollideComponent component, EntityUid target)
{
if (!TryComp<StaminaComponent>(target, out var stamComp))
return;

var ev = new StaminaDamageOnHitAttemptEvent();
RaiseLocalEvent(uid, ref ev);
if (ev.Cancelled)
return;

TakeStaminaDamage(target, component.Damage, source: uid, sound: component.Sound);
var hitEvent = new TakeStaminaDamageEvent(target);
RaiseLocalEvent(target, hitEvent);

if (hitEvent.Handled)
return;

var damage = component.Damage;

damage *= hitEvent.Multiplier;

damage += hitEvent.FlatModifier;

TakeStaminaDamage(target, damage, source: uid, sound: component.Sound);
}

private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null)
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Inventory/InventorySystem.Relay.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Chemistry;
using Content.Shared.Damage;
using Content.Shared.Damage.Events;
using Content.Shared.Electrocution;
using Content.Shared.Explosion;
using Content.Shared.Eye.Blinding.Systems;
Expand All @@ -20,6 +21,7 @@ public partial class InventorySystem
public void InitializeRelay()
{
SubscribeLocalEvent<InventoryComponent, DamageModifyEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, TakeStaminaDamageEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, ElectrocutionAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, SlipAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
Expand Down
12 changes: 12 additions & 0 deletions Content.Shared/Stunnable/StaminaDamageResistanceComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Stunnable;

[RegisterComponent, NetworkedComponent]
public sealed partial class StaminaDamageResistanceComponent : Component
{
/// <summary>
/// 1 - no reduction, 0 - full reduction
/// </summary>
[DataField] public float Coefficient = 1;
}
26 changes: 26 additions & 0 deletions Content.Shared/Stunnable/StaminaDamageResistanceSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.Damage.Events;
using Content.Shared.Examine;
using Content.Shared.Inventory;

namespace Content.Shared.Stunnable;

public sealed partial class StaminaDamageResistanceSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<StaminaDamageResistanceComponent, InventoryRelayedEvent<TakeStaminaDamageEvent>>(OnStaminaMeleeHit);
SubscribeLocalEvent<StaminaDamageResistanceComponent, ExaminedEvent>(OnExamine);
}

private void OnStaminaMeleeHit(Entity<StaminaDamageResistanceComponent> ent, ref InventoryRelayedEvent<TakeStaminaDamageEvent> args)
{
args.Args.Multiplier *= ent.Comp.Coefficient;
}
private void OnExamine(Entity<StaminaDamageResistanceComponent> ent, ref ExaminedEvent args)
{
var percentage = (1 - ent.Comp.Coefficient) * 100;
args.PushMarkup(Loc.GetString("armor-examine-stamina", ("num", percentage)));
}
}
24 changes: 24 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4969,3 +4969,27 @@ Entries:
toxin/airloss damage.
id: 6221
time: '2024-08-06T08:05:59.0000000+00:00'
- author: TJohnson
changes:
- type: Tweak
message: >-
Removed overlay restriction for vulps, you can now have as many overlay
markings as you want!
id: 6222
time: '2024-08-06T19:05:46.0000000+00:00'
- author: whateverusername0
changes:
- type: Add
message: Added different stamina damage resistance to hardsuits.
id: 6223
time: '2024-08-06T19:08:48.0000000+00:00'
- author: Skubman
changes:
- type: Add
message: >-
Add the Blood Deficiency trait, a new negative trait that makes you
slowly lose blood over time. You must routinely receive blood loss
treatment to live, and even normally non-lethal bleeding can make you
start dying slowly.
id: 6224
time: '2024-08-06T19:12:34.0000000+00:00'
1 change: 1 addition & 0 deletions Resources/Locale/en-US/armor/armor-examine.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ armor-damage-type-cold = Cold
armor-damage-type-poison = Poison
armor-damage-type-shock = Shock
armor-damage-type-structural = Structural
armor-examine-stamina = Reduces your stamina damage by [color=cyan]{$num}%[/color].
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ trait-description-HeavyweightDrunk = Alcohol is afraid of you.
trait-name-Muted = Muted
trait-description-Muted = You can't speak
trait-name-BloodDeficiency = Blood Deficiency
trait-description-BloodDeficiency =
Your body loses more blood than it can replenish.
You lose blood over time, and when left untreated you will eventually die from blood loss.
trait-name-Paracusia = Paracusia
trait-description-Paracusia = You hear sounds that aren't really there
Expand Down
3 changes: 0 additions & 3 deletions Resources/Prototypes/DeltaV/Species/vulpkanin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@
points: 1
required: true
defaultMarkings: [ VulpEar ]
Overlay:
points: 2
required: false

- type: humanoidBaseSprite
id: MobVulpkaninHead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
- type: Clothing
equipDelay: 2.5 # Hardsuits are heavy and take a while to put on/off.
unequipDelay: 2.5
- type: StaminaDamageResistance
coefficient: 0.75 # 25%

- type: entity
abstract: true
Expand Down
Loading

0 comments on commit ff25f38

Please sign in to comment.