Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIInvestigateClusterActivity.c
Go to the documentation of this file.
2{
5
6 protected bool m_bOrdersSent = false;
7
8 protected static const float INVESTIGATION_RADIUS_MIN = 20.0;
9
10 //------------------------------------------------------------------------------------
13 void SCR_AIInvestigateClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint,
14 notnull SCR_AITargetClusterState clusterState,
15 notnull TFireteamLockRefArray ftInvestigate, notnull TFireteamLockRefArray ftCover)
16 {
17 SetPriority(PRIORITY_ACTIVITY_INVESTIGATE_CLUSTER);
18 SetIsUniqueInActionQueue(false);
19
20 foreach (auto ft : ftInvestigate)
21 {
23 m_aFireteamsInvestigate.Insert(ft);
24 }
25
26 foreach (auto ft : ftCover)
27 {
29 m_aFireteamsCover.Insert(ft);
30 }
31 }
32
33 //------------------------------------------------------------------------------------
34 void GetSpecificFireteams(notnull TFireteamLockRefArray fireteamsInvestigate, notnull TFireteamLockRefArray fireteamsCover)
35 {
36 fireteamsInvestigate.Clear();
37 fireteamsCover.Clear();
38
39 foreach (auto ft : m_aFireteamsInvestigate)
40 fireteamsInvestigate.Insert(ft);
41
42 foreach (auto ft : m_aFireteamsCover)
43 fireteamsCover.Insert(ft);
44 }
45
46 //------------------------------------------------------------------------------------
48 {
49 // Was it an investigating fireteam?
51 {
52 if (m_aFireteamsInvestigate.IsEmpty())
53 {
54 #ifdef AI_DEBUG
55 AddDebugMessage("All investigating fireteams are destroyed, activity is failed");
56 #endif
57
58 Fail();
59 }
60 }
61 else
62 {
64 }
65
67 }
68
69 //------------------------------------------------------------------------------------
70 override void OnActionSelected()
71 {
72 super.OnActionSelected();
73
74 if (!m_bOrdersSent)
75 {
76 vector investigatePos;
77 float investigateRadius;
78 CalculateInvestigationArea(m_ClusterState, investigatePos, investigateRadius);
79
80 AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
81 if (!comms)
82 return;
83
84 SendInvestigateMessages(comms, investigatePos, investigateRadius);
85 }
86
87 // !! It runs once and then is suspended, we don't need to run the behavior tree for it.
88 //SetActionIsSuspended(true);
89 }
90
91 //------------------------------------------------------------------------------------
92 override void OnActionDeselected()
93 {
94 super.OnActionDeselected();
95 m_bOrdersSent = false;
97 }
98
99 //------------------------------------------------------------------------------------
100 override void OnActionCompleted()
101 {
102 super.OnActionCompleted();
104 }
105
106 //------------------------------------------------------------------------------------
107 override void OnActionFailed()
108 {
109 super.OnActionFailed();
111 }
112
113 //------------------------------------------------------------------------------------
114 override void OnActionRemoved()
115 {
116 // Release fireteams instantly, if action is still referenced by something else
117 super.OnActionRemoved();
119 m_aFireteamsCover.Clear();
120 }
121
122 //------------------------------------------------------------------------------------
123 protected void SendCancelMessages()
124 {
125 AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
126 if (!comms)
127 return;
128
129 // Send to all agents in all assigned fireteams
130 array<AIAgent> agents = {};
132 {
133 ft.GetFireteam().GetMembers(agents);
134 foreach (AIAgent agent : agents)
135 {
136 if (!agent)
137 continue;
138
140
141 msg.SetReceiver(agent);
142 comms.RequestBroadcast(msg, agent);
143 }
144 }
145 }
146
147 //------------------------------------------------------------------------------------
148 protected void SendInvestigateMessages(AICommunicationComponent comms, vector pos, float radius)
149 {
150 array<AIAgent> agents = {};
152 {
153 ft.GetFireteam().GetMembers(agents);
154 foreach (AIAgent agent : agents)
155 {
156 if (!agent)
157 continue;
158
159 if (SCR_AICompartmentHandling.IsInCompartment(agent))
160 continue;
161
162 // Duration is large, since soldiers' investigation is tied to this activity
163 SCR_AIMessage_Investigate msg = SCR_AIMessage_Investigate.Create(this,pos, radius, true, duration: 10000);
164 msg.SetReceiver(agent);
165 comms.RequestBroadcast(msg, agent);
166 }
167 }
168
170 {
171 ft.GetFireteam().GetMembers(agents);
172 foreach (AIAgent agent : agents)
173 {
174 if (!agent)
175 continue;
176
177 if (SCR_AICompartmentHandling.IsInCompartment(agent))
178 continue;
179
181 msg.m_RelatedGroupActivity = this;
182 msg.SetReceiver(agent);
183 comms.RequestBroadcast(msg, agent);
184 }
185 }
186 }
187
188 //------------------------------------------------------------------------------------
190 static void CalculateInvestigationArea(notnull SCR_AITargetClusterState s, out vector outCenterPos, out float outRadius)
191 {
192 const float minRadius = INVESTIGATION_RADIUS_MIN;
193
194 vector center = 0.5*(s.m_vBBMin + s.m_vBBMax);
195 float radius = Math.Max(minRadius, vector.DistanceXZ(center, s.m_vBBMax));
196
197 outCenterPos = center;
198 outRadius = radius;
199 }
200
201 //------------------------------------------------------------------------------------------------
202 override string GetDebugPanelText()
203 {
204 // List all assigned fireteams
205 string str = "FTs: (";
207 str = str + string.Format("%1, ", m_Utility.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
208 str = str + "| ";
210 str = str + string.Format("%1, ", m_Utility.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
211
212 str = str + string.Format(") => C: %1", m_Utility.m_Perception.GetTargetClusterStateId(m_ClusterState));
213
214 return str;
215 }
216}
void Fail(bool doNotCompleteWaypoint)
enum SCR_EAIActivityCause m_Utility
array< ref SCR_AIGroupFireteamLock > TFireteamLockRefArray
void SCR_AIMessage_CoverCluster()
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
Definition Math.c:13
ref TFireteamLockRefArray m_aAssignedFireteams
void UnregisterFireteam(notnull SCR_AIGroupFireteamLock ftLock)
void RegisterFireteam(notnull SCR_AIGroupFireteamLock ftLock)
Registers fireteam within this activity.
void SCR_AIFireteamsClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint, notnull SCR_AITargetClusterState clusterState)
static bool RemoveFireteamLock(TFireteamLockRefArray locksArray, SCR_AIGroupFireteam ft)
void SendInvestigateMessages(AICommunicationComponent comms, vector pos, float radius)
void GetSpecificFireteams(notnull TFireteamLockRefArray fireteamsInvestigate, notnull TFireteamLockRefArray fireteamsCover)
void SCR_AIInvestigateClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint, notnull SCR_AITargetClusterState clusterState, notnull TFireteamLockRefArray ftInvestigate, notnull TFireteamLockRefArray ftCover)
override void OnFireteamRemovedFromGroup(SCR_AIGroupFireteam ft)
static void CalculateInvestigationArea(notnull SCR_AITargetClusterState s, out vector outCenterPos, out float outRadius)
Calculates position and radius of investigation area.