Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AILookAtPosition.c
Go to the documentation of this file.
2{
3 [Attribute("1", UIWidgets.CheckBox, "Succeed when requested looking too close" )]
4 protected bool m_bSuccessWhenClose;
5
6 [Attribute("1.5", UIWidgets.EditBox, "Vertical offset to add to position" )]
7 protected float m_fVerticalOffset;
8
9 [Attribute("1.5", UIWidgets.EditBox, "DistSQ below look is ignored" )]
10 protected float m_fIgnoreLookDistSq;
11
12 [Attribute("20", UIWidgets.EditBox, "Priority of the look" )]
13 protected float m_fPriority;
14
15 protected static const string POSITION_PORT = "PositionIn";
16 protected static const string POSITION_CORRECTION_PORT = "PositionOut";
17 protected static const string PRIORITY_PORT = "PriorityIn";
18
19 protected SCR_AIUtilityComponent m_Utility;
20
21 //-----------------------------------------------------------------------------------------------
22 static override bool VisibleInPalette() {return true;}
23
24 //-----------------------------------------------------------------------------------------------
25 protected static ref TStringArray s_aVarsIn = {
28 };
29 override array<string> GetVariablesIn()
30 {
31 return s_aVarsIn;
32 }
33
34 protected static ref TStringArray s_aVarsOut = {
36 };
37 override array<string> GetVariablesOut()
38 {
39 return s_aVarsOut;
40 }
41
42 //-----------------------------------------------------------------------------------------------
43 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
44 {
45 vector lookPosition;
46 float priority;
47
48 if (!m_Utility)
49 {
50 m_Utility = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
51 if (!m_Utility)
52 {
53 NodeError(this, owner, "This character does not have UtilityComponent!");
54 return ENodeResult.FAIL;
55 }
56 }
57
58 if (!GetVariableIn(PRIORITY_PORT,priority))
59 priority = m_fPriority;
60
61 if (!GetVariableIn(POSITION_PORT,lookPosition))
62 return ENodeResult.FAIL;
63
64 if (lookPosition == vector.Zero)
65 {
66 NodeError(this,owner, "Provided zero vector!");
67 return ENodeResult.FAIL;
68 }
69
70 if (!m_Utility.m_LookAction)
71 return ENodeResult.FAIL;
72
73 lookPosition[1] = lookPosition[1] + m_fVerticalOffset;
74
75 if (vector.DistanceSq(lookPosition, m_Utility.GetOrigin()) < m_fIgnoreLookDistSq)
76 {
77 // distance is too close to look at
80 return ENodeResult.SUCCESS;
81 else
82 return ENodeResult.FAIL;
83 }
84
85 m_Utility.m_LookAction.LookAt(lookPosition, priority);
87 return ENodeResult.SUCCESS;
88 }
89
90 //-----------------------------------------------------------------------------------------------
91 protected static override string GetOnHoverDescription()
92 {
93 return "Look at position setter for execution inside tree LookAction.bt, the position may be corrected by terrain";
94 }
95};
96
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition NodeError.c:3
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
proto void ClearVariable(string name)
static const string PRIORITY_PORT
static override bool VisibleInPalette()
static const string POSITION_CORRECTION_PORT
override array< string > GetVariablesOut()
static ref TStringArray s_aVarsOut
SCR_AIUtilityComponent m_Utility
static override string GetOnHoverDescription()
override array< string > GetVariablesIn()
static const string POSITION_PORT
static ref TStringArray s_aVarsIn
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
ENodeResult
Definition ENodeResult.c:13
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385