diff --git a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs index a71091ad97dd42..6d8401399ba233 100644 --- a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs +++ b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs @@ -8,6 +8,8 @@ using Content.Shared.Mobs.Components; using Content.Shared.Silicons.Bots; using Content.Shared.Emag.Components; +using Content.Shared.Stealth.Components; +using Robust.Shared.Containers; namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific; @@ -17,6 +19,7 @@ public sealed partial class PickNearbyInjectableOperator : HTNOperator private EntityLookupSystem _lookup = default!; private MedibotSystem _medibot = default!; private PathfindingSystem _pathfinding = default!; + private SharedContainerSystem _container = default!; //ss220 stealth inject fix [DataField("rangeKey")] public string RangeKey = NPCBlackboard.MedibotInjectRange; @@ -38,6 +41,7 @@ public override void Initialize(IEntitySystemManager sysManager) _lookup = sysManager.GetEntitySystem(); _medibot = sysManager.GetEntitySystem(); _pathfinding = sysManager.GetEntitySystem(); + _container = sysManager.GetEntitySystem(); //ss220 npc stealth inject fix } public override async Task<(bool Valid, Dictionary? Effects)> Plan(NPCBlackboard blackboard, @@ -56,6 +60,7 @@ public override void Initialize(IEntitySystemManager sysManager) var recentlyInjected = _entManager.GetEntityQuery(); var mobState = _entManager.GetEntityQuery(); var emaggedQuery = _entManager.GetEntityQuery(); + var stealthQuery = _entManager.GetEntityQuery(); //ss220 medibot inject in stealth entity fix foreach (var entity in _lookup.GetEntitiesInRange(owner, range)) { @@ -64,6 +69,17 @@ public override void Initialize(IEntitySystemManager sysManager) damageQuery.TryGetComponent(entity, out var damage) && !recentlyInjected.HasComponent(entity)) { + //ss220 medibot inject in stealth entity fix start + if (_container.IsEntityInContainer(entity)) + { + continue; + } + if (stealthQuery.TryGetComponent(entity, out var stealthComponent) && stealthComponent.Enabled) + { + continue; + } + //ss220 medibot inject in stealth entity fix end + // no treating dead bodies if (!_medibot.TryGetTreatment(medibot, state.CurrentState, out var treatment)) continue;