Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIAttackClusterActivity.c
Go to the documentation of this file.
2{
5
6 bool m_bOrdersSent = false;
7
8 //------------------------------------------------------------------------------------
9 void SCR_AIAttackClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint,
10 notnull SCR_AITargetClusterState clusterState,
11 notnull TFireteamLockRefArray ftAttack, notnull TFireteamLockRefArray ftCover)
12 {
13 SetPriority(PRIORITY_ACTIVITY_ATTACK_CLUSTER);
14 SetIsUniqueInActionQueue(false);
15
16 m_ClusterState = clusterState;
17
18 foreach (auto ft : ftAttack)
19 {
21 m_aFireteamsAttack.Insert(ft);
22 }
23
24 foreach (auto ft : ftCover)
25 {
27 m_aFireteamsCover.Insert(ft);
28 }
29 }
30
31 //------------------------------------------------------------------------------------
32 void GetSpecificFireteams(notnull TFireteamLockRefArray fireteamsAttack, notnull TFireteamLockRefArray fireteamsCover)
33 {
34 fireteamsAttack.Clear();
35 fireteamsCover.Clear();
36
37 foreach (auto ft : m_aFireteamsAttack)
38 fireteamsAttack.Insert(ft);
39
40 foreach (auto ft : m_aFireteamsCover)
41 fireteamsCover.Insert(ft);
42 }
43
44 //------------------------------------------------------------------------------------
46 {
48 {
49 // Was an attacking fireteam
50 if (m_aFireteamsAttack.IsEmpty())
51 {
52 #ifdef AI_DEBUG
53 AddDebugMessage("All attacking fireteams are destroyed, activity is failed");
54 #endif
55 Fail();
56 }
57 }
58 else
59 {
61 }
62
64 }
65
66 //------------------------------------------------------------------------------------
67 override void OnActionSelected()
68 {
69 super.OnActionSelected();
70
71 if (!m_bOrdersSent)
72 {
73 SCR_ChimeraAIAgent leader = SCR_ChimeraAIAgent.Cast(m_Utility.m_Owner.GetLeaderAgent());
74 if (leader)
75 {
76 SCR_AICommsHandler commsHandler = SCR_AISoundHandling.FindCommsHandler(leader);
77 if (!commsHandler.CanBypass())
78 {
80 {
81 IEntity talkRequestEntity = ftLock.GetFireteam().GetFirstMemberEntity();
82
83 int flankValue = Math.RandomIntInclusive(0, 1);
84 SCR_AITalkRequest rq = new SCR_AITalkRequest(ECommunicationType.REPORT_FLANK, talkRequestEntity, vector.Zero, flankValue, false, false, SCR_EAITalkRequestPreset.MANDATORY);
85 commsHandler.AddRequest(rq);
86 }
87 }
88 }
89
91 m_bOrdersSent = true;
92 }
93
94 // !! It runs once and then is suspended, we don't need to run the behavior tree for it.
95 //SetActionIsSuspended(true);
96 }
97
98 //------------------------------------------------------------------------------------
99 override void OnActionDeselected()
100 {
101 super.OnActionDeselected();
102 m_bOrdersSent = false;
104 }
105
106 //------------------------------------------------------------------------------------
107 override void OnActionCompleted()
108 {
109 super.OnActionCompleted();
111 }
112
113 //------------------------------------------------------------------------------------
114 override void OnActionFailed()
115 {
116 super.OnActionFailed();
118 }
119
120 //------------------------------------------------------------------------------------
121 override void OnActionRemoved()
122 {
123 // Release fireteams instantly, if action is still referenced by something else
124 super.OnActionRemoved();
125 m_aFireteamsAttack.Clear();
126 m_aFireteamsCover.Clear();
127 }
128
129
130 //------------------------------------------------------------------------------------
132 {
133 AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
134 if (!comms)
135 return;
136
137 array<AIAgent> agents = {};
139 {
140 ft.GetFireteam().GetMembers(agents);
141 foreach (AIAgent agent : agents)
142 {
143 if (!agent)
144 continue;
145
146 if (SCR_AICompartmentHandling.IsInCompartment(agent))
147 continue;
148
150 msg.m_RelatedGroupActivity = this;
151 msg.SetReceiver(agent);
152 comms.RequestBroadcast(msg, agent);
153 }
154 }
155
157 {
158 ft.GetFireteam().GetMembers(agents);
159 foreach (AIAgent agent : agents)
160 {
161 if (!agent)
162 continue;
163
164 if (SCR_AICompartmentHandling.IsInCompartment(agent))
165 continue;
166
167 SCR_AIMessage_AttackCluster msg = SCR_AIMessage_AttackCluster.Create(m_ClusterState, true); // Attacking fireteam is allowed to investigate
168 msg.m_RelatedGroupActivity = this;
169 msg.SetReceiver(agent);
170 comms.RequestBroadcast(msg, agent);
171 }
172 }
173 }
174
175 //------------------------------------------------------------------------------------
177 {
178 AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
179 if (!comms)
180 return;
181
182 array<AIAgent> agents = {};
183 foreach (SCR_AIGroupFireteamLock ft : m_aAssignedFireteams) // Send to all fireteams
184 {
185 ft.GetFireteam().GetMembers(agents);
186 foreach (AIAgent agent : agents)
187 {
188 if (!agent)
189 continue;
190
192 msg.m_RelatedGroupActivity = this;
193 msg.SetReceiver(agent);
194 comms.RequestBroadcast(msg, agent);
195
196 SCR_AIMessage_Cancel msgCancel = SCR_AIMessage_Cancel.Create(this);
197 msgCancel.SetReceiver(agent);
198 comms.RequestBroadcast(msgCancel, agent);
199 }
200 }
201 }
202
203 //------------------------------------------------------------------------------------------------
204 override string GetDebugPanelText()
205 {
206 // List all assigned fireteams
207 string str = "FTs: (";
209 str = str + string.Format("%1, ", m_Utility.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
210 str = str + "| ";
212 str = str + string.Format("%1, ", m_Utility.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
213
214 str = str + string.Format(") => C: %1", m_Utility.m_Perception.GetTargetClusterStateId(m_ClusterState));
215
216 return str;
217 }
218}
void Fail(bool doNotCompleteWaypoint)
enum SCR_EAIActivityCause m_Utility
array< SCR_AIGroupFireteamLock > TFireteamLockArray
array< ref SCR_AIGroupFireteamLock > TFireteamLockRefArray
SCR_AIMessage_AttackCluster SCR_AIMessageGoal SCR_AIMessage_AttackClusterDone()
ECommunicationType
void SCR_AITalkRequest(ECommunicationType type, IEntity entity, vector pos, int enumSignal, bool transmitIfNoReceivers, bool transmitIfPassenger, SCR_EAITalkRequestPreset preset)
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
Definition Math.c:13
void GetSpecificFireteams(notnull TFireteamLockRefArray fireteamsAttack, notnull TFireteamLockRefArray fireteamsCover)
void SCR_AIAttackClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint, notnull SCR_AITargetClusterState clusterState, notnull TFireteamLockRefArray ftAttack, notnull TFireteamLockRefArray ftCover)
override void OnFireteamRemovedFromGroup(SCR_AIGroupFireteam ft)
ref TFireteamLockArray m_aFireteamsAttack
void AddRequest(SCR_AITalkRequest request)
bool CanBypass(SCR_AITalkRequest request=null)
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)