Skip to content

Commit

Permalink
FIX: Medibot can inject stealthy entities (#2303)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReeZer2 authored Dec 5, 2024
1 parent 69700ff commit a4e1889
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -38,6 +41,7 @@ public override void Initialize(IEntitySystemManager sysManager)
_lookup = sysManager.GetEntitySystem<EntityLookupSystem>();
_medibot = sysManager.GetEntitySystem<MedibotSystem>();
_pathfinding = sysManager.GetEntitySystem<PathfindingSystem>();
_container = sysManager.GetEntitySystem<SharedContainerSystem>(); //ss220 npc stealth inject fix
}

public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard,
Expand All @@ -56,6 +60,7 @@ public override void Initialize(IEntitySystemManager sysManager)
var recentlyInjected = _entManager.GetEntityQuery<NPCRecentlyInjectedComponent>();
var mobState = _entManager.GetEntityQuery<MobStateComponent>();
var emaggedQuery = _entManager.GetEntityQuery<EmaggedComponent>();
var stealthQuery = _entManager.GetEntityQuery<StealthComponent>(); //ss220 medibot inject in stealth entity fix

foreach (var entity in _lookup.GetEntitiesInRange(owner, range))
{
Expand All @@ -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;
Expand Down

0 comments on commit a4e1889

Please sign in to comment.