Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emp Flashlight #5

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs
Original file line number Diff line number Diff line change
@@ -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;

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

public bool TryEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args)
{

if (!TryComp<LimitedChargesComponent>(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;
}
}

2 changes: 2 additions & 0 deletions Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-FlashlightEmp = Фонарик
.desc = Он озаряет путь к свободе.
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uplink-emp-flashlight-name = Электромагнитный фонарик
uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства.
9 changes: 9 additions & 0 deletions Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
@@ -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
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
Loading