Skip to content

Commit

Permalink
Wounds are done
Browse files Browse the repository at this point in the history
  • Loading branch information
Just-a-Unity-Dev committed Mar 26, 2024
1 parent d746bde commit e23b5a0
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Content.Server/_FTL/Wounds/WoundTreatmentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<WoundThresholdComponent, WoundsHolderComponent, DamageableComponent>();
while (query.MoveNext(out var entity, out var thresholdComponent, out var woundsHolderComponent, out var damageableComponent))
{
thresholdComponent.TimeSinceLastUpdate += frameTime;

if (thresholdComponent.TimeSinceLastUpdate < 5)
continue; // run this every 5 seconds

Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Damage/DamageSpecifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public sealed partial class DamageSpecifier : IEquatable<DamageSpecifier>
/// <summary>
/// What wounds should be (and their probability of being) applied?
/// </summary>
[DataField("wounds"), ViewVariables]
[DataField("wounds", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<float, EntityPrototype>)), ViewVariables]
public Dictionary<string, float>? Wounds;

[JsonIgnore]
Expand Down
22 changes: 22 additions & 0 deletions Content.Shared/_FTL/Wounds/SharedWoundsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public sealed class SharedWoundsSystem : EntitySystem
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
public const string ContainerName = "wounds";

// TODO: Integrate ALL of this with events

/// <inheritdoc/>
public override void Initialize()
{
Expand All @@ -45,6 +47,13 @@ private void OnComponentInit(EntityUid uid, WoundsHolderComponent component, Com
component.Wounds = _containerSystem.EnsureContainer<Container>(uid, ContainerName);
}

/// <summary>
/// Attempts to add a wound to an entity.
/// </summary>
/// <param name="woundPrototype"></param>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <returns></returns>
public bool TryAddWound(EntProtoId woundPrototype, EntityUid uid, WoundsHolderComponent? component = null)
{
if (!Resolve(uid, ref component))
Expand All @@ -69,6 +78,11 @@ public bool TryAddWound(EntProtoId woundPrototype, EntityUid uid, WoundsHolderCo
return true;
}

/// <summary>
/// Gets the total damage of all wounds from a WHC.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
[PublicAPI]
public DamageSpecifier GetDamageFromWounds(WoundsHolderComponent component)
{
Expand All @@ -84,6 +98,14 @@ public DamageSpecifier GetDamageFromWounds(WoundsHolderComponent component)
return damage;
}

/// <summary>
/// Attempts to get damage from wounds given an entity.
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="spec"></param>
/// <returns></returns>
[PublicAPI]
public bool TryGetDamageFromWounds(EntityUid uid, WoundsHolderComponent? component, out DamageSpecifier spec)
{
if (!Resolve(uid, ref component, false))
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/_FTL/Wounds/WoundComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public sealed partial class WoundComponent : Component
/// How much damage does this wound do permanently?
/// </summary>
[DataField, ViewVariables] public DamageSpecifier? Damage;

/// <summary>
/// How severe is this wound?
/// </summary>
[DataField, ViewVariables] public float Severity = 1f;

/// <summary>
/// What does it say when this wound is examined?
/// </summary>
Expand Down
39 changes: 39 additions & 0 deletions Resources/Locale/en-US/_ftl/wounds.ftl
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
health-examinable-debug-wound = [color=green]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } ones and zeros coming out of { POSS-ADJ($target) } body![/color]
health-examinable-laceration-wound = { CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } a really bad looking [color=red]laceration[/color] on { POSS-ADJ($target) } body![/color]
health-examinable-abrasion-wound = { CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } a [color=red]large scrape[/color] across { POSS-ADJ($target) } body ![/color]
health-examinable-puncture-wound = { CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } [color=red]holes[/color] all across { POSS-ADJ($target) } body![/color]
health-examinable-gunshot-wound = { CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } a [color=red]bullet[/color] lodged in { POSS-ADJ($target) } body![/color]
health-examinable-fracture-wound = { CAPITALIZE(SUBJECT($target)) } shouldn't have { POSS-ADJ($target) } [color=red]bones[/color] looking like that...[/color]
health-examinable-sprain-wound = { CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } { POSS-ADJ($target) } [color=red]foot bending[/color] really weirdly...[/color]
health-examinable-burns-wound = { CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } really bad looking [color=orange]burns[color] all across { POSS-ADJ($target) } body!
popup-wound-cured = { CAPITALIZE(POSS-ADJ($target)) } {$woundName} is healed.
popup-wound-need-item = You need to hold an item that can perform {$item} in your hand!
popup-wound-need-hand = You need a hand!
verb-categories-select-wound = Select Wound
popup-wound-clamping-began = You begin to clamp the wound...
popup-wound-clamping-began-other = { CAPITALIZE(SUBJECT($target)) } begins to clamps the wound...
popup-wound-incision-began = You begin to create an incision...
popup-wound-incision-began-other = { CAPITALIZE(SUBJECT($target)) } creates an incision...
popup-wound-sow-began = You begin to sow the wound together...
popup-wound-sow-began-other = { CAPITALIZE(SUBJECT($target)) } sows the wound together...
popup-wound-seal-began = You begin to seal the wound...
popup-wound-seal-began-other = { CAPITALIZE(SUBJECT($target)) } seals the wound...
popup-wound-bone-cutting-began = You begin cutting through the bone...
popup-wound-bone-cutting-began-other = { CAPITALIZE(SUBJECT($target)) } cuts through the bone...
popup-wound-retractor-began = You begin to retract the skin...
popup-wound-retractor-began-other = { CAPITALIZE(SUBJECT($target)) } retracts the skin...
popup-wound-bullet-removal-began = You begin to remove the bullet...
popup-wound-bullet-removal-began-other = { CAPITALIZE(SUBJECT($target)) } removes the bullet...
popup-wound-bone-set-began = You begin setting the bone...
popup-wound-bone-set-began-other = { CAPITALIZE(SUBJECT($target)) } sets the bone...
popup-wound-seal-began = You begin to seal the wound...
popup-wound-seal-began-other = { CAPITALIZE(SUBJECT($target)) } seals the wound...
popup-wound-sow-attempt-began = You try to connect the skin together...
popup-wound-sow-attempt-began-other = { CAPITALIZE(SUBJECT($target)) } does their best to connect the skin...
popup-wound-generic-began = You begin treating the wound...
popup-wound-generic-began-other = { CAPITALIZE(SUBJECT($target)) } begins treating the wound...
popup-wound-generic-ended = You finish treating the wound.
Expand Down
22 changes: 17 additions & 5 deletions Resources/Prototypes/Entities/Mobs/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,28 @@
- type: WoundsHolder
- type: WoundThreshold
thresholds:
- wound: WoundDebug
- wound: WoundLaceration
damageType: Slash
probability: 1
threshold: 35
- wound: WoundAbrasion
damageType: Blunt
probability: 0.6
threshold: 45
probability: 1
threshold: 25
- wound: WoundFracture
damageType: Blunt
probability: 1
threshold: 65
- wound: WoundPuncture
damageType: Pierce
probability: 1
threshold: 50
- type: ConstantDamage
probability: .5
checkFrequency: 60
checkFrequency: 120
damage:
types:
VeilIndividualExposure: 3
VeilIndividualExposure: 1
- type: Destructible
thresholds:
- trigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
types:
Structural: 1000
groups:
Brute: 1000
Brute: 75
wounds:
WoundGunshot: 1

- type: entity
id: Bullet53mmAP
Expand All @@ -30,7 +32,7 @@
types:
Structural: 1500
groups:
Brute: 2500
Brute: 250

- type: entity
id: Bullet80mmAP
Expand All @@ -47,7 +49,7 @@
types:
Structural: 2000
groups:
Brute: 5000
Brute: 500

- type: entity
id: Bullet105mmAP
Expand All @@ -64,7 +66,7 @@
types:
Structural: 2500
groups:
Brute: 8000
Brute: 800

- type: entity
id: Bullet120mmAP
Expand All @@ -81,7 +83,7 @@
types:
Structural: 10000
groups:
Brute: 9000
Brute: 900

- type: entity
id: Bullet140mmAP
Expand All @@ -98,4 +100,4 @@
types:
Structural: 5000
groups:
Brute: 10000
Brute: 1000
File renamed without changes.
135 changes: 135 additions & 0 deletions Resources/Prototypes/_FTL/Entities/Wounds/wounds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
- type: entity
id: WoundLaceration
name: laceration
components:
- type: Wound
woundExamineMessage: health-examinable-laceration-wound
paths:
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-clamping-began
length: 12
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-sow-began
length: 20
damage:
types:
Slash: 35

- type: entity
id: WoundAbrasion
name: abrasion
components:
- type: Wound
woundExamineMessage: health-examinable-abrasion-wound
paths:
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-clamping-began
length: 12
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-sow-attempt-began
length: 20
damage:
types:
Blunt: 25

- type: entity
id: WoundPuncture
name: puncture
components:
- type: Wound
woundExamineMessage: health-examinable-puncture-wound
paths:
- !type:ToolTreatmentPath
quality: Slicing
beginMessage: popup-wound-incision-began
length: 8
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-retractor-began
length: 4
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-clamping-began
length: 4
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-sow-began
length: 7
- !type:ToolTreatmentPath
quality: Welding
beginMessage: popup-wound-seal-began
length: 5
damage:
types:
Pierce: 35

- type: entity
id: WoundGunshot
name: gunshot
components:
- type: Wound
woundExamineMessage: health-examinable-gunshot-wound
paths:
# Process: Incision -> Retract skin -> Saw -> Clamp bleeders -> Remove bullet -> Seal
- !type:ToolTreatmentPath
quality: Slicing
beginMessage: popup-wound-incision-began
length: 8
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-retractor-began
length: 4
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-clamping-began
length: 4
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-bullet-removal-began
length: 16
- !type:ToolTreatmentPath
quality: Welding
beginMessage: popup-wound-seal-began
length: 8
damage:
types:
Pierce: 45

- type: entity
id: WoundFracture
name: fracture
components:
- type: Wound
woundExamineMessage: health-examinable-fracture-wound
paths:
- !type:ToolTreatmentPath
quality: Slicing
beginMessage: popup-wound-incision-began
length: 8
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-retractor-began
length: 4
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-clamping-began
length: 4
- !type:ToolTreatmentPath
quality: Sawing
beginMessage: popup-wound-bone-cutting-began
length: 7
- !type:ToolTreatmentPath
quality: Cutting
beginMessage: popup-wound-bone-set-began
length: 16
- !type:ToolTreatmentPath
quality: Welding
beginMessage: popup-wound-seal-began
length: 8
damage:
types:
Pierce: 45

0 comments on commit e23b5a0

Please sign in to comment.