(c3a729b34) Fix ai reporting only working if there's someone with the appropriate objective. Use the target's hull instead of using the reporter's hull. Take bleeding into account when filtering rescue targets.

This commit is contained in:
Joonas Rikkonen
2019-05-16 06:54:49 +03:00
parent 4c4cac9c39
commit 81fe275299
13 changed files with 140 additions and 216 deletions
@@ -9,7 +9,7 @@ namespace Barotrauma
public override string DebugTag => "rescue all";
public override bool ForceRun => true;
private const float vitalityThreshold = 0.85f;
private const float vitalityThreshold = 0.8f;
private const float vitalityThresholdForOrders = 0.95f;
public static float GetVitalityThreshold(AIObjectiveManager manager) => manager.CurrentOrder is AIObjectiveRescueAll ? vitalityThresholdForOrders : vitalityThreshold;
@@ -35,10 +35,9 @@ namespace Barotrauma
public static bool IsValidTarget(Character target, Character character)
{
if (target == null || target.IsDead || target.Removed) { return false; }
if (target == character) { return false; } // TODO: enable healing self
if (!HumanAIController.IsFriendly(character, target)) { return false; }
if (!(character.AIController is HumanAIController humanAI)) { return false; }
if (target.Vitality / target.MaxVitality > GetVitalityThreshold(humanAI.ObjectiveManager)) { return false; }
if (target.Bleeding < 1 && target.Vitality / target.MaxVitality > GetVitalityThreshold(humanAI.ObjectiveManager)) { return false; }
if (target.Submarine == null) { return false; }
if (target.Submarine.TeamID != character.Submarine.TeamID) { return false; }
if (target.CurrentHull == null) { return false; }