Medibot Fix (#18063)
This commit is contained in:
@@ -53,8 +53,6 @@ public sealed class MedibotInjectOperator : HTNOperator
|
||||
if (!_entMan.TryGetComponent<MedibotComponent>(owner, out var botComp))
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
// To avoid spam, the rest of this needs fixing.
|
||||
_entMan.EnsureComponent<NPCRecentlyInjectedComponent>(target);
|
||||
|
||||
if (!_entMan.TryGetComponent<DamageableComponent>(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<EmaggedComponent>(owner) && total < MedibotComponent.EmergencyMedDamageThreshold)
|
||||
{
|
||||
total = MedibotComponent.EmergencyMedDamageThreshold;
|
||||
}
|
||||
|
||||
if (total == 0)
|
||||
return HTNOperatorStatus.Failed;
|
||||
|
||||
if (total >= MedibotComponent.EmergencyMedDamageThreshold)
|
||||
{
|
||||
_entMan.EnsureComponent<NPCRecentlyInjectedComponent>(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<NPCRecentlyInjectedComponent>(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);
|
||||
|
||||
@@ -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,10 +56,16 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
|
||||
if (mobState.HasComponent(entity) &&
|
||||
injectQuery.HasComponent(entity) &&
|
||||
damageQuery.TryGetComponent(entity, out var damage) &&
|
||||
damage.TotalDamage > 0 &&
|
||||
!recentlyInjected.HasComponent(entity))
|
||||
//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))
|
||||
{
|
||||
var path = await _pathfinding.GetPath(owner, entity, SharedInteractionSystem.InteractionRange, cancelToken);
|
||||
//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;
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed class MedibotComponent : Component
|
||||
public string StandardMed = "Tricordrazine";
|
||||
|
||||
[DataField("standardMedAmount")]
|
||||
public float StandardMedAmount = 15f;
|
||||
public float StandardMedAmount = 30f;
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
branches:
|
||||
- tasks:
|
||||
- id: PickNearbyInjectablePrimitive
|
||||
- id: MedibotSpeakPrimitive
|
||||
- id: MoveToAccessiblePrimitive
|
||||
- id: MedibotSpeakPrimitive
|
||||
- id: SetIdleTimePrimitive
|
||||
- id: WaitIdleTimePrimitive
|
||||
- id: MedibotInjectPrimitive
|
||||
|
||||
Reference in New Issue
Block a user