3 using System.Collections.Generic;
16 private readonly HashSet<Character> charactersWithMinorInjuries =
new HashSet<Character>();
18 private const float vitalityThreshold = 75;
19 private const float vitalityThresholdForOrders = 90;
24 return vitalityThreshold;
28 return character == target || manager.HasOrder<
AIObjectiveRescueAll>() ? vitalityThresholdForOrders : vitalityThreshold;
33 : base(character, objectiveManager, priorityModifier) { }
37 if (!
IsValidTarget(target, character, out
bool ignoredasMinorWounds))
39 if (ignoredasMinorWounds)
44 if (character.IsOnPlayerTeam && target != character && !charactersWithMinorInjuries.Contains(target))
49 charactersWithMinorInjuries.Add(target);
50 character.Speak(TextManager.GetWithVariable(
"dialogignoreminorinjuries",
"[targetname]", target.
Name).Value,
52 identifier: $
"notreatableafflictions{target.Name}".ToIdentifier(),
53 minDurationBetweenSimilar: 10.0f);
66 if (
Targets.None()) {
return 100; }
67 if (!objectiveManager.IsOrder(
this))
76 if (
Targets.Contains(character))
79 if (character.Bleeding > 10)
87 return worstCondition;
94 vitality += Math.Min(character.
Oxygen, 0);
97 float strength = character.CharacterHealth.GetPredictedStrength(affliction, predictFutureDuration: 10.0f);
98 vitality -= affliction.
GetVitalityDecrease(character.CharacterHealth, strength) / character.MaxVitality * 100;
108 return Math.Clamp(vitality, 0, 100);
114 foreach (
Affliction affliction
in allAfflictions)
118 if (!ignoreTreatmentThreshold)
122 float totalAfflictionStrength = character.CharacterHealth.GetTotalAdjustedAfflictionStrength(affliction);
126 yield
return affliction;
138 ignoredAsMinorWounds =
false;
139 if (target ==
null || target.
IsDead || target.
Removed) {
return false; }
141 if (target.
IsPet) {
return false; }
143 bool isBelowTreatmentThreshold;
144 float vitalityFactor;
147 if (!IsValidTargetForAI(target, humanAI)) {
return false; }
149 isBelowTreatmentThreshold = vitalityFactor <
GetVitalityThreshold(humanAI.ObjectiveManager, character, target);
154 isBelowTreatmentThreshold = vitalityFactor < vitalityThreshold;
157 bool isValidTarget = isBelowTreatmentThreshold && hasTreatableAfflictions;
160 ignoredAsMinorWounds = hasTreatableAfflictions || vitalityFactor < 100;
162 return isValidTarget;
170 if (!character.
IsMedic && target != character)
191 if (target != character && target.
IsBot && HumanAIController.IsActive(target) && target.
AIController is HumanAIController targetAI)
194 if (targetAI.ObjectiveManager.HasActiveObjective<AIObjectiveCombat>() ||
195 targetAI.ObjectiveManager.HasActiveObjective<AIObjectiveFindSafety>() ||
196 targetAI.ObjectiveManager.HasActiveObjective<AIObjectiveRescue>())
204 if (Character.CharacterList.Any(c => c.CurrentHull == target.
CurrentHull && !HumanAIController.IsFriendly(character, c) && HumanAIController.IsActive(c))) {
return false; }
readonly Character Character
An objective that creates specific kinds of subobjectives for specific types of targets,...
override bool AllowInAnySub
override bool AllowOutsideSubmarine
override void OnObjectiveCompleted(AIObjective objective, Character target)
static bool IsValidTarget(Character target, Character character, out bool ignoredAsMinorWounds)
override bool InverseTargetPriority
override Identifier Identifier
static IEnumerable< Affliction > GetTreatableAfflictions(Character character, bool ignoreTreatmentThreshold)
override IEnumerable< Character > GetList()
List of all possible items of the specified type. Used for filtering the removed objectives.
override float GetTargetPriority()
Returns a priority value based on the current targets (e.g. high prio when there's lots of severe fir...
static float GetVitalityThreshold(AIObjectiveManager manager, Character character, Character target)
AIObjectiveRescueAll(Character character, AIObjectiveManager objectiveManager, float priorityModifier=1)
static float GetVitalityFactor(Character character)
override bool IsValidTarget(Character target)
override AIObjective ObjectiveConstructor(Character target)
float GetVitalityDecrease(CharacterHealth characterHealth)
readonly AfflictionPrefab Prefab
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
readonly bool IsBuff
If set to true, the game will recognize this affliction as a buff. This means, among other things,...
ImmutableHashSet< Identifier > IgnoreTreatmentIfAfflictedBy
Bots will not try to treat the affliction if the character has any of these afflictions
bool HasTreatments
Can this affliction be treated with some item?
static readonly Identifier ParalysisType
readonly Identifier AfflictionType
Arbitrary string that is used to identify the type of the affliction.
readonly float TreatmentThreshold
How strong the affliction needs to be before bots attempt to treat it. Also effects when the afflicti...
static readonly Identifier PoisonType
IReadOnlyCollection< Affliction > GetAllAfflictions()
float GetDamageDoneByAttacker(Character otherCharacter)
CharacterHealth CharacterHealth
virtual AIController AIController
static readonly List< Character > CharacterList
bool IsTrueForAnyCrewMember(Func< Character, bool > predicate, bool onlyActive=true, bool onlyConnectedSubs=false)
Including the player characters in the same team.
AIObjectiveManager ObjectiveManager
static bool IsFriendly(Character me, Character other, bool onlySameTeam=false)
readonly HashSet< Hull > UnsafeHulls
bool IsEntityFoundOnThisSub(MapEntity entity, bool includingConnectedSubs, bool allowDifferentTeam=false, bool allowDifferentType=false)