Sentient medibot now can inject (#32110)
medibot player injection Co-authored-by: YourUsername <you@example.com>
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
namespace Content.Server.NPC.Components
|
||||
{
|
||||
/// Added when a medibot injects someone
|
||||
/// So they don't get injected again for at least a minute.
|
||||
[RegisterComponent]
|
||||
public sealed partial class NPCRecentlyInjectedComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("accumulator")]
|
||||
public float Accumulator = 0f;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("removeTime")]
|
||||
public TimeSpan RemoveTime = TimeSpan.FromMinutes(1);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.NPC.Components;
|
||||
using Content.Shared.NPC.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Emag.Components;
|
||||
@@ -55,34 +55,11 @@ public sealed partial class MedibotInjectOperator : HTNOperator
|
||||
if (!_entMan.TryGetComponent<MedibotComponent>(owner, out var botComp))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
|
||||
if (!_entMan.TryGetComponent<DamageableComponent>(target, out var damage))
|
||||
if (!_medibot.CheckInjectable((owner, botComp), target) || !_medibot.TryInject((owner, botComp), target))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
if (!_solutionContainer.TryGetInjectableSolution(target, out var injectable, out _))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
if (!_interaction.InRangeUnobstructed(owner, target))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
var total = damage.TotalDamage;
|
||||
|
||||
// always inject healthy patients when emagged
|
||||
if (total == 0 && !_entMan.HasComponent<EmaggedComponent>(owner))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
if (!_entMan.TryGetComponent<MobStateComponent>(target, out var mobState))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
var state = mobState.CurrentState;
|
||||
if (!_medibot.TryGetTreatment(botComp, mobState.CurrentState, out var treatment) || !treatment.IsValid(total))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
_entMan.EnsureComponent<NPCRecentlyInjectedComponent>(target);
|
||||
_solutionContainer.TryAddReagent(injectable.Value, treatment.Reagent, treatment.Quantity, out _);
|
||||
_popup.PopupEntity(Loc.GetString("hypospray-component-feel-prick-message"), target, target);
|
||||
_audio.PlayPvs(botComp.InjectSound, target);
|
||||
_chat.TrySendInGameICMessage(owner, Loc.GetString("medibot-finish-inject"), InGameICChatType.Speak, hideChat: true, hideLog: true);
|
||||
|
||||
return HTNOperatorStatus.Finished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.NPC.Components;
|
||||
using Content.Shared.NPC.Components;
|
||||
using Content.Server.NPC.Pathfinding;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.NPC.Components;
|
||||
using Content.Shared.NPC.Components;
|
||||
|
||||
namespace Content.Server.NPC.Systems;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user