From a88596cc49d886c005a3078b2b2337cd0166f8d2 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Wed, 4 Dec 2024 03:11:13 +0300 Subject: [PATCH] Emp Flashlight (#5) (#1189) # Description Ports https://github.com/WWhiteDreamProject/wwdpublic/pull/5 # Changelog :cl: - add: Added the EMP Flashlight to Syndicate Uplinks. --------- Co-authored-by: Ivan <126400932+HellCatten@users.noreply.github.com> (cherry picked from commit 7c0c16e3f2c07bad045c09e13a95855c356024ac) --- .../EmpFlashlight/EmpOnHitComponent.cs | 19 ++++++++ .../EmpFlashlight/EmpOnHitSystem.cs | 44 +++++++++++++++++++ .../Locale/en-US/store/uplink-catalog.ftl | 3 ++ .../entities/objects/tools/empflashlight.ftl | 2 + .../Locale/ru-RU/store/uplink-catalog.ftl | 3 ++ .../Prototypes/Catalog/uplink_catalog.yml | 10 +++++ .../Entities/Objects/Tools/EmpFlashlight.yml | 26 +++++++++++ 7 files changed, 107 insertions(+) create mode 100644 Content.Server/EmpFlashlight/EmpOnHitComponent.cs create mode 100644 Content.Server/EmpFlashlight/EmpOnHitSystem.cs create mode 100644 Resources/Locale/ru-RU/entities/objects/tools/empflashlight.ftl create mode 100644 Resources/Prototypes/Entities/Objects/Tools/EmpFlashlight.yml diff --git a/Content.Server/EmpFlashlight/EmpOnHitComponent.cs b/Content.Server/EmpFlashlight/EmpOnHitComponent.cs new file mode 100644 index 0000000000..bce182d63a --- /dev/null +++ b/Content.Server/EmpFlashlight/EmpOnHitComponent.cs @@ -0,0 +1,19 @@ +namespace Content.Server.EmpFlashlight; + +/// +/// Upon being triggered will EMP target. +/// +[RegisterComponent] +[Access(typeof(EmpOnHitSystem))] + +public sealed partial class EmpOnHitComponent : Component +{ + [DataField] + public float Range = 1.0f; + + [DataField] + public float EnergyConsumption; + + [DataField] + public float DisableDuration = 60f; +} diff --git a/Content.Server/EmpFlashlight/EmpOnHitSystem.cs b/Content.Server/EmpFlashlight/EmpOnHitSystem.cs new file mode 100644 index 0000000000..19b7300f9b --- /dev/null +++ b/Content.Server/EmpFlashlight/EmpOnHitSystem.cs @@ -0,0 +1,44 @@ +using Content.Shared.Weapons.Melee.Events; +using Content.Server.Emp; +using Content.Shared.Charges.Systems; +using Content.Shared.Charges.Components; + +namespace Content.Server.EmpFlashlight; + +public sealed class EmpOnHitSystem : EntitySystem +{ + + [Dependency] private readonly EmpSystem _emp = default!; + [Dependency] private readonly SharedChargesSystem _charges = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(HandleEmpHit); + } + + public bool TryEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args) + { + + if (!TryComp(uid, out LimitedChargesComponent? charges) + || _charges.IsEmpty(uid, charges) + || args.HitEntities.Count <= 0) + return false; + + _charges.UseCharge(uid, charges); + return true; + } + + private void HandleEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args) + { + if (!TryEmpHit(uid, comp, args)) + return; + + foreach (var affected in args.HitEntities) + _emp.EmpPulse(_transform.GetMapCoordinates(affected), comp.Range, comp.EnergyConsumption, comp.DisableDuration); + + args.Handled = true; + } +} + diff --git a/Resources/Locale/en-US/store/uplink-catalog.ftl b/Resources/Locale/en-US/store/uplink-catalog.ftl index e1b9776deb..1754bb89d3 100644 --- a/Resources/Locale/en-US/store/uplink-catalog.ftl +++ b/Resources/Locale/en-US/store/uplink-catalog.ftl @@ -26,6 +26,9 @@ uplink-fire-axe-flaming-desc = A classic-style weapon infused with advanced atmo uplink-gloves-north-star-name = Gloves of the North Star uplink-gloves-north-star-desc = A pair of gloves that reduce your punching cooldown drastically, allowing you to beat people to death in a flurry of punches. +uplink-emp-flashlight-name = Emp Flashlight +uplink-emp-flashlight-desc = A rechargeable device disguised as a flashlight designed to disrupt electronic systems. Useful for disrupting communications, security's energy weapons, and APCs when you're in a tight spot. + # Explosives uplink-explosive-grenade-name = Explosive Grenade uplink-explosive-grenade-desc = A simplistic grenade with a three-and-a-half-second long fuse that is geared towards injuring personnel. Causes minimal hull damage. diff --git a/Resources/Locale/ru-RU/entities/objects/tools/empflashlight.ftl b/Resources/Locale/ru-RU/entities/objects/tools/empflashlight.ftl new file mode 100644 index 0000000000..e9ffe8e039 --- /dev/null +++ b/Resources/Locale/ru-RU/entities/objects/tools/empflashlight.ftl @@ -0,0 +1,2 @@ +ent-FlashlightEmp = Фонарик + .desc = Он озаряет путь к свободе. diff --git a/Resources/Locale/ru-RU/store/uplink-catalog.ftl b/Resources/Locale/ru-RU/store/uplink-catalog.ftl index eee4377eb8..8bc90dd161 100644 --- a/Resources/Locale/ru-RU/store/uplink-catalog.ftl +++ b/Resources/Locale/ru-RU/store/uplink-catalog.ftl @@ -29,6 +29,9 @@ uplink-fire-axe-flaming-desc = Оружие в классическом стил uplink-gloves-north-star-name = Перчатки Полярной звезды uplink-gloves-north-star-desc = Пара перчаток, которые резко сокращают время восстановления ваших ударов, позволяя вам избивать людей до смерти шквалом ударов. +uplink-emp-flashlight-name = Электромагнитный фонарик +uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства. + # Explosives uplink-explosive-grenade-name = Разрывная граната uplink-explosive-grenade-desc = Граната, которая производит небольшой, но разрушительный взрыв. diff --git a/Resources/Prototypes/Catalog/uplink_catalog.yml b/Resources/Prototypes/Catalog/uplink_catalog.yml index 9e19f4ecbf..e76c55969c 100644 --- a/Resources/Prototypes/Catalog/uplink_catalog.yml +++ b/Resources/Prototypes/Catalog/uplink_catalog.yml @@ -1417,6 +1417,16 @@ categories: - UplinkUtility +- type: listing + id: UplinkEmpFlashlight + name: uplink-emp-flashlight-name + description: uplink-emp-flashlight-desc + productEntity: FlashlightEmp + cost: + Telecrystal: 3 + categories: + - UplinkUtility + # Armor - type: listing diff --git a/Resources/Prototypes/Entities/Objects/Tools/EmpFlashlight.yml b/Resources/Prototypes/Entities/Objects/Tools/EmpFlashlight.yml new file mode 100644 index 0000000000..1da304ba1a --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Tools/EmpFlashlight.yml @@ -0,0 +1,26 @@ +- type: entity + parent: FlashlightLantern + id: FlashlightEmp + name: flashlight + description: It lights the way to freedom. + suffix: EMP + components: + - type: ItemSlots + slots: + cell_slot: + name: power-cell-clot-component-spot-name-default + startingItem: PowerCellHigh + - type: MeleeWeapon + wideAnimationRotation: -135 + damage: + types: + Blunt: 12 + angle: 60 + animation: WeaponArcThrust + - type: EmpOnHit + range: 0.1 + energyConsumption: 100000 + disableDuration: 100 + - type: LimitedCharges + - type: AutoRecharge + rechargeDuration: 60