Attacking a powered light now shocks an unarmed attacker (#18340)

This commit is contained in:
Errant
2023-07-27 07:37:09 +00:00
committed by GitHub
parent b728636283
commit c6d2fe6d03
2 changed files with 37 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Administration.Logs;
using Content.Server.Light.Components;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.NodeGroups;
@@ -76,6 +77,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
SubscribeLocalEvent<ElectrifiedComponent, InteractHandEvent>(OnElectrifiedHandInteract);
SubscribeLocalEvent<ElectrifiedComponent, InteractUsingEvent>(OnElectrifiedInteractUsing);
SubscribeLocalEvent<RandomInsulationComponent, MapInitEvent>(OnRandomInsulationMapInit);
SubscribeLocalEvent<PoweredLightComponent, AttackedEvent>(OnLightAttacked);
UpdatesAfter.Add(typeof(PowerNetSystem));
}
@@ -159,15 +161,15 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
TryDoElectrifiedAct(uid, args.OtherEntity, 1, electrified);
}
private void OnElectrifiedAttacked(EntityUid uid, ElectrifiedComponent electrified, AttackedEvent args)
{
if (!electrified.OnAttacked)
return;
private void OnElectrifiedAttacked(EntityUid uid, ElectrifiedComponent electrified, AttackedEvent args)
{
if (!electrified.OnAttacked)
return;
if (_meleeWeapon.GetDamage(args.Used, args.User).Total == 0)
return;
if (_meleeWeapon.GetDamage(args.Used, args.User).Total == 0)
return;
TryDoElectrifiedAct(uid, args.User, 1, electrified);
TryDoElectrifiedAct(uid, args.User, 1, electrified);
}
private void OnElectrifiedHandInteract(EntityUid uid, ElectrifiedComponent electrified, InteractHandEvent args)
@@ -176,6 +178,22 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
TryDoElectrifiedAct(uid, args.User, 1, electrified);
}
private void OnLightAttacked(EntityUid uid, PoweredLightComponent component, AttackedEvent args)
{
if (_meleeWeapon.GetDamage(args.Used, args.User).Total == 0)
return;
if (args.Used != args.User)
return;
if (component.CurrentLit == false)
return;
DoCommonElectrocution(args.User, uid, component.UnarmedHitShock, component.UnarmedHitStun, false, 1);
}
private void OnElectrifiedInteractUsing(EntityUid uid, ElectrifiedComponent electrified, InteractUsingEvent args)
{
if (!electrified.OnInteractUsing)

View File

@@ -68,5 +68,17 @@ namespace Content.Server.Light.Components
/// </summary>
[DataField("ejectBulbDelay")]
public float EjectBulbDelay = 2;
/// <summary>
/// Shock damage done to a mob that hits the light with an unarmed attack
/// </summary>
[DataField("unarmedHitShock")]
public int UnarmedHitShock = 20;
/// <summary>
/// Stun duration applied to a mob that hits the light with an unarmed attack
/// </summary>
[DataField("unarmedHitStun")]
public TimeSpan UnarmedHitStun = TimeSpan.FromSeconds(5);
}
}