Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetSAWaypointAttributes.c
Go to the documentation of this file.
1 class SCR_AIGetSAWaypointAttributes : AITaskScripted
2 {
3  static const string WAYPOINT_PORT = "WaypointIn";
4  static const string COMPONENT_PORT = "SmartActionComponent";
5 
6  //------------------------------------------------------------------------------------------
7  protected override bool VisibleInPalette()
8  {
9  return true;
10  }
11 
12  //------------------------------------------------------------------------------------------
13  protected static ref TStringArray s_aVarsIn = {
14  WAYPOINT_PORT
15  };
16  override TStringArray GetVariablesIn()
17  {
18  return s_aVarsIn;
19  }
20 
21  //------------------------------------------------------------------------------------------
22  protected static ref TStringArray s_aVarsOut = {
23  COMPONENT_PORT
24  };
25  override TStringArray GetVariablesOut()
26  {
27  return s_aVarsOut;
28  }
29 
30  //------------------------------------------------------------------------------------------
31  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
32  {
33  AIGroup group = AIGroup.Cast(owner);
34  if (!group)
35  {
36  SCR_AgentMustBeAIGroup(this, owner);
37  return ENodeResult.FAIL;
38  }
39 
40  AIWaypoint wp;
41  if(!GetVariableIn(WAYPOINT_PORT,wp))
42  wp = group.GetCurrentWaypoint();
43  if (!wp)
44  return ENodeResult.FAIL;
45 
47 
48  if (!SAWP)
49  return ENodeResult.FAIL;
50 
51  IEntity SAEntity;
52  string SATag;
53 
54  SAWP.GetSmartActionEntity(SAEntity, SATag);
55 
56  if (!SAEntity || SATag.IsEmpty())
57  return ENodeResult.FAIL;
58 
59  if (SAEntity)
60  {
61  array<Managed> outComponents = {};
63  array<string> outTags = {};
64  SAEntity.FindComponents(SCR_AISmartActionComponent, outComponents);
65  // searching in hierarchy of SAEntity for SmartActionComponents
66  IEntity child = SAEntity.GetChildren();
67  while (child)
68  {
69  array<Managed> entityComponents = {};
70  child.FindComponents(SCR_AISmartActionComponent,entityComponents);
71  outComponents.InsertAll(entityComponents);
72  child = child.GetSibling();
73  }
74  // searching SmartActionComponents of smartactions with correct TAG
75  foreach (Managed outComponent : outComponents)
76  {
77  component = SCR_AISmartActionComponent.Cast(outComponent);
78  if (!component)
79  continue;
80  component.GetTags(outTags);
81  if (outTags.Contains(SATag) && component.IsActionAccessible())
82  {
83  SetVariableOut(COMPONENT_PORT, component);
84  return ENodeResult.SUCCESS;
85  }
86  }
87  }
88  return ENodeResult.FAIL;
89  }
90 
91  //------------------------------------------------------------------------------------------
92  protected override string GetOnHoverDescription()
93  {
94  return "Returns SmartActionComponent set on waypoint, fails if waypoint is not set properly (entity or tag is missing).";
95  }
96 };
SCR_AgentMustBeAIGroup
void SCR_AgentMustBeAIGroup(Node node, AIAgent owner)
Definition: NodeError.c:14
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
SCR_AISmartActionComponent
Definition: SCR_AISmartActionComponent.c:9
SCR_AIGetSAWaypointAttributes
Definition: SCR_AIGetSAWaypointAttributes.c:1
SCR_SmartActionWaypoint
Definition: SCR_SmartActionWaypoint.c:4