diff --git a/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs b/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs new file mode 100644 index 0000000000..071de4ce80 --- /dev/null +++ b/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs @@ -0,0 +1,24 @@ +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.ViewVariables; +using Content.Server._White.EmpFlashlight; +using Content.Server.Emp; + +namespace Content.Server._White.EmpFlashlight; + +/// +/// Upon being triggered will EMP target. +/// +[RegisterComponent] +[Access(typeof(EmpOnHitSystem))] + +public sealed partial class EmpOnHitComponent: Component +{ + [DataField("range"), ViewVariables(VVAccess.ReadWrite)] + public float Range = 1.0f; + + [DataField("energyConsumption"), ViewVariables(VVAccess.ReadWrite)] + public float EnergyConsumption; + + [DataField("disableDuration"), ViewVariables(VVAccess.ReadWrite)] + public float DisableDuration = 60f; +} diff --git a/Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs b/Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs new file mode 100644 index 0000000000..9fd86c20be --- /dev/null +++ b/Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs @@ -0,0 +1,52 @@ +using Content.Shared.Weapons.Melee.Events; +using Content.Server.Emp; +using Content.Shared.Charges.Systems; +using Content.Shared.Charges.Components; + +namespace Content.Server._White.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)) + return false; + + if (_charges.IsEmpty(uid, charges)) + return false; + + if (args.HitEntities.Count > 0) + { + _charges.UseCharge(uid,charges); + return true; + } + + return false; + } + + 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/_white/store/uplink-catalog.ftl b/Resources/Locale/en-US/_white/store/uplink-catalog.ftl new file mode 100644 index 0000000000..7e0b0b791e --- /dev/null +++ b/Resources/Locale/en-US/_white/store/uplink-catalog.ftl @@ -0,0 +1,2 @@ +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. diff --git a/Resources/Locale/ru-RU/_white/prototypes/entities/objects/tools/empflashlight.ftl b/Resources/Locale/ru-RU/_white/prototypes/entities/objects/tools/empflashlight.ftl new file mode 100644 index 0000000000..e9ffe8e039 --- /dev/null +++ b/Resources/Locale/ru-RU/_white/prototypes/entities/objects/tools/empflashlight.ftl @@ -0,0 +1,2 @@ +ent-FlashlightEmp = Фонарик + .desc = Он озаряет путь к свободе. diff --git a/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl b/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl new file mode 100644 index 0000000000..5bb4067557 --- /dev/null +++ b/Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl @@ -0,0 +1,2 @@ +uplink-emp-flashlight-name = Электромагнитный фонарик +uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства. diff --git a/Resources/Prototypes/_White/Catalog/uplink_catalog.yml b/Resources/Prototypes/_White/Catalog/uplink_catalog.yml new file mode 100644 index 0000000000..ed2e10a2ee --- /dev/null +++ b/Resources/Prototypes/_White/Catalog/uplink_catalog.yml @@ -0,0 +1,9 @@ +- type: listing + id: UplinkEmpFlashlight + name: uplink-emp-flashlight-name + description: uplink-emp-flashlight-desc + productEntity: FlashlightEmp + cost: + Telecrystal: 3 + categories: + - UplinkUtility diff --git a/Resources/Prototypes/_White/Entities/Objects/Tools/EmpFlashlight.yml b/Resources/Prototypes/_White/Entities/Objects/Tools/EmpFlashlight.yml new file mode 100644 index 0000000000..1da304ba1a --- /dev/null +++ b/Resources/Prototypes/_White/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