Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AILookAtPosition.c
Go to the documentation of this file.
1 class SCR_AILookAtPosition: AITaskScripted
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  override bool VisibleInPalette() {return true;}
23 
24  //-----------------------------------------------------------------------------------------------
25  protected static ref TStringArray s_aVarsIn = {
26  POSITION_PORT,
27  PRIORITY_PORT
28  };
29  override array<string> GetVariablesIn()
30  {
31  return s_aVarsIn;
32  }
33 
34  protected static ref TStringArray s_aVarsOut = {
35  POSITION_CORRECTION_PORT
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
78  ClearVariable(POSITION_CORRECTION_PORT);
79  if (m_bSuccessWhenClose)
80  return ENodeResult.SUCCESS;
81  else
82  return ENodeResult.FAIL;
83  }
84 
85  m_Utility.m_LookAction.LookAt(lookPosition, priority);
86  SetVariableOut(POSITION_CORRECTION_PORT,lookPosition);
87  return ENodeResult.SUCCESS;
88  }
89 
90  //-----------------------------------------------------------------------------------------------
91  protected 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 
SCR_AILookAtPosition
Definition: SCR_AILookAtPosition.c:1
m_fPriority
int m_fPriority
Definition: SCR_DestructionBaseComponent.c:713
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.
m_fVerticalOffset
float m_fVerticalOffset
Definition: ForestGeneratorObjects.c:60