- add: Defib fun. (#567)
This commit is contained in:
@@ -7,8 +7,12 @@ using Content.Server.Ghost;
|
|||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.PowerCell;
|
using Content.Server.PowerCell;
|
||||||
using Content.Server.Traits.Assorted;
|
using Content.Server.Traits.Assorted;
|
||||||
|
using Content.Shared._White.Item.DelayedKnockdown;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.Damage.Components;
|
||||||
|
using Content.Shared.Damage.Events;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
|
using Content.Shared.Emag.Systems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Components;
|
using Content.Shared.Interaction.Components;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
@@ -20,6 +24,8 @@ using Content.Shared.Mobs.Systems;
|
|||||||
using Content.Shared.PowerCell;
|
using Content.Shared.PowerCell;
|
||||||
using Content.Shared.Timing;
|
using Content.Shared.Timing;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
|
using Content.Shared.Weapons.Melee;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -54,8 +60,25 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<DefibrillatorComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
|
SubscribeLocalEvent<DefibrillatorComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
|
||||||
SubscribeLocalEvent<DefibrillatorComponent, AfterInteractEvent>(OnAfterInteract);
|
SubscribeLocalEvent<DefibrillatorComponent, AfterInteractEvent>(OnAfterInteract);
|
||||||
SubscribeLocalEvent<DefibrillatorComponent, DefibrillatorZapDoAfterEvent>(OnDoAfter);
|
SubscribeLocalEvent<DefibrillatorComponent, DefibrillatorZapDoAfterEvent>(OnDoAfter);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DefibrillatorComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt); // WD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WD START
|
||||||
|
private void OnStaminaHitAttempt(Entity<DefibrillatorComponent> ent, ref StaminaDamageOnHitAttemptEvent args)
|
||||||
|
{
|
||||||
|
var (uid, comp) = ent;
|
||||||
|
if (comp.Enabled && _powerCell.TryUseActivatableCharge(uid))
|
||||||
|
{
|
||||||
|
if (!_powerCell.HasActivatableCharge(uid))
|
||||||
|
TryDisable(uid, comp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
// WD END
|
||||||
|
|
||||||
private void OnUseInHand(EntityUid uid, DefibrillatorComponent component, UseInHandEvent args)
|
private void OnUseInHand(EntityUid uid, DefibrillatorComponent component, UseInHandEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled || !TryComp(uid, out UseDelayComponent? useDelay) || _useDelay.IsDelayed((uid, useDelay)))
|
if (args.Handled || !TryComp(uid, out UseDelayComponent? useDelay) || _useDelay.IsDelayed((uid, useDelay)))
|
||||||
@@ -159,8 +182,8 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
if (!_powerCell.HasActivatableCharge(uid, user: user))
|
if (!_powerCell.HasActivatableCharge(uid, user: user))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_mobState.IsAlive(target, mobState))
|
// if (_mobState.IsAlive(target, mobState))
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -177,6 +200,7 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.DoAfterDuration, new DefibrillatorZapDoAfterEvent(),
|
return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.DoAfterDuration, new DefibrillatorZapDoAfterEvent(),
|
||||||
uid, target, uid)
|
uid, target, uid)
|
||||||
{
|
{
|
||||||
|
BreakOnMove = user == target, // WD EDIT
|
||||||
BlockDuplicate = true,
|
BlockDuplicate = true,
|
||||||
BreakOnHandChange = true,
|
BreakOnHandChange = true,
|
||||||
NeedHand = true
|
NeedHand = true
|
||||||
@@ -206,7 +230,13 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
ICommonSession? session = null;
|
ICommonSession? session = null;
|
||||||
|
|
||||||
var dead = true;
|
var dead = true;
|
||||||
if (_rotting.IsRotten(target))
|
// WD EDIT START
|
||||||
|
var alive = false;
|
||||||
|
if (_mobState.IsAlive(target))
|
||||||
|
{
|
||||||
|
alive = true;
|
||||||
|
}
|
||||||
|
else if (_rotting.IsRotten(target)) // WD EDIT END
|
||||||
{
|
{
|
||||||
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-rotten"),
|
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-rotten"),
|
||||||
InGameICChatType.Speak, true);
|
InGameICChatType.Speak, true);
|
||||||
@@ -246,7 +276,7 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sound = dead || session == null
|
var sound = !alive && (dead || session == null) // WD EDIT
|
||||||
? component.FailureSound
|
? component.FailureSound
|
||||||
: component.SuccessSound;
|
: component.SuccessSound;
|
||||||
_audio.PlayPvs(sound, uid);
|
_audio.PlayPvs(sound, uid);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -86,6 +87,10 @@ public sealed partial class DefibrillatorComponent : Component
|
|||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("readySound")]
|
[ViewVariables(VVAccess.ReadWrite), DataField("readySound")]
|
||||||
public SoundSpecifier? ReadySound = new SoundPathSpecifier("/Audio/Items/Defib/defib_ready.ogg");
|
public SoundSpecifier? ReadySound = new SoundPathSpecifier("/Audio/Items/Defib/defib_ready.ogg");
|
||||||
|
|
||||||
|
// WD EDIT
|
||||||
|
[DataField]
|
||||||
|
public EntityWhitelist? EmaggedAttackWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public sealed partial class MeleeWeaponComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField]
|
[DataField]
|
||||||
|
[AutoNetworkedField] // WD EDIT
|
||||||
public bool Hidden;
|
public bool Hidden;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -75,10 +76,10 @@ public sealed partial class MeleeWeaponComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||||
public bool CanMiss;
|
public bool CanMiss;
|
||||||
|
|
||||||
[DataField]
|
[DataField, AutoNetworkedField]
|
||||||
public EntityWhitelist? AttackWhitelist;
|
public EntityWhitelist? AttackWhitelist;
|
||||||
|
|
||||||
[DataField]
|
[DataField, AutoNetworkedField]
|
||||||
public EntityWhitelist? AttackBlacklist;
|
public EntityWhitelist? AttackBlacklist;
|
||||||
|
|
||||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
|
||||||
|
|||||||
50
Content.Shared/_White/Item/DefibEmagSystem.cs
Normal file
50
Content.Shared/_White/Item/DefibEmagSystem.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using Content.Shared._White.Item.DelayedKnockdown;
|
||||||
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.Damage.Components;
|
||||||
|
using Content.Shared.Emag.Systems;
|
||||||
|
using Content.Shared.Medical;
|
||||||
|
using Content.Shared.Weapons.Melee;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
|
||||||
|
namespace Content.Shared._White.Item;
|
||||||
|
|
||||||
|
public sealed class DefibEmagSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DefibrillatorComponent, GotEmaggedEvent>(OnEmag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEmag(Entity<DefibrillatorComponent> ent, ref GotEmaggedEvent args)
|
||||||
|
{
|
||||||
|
var (uid, comp) = ent;
|
||||||
|
comp.ZapDamage = 55;
|
||||||
|
comp.ZapDelay = TimeSpan.FromSeconds(1);
|
||||||
|
comp.WritheDuration = TimeSpan.FromSeconds(6);
|
||||||
|
var meleeWeapon = new MeleeWeaponComponent
|
||||||
|
{
|
||||||
|
Hidden = true,
|
||||||
|
AttackRate = 0.2f,
|
||||||
|
CanHeavyAttack = false,
|
||||||
|
AttackWhitelist = comp.EmaggedAttackWhitelist,
|
||||||
|
EquipCooldown = 1f,
|
||||||
|
Damage = new DamageSpecifier()
|
||||||
|
};
|
||||||
|
var delayedKnockdown = new DelayedKnockdownOnHitComponent
|
||||||
|
{
|
||||||
|
Delay = TimeSpan.Zero,
|
||||||
|
KnockdownTime = TimeSpan.FromSeconds(1.5)
|
||||||
|
};
|
||||||
|
var staminaDamage = new StaminaDamageOnHitComponent
|
||||||
|
{
|
||||||
|
Damage = 60f,
|
||||||
|
Sound = new SoundCollectionSpecifier("sparks")
|
||||||
|
};
|
||||||
|
AddComp(uid, meleeWeapon, true);
|
||||||
|
AddComp(uid, delayedKnockdown, true);
|
||||||
|
AddComp(uid, staminaDamage, true);
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ public sealed class DelayedKnockdownOnHitSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
var jitterTime = ent.Comp.JitterTime;
|
var jitterTime = ent.Comp.JitterTime;
|
||||||
var stutterTime = ent.Comp.StutterTime;
|
var stutterTime = ent.Comp.StutterTime;
|
||||||
|
var delay = ent.Comp.Delay;
|
||||||
|
var knockdownTime = ent.Comp.KnockdownTime;
|
||||||
foreach (var (uid, _) in args.HitList)
|
foreach (var (uid, _) in args.HitList)
|
||||||
{
|
{
|
||||||
if (!TryComp(uid, out StatusEffectsComponent? statusEffects))
|
if (!TryComp(uid, out StatusEffectsComponent? statusEffects))
|
||||||
@@ -38,12 +40,17 @@ public sealed class DelayedKnockdownOnHitSystem : EntitySystem
|
|||||||
_jitter.DoJitter(uid, jitterTime, true, status: statusEffects);
|
_jitter.DoJitter(uid, jitterTime, true, status: statusEffects);
|
||||||
if (stutterTime > TimeSpan.Zero)
|
if (stutterTime > TimeSpan.Zero)
|
||||||
_stutter.DoStutter(uid, stutterTime, true, statusEffects);
|
_stutter.DoStutter(uid, stutterTime, true, statusEffects);
|
||||||
|
if (delay <= TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
_stun.TryKnockdown(uid, knockdownTime, true, statusEffects);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (HasComp<KnockedDownComponent>(uid))
|
if (HasComp<KnockedDownComponent>(uid))
|
||||||
continue;
|
continue;
|
||||||
var delayedKnockdown = EnsureComp<DelayedKnockdownComponent>(uid);
|
var delayedKnockdown = EnsureComp<DelayedKnockdownComponent>(uid);
|
||||||
delayedKnockdown.KnockdownTime = TimeSpan.FromSeconds(Math.Max(ent.Comp.KnockdownTime.TotalSeconds,
|
delayedKnockdown.KnockdownTime = TimeSpan.FromSeconds(Math.Max(knockdownTime.TotalSeconds,
|
||||||
delayedKnockdown.KnockdownTime.TotalSeconds));
|
delayedKnockdown.KnockdownTime.TotalSeconds));
|
||||||
var knockdownMoment = _timing.CurTime + ent.Comp.Delay;
|
var knockdownMoment = _timing.CurTime + delay;
|
||||||
if (knockdownMoment < delayedKnockdown.KnockdownMoment)
|
if (knockdownMoment < delayedKnockdown.KnockdownMoment)
|
||||||
delayedKnockdown.KnockdownMoment = knockdownMoment;
|
delayedKnockdown.KnockdownMoment = knockdownMoment;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,9 @@
|
|||||||
zapHeal:
|
zapHeal:
|
||||||
types:
|
types:
|
||||||
Asphyxiation: -40
|
Asphyxiation: -40
|
||||||
|
emaggedAttackWhitelist:
|
||||||
|
components:
|
||||||
|
- Stamina
|
||||||
- type: DoAfter
|
- type: DoAfter
|
||||||
- type: UseDelay
|
- type: UseDelay
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
|
|||||||
Reference in New Issue
Block a user