From 325ccc1c178d5a4aef7405e6907ca55c2ddb0d24 Mon Sep 17 00:00:00 2001 From: ZeroDayDaemon <60460608+ZeroDayDaemon@users.noreply.github.com> Date: Sat, 5 Nov 2022 11:32:00 -0400 Subject: [PATCH] Add DamagePopup, Target Entities, And Practice Laser Gun (#12317) --- .../Damage/Components/DamagePopupComponent.cs | 20 +++ .../Damage/Systems/DamagePopupSystem.cs | 36 +++++ .../Objects/Specific/Security/target.yml | 148 ++++++++++++++++++ .../Weapons/Guns/Battery/battery_guns.yml | 10 ++ .../Weapons/Guns/Projectiles/hitscan.yml | 15 ++ .../Entities/Structures/Machines/lathe.yml | 3 + .../Prototypes/Recipes/Lathes/security.yml | 30 ++++ .../Specific/Security/target.rsi/meta.json | 26 +++ .../Specific/Security/target.rsi/target_c.png | Bin 0 -> 435 bytes .../Specific/Security/target.rsi/target_f.png | Bin 0 -> 424 bytes .../Specific/Security/target.rsi/target_h.png | Bin 0 -> 341 bytes .../Specific/Security/target.rsi/target_s.png | Bin 0 -> 371 bytes .../Security/target.rsi/target_stake.png | Bin 0 -> 312 bytes 13 files changed, 288 insertions(+) create mode 100644 Content.Server/Damage/Components/DamagePopupComponent.cs create mode 100644 Content.Server/Damage/Systems/DamagePopupSystem.cs create mode 100644 Resources/Prototypes/Entities/Objects/Specific/Security/target.yml create mode 100644 Resources/Textures/Objects/Specific/Security/target.rsi/meta.json create mode 100644 Resources/Textures/Objects/Specific/Security/target.rsi/target_c.png create mode 100644 Resources/Textures/Objects/Specific/Security/target.rsi/target_f.png create mode 100644 Resources/Textures/Objects/Specific/Security/target.rsi/target_h.png create mode 100644 Resources/Textures/Objects/Specific/Security/target.rsi/target_s.png create mode 100644 Resources/Textures/Objects/Specific/Security/target.rsi/target_stake.png diff --git a/Content.Server/Damage/Components/DamagePopupComponent.cs b/Content.Server/Damage/Components/DamagePopupComponent.cs new file mode 100644 index 0000000000..bbb9efd77c --- /dev/null +++ b/Content.Server/Damage/Components/DamagePopupComponent.cs @@ -0,0 +1,20 @@ +using Content.Server.Damage.Systems; + +namespace Content.Server.Damage.Components; + +[RegisterComponent, Access(typeof(DamagePopupSystem))] +public sealed class DamagePopupComponent : Component +{ + /// + /// Enum that will be used to determine the type of damage popup displayed. + /// + [DataField("damagePopupType")] [ViewVariables(VVAccess.ReadWrite)] + public DamagePopupType Type = DamagePopupType.Combined; +} +public enum DamagePopupType +{ + Combined, + Total, + Delta, + Hit, +}; diff --git a/Content.Server/Damage/Systems/DamagePopupSystem.cs b/Content.Server/Damage/Systems/DamagePopupSystem.cs new file mode 100644 index 0000000000..ba405e6393 --- /dev/null +++ b/Content.Server/Damage/Systems/DamagePopupSystem.cs @@ -0,0 +1,36 @@ +using Content.Server.Damage.Components; +using Content.Server.Popups; +using Content.Shared.Damage; +using Robust.Shared.Player; + +namespace Content.Server.Damage.Systems; + +public sealed class DamagePopupSystem : EntitySystem +{ + [Dependency] private readonly PopupSystem _popupSystem = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnDamageChange); + } + + private void OnDamageChange(EntityUid uid, DamagePopupComponent component, DamageChangedEvent args) + { + if (args.DamageDelta != null) + { + var damageTotal = args.Damageable.TotalDamage; + var damageDelta = args.DamageDelta.Total; + + var msg = component.Type switch + { + DamagePopupType.Delta => damageDelta.ToString(), + DamagePopupType.Total => damageTotal.ToString(), + DamagePopupType.Combined => damageDelta + " | " + damageTotal, + DamagePopupType.Hit => "!", + _ => "Invalid type", + }; + _popupSystem.PopupEntity(msg, uid, Filter.Pvs(uid, 2F, EntityManager)); + } + } +} diff --git a/Resources/Prototypes/Entities/Objects/Specific/Security/target.yml b/Resources/Prototypes/Entities/Objects/Specific/Security/target.yml new file mode 100644 index 0000000000..304a48258a --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Specific/Security/target.yml @@ -0,0 +1,148 @@ +- type: entity + id: BaseTarget + parent: BaseStructureDynamic + abstract: true + components: + - type: Sprite + sprite: Objects/Specific/Security/target.rsi + state: target_stake + noRot: true + netsync: false + - type: Repairable + - type: DamagePopup + damagePopupType: Combined + - type: Fixtures + fixtures: + - shape: + !type:PhysShapeCircle + radius: 0.35 + density: 200 + mask: + - FullTileMask + layer: + - WallLayer + - type: InteractionOutline + - type: Physics + - type: Damageable + damageContainer: Inorganic + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 50 + behaviors: + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel: + min: 5 + max: 5 + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:DoActsBehavior + acts: [ "Destruction" ] + +- type: entity + name: human target + id: TargetHuman + parent: BaseTarget + description: A shooting target. This one is a human. + components: + - type: Sprite + sprite: Objects/Specific/Security/target.rsi + state: target_h + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 500 + behaviors: + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel: + min: 10 + max: 10 + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:DoActsBehavior + acts: [ "Destruction" ] + +- type: entity + name: syndicate target + id: TargetSyndicate + parent: BaseTarget + description: A shooting target. This one is a syndicate agent. + components: + - type: Sprite + sprite: Objects/Specific/Security/target.rsi + state: target_s + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 500 + behaviors: + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel: + min: 10 + max: 10 + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:DoActsBehavior + acts: [ "Destruction" ] + +- type: entity + name: clown target + id: TargetClown + parent: BaseTarget + description: A shooting target. This one is a clown. + components: + - type: Sprite + sprite: Objects/Specific/Security/target.rsi + state: target_c + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 500 + behaviors: + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel: + min: 10 + max: 10 + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:DoActsBehavior + acts: [ "Destruction" ] + +# put it on a salvage or something +- type: entity + name: strange target + id: TargetStrange + parent: BaseTarget + description: A shooting target. You aren't quite sure what this one is, but it seems to be extra robust. + components: + - type: Sprite + sprite: Objects/Specific/Security/target.rsi + state: target_f + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 2000 + behaviors: + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel: + min: 10 + max: 10 + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:DoActsBehavior + acts: [ "Destruction" ] diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml index 79cd9fc79f..1bc5266edc 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml @@ -115,6 +115,16 @@ proto: RedLaser fireCost: 62.5 +- type: entity + name: practice laser gun + parent: WeaponLaserCarbine + id: WeaponLaserCarbinePractice + description: A modified version of the basic laser gun, this one fires less concentrated energy bolts designed for target practice. + components: + - type: HitscanBatteryAmmoProvider + proto: RedLaserPractice + fireCost: 62.5 + - type: entity name: pulse pistol parent: BaseWeaponBatterySmall diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml index ff142824d7..c3349e2648 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml @@ -30,6 +30,21 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi state: impact_laser +- type: hitscan + id: RedLaserPractice + damage: + types: + Heat: 0 + muzzleFlash: + sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi + state: muzzle_laser + travelFlash: + sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi + state: beam + impactFlash: + sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi + state: impact_laser + - type: hitscan id: RedMediumLaser damage: diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index a5880d4da2..4569a642f1 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -347,6 +347,9 @@ - CartridgeCaselessRifleRubber - CartridgeLightRifleRubber - CartridgeRifleRubber + - TargetHuman + - TargetSyndicate + - TargetClown - type: MaterialStorage whitelist: tags: diff --git a/Resources/Prototypes/Recipes/Lathes/security.yml b/Resources/Prototypes/Recipes/Lathes/security.yml index 8002dd1a3a..f59cdd19c4 100644 --- a/Resources/Prototypes/Recipes/Lathes/security.yml +++ b/Resources/Prototypes/Recipes/Lathes/security.yml @@ -170,3 +170,33 @@ Plastic: 15 Steel: 10 Glass: 5 + +- type: latheRecipe + id: TargetHuman + icon: + sprite: Objects/Specific/Security/target.rsi + state: target_h + result: TargetHuman + completetime: 5 + materials: + Steel: 10 + +- type: latheRecipe + id: TargetClown + icon: + sprite: Objects/Specific/Security/target.rsi + state: target_c + result: TargetClown + completetime: 5 + materials: + Steel: 10 + +- type: latheRecipe + id: TargetSyndicate + icon: + sprite: Objects/Specific/Security/target.rsi + state: target_s + result: TargetSyndicate + completetime: 5 + materials: + Steel: 10 diff --git a/Resources/Textures/Objects/Specific/Security/target.rsi/meta.json b/Resources/Textures/Objects/Specific/Security/target.rsi/meta.json new file mode 100644 index 0000000000..de64cfcf1f --- /dev/null +++ b/Resources/Textures/Objects/Specific/Security/target.rsi/meta.json @@ -0,0 +1,26 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/blob/a0f470046f01c2e8643d27e8dac8b9cb08b9a68d/icons/obj/objects.dmi", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "target_stake" + }, + { + "name": "target_h" + }, + { + "name": "target_s" + }, + { + "name": "target_c" + }, + { + "name": "target_f" + } + ] +} diff --git a/Resources/Textures/Objects/Specific/Security/target.rsi/target_c.png b/Resources/Textures/Objects/Specific/Security/target.rsi/target_c.png new file mode 100644 index 0000000000000000000000000000000000000000..6a1105d5a289dfa471a8c49db64a9805f38cb748 GIT binary patch literal 435 zcmV;k0ZjghP)qrKP2VX*yqDUxs2Hmv16I|E~oA0004WQchCV=-0C=2JR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+ z(=$pSoZ^zil2jm5sU)!|J+&l0S&54?C9|j)C}haRnO2mTn+jnoE4cc(fK3JfnfDu1 zjAD3c0002aNklEvRtBT9 zVDT~^288$(fa~!NWe`yr`AKMdV~4ia40h!E0z$RUxjc;k@fKoxwKlLCxH%$sVONi2oxe*4o;(BSqE9hv4)g`N2Ztq1Iad&^T`I^?09RP& zZcZ<7D>QM+aE*TfhG_}YY|4{h7sfCm+g}CUvF%flk*fR(pu_}5;`sePJl%yQVygfE002ovPDHLkV1nP+tC0Wz literal 0 HcmV?d00001 diff --git a/Resources/Textures/Objects/Specific/Security/target.rsi/target_f.png b/Resources/Textures/Objects/Specific/Security/target.rsi/target_f.png new file mode 100644 index 0000000000000000000000000000000000000000..2ab0416452521c39da482fef9df21d74cab21c09 GIT binary patch literal 424 zcmV;Z0ayNsP)b>!3?vN$`9T-IKphPD0Uf%qKk(##XbduP>(E!^2i4M{571Wa0SsiwAC$?0>c%!@ zIp~rDJlLeo6L~rr-~k~{=Zim`FFrSCj6$0D^zj~wOcjswq$s6{ySn~G;_dY%#6G{i zLu^;qNdzz@*&mPodB2CIY5v5lweWK|0JbgOr2_x}*tV#Y@&Eut6rLMnLOfMlMUF6s z!a2wy5O-lM%C&{#)e{j|YgZA#H7_Zpyw*D0Gc!2n@a_Z#0Z#1#07xcMrmor;GdX)A z0%rCpB#JdHA9lcS#n4)ZPHjTqR`I1>kV2x67H4K)=2;(zbEG6hBer854+3HW(!(X?BosTL)ZLV=-0C=2J zR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+(=$pSoZ^zil2jm5 zsU)!|J+&l0Ly3zsC9|j)C}haRnO2mTn+jnoE4cc(fK3Jfnx-3BOOUt~0001dNkll%(eM$i{V&3`CL0xW%&PQxg40m* z3TR!m?q*Ut9LPNcH}^;ad;>pL$*;)N1TB5 nDUdg)TUqlO5@C_@vYWgBpivUn1?y9D00000NkvXXu0mjfIeUT` literal 0 HcmV?d00001 diff --git a/Resources/Textures/Objects/Specific/Security/target.rsi/target_s.png b/Resources/Textures/Objects/Specific/Security/target.rsi/target_s.png new file mode 100644 index 0000000000000000000000000000000000000000..149e6868661b11d4554de95f6d920be6df134ce7 GIT binary patch literal 371 zcmV-(0gV2MP)V=-0C=2J zR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+(=$pSoZ^zil2jm5 zsU)!|J+&mhSc!`>C9|j)C}haRnO2mTn+jnoE4cc(fK3JfoF^M(ncIrE0001*Nkls)ROu5?Z#8gv!giDpOca=c7ct5~Sb8rW z&|9Mev>RMM;++vk?{5#1PE}`#sOz{v64qbn%T5sVCU{a(9RiX0coK#z=>gzD z#IOu4yG5<#05-=4fvW=3FEQ1*OTRswE;_ttxUS z&ijQvdgOCbM~jV1x~OoOsOqz2PB%_*t*g^ZxXh^fPL}iEc9EGtn`1p)978lFUOjb? zw?ToYH8F+hww?mNSpoBlf5x6wngYVfkBgTe~ HDWM4fD8+a- literal 0 HcmV?d00001