From 3b40b4aafaf6b64681a0a18e3bbd8fb58e00dcfb Mon Sep 17 00:00:00 2001
From: Injazz <43905364+Injazz@users.noreply.github.com>
Date: Thu, 21 Mar 2019 20:55:16 +0500
Subject: [PATCH] Healing component and Medkit (#143)
Medkit to heal yourself and your buddy
known issues:
- [ ] it doesn't restore screen effects that happens when health status go into crit and dead
---
Content.Server/Content.Server.csproj | 4 ++
Content.Server/EntryPoint.cs | 2 +
.../Components/Healing/HealingComponent.cs | 64 +++++++++++++++++++
.../DamageThresholdTemplates/HumanTemplate.cs | 1 +
Resources/Maps/stationstation.yml | 4 +-
.../{prototype_test.yml => Medkit.yml} | 10 +--
6 files changed, 79 insertions(+), 6 deletions(-)
create mode 100644 Content.Server/GameObjects/Components/Healing/HealingComponent.cs
rename Resources/Prototypes/Entities/{prototype_test.yml => Medkit.yml} (61%)
diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj
index c99c18b184..67ac7871d1 100644
--- a/Content.Server/Content.Server.csproj
+++ b/Content.Server/Content.Server.csproj
@@ -141,6 +141,7 @@
+
@@ -183,4 +184,7 @@
+
+
+
\ No newline at end of file
diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs
index c708ab73dd..96353380fc 100644
--- a/Content.Server/EntryPoint.cs
+++ b/Content.Server/EntryPoint.cs
@@ -102,6 +102,8 @@ namespace Content.Server
factory.Register();
factory.Register();
+ factory.Register();
+
factory.Register();
factory.Register();
diff --git a/Content.Server/GameObjects/Components/Healing/HealingComponent.cs b/Content.Server/GameObjects/Components/Healing/HealingComponent.cs
new file mode 100644
index 0000000000..1e6fd58f0c
--- /dev/null
+++ b/Content.Server/GameObjects/Components/Healing/HealingComponent.cs
@@ -0,0 +1,64 @@
+using System;
+using SS14.Shared.GameObjects;
+using Content.Server.GameObjects.EntitySystems;
+using SS14.Shared.Interfaces.GameObjects;
+using SS14.Shared.Map;
+using SS14.Shared.IoC;
+using SS14.Server.GameObjects;
+using SS14.Shared.Maths;
+using SS14.Server.Interfaces.GameObjects;
+using SS14.Shared.Interfaces.Timing;
+using SS14.Shared.GameObjects.EntitySystemMessages;
+using SS14.Shared.Serialization;
+using SS14.Shared.Interfaces.GameObjects.Components;
+using Content.Shared.GameObjects;
+
+namespace Content.Server.GameObjects.Components.Weapon.Melee
+{
+ public class HealingComponent : Component, IAfterAttack, IUse
+ {
+ public override string Name => "Healing";
+
+ public int Heal = 100;
+
+ public override void ExposeData(ObjectSerializer serializer)
+ {
+ base.ExposeData(serializer);
+
+ serializer.DataField(ref Heal, "heal", 100);
+ }
+
+ void IAfterAttack.Afterattack(IEntity user, GridCoordinates clicklocation, IEntity attacked)
+ {
+ if (attacked == null)
+ {
+ return;
+ }
+ if (attacked.TryGetComponent(out DamageableComponent damagecomponent))
+ {
+ damagecomponent.TakeHealing(DamageType.Brute, Heal);
+ DropAndDelete(user);
+ }
+ }
+
+ bool IUse.UseEntity(IEntity user)
+ {
+ if (user.TryGetComponent(out DamageableComponent damagecomponent))
+ {
+ damagecomponent.TakeHealing(DamageType.Brute, Heal);
+ DropAndDelete(user);
+ return false;
+ }
+ return false;
+ }
+
+ void DropAndDelete(IEntity user)
+ {
+ if(user.TryGetComponent(out HandsComponent handscomponent))
+ {
+ handscomponent.Drop(Owner);
+ Owner.Delete();
+ }
+ }
+ }
+}
diff --git a/Content.Server/GameObjects/Components/Mobs/DamageThresholdTemplates/HumanTemplate.cs b/Content.Server/GameObjects/Components/Mobs/DamageThresholdTemplates/HumanTemplate.cs
index e1d903dd19..76c7b68d02 100644
--- a/Content.Server/GameObjects/Components/Mobs/DamageThresholdTemplates/HumanTemplate.cs
+++ b/Content.Server/GameObjects/Components/Mobs/DamageThresholdTemplates/HumanTemplate.cs
@@ -11,6 +11,7 @@ namespace Content.Server.GameObjects
public override List<(DamageType, int, ThresholdType)> AllowedStates => new List<(DamageType, int, ThresholdType)>()
{
+ (DamageType.Total, critvalue-1, ThresholdType.None),
(DamageType.Total, critvalue, ThresholdType.Critical),
(DamageType.Total, 300, ThresholdType.Death),
};
diff --git a/Resources/Maps/stationstation.yml b/Resources/Maps/stationstation.yml
index 0466b82f4c..db341e4fbe 100644
--- a/Resources/Maps/stationstation.yml
+++ b/Resources/Maps/stationstation.yml
@@ -298,13 +298,13 @@ entities:
pos: -1.984375,-4.484375
rot: -1.570796 rad
type: Transform
-- type: medkit_r
+- type: Medkit
components:
- grid: 0
pos: -0.859375,-3.921875
rot: -1.570796 rad
type: Transform
-- type: medkit_r
+- type: Medkit
components:
- grid: 0
pos: -0.921875,-4.640625
diff --git a/Resources/Prototypes/Entities/prototype_test.yml b/Resources/Prototypes/Entities/Medkit.yml
similarity index 61%
rename from Resources/Prototypes/Entities/prototype_test.yml
rename to Resources/Prototypes/Entities/Medkit.yml
index cd7255b39a..effa31482a 100644
--- a/Resources/Prototypes/Entities/prototype_test.yml
+++ b/Resources/Prototypes/Entities/Medkit.yml
@@ -1,11 +1,13 @@
- type: entity
- id: medkit_r
name: Medkit
+ parent: BaseItem
+ id: Medkit
components:
- - type: Clickable
- type: Sprite
texture: Objects/medkit_r.png
-
- type: Icon
texture: Objects/medkit_r.png
-
+ - type: Healing
+ heal: 100
+ - type: Item
+ Size: 24
\ No newline at end of file