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_AITargetClusterState.c
Go to the documentation of this file.
1
5
6
enum
EAITargetClusterState
7
{
8
UNINITIALIZED
,
// We have never processed it yet
9
NONE
,
// We don't know what to do with this yet
10
INVESTIGATING
,
// We are investigating the targets
11
ATTACKING
,
// We are attacking the targets
12
DEFENDING
,
// We defend ourselves against the targets
13
LOST
// We haven't detected anything here for a long time, it's too old
14
}
15
16
class
SCR_AITargetClusterState
17
{
18
SCR_AIGroupTargetCluster
m_Cluster
;
19
20
// Related to our processing of this cluster
21
ref
SCR_AIActivityBase
m_Activity
;
// Activity assigned for this cluster
22
float
m_fTimer_ms
= 0;
23
float
m_fMaxAge_s
;
// When age is above this, we switch to lost state
24
EAITargetClusterState
m_eState
=
EAITargetClusterState
.NONE;
// Those two must be different at start to trigger a state switch event
25
EAITargetClusterState
m_ePrevState
=
EAITargetClusterState
.UNINITIALIZED;
26
27
// Values updated by ProcessTargets() call
28
vector
m_vBBMax
;
29
vector
m_vBBMin
;
30
float
m_fDistMin
;
31
float
m_fMaxTimestamp
;
32
int
m_iCountDetected
;
33
int
m_iCountIdentified
;
34
int
m_iCountLost
;
35
int
m_iCountDestroyed
;
36
int
m_iCountAlive
;
37
38
// Target might remain marked as endangering even after it was destroyed, be careful when using this variable!
39
int
m_iCountEndangering
;
40
41
42
void
SCR_AITargetClusterState
(
SCR_AIGroupTargetCluster
cluster)
43
{
44
m_Cluster
= cluster;
45
}
46
48
void
ProcessTargets
()
49
{
50
int
nDetected = 0;
51
int
nIdentified = 0;
52
int
nLost = 0;
53
int
nDestroyed = 0;
54
int
nAlive = 0;
55
56
float
maxTimestamp = 0;
57
int
nEndangering = 0;
58
float
distMin =
float
.MAX;
59
60
vector
bbMax =
vector
.Zero;
61
vector
bbMin =
vector
.Zero;
62
63
if
(
m_Cluster
&& !
m_Cluster
.m_aTargets.IsEmpty())
64
{
65
bbMax =
Vector
(-
float
.
MAX
, -
float
.
MAX
, -
float
.
MAX
);
66
bbMin =
Vector
(
float
.
MAX
,
float
.
MAX
,
float
.
MAX
);
67
68
foreach
(
int
tgtId, SCR_AITargetInfo target :
m_Cluster
.m_aTargets)
69
{
70
EAITargetInfoCategory
category
= target.m_eCategory;
71
switch
(
category
)
72
{
73
case
EAITargetInfoCategory
.DETECTED: nDetected++; nAlive++;
break
;
74
case
EAITargetInfoCategory
.IDENTIFIED: nIdentified++; nAlive++;
break
;
75
case
EAITargetInfoCategory
.DESTROYED: nDestroyed++;
break
;
76
case
EAITargetInfoCategory
.LOST: nLost++; nAlive++;
break
;
77
case
EAITargetInfoCategory
.DISARMED: nDestroyed++;
break
;
// Disarmed counts as destroyed. All outside code should not know the target is disarmed and should pretend the target is destroyed.
78
}
79
80
if
(target.m_fTimestamp > maxTimestamp)
81
maxTimestamp = target.m_fTimestamp;
82
83
float
distance
=
m_Cluster
.m_aDistances[tgtId];
84
if
(
distance
< distMin)
85
distMin =
distance
;
86
87
vector
tgtPos = target.m_vWorldPos;
88
for
(
int
i = 0; i < 3; i++)
89
{
90
float
tgtPosI = tgtPos[i];
91
if
(tgtPosI > bbMax[i])
92
bbMax[i] = tgtPosI;
93
if
(tgtPosI < bbMin[i])
94
bbMin[i] = tgtPosI;
95
}
96
97
if
(target.m_bEndangering)
98
nEndangering++;
99
}
100
}
101
102
m_iCountLost
= nLost;
103
m_iCountDetected
= nDetected;
104
m_iCountIdentified
= nIdentified;
105
m_iCountDestroyed
= nDestroyed;
106
m_iCountAlive
= nAlive;
107
m_iCountEndangering
= nEndangering;
108
m_fMaxTimestamp
= maxTimestamp;
109
m_vBBMin
= bbMin;
110
m_vBBMax
= bbMax;
111
m_fDistMin
= distMin;
112
}
113
116
float
GetTimeSinceLastNewInformation
()
117
{
118
PerceptionManager pm =
GetGame
().GetPerceptionManager();
119
if
(!pm)
120
return
0;
121
122
return
pm.GetTime() -
m_fMaxTimestamp
;
123
}
124
125
//---------------------------------------------------------------------------
126
// Returns center position of cluster based on cluster bouding box
127
vector
GetCenterPosition
()
128
{
129
return
0.5 * (
m_vBBMin
+
m_vBBMax
);
130
}
131
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_AIActivityBase
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
Definition
SCR_AIActivity.c:44
m_fMaxTimestamp
float m_fMaxTimestamp
Definition
SCR_AITargetClusterState.c:31
m_iCountLost
int m_iCountLost
Definition
SCR_AITargetClusterState.c:34
ProcessTargets
void ProcessTargets()
Counts targets and saves them in member variables.
Definition
SCR_AITargetClusterState.c:48
m_fTimer_ms
float m_fTimer_ms
Definition
SCR_AITargetClusterState.c:22
m_Activity
ref SCR_AIActivityBase m_Activity
Definition
SCR_AITargetClusterState.c:21
m_vBBMax
vector m_vBBMax
Definition
SCR_AITargetClusterState.c:28
m_vBBMin
vector m_vBBMin
Definition
SCR_AITargetClusterState.c:29
m_iCountDestroyed
int m_iCountDestroyed
Definition
SCR_AITargetClusterState.c:35
m_ePrevState
EAITargetClusterState m_ePrevState
Definition
SCR_AITargetClusterState.c:25
m_iCountDetected
int m_iCountDetected
Definition
SCR_AITargetClusterState.c:32
SCR_AITargetClusterState
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
Definition
SCR_AITargetClusterState.c:42
m_iCountIdentified
int m_iCountIdentified
Definition
SCR_AITargetClusterState.c:33
m_fDistMin
float m_fDistMin
Definition
SCR_AITargetClusterState.c:30
m_fMaxAge_s
float m_fMaxAge_s
Definition
SCR_AITargetClusterState.c:23
GetCenterPosition
vector GetCenterPosition()
Definition
SCR_AITargetClusterState.c:127
EAITargetClusterState
EAITargetClusterState
Definition
SCR_AITargetClusterState.c:7
ATTACKING
@ ATTACKING
Definition
SCR_AITargetClusterState.c:11
DEFENDING
@ DEFENDING
Definition
SCR_AITargetClusterState.c:12
INVESTIGATING
@ INVESTIGATING
Definition
SCR_AITargetClusterState.c:10
UNINITIALIZED
@ UNINITIALIZED
Definition
SCR_AITargetClusterState.c:8
GetTimeSinceLastNewInformation
float GetTimeSinceLastNewInformation()
Definition
SCR_AITargetClusterState.c:116
m_iCountAlive
int m_iCountAlive
Definition
SCR_AITargetClusterState.c:36
m_iCountEndangering
int m_iCountEndangering
Definition
SCR_AITargetClusterState.c:39
m_Cluster
enum EAITargetClusterState m_Cluster
m_eState
EAITargetClusterState m_eState
Definition
SCR_AITargetClusterState.c:24
EAITargetInfoCategory
EAITargetInfoCategory
Definition
SCR_AITargetInfo.c:2
LOST
@ LOST
Definition
SCR_AITargetInfo.c:6
distance
float distance
Definition
SCR_DestructibleTreeV2.c:29
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
SCR_AIGroupTargetCluster
Definition
SCR_AIGroupTargetCluster.c:42
vector
Definition
vector.c:13
NONE
@ NONE
When Shape is created and not initialized yet.
Definition
ShapeType.c:15
MAX
@ MAX
Definition
ETurretContextID.c:19
Vector
proto native vector Vector(float x, float y, float z)
scripts
Game
AI
Group
SCR_AITargetClusterState.c
Generated by
1.17.0