Make melee damage not go through MeleeHitEvent.cs (#16881)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Power.NodeGroups;
|
||||
using Content.Server.Weapons.Melee;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Database;
|
||||
@@ -37,6 +38,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
|
||||
[Dependency] private readonly SharedJitteringSystem _jittering = default!;
|
||||
[Dependency] private readonly MeleeWeaponSystem _meleeWeapon = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedStutteringSystem _stuttering = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
@@ -161,12 +163,8 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
if (!electrified.OnAttacked)
|
||||
return;
|
||||
|
||||
//Dont shock if the attacker used a toy
|
||||
if (EntityManager.TryGetComponent<MeleeWeaponComponent>(args.Used, out var meleeWeaponComponent))
|
||||
{
|
||||
if (meleeWeaponComponent.Damage.Total == 0)
|
||||
return;
|
||||
}
|
||||
if (_meleeWeapon.GetDamage(args.Used).Total == 0)
|
||||
return;
|
||||
|
||||
TryDoElectrifiedAct(uid, args.User, 1, electrified);
|
||||
}
|
||||
@@ -220,7 +218,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
entity,
|
||||
uid,
|
||||
(int) (electrified.ShockDamage * MathF.Pow(RecursiveDamageMultiplier, depth)),
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth)),
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth)),
|
||||
true,
|
||||
electrified.SiemensCoefficient
|
||||
);
|
||||
@@ -249,7 +247,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
uid,
|
||||
node,
|
||||
(int) (electrified.ShockDamage * MathF.Pow(RecursiveDamageMultiplier, depth) * damageMult),
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth) * timeMult),
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth) * timeMult),
|
||||
true,
|
||||
electrified.SiemensCoefficient);
|
||||
}
|
||||
@@ -374,7 +372,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!_statusEffects.TryAddStatusEffect<ElectrocutedComponent>(uid, StatusEffectKey, time, refresh, statusEffects))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Power.Components;
|
||||
using Content.Server.Power.Events;
|
||||
using Content.Server.Stunnable.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction.Events;
|
||||
@@ -27,15 +28,16 @@ namespace Content.Server.Stunnable.Systems
|
||||
SubscribeLocalEvent<StunbatonComponent, UseInHandEvent>(OnUseInHand);
|
||||
SubscribeLocalEvent<StunbatonComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<StunbatonComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
|
||||
SubscribeLocalEvent<StunbatonComponent, MeleeHitEvent>(OnMeleeHit);
|
||||
SubscribeLocalEvent<StunbatonComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
|
||||
}
|
||||
|
||||
private void OnMeleeHit(EntityUid uid, StunbatonComponent component, MeleeHitEvent args)
|
||||
private void OnGetMeleeDamage(EntityUid uid, StunbatonComponent component, ref GetMeleeDamageEvent args)
|
||||
{
|
||||
if (!component.Activated) return;
|
||||
if (!component.Activated)
|
||||
return;
|
||||
|
||||
// Don't apply damage if it's activated; just do stamina damage.
|
||||
args.BonusDamage -= args.BaseDamage;
|
||||
args.Damage = new DamageSpecifier();
|
||||
}
|
||||
|
||||
private void OnStaminaHitAttempt(EntityUid uid, StunbatonComponent component, ref StaminaDamageOnHitAttemptEvent args)
|
||||
|
||||
@@ -44,13 +44,13 @@ namespace Content.Server.Tools
|
||||
SubscribeLocalEvent<WelderComponent, ToolDoAfterEvent>(OnWelderDoAfter);
|
||||
SubscribeLocalEvent<WelderComponent, ComponentShutdown>(OnWelderShutdown);
|
||||
SubscribeLocalEvent<WelderComponent, ComponentGetState>(OnWelderGetState);
|
||||
SubscribeLocalEvent<WelderComponent, MeleeHitEvent>(OnMeleeHit);
|
||||
SubscribeLocalEvent<WelderComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
|
||||
}
|
||||
|
||||
private void OnMeleeHit(EntityUid uid, WelderComponent component, MeleeHitEvent args)
|
||||
private void OnGetMeleeDamage(EntityUid uid, WelderComponent component, ref GetMeleeDamageEvent args)
|
||||
{
|
||||
if (!args.Handled && component.Lit)
|
||||
args.BonusDamage += component.LitMeleeDamageBonus;
|
||||
if (component.Lit)
|
||||
args.Damage += component.LitMeleeDamageBonus;
|
||||
}
|
||||
|
||||
public (FixedPoint2 fuel, FixedPoint2 capacity) GetWelderFuelAndCapacity(EntityUid uid, WelderComponent? welder = null, SolutionContainerManagerComponent? solutionContainer = null)
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed class EnergySwordSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<EnergySwordComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<EnergySwordComponent, MeleeHitEvent>(OnMeleeHit);
|
||||
SubscribeLocalEvent<EnergySwordComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
|
||||
SubscribeLocalEvent<EnergySwordComponent, UseInHandEvent>(OnUseInHand);
|
||||
SubscribeLocalEvent<EnergySwordComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<EnergySwordComponent, IsHotEvent>(OnIsHotEvent);
|
||||
@@ -42,13 +42,13 @@ public sealed class EnergySwordSystem : EntitySystem
|
||||
comp.BladeColor = _random.Pick(comp.ColorOptions);
|
||||
}
|
||||
|
||||
private void OnMeleeHit(EntityUid uid, EnergySwordComponent comp, MeleeHitEvent args)
|
||||
private void OnGetMeleeDamage(EntityUid uid, EnergySwordComponent comp, ref GetMeleeDamageEvent args)
|
||||
{
|
||||
if (!comp.Activated)
|
||||
return;
|
||||
|
||||
// Overrides basic blunt damage with burn+slash as set in yaml
|
||||
args.BonusDamage = comp.LitDamageBonus;
|
||||
args.Damage = comp.LitDamageBonus;
|
||||
}
|
||||
|
||||
private void OnUseInHand(EntityUid uid, EnergySwordComponent comp, UseInHandEvent args)
|
||||
@@ -57,7 +57,7 @@ public sealed class EnergySwordSystem : EntitySystem
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
|
||||
if (comp.Activated)
|
||||
{
|
||||
var ev = new EnergySwordDeactivatedEvent();
|
||||
@@ -120,7 +120,7 @@ public sealed class EnergySwordSystem : EntitySystem
|
||||
{
|
||||
malus.Malus += comp.LitDisarmMalus;
|
||||
}
|
||||
|
||||
|
||||
_audio.Play(comp.ActivateSound, Filter.Pvs(uid, entityManager: EntityManager), uid, true, comp.ActivateSound.Params);
|
||||
|
||||
comp.Activated = true;
|
||||
|
||||
@@ -62,16 +62,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
if (!args.CanInteract || !args.CanAccess || component.HideFromExamine)
|
||||
return;
|
||||
|
||||
var getDamage = new MeleeHitEvent(new List<EntityUid>(), args.User, uid, component.Damage);
|
||||
getDamage.IsHit = false;
|
||||
RaiseLocalEvent(uid, getDamage);
|
||||
|
||||
var damageSpec = GetDamage(component);
|
||||
|
||||
if (damageSpec == null)
|
||||
damageSpec = new DamageSpecifier();
|
||||
|
||||
damageSpec += getDamage.BonusDamage;
|
||||
var damageSpec = GetDamage(uid, component);
|
||||
|
||||
if (damageSpec.Total == FixedPoint2.Zero)
|
||||
return;
|
||||
@@ -115,10 +106,6 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
private DamageSpecifier? GetDamage(MeleeWeaponComponent component)
|
||||
{
|
||||
return component.Damage.Total > FixedPoint2.Zero ? component.Damage : null;
|
||||
}
|
||||
|
||||
protected override void Popup(string message, EntityUid? uid, EntityUid? user)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user