Bandaid medibots (#11718)
This commit is contained in:
@@ -42,7 +42,7 @@ public sealed class MoveToOperator : HTNOperator
|
||||
/// Where the pathfinding result will be stored (if applicable). This gets removed after execution.
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("pathfindKey")]
|
||||
public string PathfindKey = "MovementPathfind";
|
||||
public string PathfindKey = NPCBlackboard.PathfindKey;
|
||||
|
||||
/// <summary>
|
||||
/// How close we need to get before considering movement finished.
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed class PickAccessibleComponentOperator : HTNOperator
|
||||
/// Where the pathfinding result will be stored (if applicable). This gets removed after execution.
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("pathfindKey")]
|
||||
public string PathfindKey = "MovementPathfind";
|
||||
public string PathfindKey = NPCBlackboard.PathfindKey;
|
||||
|
||||
public override void Initialize(IEntitySystemManager sysManager)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class PickAccessibleOperator : HTNOperator
|
||||
/// Where the pathfinding result will be stored (if applicable). This gets removed after execution.
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("pathfindKey")]
|
||||
public string PathfindKey = "MovementPathfind";
|
||||
public string PathfindKey = NPCBlackboard.PathfindKey;
|
||||
|
||||
public override void Initialize(IEntitySystemManager sysManager)
|
||||
{
|
||||
|
||||
@@ -50,6 +50,9 @@ public sealed class MedibotInjectOperator : HTNOperator
|
||||
if (!_entManager.TryGetComponent<MedibotComponent>(owner, out var botComp))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
// To avoid spam, the rest of this needs fixing.
|
||||
_entManager.EnsureComponent<NPCRecentlyInjectedComponent>(target);
|
||||
|
||||
if (!_entManager.TryGetComponent<DamageableComponent>(target, out var damage))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
@@ -62,20 +65,18 @@ public sealed class MedibotInjectOperator : HTNOperator
|
||||
if (damage.TotalDamage == 0)
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
if (damage.TotalDamage <= MedibotComponent.StandardMedDamageThreshold)
|
||||
if (damage.TotalDamage >= MedibotComponent.EmergencyMedDamageThreshold)
|
||||
{
|
||||
_solutionSystem.TryAddReagent(target, injectable, botComp.StandardMed, botComp.StandardMedInjectAmount, out var accepted);
|
||||
_entManager.EnsureComponent<NPCRecentlyInjectedComponent>(target);
|
||||
_solutionSystem.TryAddReagent(target, injectable, botComp.EmergencyMed, botComp.EmergencyMedInjectAmount, out var accepted);
|
||||
_popupSystem.PopupEntity(Loc.GetString("hypospray-component-feel-prick-message"), target, Filter.Entities(target));
|
||||
SoundSystem.Play("/Audio/Items/hypospray.ogg", Filter.Pvs(target), target);
|
||||
_chat.TrySendInGameICMessage(owner, Loc.GetString("medibot-finish-inject"), InGameICChatType.Speak, false);
|
||||
return HTNOperatorStatus.Finished;
|
||||
}
|
||||
|
||||
if (damage.TotalDamage >= MedibotComponent.EmergencyMedDamageThreshold)
|
||||
if (damage.TotalDamage >= MedibotComponent.StandardMedDamageThreshold)
|
||||
{
|
||||
_solutionSystem.TryAddReagent(target, injectable, botComp.EmergencyMed, botComp.EmergencyMedInjectAmount, out var accepted);
|
||||
_entManager.EnsureComponent<NPCRecentlyInjectedComponent>(target);
|
||||
_solutionSystem.TryAddReagent(target, injectable, botComp.StandardMed, botComp.StandardMedInjectAmount, out var accepted);
|
||||
_popupSystem.PopupEntity(Loc.GetString("hypospray-component-feel-prick-message"), target, Filter.Entities(target));
|
||||
SoundSystem.Play("/Audio/Items/hypospray.ogg", Filter.Pvs(target), target);
|
||||
_chat.TrySendInGameICMessage(owner, Loc.GetString("medibot-finish-inject"), InGameICChatType.Speak, false);
|
||||
|
||||
@@ -2,7 +2,9 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.NPC.Components;
|
||||
using Content.Server.NPC.Pathfinding;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MobState.Components;
|
||||
|
||||
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
|
||||
@@ -11,6 +13,7 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
private EntityLookupSystem _lookup = default!;
|
||||
private PathfindingSystem _pathfinding = default!;
|
||||
|
||||
[ViewVariables, DataField("rangeKey")] public string RangeKey = NPCBlackboard.MedibotInjectRange;
|
||||
|
||||
@@ -30,6 +33,7 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
|
||||
{
|
||||
base.Initialize(sysManager);
|
||||
_lookup = sysManager.GetEntitySystem<EntityLookupSystem>();
|
||||
_pathfinding = sysManager.GetEntitySystem<PathfindingSystem>();
|
||||
}
|
||||
|
||||
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard,
|
||||
@@ -53,10 +57,16 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
|
||||
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>()
|
||||
{
|
||||
{TargetKey, entity},
|
||||
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(entity).Coordinates}
|
||||
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(entity).Coordinates},
|
||||
{NPCBlackboard.PathfindKey, path},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user