Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetPosForward.c
Go to the documentation of this file.
1 class SCR_AIGetPosForward: AITaskScripted
2 {
3  static const string PORT_DISTANCE = "DistanceIn";
4  static const string PORT_RESULT_VECTOR = "VectorOut";
5  static const string PORT_TARGET = "TargetIn";
6 
7  [Attribute("10", UIWidgets.EditBox, PORT_DISTANCE)]
8  float m_Distance;
9 
10  protected vector m_ResultVector;
11  protected IEntity m_Target;
12 
13  //------------------------------------------------------------------------------------------------
14  override void OnInit(AIAgent owner)
15  {
16  if (GetVariableIn(PORT_DISTANCE, m_Distance) && (GetVariableType(true, PORT_DISTANCE) != int && GetVariableType(true, PORT_DISTANCE) != float) )
17  {
18  NodeError(this, owner, PORT_DISTANCE + " type should be number");
19  }
20  }
21 
22  //------------------------------------------------------------------------------------------------
23  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
24  {
25  if (!GetVariableIn(PORT_TARGET,m_Target))
26  m_Target = owner;
27 
28  AIAgent agent = AIAgent.Cast(m_Target);
29  if (agent)
30  m_Target = agent.GetControlledEntity();
31 
32  if (!m_Target)
33  return ENodeResult.FAIL;
34 
35  vector direction = m_Target.GetYawPitchRoll().AnglesToVector();
36 
37  if (GetVariableType(true, PORT_DISTANCE) == int)
38  {
39  int distance;
40  GetVariableIn(PORT_DISTANCE, distance);
41  m_Distance = distance;
42  }
43  else if (GetVariableType(true, PORT_DISTANCE) == float)
44  {
45  GetVariableIn(PORT_DISTANCE, m_Distance);
46  }
47 
48  vector pos = m_Target.GetOrigin();
49 
50  vector forwardVector = pos + ( direction * m_Distance );
51  // snap the vector on ground, for valid location to run to
52  forwardVector[1] = m_Target.GetWorld().GetSurfaceY(forwardVector[0], forwardVector[2]);
53 
54  m_ResultVector = forwardVector;
55 
56  SetVariableOut(PORT_RESULT_VECTOR, m_ResultVector);
57 
58  return ENodeResult.SUCCESS;
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  protected override string GetOnHoverDescription()
63  {
64  return "It will return world position of forward vector of provided target entity multiplied by distance. If no target specified, owner will be used.";
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  override bool VisibleInPalette()
69  {
70  return true;
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  protected static ref TStringArray s_aVarsIn = {
75  PORT_TARGET,
76  PORT_DISTANCE
77  };
78  override TStringArray GetVariablesIn()
79  {
80  return s_aVarsIn;
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  protected static ref TStringArray s_aVarsOut = {
85  PORT_RESULT_VECTOR
86  };
87  override TStringArray GetVariablesOut()
88  {
89  return s_aVarsOut;
90  }
91 };
direction
vector direction
Definition: SCR_DestructibleTreeV2.c:31
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
m_Target
class SCR_AIPolar m_Target
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_AIGetPosForward
Definition: SCR_AIGetPosForward.c:1
distance
float distance
Definition: SCR_DestructibleTreeV2.c:29