Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIHealingBehavior.c
Go to the documentation of this file.
1// AI healing behaviour
2// TODO: You have to handle situation, in which movement can be disabled (in AIConfig component)
3
5{
6 IEntity m_EntityToHeal;
7
8 SCR_AIInfoComponent m_AIInfo;
9 SCR_DamageManagerComponent m_DamageManager;
10
11 protected const float PRIORITY_DELAY_MIN_MS = 800.0; // Delay until action returns its max priority
12 protected const float PRIORITY_DELAY_MAX_MS = 1200.0;
13
14 protected const float MAX_TIME_TO_UNCON_HIGH_PRIORITY_S = 30; // Time in seconds to losing consciousness below which we treat healing ourselves as high priority
15
16 protected float m_fTimeCreated_ms;
17 protected float m_fPriorityDelay_ms;
18
19 //-------------------------------------------------------------------------------------------------------------------------------
21 void SCR_AIHealBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity entityToHeal, bool allowHealMove, float priority = PRIORITY_BEHAVIOR_HEAL, float priorityLevel = PRIORITY_LEVEL_NORMAL)
22 {
23 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/Heal.bt";
24 m_EntityToHeal = entityToHeal;
25 SetPriority(priority);
26 m_fPriorityLevel.m_Value = priorityLevel;
27 m_fTimeCreated_ms = GetGame().GetWorld().GetWorldTime();
29
30 SCR_AIUtilityComponent aiUtilComp = utility;
31 if (!aiUtilComp)
32 return;
33
34 IEntity owner = aiUtilComp.m_OwnerEntity;
35 if (owner)
36 {
37 m_DamageManager = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
38 m_AIInfo = aiUtilComp.m_AIInfo;
39 }
40 }
41
42 //---------------------------------------------------------------------------------------------------------------------------------
43 override int GetCause()
44 {
45 return SCR_EAIBehaviorCause.DANGER_MEDIUM;
46 }
47
48 //---------------------------------------------------------------------------------------------------------------------------------
49 override void OnActionCompleted()
50 {
51 super.OnActionCompleted();
52#ifdef WORKBENCH
53 SCR_AIDebugVisualization.VisualizeMessage(m_Utility.m_OwnerEntity, "Unit healed", EAIDebugCategory.INFO, 5);
54#endif
55 }
56
57 //---------------------------------------------------------------------------------------------------------------------------------
58 override float CustomEvaluate()
59 {
60 if (!(GetGame().GetWorld().GetWorldTime() - m_fTimeCreated_ms > m_fPriorityDelay_ms))
61 return 0;
62
63 // We should heal ourselves with high priority if time to uncon is lower then treshold
64 if (m_AIInfo && m_AIInfo.GetBleedTimeToUnconscious() < MAX_TIME_TO_UNCON_HIGH_PRIORITY_S)
65 return PRIORITY_BEHAVIOR_HEAL_HIGH_PRIORITY;
66
67 if (m_Utility.m_ThreatSystem.GetThreatMeasureWithoutInjuryFactor() < SCR_AIThreatSystem.VIGILANT_THRESHOLD)
68 return GetPriority();
69
70 return 0;
71 }
72};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref SCR_BTParam< float > m_fPriorityLevel
enum EAIActionFailReason PRIORITY_LEVEL_NORMAL
ResourceName m_sBehaviorTree
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
SCR_EAIBehaviorCause
EAIDebugCategory
Definition SCR_AIWorld.c:12
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
static void VisualizeMessage(IEntity entity, string message, EAIDebugCategory category, float showTime, Color color=Color.White, float fontSize=16, bool ignoreCategory=false)
const float MAX_TIME_TO_UNCON_HIGH_PRIORITY_S
void SCR_AIHealBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity entityToHeal, bool allowHealMove, float priority=PRIORITY_BEHAVIOR_HEAL, float priorityLevel=PRIORITY_LEVEL_NORMAL)
priority should be between normal Move and AttackMove and replaced by enum later, maybe evaluated dyn...
override void OnActionCompleted()
override float CustomEvaluate()