Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGetTarget.c
Go to the documentation of this file.
2{
3 [Attribute("1", UIWidgets.EditBox, "Filter target by how long ago it was seen", "")]
4 float m_fTimeSinceSeenMax;
5
6 [Attribute("20", UIWidgets.EditBox, "Filter target by how far it can be", "")]
7 float m_fDetectionRange;
8
9 [Attribute("0", UIWidgets.ComboBox, "Wanted target type", "", ParamEnumArray.FromEnum(ETargetCategory) )]
10 ETargetCategory m_eTargetType;
11
12 protected static const string PORT_BASE_TARGET = "BaseTarget";
13
14 protected PerceptionComponent m_PerceptionComp;
15 #ifdef WORKBENCH
16 protected ref Shape m_Shape;
17 #endif
18
19 static override bool VisibleInPalette()
20 {
21 return true;
22 }
23
24 protected override string GetNodeMiddleText()
25 {
26 return "LastSeenMax: " + m_fTimeSinceSeenMax.ToString() + "\n" +
27 "TargetCategory: " + typename.EnumToString(ETargetCategory, m_eTargetType);
28 }
29
30 override void OnInit(AIAgent owner)
31 {
32 GenericEntity ent = GenericEntity.Cast(owner.GetControlledEntity());
33 if (!ent)
34 return;
35
36 m_PerceptionComp = PerceptionComponent.Cast(ent.FindComponent(PerceptionComponent));
37 }
38
39 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
40 {
41 BaseTarget baseTarget = m_PerceptionComp.GetClosestTarget(m_eTargetType, m_fTimeSinceSeenMax, m_fTimeSinceSeenMax);
42
43 if (!baseTarget || baseTarget.GetDistance() > m_fDetectionRange)
44 return ENodeResult.FAIL;
45
46#ifdef WORKBENCH
47 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_AI_SHOW_TARGET_LASTSEEN))
48 m_Shape = Shape.CreateSphere(COLOR_BLUE_A, ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER|ShapeFlags.TRANSP, baseTarget.GetLastSeenPosition(), 0.1);
49#endif
51 return ENodeResult.SUCCESS;
52 }
53
54 protected static ref TStringArray s_aVarsOut = {
56 };
58 {
59 return s_aVarsOut;
60 }
61};
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto external Managed FindComponent(typename typeName)
proto void SetVariableOut(string name, void val)
override string GetNodeMiddleText()
static override bool VisibleInPalette()
override void OnInit(AIAgent owner)
PerceptionComponent m_PerceptionComp
static ref TStringArray s_aVarsOut
override TStringArray GetVariablesOut()
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
static const string PORT_BASE_TARGET
Instance of created debug visualizer.
Definition Shape.c:14
ENodeResult
Definition ENodeResult.c:13
const int COLOR_BLUE_A
Definition constants.c:28
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
ETargetCategory
array< string > TStringArray
Definition Types.c:385