Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetTarget.c
Go to the documentation of this file.
1 class SCR_AIGetTarget: AITaskScripted
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  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
50  SetVariableOut(PORT_BASE_TARGET, baseTarget);
51  return ENodeResult.SUCCESS;
52  }
53 
54  protected static ref TStringArray s_aVarsOut = {
55  PORT_BASE_TARGET
56  };
57  override TStringArray GetVariablesOut()
58  {
59  return s_aVarsOut;
60  }
61 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
ETargetCategory
ETargetCategory
Definition: ETargetCategory.c:12
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
BaseTarget
Definition: BaseTarget.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_Shape
private ref Shape m_Shape
Definition: UnitDisplayComponent.c:11
SCR_AIGetTarget
Definition: SCR_AIGetTarget.c:1
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3