Skip to content

Commit

Permalink
Emp Flashlight (#5) (#1189)
Browse files Browse the repository at this point in the history
# Description

Ports #5

# Changelog

:cl:
- add: Added the EMP Flashlight to Syndicate Uplinks.

---------

Co-authored-by: Ivan <[email protected]>

(cherry picked from commit 7c0c16e3f2c07bad045c09e13a95855c356024ac)
  • Loading branch information
VMSolidus authored and Spatison committed Dec 7, 2024
1 parent 36e411b commit a88596c
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Content.Server/EmpFlashlight/EmpOnHitComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Content.Server.EmpFlashlight;

/// <summary>
/// Upon being triggered will EMP target.
/// </summary>
[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;
}
44 changes: 44 additions & 0 deletions Content.Server/EmpFlashlight/EmpOnHitSystem.cs
Original file line number Diff line number Diff line change
@@ -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<EmpOnHitComponent, MeleeHitEvent>(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;
}
}

3 changes: 3 additions & 0 deletions Resources/Locale/en-US/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-FlashlightEmp = Фонарик
.desc = Он озаряет путь к свободе.
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Граната, которая производит небольшой, но разрушительный взрыв.
Expand Down
10 changes: 10 additions & 0 deletions Resources/Prototypes/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions Resources/Prototypes/Entities/Objects/Tools/EmpFlashlight.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a88596c

Please sign in to comment.