Medibot Fix (#18063)

This commit is contained in:
Arendian
2023-07-15 21:59:45 +02:00
committed by GitHub
parent b3a1b97919
commit 040cfe3aae
5 changed files with 31 additions and 25 deletions

View File

@@ -6,6 +6,8 @@ using Content.Server.NPC.Pathfinding;
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.Mobs.Components;
using Content.Shared.Silicons.Bots;
using Content.Shared.Emag.Components;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
@@ -54,21 +56,27 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
if (mobState.HasComponent(entity) &&
injectQuery.HasComponent(entity) &&
damageQuery.TryGetComponent(entity, out var damage) &&
damage.TotalDamage > 0 &&
!recentlyInjected.HasComponent(entity))
{
var path = await _pathfinding.GetPath(owner, entity, SharedInteractionSystem.InteractionRange, cancelToken);
if (path.Result == PathResult.NoPath)
continue;
return (true, new Dictionary<string, object>()
//Only go towards a target if the bot can actually help them or if the medibot is emagged
if (damage.TotalDamage > MedibotComponent.StandardMedDamageThreshold &&
damage.TotalDamage <= MedibotComponent.StandardMedDamageThresholdStop ||
damage.TotalDamage > MedibotComponent.EmergencyMedDamageThreshold ||
_entManager.HasComponent<EmaggedComponent>(owner))
{
{TargetKey, entity},
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(entity).Coordinates},
{NPCBlackboard.PathfindKey, path},
});
}
//Needed to make sure it doesn't sometimes stop right outside it's interaction range
var pathRange = SharedInteractionSystem.InteractionRange - 1f;
var path = await _pathfinding.GetPath(owner, entity, pathRange, cancelToken);
if (path.Result == PathResult.NoPath)
continue;
return (true, new Dictionary<string, object>()
{
{TargetKey, entity},
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(entity).Coordinates},
{NPCBlackboard.PathfindKey, path},
});
}
}
return (false, null);