emag medibot to make it poison patients (#15377)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
38
Content.Shared/Silicons/Bots/EmaggableMedibotComponent.cs
Normal file
38
Content.Shared/Silicons/Bots/EmaggableMedibotComponent.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Silicons.Bots;
|
||||
|
||||
/// <summary>
|
||||
/// Replaced the medibot's meds with these when emagged. Could be poison, could be fun.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(MedibotSystem))]
|
||||
public sealed partial class EmaggableMedibotComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Med the bot will inject when UNDER the standard med damage threshold.
|
||||
/// </summary>
|
||||
[DataField("standardMed", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>)), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public string StandardMed = "Tricordrazine";
|
||||
|
||||
[DataField("standardMedAmount"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public float StandardMedAmount = 15f;
|
||||
|
||||
/// <summary>
|
||||
/// Med the bot will inject when OVER the emergency med damage threshold.
|
||||
/// </summary>
|
||||
[DataField("emergencyMed", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>)), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public string EmergencyMed = "Inaprovaline";
|
||||
|
||||
[DataField("emergencyMedAmount"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public float EmergencyMedAmount = 15f;
|
||||
|
||||
/// <summary>
|
||||
/// Sound to play when the bot has been emagged
|
||||
/// </summary>
|
||||
[DataField("sparkSound")]
|
||||
public SoundSpecifier SparkSound = new SoundCollectionSpecifier("sparks");
|
||||
}
|
||||
41
Content.Shared/Silicons/Bots/MedibotComponent.cs
Normal file
41
Content.Shared/Silicons/Bots/MedibotComponent.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Silicons.Bots;
|
||||
|
||||
/// <summary>
|
||||
/// Used by the server for NPC medibot injection.
|
||||
/// Currently no clientside prediction done, only exists in shared for emag handling.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Access(typeof(MedibotSystem))]
|
||||
public sealed class MedibotComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Med the bot will inject when UNDER the standard med damage threshold.
|
||||
/// </summary>
|
||||
[DataField("standardMed", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
public string StandardMed = "Tricordrazine";
|
||||
|
||||
[DataField("standardMedAmount")]
|
||||
public float StandardMedAmount = 15f;
|
||||
|
||||
/// <summary>
|
||||
/// Med the bot will inject when OVER the emergency med damage threshold.
|
||||
/// </summary>
|
||||
[DataField("emergencyMed", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
public string EmergencyMed = "Inaprovaline";
|
||||
|
||||
[DataField("emergencyMedAmount")]
|
||||
public float EmergencyMedAmount = 15f;
|
||||
|
||||
/// <summary>
|
||||
/// Sound played after injecting a patient.
|
||||
/// </summary>
|
||||
[DataField("injectSound")]
|
||||
public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg");
|
||||
|
||||
public const float StandardMedDamageThreshold = 50f;
|
||||
public const float EmergencyMedDamageThreshold = 100f;
|
||||
}
|
||||
33
Content.Shared/Silicons/Bots/MedibotSystem.cs
Normal file
33
Content.Shared/Silicons/Bots/MedibotSystem.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Silicons.Bots;
|
||||
|
||||
/// <summary>
|
||||
/// Handles emagging medibots
|
||||
/// </summary>
|
||||
public sealed class MedibotSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<EmaggableMedibotComponent, GotEmaggedEvent>(OnEmagged);
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, EmaggableMedibotComponent comp, ref GotEmaggedEvent args)
|
||||
{
|
||||
if (!TryComp<MedibotComponent>(uid, out var medibot))
|
||||
return;
|
||||
|
||||
_audio.PlayPredicted(comp.SparkSound, uid, args.UserUid, AudioParams.Default.WithVolume(8));
|
||||
|
||||
medibot.StandardMed = comp.StandardMed;
|
||||
medibot.StandardMedAmount = comp.StandardMedAmount;
|
||||
medibot.EmergencyMed = comp.EmergencyMed;
|
||||
medibot.EmergencyMedAmount = comp.EmergencyMedAmount;
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user