Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
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
4
class
SCR_AIHealBehavior
:
SCR_AIBehaviorBase
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();
28
m_fPriorityDelay_ms
=
Math
.RandomFloat(
PRIORITY_DELAY_MIN_MS
,
PRIORITY_DELAY_MAX_MS
);
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
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
m_fPriorityLevel
ref SCR_BTParam< float > m_fPriorityLevel
Definition
SCR_AIAction.c:87
PRIORITY_LEVEL_NORMAL
enum EAIActionFailReason PRIORITY_LEVEL_NORMAL
m_sBehaviorTree
ResourceName m_sBehaviorTree
Definition
SCR_AIAction.c:89
SCR_AIActivityBase
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
Definition
SCR_AIActivity.c:44
m_Utility
enum SCR_EAIActivityCause m_Utility
SCR_AIBehaviorBase
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
Definition
SCR_AIBehavior.c:23
SCR_EAIBehaviorCause
SCR_EAIBehaviorCause
Definition
SCR_AIBehavior.c:2
EAIDebugCategory
EAIDebugCategory
Definition
SCR_AIWorld.c:12
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
Math
Definition
Math.c:13
SCR_AIDebugVisualization
Definition
SCR_AIDebugVisualization.c:10
SCR_AIDebugVisualization::VisualizeMessage
static void VisualizeMessage(IEntity entity, string message, EAIDebugCategory category, float showTime, Color color=Color.White, float fontSize=16, bool ignoreCategory=false)
Definition
SCR_AIDebugVisualization.c:34
SCR_AIHealBehavior::PRIORITY_DELAY_MIN_MS
const float PRIORITY_DELAY_MIN_MS
Definition
SCR_AIHealingBehavior.c:11
SCR_AIHealBehavior::MAX_TIME_TO_UNCON_HIGH_PRIORITY_S
const float MAX_TIME_TO_UNCON_HIGH_PRIORITY_S
Definition
SCR_AIHealingBehavior.c:14
SCR_AIHealBehavior::SCR_AIHealBehavior
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...
Definition
SCR_AIHealingBehavior.c:21
SCR_AIHealBehavior::GetCause
override int GetCause()
Definition
SCR_AIHealingBehavior.c:43
SCR_AIHealBehavior::m_fPriorityDelay_ms
float m_fPriorityDelay_ms
Definition
SCR_AIHealingBehavior.c:17
SCR_AIHealBehavior::m_fTimeCreated_ms
float m_fTimeCreated_ms
Definition
SCR_AIHealingBehavior.c:16
SCR_AIHealBehavior::PRIORITY_DELAY_MAX_MS
const float PRIORITY_DELAY_MAX_MS
Definition
SCR_AIHealingBehavior.c:12
SCR_AIHealBehavior::OnActionCompleted
override void OnActionCompleted()
Definition
SCR_AIHealingBehavior.c:49
SCR_AIHealBehavior::CustomEvaluate
override float CustomEvaluate()
Definition
SCR_AIHealingBehavior.c:58
SCR_AIInfoComponent
Definition
SCR_AIInfoComponent.c:46
SCR_AIThreatSystem
Definition
SCR_AIThreatSystem.c:18
GetPriority
int GetPriority()
Definition
SCR_BaseManualCameraComponent.c:247
scripts
Game
AI
Behavior
SCR_AIHealingBehavior.c
Generated by
1.17.0