Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AITargetClusterState.c
Go to the documentation of this file.
1
5
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
17{
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
26
27 // Values updated by ProcessTargets() call
37
38 // Target might remain marked as endangering even after it was destroyed, be careful when using this variable!
40
41
43 {
44 m_Cluster = cluster;
45 }
46
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
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
128 {
129 return 0.5 * (m_vBBMin + m_vBBMax);
130 }
131}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
float m_fMaxTimestamp
void ProcessTargets()
Counts targets and saves them in member variables.
float m_fTimer_ms
ref SCR_AIActivityBase m_Activity
vector m_vBBMax
vector m_vBBMin
int m_iCountDestroyed
EAITargetClusterState m_ePrevState
int m_iCountDetected
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
int m_iCountIdentified
float m_fDistMin
float m_fMaxAge_s
vector GetCenterPosition()
float GetTimeSinceLastNewInformation()
int m_iCountAlive
int m_iCountEndangering
enum EAITargetClusterState m_Cluster
EAITargetClusterState m_eState
EAITargetInfoCategory
@ LOST
float distance
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
@ MAX
proto native vector Vector(float x, float y, float z)