Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDefendFromClusterActivity.c
Go to the documentation of this file.
2 {
3  bool m_bOrdersSent = false;
4 
5  //------------------------------------------------------------------------------------
6  void SCR_AIDefendFromClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint,
7  notnull SCR_AITargetClusterState clusterState,
8  notnull TFireteamLockRefArray fireteams)
9  {
10  SetPriority(PRIORITY_ACTIVITY_DEFEND_FROM_CLUSTER);
11  SetIsUniqueInActionQueue(false);
12 
13  foreach (auto ft : fireteams)
14  {
15  RegisterFireteam(ft);
16  }
17  }
18 
19  //------------------------------------------------------------------------------------
20  override void OnFireteamRemovedFromGroup(SCR_AIGroupFireteam ft)
21  {
22  UnregisterFireteam(ft);
23  }
24 
25  //------------------------------------------------------------------------------------
26  override void OnActionSelected()
27  {
28  super.OnActionSelected();
29 
30  if (!m_bOrdersSent)
31  {
32  SendDefendMessages();
33  m_bOrdersSent = true;
34  }
35 
36  // !! It runs once and then is suspended, we don't need to run the behavior tree for it.
37  //SetActionIsSuspended(true);
38  }
39 
40  //------------------------------------------------------------------------------------
41  override void OnActionDeselected()
42  {
43  super.OnActionDeselected();
44  SendCancelMessages();
45  }
46 
47  //------------------------------------------------------------------------------------
48  void SendDefendMessages()
49  {
50  AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
51  if (!comms)
52  return;
53 
54  array<AIAgent> agents = {};
55  foreach (SCR_AIGroupFireteamLock ft : m_aAssignedFireteams)
56  {
57  ft.GetFireteam().GetMembers(agents);
58  foreach (AIAgent agent : agents)
59  {
60  if (!agent)
61  continue;
62 
63  if (SCR_AICompartmentHandling.IsInCompartment(agent))
64  continue;
65 
66  // Now we send attack message, but forbit investigation there
67  SCR_AIMessage_AttackCluster msg = SCR_AIMessage_AttackCluster.Create(m_ClusterState, false);
68  msg.m_RelatedGroupActivity = this;
69  msg.SetReceiver(agent);
70  comms.RequestBroadcast(msg, agent);
71  }
72  }
73  }
74 
75  //------------------------------------------------------------------------------------
76  void SendCancelMessages()
77  {
78  AICommunicationComponent comms = m_Utility.m_Owner.GetCommunicationComponent();
79  if (!comms)
80  return;
81 
82  array<AIAgent> agents = {};
83  foreach (SCR_AIGroupFireteamLock ft : m_aAssignedFireteams) // Send to all fireteams
84  {
85  ft.GetFireteam().GetMembers(agents);
86  foreach (AIAgent agent : agents)
87  {
88  if (!agent)
89  continue;
90 
91  SCR_AIMessage_Cancel msgCancel = SCR_AIMessage_Cancel.Create(this);
92  msgCancel.SetReceiver(agent);
93  comms.RequestBroadcast(msgCancel, agent);
94  }
95  }
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  override string GetDebugPanelText()
100  {
101  // List all assigned fireteams
102  string str = "FTs: (";
103  foreach (SCR_AIGroupFireteamLock ftLock : m_aAssignedFireteams)
104  {
105  str = str + string.Format("%1, ", m_Utility.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
106  }
107  str = str + string.Format(") => C: %1", m_Utility.m_Perception.GetTargetClusterStateId(m_ClusterState));
108 
109  return str;
110  }
111 }
SCR_AIDefendFromClusterActivity
Definition: SCR_AIDefendFromClusterActivity.c:1
SCR_AIMessage_Cancel
Definition: SCR_AIMessage.c:263
SCR_AIMessage_AttackCluster
Definition: SCR_AIMessage.c:305
SCR_AIGroupFireteam
Definition: SCR_AIGroupFireteam.c:1
SCR_AIFireteamsClusterActivity
Definition: SCR_AIFireteamsClusterActivity.c:6
TFireteamLockRefArray
array< ref SCR_AIGroupFireteamLock > TFireteamLockRefArray
Definition: SCR_AIGroupFireteamLock.c:6
SCR_AIGroupFireteamLock
Definition: SCR_AIGroupFireteamLock.c:9
SCR_AITargetClusterState
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
Definition: SCR_AITargetClusterState.c:38
SCR_AICompartmentHandling
Definition: SCR_AIUtils.c:76