Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGetPosForward.c
Go to the documentation of this file.
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
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 static 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 static override bool VisibleInPalette()
69 {
70 return true;
71 }
72
73 //------------------------------------------------------------------------------------------------
74 protected static ref TStringArray s_aVarsIn = {
75 PORT_TARGET,
76 PORT_DISTANCE
77 };
79 {
80 return s_aVarsIn;
81 }
82
83 //------------------------------------------------------------------------------------------------
84 protected static ref TStringArray s_aVarsOut = {
85 PORT_RESULT_VECTOR
86 };
88 {
89 return s_aVarsOut;
90 }
91};
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition NodeError.c:3
float distance
vector direction
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
proto external GetVariableType(bool inputPort, string name)
static ref TStringArray s_aVarsOut
override TStringArray GetVariablesIn()
static override bool VisibleInPalette()
static override string GetOnHoverDescription()
override TStringArray GetVariablesOut()
override void OnInit(AIAgent owner)
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
static ref TStringArray s_aVarsIn
ENodeResult
Definition ENodeResult.c:13
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385