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_AIInvestigateClusterActivity.c
Go to the documentation of this file.
1
class
SCR_AIInvestigateClusterActivity
:
SCR_AIFireteamsClusterActivity
2
{
3
protected
ref
TFireteamLockRefArray
m_aFireteamsInvestigate
= {};
4
protected
ref
TFireteamLockRefArray
m_aFireteamsCover
= {};
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
{
22
RegisterFireteam
(ft);
23
m_aFireteamsInvestigate
.Insert(ft);
24
}
25
26
foreach
(
auto
ft : ftCover)
27
{
28
RegisterFireteam
(ft);
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
//------------------------------------------------------------------------------------
47
override
void
OnFireteamRemovedFromGroup
(
SCR_AIGroupFireteam
ft)
48
{
49
// Was it an investigating fireteam?
50
if
(
SCR_AIGroupFireteamLock
.
RemoveFireteamLock
(
m_aFireteamsInvestigate
, ft))
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
{
63
SCR_AIGroupFireteamLock
.
RemoveFireteamLock
(
m_aFireteamsCover
, ft);
64
}
65
66
UnregisterFireteam
(ft);
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
;
96
SendCancelMessages
();
97
}
98
99
//------------------------------------------------------------------------------------
100
override
void
OnActionCompleted
()
101
{
102
super.OnActionCompleted();
103
SendCancelMessages
();
104
}
105
106
//------------------------------------------------------------------------------------
107
override
void
OnActionFailed
()
108
{
109
super.OnActionFailed();
110
SendCancelMessages
();
111
}
112
113
//------------------------------------------------------------------------------------
114
override
void
OnActionRemoved
()
115
{
116
// Release fireteams instantly, if action is still referenced by something else
117
super.OnActionRemoved();
118
m_aFireteamsInvestigate
.Clear();
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 = {};
131
foreach
(
SCR_AIGroupFireteamLock
ft :
m_aAssignedFireteams
)
132
{
133
ft.GetFireteam().GetMembers(agents);
134
foreach
(AIAgent agent : agents)
135
{
136
if
(!agent)
137
continue
;
138
139
SCR_AIMessage_Cancel
msg =
SCR_AIMessage_Cancel
.Create(
this
);
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 = {};
151
foreach
(
SCR_AIGroupFireteamLock
ft :
m_aFireteamsInvestigate
)
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
169
foreach
(
SCR_AIGroupFireteamLock
ft :
m_aFireteamsCover
)
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
180
SCR_AIMessage_CoverCluster
msg =
new
SCR_AIMessage_CoverCluster
();
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: ("
;
206
foreach
(
SCR_AIGroupFireteamLock
ftLock :
m_aFireteamsInvestigate
)
207
str = str +
string
.Format(
"%1, "
,
m_Utility
.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
208
str = str +
"| "
;
209
foreach
(
SCR_AIGroupFireteamLock
ftLock :
m_aFireteamsCover
)
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
}
Fail
void Fail(bool doNotCompleteWaypoint)
Definition
SCR_AIActivity.c:75
m_Utility
enum SCR_EAIActivityCause m_Utility
TFireteamLockRefArray
array< ref SCR_AIGroupFireteamLock > TFireteamLockRefArray
Definition
SCR_AIGroupFireteamLock.c:6
SCR_AIMessage_CoverCluster
void SCR_AIMessage_CoverCluster()
Definition
SCR_AIMessage.c:354
SCR_AITargetClusterState
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
Definition
SCR_AITargetClusterState.c:42
Math
Definition
Math.c:13
SCR_AICompartmentHandling
Definition
SCR_AIUtils.c:153
SCR_AIFireteamsActivity::m_aAssignedFireteams
ref TFireteamLockRefArray m_aAssignedFireteams
Definition
SCR_AIFireteamsActivity.c:8
SCR_AIFireteamsActivity::UnregisterFireteam
void UnregisterFireteam(notnull SCR_AIGroupFireteamLock ftLock)
Definition
SCR_AIFireteamsActivity.c:54
SCR_AIFireteamsActivity::RegisterFireteam
void RegisterFireteam(notnull SCR_AIGroupFireteamLock ftLock)
Registers fireteam within this activity.
Definition
SCR_AIFireteamsActivity.c:45
SCR_AIFireteamsClusterActivity::SCR_AIFireteamsClusterActivity
void SCR_AIFireteamsClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint, notnull SCR_AITargetClusterState clusterState)
Definition
SCR_AIFireteamsClusterActivity.c:11
SCR_AIFireteamsClusterActivity::m_ClusterState
SCR_AITargetClusterState m_ClusterState
Definition
SCR_AIFireteamsClusterActivity.c:8
SCR_AIGroupFireteam
Definition
SCR_AIGroupFireteam.c:4
SCR_AIGroupFireteamLock
Definition
SCR_AIGroupFireteamLock.c:10
SCR_AIGroupFireteamLock::RemoveFireteamLock
static bool RemoveFireteamLock(TFireteamLockRefArray locksArray, SCR_AIGroupFireteam ft)
Definition
SCR_AIGroupFireteamLock.c:85
SCR_AIGroupUtilityComponent
Definition
SCR_AIGroupUtilityComponent.c:18
SCR_AIInvestigateClusterActivity::m_bOrdersSent
bool m_bOrdersSent
Definition
SCR_AIInvestigateClusterActivity.c:6
SCR_AIInvestigateClusterActivity::OnActionCompleted
override void OnActionCompleted()
Definition
SCR_AIInvestigateClusterActivity.c:100
SCR_AIInvestigateClusterActivity::OnActionDeselected
override void OnActionDeselected()
Definition
SCR_AIInvestigateClusterActivity.c:92
SCR_AIInvestigateClusterActivity::INVESTIGATION_RADIUS_MIN
static const float INVESTIGATION_RADIUS_MIN
Definition
SCR_AIInvestigateClusterActivity.c:8
SCR_AIInvestigateClusterActivity::SendInvestigateMessages
void SendInvestigateMessages(AICommunicationComponent comms, vector pos, float radius)
Definition
SCR_AIInvestigateClusterActivity.c:148
SCR_AIInvestigateClusterActivity::GetSpecificFireteams
void GetSpecificFireteams(notnull TFireteamLockRefArray fireteamsInvestigate, notnull TFireteamLockRefArray fireteamsCover)
Definition
SCR_AIInvestigateClusterActivity.c:34
SCR_AIInvestigateClusterActivity::m_aFireteamsInvestigate
ref TFireteamLockRefArray m_aFireteamsInvestigate
Definition
SCR_AIInvestigateClusterActivity.c:3
SCR_AIInvestigateClusterActivity::OnActionFailed
override void OnActionFailed()
Definition
SCR_AIInvestigateClusterActivity.c:107
SCR_AIInvestigateClusterActivity::SCR_AIInvestigateClusterActivity
void SCR_AIInvestigateClusterActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint, notnull SCR_AITargetClusterState clusterState, notnull TFireteamLockRefArray ftInvestigate, notnull TFireteamLockRefArray ftCover)
Definition
SCR_AIInvestigateClusterActivity.c:13
SCR_AIInvestigateClusterActivity::OnFireteamRemovedFromGroup
override void OnFireteamRemovedFromGroup(SCR_AIGroupFireteam ft)
Definition
SCR_AIInvestigateClusterActivity.c:47
SCR_AIInvestigateClusterActivity::SendCancelMessages
void SendCancelMessages()
Definition
SCR_AIInvestigateClusterActivity.c:123
SCR_AIInvestigateClusterActivity::OnActionRemoved
override void OnActionRemoved()
Definition
SCR_AIInvestigateClusterActivity.c:114
SCR_AIInvestigateClusterActivity::CalculateInvestigationArea
static void CalculateInvestigationArea(notnull SCR_AITargetClusterState s, out vector outCenterPos, out float outRadius)
Calculates position and radius of investigation area.
Definition
SCR_AIInvestigateClusterActivity.c:190
SCR_AIInvestigateClusterActivity::OnActionSelected
override void OnActionSelected()
Definition
SCR_AIInvestigateClusterActivity.c:70
SCR_AIInvestigateClusterActivity::m_aFireteamsCover
ref TFireteamLockRefArray m_aFireteamsCover
Definition
SCR_AIInvestigateClusterActivity.c:4
SCR_AIInvestigateClusterActivity::GetDebugPanelText
override string GetDebugPanelText()
Definition
SCR_AIInvestigateClusterActivity.c:202
SCR_AIMessage_Cancel
Definition
SCR_AIMessage.c:269
SCR_AIMessage_CoverCluster
Definition
SCR_AIMessage.c:344
SCR_AIMessage_Investigate
Definition
SCR_AIMessage.c:417
vector
Definition
vector.c:13
scripts
Game
AI
Behavior
ClusterActivities
SCR_AIInvestigateClusterActivity.c
Generated by
1.17.0