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_AIFindTargetToLookAt.c
Go to the documentation of this file.
1
class
SCR_AIFindTagetToLookAt
:
AITaskScripted
2
{
3
[
Attribute
(
"1"
,
UIWidgets
.EditBox,
"Max time since target was last seen"
,
""
)]
4
float
m_fTimeSinceSeenMax_S;
5
6
[
Attribute
(
"1"
,
UIWidgets
.EditBox,
"Max time since target was last detected"
,
""
)]
7
float
m_fTimeSinceDetectedMax_S;
8
9
protected
static
const
string
PORT_BASE_TARGET
=
"BaseTarget"
;
10
11
protected
PerceptionComponent
m_PerceptionComp
;
12
protected
SCR_AIConfigComponent
m_ConfigComp
;
13
14
#ifdef WORKBENCH
15
protected
ref
Shape
m_Shape;
16
#endif
17
18
19
override
void
OnInit
(AIAgent owner)
20
{
21
GenericEntity
ent =
GenericEntity
.Cast(owner.GetControlledEntity());
22
if
(!ent)
23
return
;
24
25
m_PerceptionComp
= PerceptionComponent.Cast(ent.
FindComponent
(PerceptionComponent));
26
m_ConfigComp
= SCR_AIConfigComponent.Cast(owner.FindComponent(SCR_AIConfigComponent));
27
}
28
29
30
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
31
{
32
if
(!
m_ConfigComp
|| !
m_ConfigComp
.m_EnablePerception || !
m_PerceptionComp
)
33
return
ENodeResult
.FAIL;
34
35
BaseTarget
outTarget = null;
36
37
float
updateInterval =
m_PerceptionComp
.GetUpdateInterval();
38
float
timeSinceSeenMax =
Math
.Max(m_fTimeSinceSeenMax_S, updateInterval) + 0.02;
39
float
timeSinceDetectedMax =
Math
.Max(m_fTimeSinceDetectedMax_S, updateInterval) + 0.02;
40
41
// Firse we search for target in detected category, since these targets are new and not identified yet
42
outTarget =
m_PerceptionComp
.GetClosestTarget(
ETargetCategory
.DETECTED, timeSinceSeenMax, timeSinceDetectedMax);
43
44
//if (outTarget)
45
// Print("SCR_AIFindTagetToLookAt: Found detected target");
46
47
// If there is no target in detected category, also check targets in enemy category
48
// Once target was identified, it stays in enemy category for a long time
49
if
(!outTarget)
50
{
51
outTarget =
m_PerceptionComp
.GetClosestTarget(
ETargetCategory
.ENEMY, timeSinceSeenMax, timeSinceDetectedMax);
52
//if (outTarget)
53
// Print("SCR_AIFindTagetToLookAt: Found enemy target");
54
}
55
56
//Print(string.Format("SCR_AIFindTagetToLookAt: Returning target: %1", outTarget));
57
58
// Temporary fix to not look at disarmed (unconscious) targets
59
// Ideally it should be handled through GetClosestTarget call
60
if
(outTarget && outTarget.IsDisarmed())
61
outTarget = null;
62
63
SetVariableOut
(
PORT_BASE_TARGET
, outTarget);
64
65
#ifdef WORKBENCH
66
if
(outTarget &&
DiagMenu
.GetBool(
SCR_DebugMenuID
.DEBUGUI_AI_SHOW_TARGET_LASTSEEN))
67
{
68
m_Shape =
Shape
.CreateSphere(
COLOR_BLUE_A
,
ShapeFlags
.NOOUTLINE|
ShapeFlags
.NOZBUFFER|
ShapeFlags
.TRANSP, outTarget.GetLastSeenPosition(), 0.1);
69
}
70
#endif
71
72
if
(outTarget)
73
return
ENodeResult
.SUCCESS;
74
else
75
return
ENodeResult
.FAIL;
76
}
77
78
79
protected
static
ref
TStringArray
s_aVarsOut
= {
80
PORT_BASE_TARGET
81
};
82
override
TStringArray
GetVariablesOut
()
83
{
84
return
s_aVarsOut
;
85
}
86
87
static
override
bool
VisibleInPalette
()
88
{
89
return
true
;
90
}
91
};
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition
DebugMenuID.c:4
AITaskScripted
Definition
AITaskScripted.c:13
BaseTarget
Definition
BaseTarget.c:13
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
GenericEntity
Definition
GenericEntity.c:16
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
Math
Definition
Math.c:13
Node::SetVariableOut
proto void SetVariableOut(string name, void val)
SCR_AIFindTagetToLookAt
Definition
SCR_AIFindTargetToLookAt.c:2
SCR_AIFindTagetToLookAt::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AIFindTargetToLookAt.c:19
SCR_AIFindTagetToLookAt::m_PerceptionComp
PerceptionComponent m_PerceptionComp
Definition
SCR_AIFindTargetToLookAt.c:11
SCR_AIFindTagetToLookAt::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIFindTargetToLookAt.c:87
SCR_AIFindTagetToLookAt::s_aVarsOut
static ref TStringArray s_aVarsOut
Definition
SCR_AIFindTargetToLookAt.c:79
SCR_AIFindTagetToLookAt::PORT_BASE_TARGET
static const string PORT_BASE_TARGET
Definition
SCR_AIFindTargetToLookAt.c:9
SCR_AIFindTagetToLookAt::GetVariablesOut
override TStringArray GetVariablesOut()
Definition
SCR_AIFindTargetToLookAt.c:82
SCR_AIFindTagetToLookAt::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIFindTargetToLookAt.c:30
SCR_AIFindTagetToLookAt::m_ConfigComp
SCR_AIConfigComponent m_ConfigComp
Definition
SCR_AIFindTargetToLookAt.c:12
Shape
Instance of created debug visualizer.
Definition
Shape.c:14
UIWidgets
Definition
attributes.c:40
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
COLOR_BLUE_A
const int COLOR_BLUE_A
Definition
constants.c:28
ShapeFlags
ShapeFlags
Definition
ShapeFlags.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ETargetCategory
ETargetCategory
Definition
ETargetCategory.c:13
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Soldier
SCR_AIFindTargetToLookAt.c
Generated by
1.17.0