Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIBehavior.c
Go to the documentation of this file.
2{
3 SAFE = 10, // There's nothing better to do and we are safe
4 SELF_AID = 20, // Minor actions related to caring about ourselves
5 GROUP_GOAL = 30, // Doing something on behalf of group
6 DANGER_LOW = 40, // Reacting to dangers of not immediate potential death, like gunshots
7 COMBAT = 50, // Combat related behaviors
8 DANGER_MEDIUM = 60, // Avoiding non-immediate certain death (healing injury)
9 DANGER_HIGH = 70, // Avoiding immediate certain death (car, grenade)
10 ALWAYS = 1000 // Special value for settings to run in all behaviors
11}
12
13class SCR_AIBehaviorBase : SCR_AIActionBase
14{
15 SCR_AIUtilityComponent m_Utility;
16
17 float m_fThreat = 0.0; // This threat value will be added to the calculated threat level in threat system
18 bool m_bAllowLook = true;
19 bool m_bResetLook = false;
20 bool m_bUseCombatMove = false;
21
22 //---------------------------------------------------------------------------------------------------------------------------------
23 void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
24 {
25 m_Utility = utility;
26 SetRelatedGroupActivity(groupActivity);
27 if (groupActivity)
28 groupActivity.OnChildBehaviorCreated(this);
29 }
30
31 //---------------------------------------------------------------------------------------------------------------------------------
33 {
34 return SCR_AIActivityBase.Cast(GetRelatedGroupActivity());
35 }
36
37 //---------------------------------------------------------------------------------------------------------------------------------
38 override void OnActionSelected()
39 {
40 super.OnActionSelected();
41 if (m_bResetLook)
42 m_Utility.m_LookAction.Cancel();
43 }
44
45 //---------------------------------------------------------------------------------------------------------------------------------
46 #ifdef AI_DEBUG
47 override protected void AddDebugMessage(string str)
48 {
49 if (!m_Utility)
50 return;
51
52 AIAgent ownerAgent = m_Utility.GetOwner();
53 if (!ownerAgent)
54 return;
55
56 SCR_AIInfoBaseComponent infoComp = SCR_AIInfoBaseComponent.Cast(ownerAgent.FindComponent(SCR_AIInfoBaseComponent));
57 if (!infoComp)
58 return;
59
60 infoComp.AddDebugMessage(string.Format("%1: %2", this, str), msgType: EAIDebugMsgType.ACTION);
61 }
62 #endif
63
64 //---------------------------------------------------------------------------------------------------------------------------------
65 override void OnActionFailed()
66 {
67 super.OnActionFailed();
68 SCR_AIActivityBase relatedActivity = SCR_AIActivityBase.Cast(GetRelatedGroupActivity());
69 if (relatedActivity)
70 relatedActivity.OnChildBehaviorFinished(this);
71 }
72
73 //----------------------------------------------------------------------------------------------------------------------------------
74 override void OnActionCompleted()
75 {
76 super.OnActionCompleted();
77 SCR_AIActivityBase relatedActivity = SCR_AIActivityBase.Cast(GetRelatedGroupActivity());
78 if (relatedActivity)
79 relatedActivity.OnChildBehaviorFinished(this);
80 }
81
82};
83
84//---------------------------------------------------------------------------------------------------------------------------------
85class SCR_AIWaitBehavior : SCR_AIBehaviorBase
86{
87 void SCR_AIWaitBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
88 {
89 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/Wait.bt";
90 SetPriority(PRIORITY_BEHAVIOR_WAIT);
91 }
92
93 //---------------------------------------------------------------------------------------------------------------------------------
94 override int GetCause()
95 {
96 return SCR_EAIBehaviorCause.SAFE;
97 }
98};
99
100//---------------------------------------------------------------------------------------------------------------------------------
101class SCR_AIIdleBehavior : SCR_AIBehaviorBase
102{
103 void SCR_AIIdleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
104 {
105 if (!utility)
106 return;
107 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/Idle.bt";
108 SetPriority(PRIORITY_BEHAVIOR_IDLE);
109 }
110
111 override void OnActionSelected()
112 {
113 super.OnActionSelected();
114
115 // Temporary solution to make AI select some generic weapon suitable against infantry, like a rifle.
116 m_Utility.m_CombatComponent.SetExpectedEnemyType(EAIUnitType.UnitType_Infantry);
117 }
118
119 //---------------------------------------------------------------------------------------------------------------------------------
120 override int GetCause()
121 {
122 return SCR_EAIBehaviorCause.SAFE;
123 }
124};
void OnActionCompleted()
ResourceName m_sBehaviorTree
override void OnActionSelected()
void OnActionFailed()
int GetCause()
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
@ ALWAYS
@ SAFE
float m_fThreat
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
bool m_bResetLook
bool m_bUseCombatMove
enum SCR_EAIBehaviorCause m_Utility
SCR_AIActivityBase GetGroupActivityContext()
override void OnActionSelected()
SCR_EAIBehaviorCause
@ DANGER_LOW
@ DANGER_MEDIUM
@ GROUP_GOAL
@ COMBAT
@ SELF_AID
@ DANGER_HIGH
bool m_bAllowLook
EAIDebugMsgType
EAIUnitType
Definition EAIUnitType.c:13