diff --git a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/MedibotInjectOperator.cs b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/MedibotInjectOperator.cs index 9fa50c919a..ef7a30fd3e 100644 --- a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/MedibotInjectOperator.cs +++ b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/MedibotInjectOperator.cs @@ -53,8 +53,6 @@ public sealed class MedibotInjectOperator : HTNOperator if (!_entMan.TryGetComponent(owner, out var botComp)) return HTNOperatorStatus.Failed; - // To avoid spam, the rest of this needs fixing. - _entMan.EnsureComponent(target); if (!_entMan.TryGetComponent(target, out var damage)) return HTNOperatorStatus.Failed; @@ -65,18 +63,14 @@ public sealed class MedibotInjectOperator : HTNOperator if (!_interaction.InRangeUnobstructed(owner, target)) return HTNOperatorStatus.Failed; - // if emagged, always treat below-crit as injured (give funny juice to healthy people) var total = damage.TotalDamage; - if (_entMan.HasComponent(owner) && total < MedibotComponent.EmergencyMedDamageThreshold) - { - total = MedibotComponent.EmergencyMedDamageThreshold; - } if (total == 0) return HTNOperatorStatus.Failed; if (total >= MedibotComponent.EmergencyMedDamageThreshold) { + _entMan.EnsureComponent(target); _solution.TryAddReagent(target, injectable, botComp.EmergencyMed, botComp.EmergencyMedAmount, out var accepted); _popup.PopupEntity(Loc.GetString("hypospray-component-feel-prick-message"), target, target); _audio.PlayPvs(botComp.InjectSound, target); @@ -84,8 +78,9 @@ public sealed class MedibotInjectOperator : HTNOperator return HTNOperatorStatus.Finished; } - if (total >= MedibotComponent.StandardMedDamageThreshold) + if (total >= MedibotComponent.StandardMedDamageThreshold && total <= MedibotComponent.StandardMedDamageThresholdStop) { + _entMan.EnsureComponent(target); _solution.TryAddReagent(target, injectable, botComp.StandardMed, botComp.StandardMedAmount, out var accepted); _popup.PopupEntity(Loc.GetString("hypospray-component-feel-prick-message"), target, target); _audio.PlayPvs(botComp.InjectSound, target); diff --git a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs index 0712ea24b4..57138bf0bf 100644 --- a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs +++ b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickNearbyInjectableOperator.cs @@ -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() + //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(owner)) { - {TargetKey, entity}, - {TargetMoveKey, _entManager.GetComponent(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() + { + {TargetKey, entity}, + {TargetMoveKey, _entManager.GetComponent(entity).Coordinates}, + {NPCBlackboard.PathfindKey, path}, + }); + } } return (false, null); diff --git a/Content.Shared/Silicons/Bots/MedibotComponent.cs b/Content.Shared/Silicons/Bots/MedibotComponent.cs index b0b61390bb..b20674a23c 100644 --- a/Content.Shared/Silicons/Bots/MedibotComponent.cs +++ b/Content.Shared/Silicons/Bots/MedibotComponent.cs @@ -19,7 +19,7 @@ public sealed class MedibotComponent : Component public string StandardMed = "Tricordrazine"; [DataField("standardMedAmount")] - public float StandardMedAmount = 15f; + public float StandardMedAmount = 30f; /// /// Med the bot will inject when OVER the emergency med damage threshold. @@ -36,6 +36,7 @@ public sealed class MedibotComponent : Component [DataField("injectSound")] public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg"); - public const float StandardMedDamageThreshold = 50f; + public const float StandardMedDamageThreshold = 0f; + public const float StandardMedDamageThresholdStop = 50f; public const float EmergencyMedDamageThreshold = 100f; } diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml index 4dad45fefb..c0936dac1c 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml @@ -246,7 +246,7 @@ - type: EmaggableMedibot # when you are fine, medibot will help you go sleep standardMed: ChloralHydrate - standardMedAmount: 5 + standardMedAmount: 15 # when you are crit, medibot will help you have fun emergencyMed: SpaceDrugs emergencyMedAmount: 25 @@ -260,6 +260,8 @@ - type: Construction graph: MediBot node: bot + - type: NoSlip + - type: Anchorable - type: InteractionPopup interactSuccessString: petting-success-medibot interactFailureString: petting-failure-medibot diff --git a/Resources/Prototypes/NPCs/medibot.yml b/Resources/Prototypes/NPCs/medibot.yml index 8b51f9996b..08c30cb2a7 100644 --- a/Resources/Prototypes/NPCs/medibot.yml +++ b/Resources/Prototypes/NPCs/medibot.yml @@ -11,8 +11,8 @@ branches: - tasks: - id: PickNearbyInjectablePrimitive - - id: MedibotSpeakPrimitive - id: MoveToAccessiblePrimitive + - id: MedibotSpeakPrimitive - id: SetIdleTimePrimitive - id: WaitIdleTimePrimitive - id: MedibotInjectPrimitive