Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetRandomPoint.c
Go to the documentation of this file.
1 class SCR_AIGetRandomPoint: AITaskScripted
2 {
3  static const string WAYPOINT_PORT = "Waypoint";
4  static const string ORIGIN_PORT = "Origin";
5  static const string RADIUS_PORT = "Radius";
6  static const string EXCLUSION_RADIUS_PORT = "ExclusionRadius";
7  static const string PORT_RESULT_VECTOR = "ResultVector";
8 
9  [Attribute("10", UIWidgets.EditBox, "Radius around origin")]
10  protected float m_Radius;
11 
12  [Attribute("0", UIWidgets.EditBox, "Exclusion radius around origin")]
13  protected float m_ExclusionRadius;
14 
15  //------------------------------------------------------------------------------------------------
16  override void OnEnter(AIAgent owner)
17  {
18  if (GetVariableType(false, PORT_RESULT_VECTOR) != vector)
19  {
20  NodeError(this, owner, PORT_RESULT_VECTOR + " has to be vector");
21  }
22 
23  if (GetVariableIn(RADIUS_PORT, m_Radius) && (GetVariableType(true, RADIUS_PORT) != int && GetVariableType(true, RADIUS_PORT) != float))
24  {
25  NodeError(this, owner, RADIUS_PORT + " type should be number");
26  }
27  }
28 
29  //------------------------------------------------------------------------------------------------
30  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
31  {
32  vector origin = vector.Zero;
33  IEntity waypointEnt;
34 
35  if (GetVariableIn(WAYPOINT_PORT,waypointEnt))
36  {
37  AIWaypoint waypoint = AIWaypoint.Cast(waypointEnt);
38  if (!waypoint)
39  {
40  NodeError(this,owner, WAYPOINT_PORT + " is null! or wrong type");
41  return ENodeResult.FAIL;
42  };
43  m_Radius = waypoint.GetCompletionRadius();
44  origin = waypoint.GetOrigin();
45  }
46  else
47  {
48  if (GetVariableType(true, RADIUS_PORT) == int)
49  {
50  int radius;
51  GetVariableIn(RADIUS_PORT, radius);
52  m_Radius = radius;
53  }
54  else if (GetVariableType(true, RADIUS_PORT) == float)
55  {
56  GetVariableIn(RADIUS_PORT, m_Radius);
57  }
58 
59  if (GetVariableType(true, ORIGIN_PORT) == vector)
60  {
61  GetVariableIn(ORIGIN_PORT, origin);
62  }
63  }
64 
65  vector result = s_AIRandomGenerator.GenerateRandomPointInRadius(m_ExclusionRadius, m_Radius, origin, true);
66  result[1] = origin[1];
67  SetVariableOut(PORT_RESULT_VECTOR, result);
68 
69  return ENodeResult.SUCCESS;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  override bool VisibleInPalette()
74  {
75  return true;
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  override protected string GetOnHoverDescription()
80  {
81  return "Returns random position in circle (2D) from given point or within radius of a waypoint. When origin vector isn't present it will assume zero vector instead.";
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  protected static ref TStringArray s_aVarsIn = {
86  WAYPOINT_PORT,
87  ORIGIN_PORT,
88  RADIUS_PORT
89  };
90  override TStringArray GetVariablesIn()
91  {
92  return s_aVarsIn;
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  protected static ref TStringArray s_aVarsOut = {
97  PORT_RESULT_VECTOR
98  };
99  override TStringArray GetVariablesOut()
100  {
101  return s_aVarsOut;
102  }
103 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition: NodeError.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_AIGetRandomPoint
Definition: SCR_AIGetRandomPoint.c:1