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

@@ -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);