Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AISetStance.c
Go to the documentation of this file.
2 {
3  [Attribute("0", UIWidgets.ComboBox, "Desired character stance", "", ParamEnumArray.FromEnum(ECharacterStance) )]
4  private ECharacterStance m_eStance;
5 
6  [Attribute("0", UIWidgets.CheckBox, "Should reset stance to Standing when node is aborted")]
7  private bool m_bStandupOnAbort;
8 
9  static const string STANCE_PORT = "Stance";
10 
11  private CharacterControllerComponent m_CharacterController;
12 
13  //------------------------------------------------------------------------------------------------
14  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
15  {
17  return ENodeResult.FAIL;
18 
19  ECharacterStance stance;
20 
21  if(!GetVariableIn(STANCE_PORT,stance))
22  stance = m_eStance;
23 
24  m_AIInfo.SetStance(stance);
25  m_CharacterController.SetStanceChange(ConvertStanceToInt(stance));
26 
27  return ENodeResult.SUCCESS;
28  }
29 
30  //------------------------------------------------------------------------------------------------
31  int ConvertStanceToInt(ECharacterStance stance)
32  {
33  switch (stance)
34  {
35  case ECharacterStance.STAND:
36  return ECharacterStanceChange.STANCECHANGE_TOERECTED;
37  case ECharacterStance.CROUCH:
38  return ECharacterStanceChange.STANCECHANGE_TOCROUCH;
39  case ECharacterStance.PRONE:
40  return ECharacterStanceChange.STANCECHANGE_TOPRONE;
41  }
42  return 0;
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  override bool VisibleInPalette() {return true;}
47 
48  //------------------------------------------------------------------------------------------------
49  protected static ref TStringArray s_aVarsIn = {
50  STANCE_PORT
51  };
52  override array<string> GetVariablesIn()
53  {
54  return s_aVarsIn;
55  }
56 
57  //------------------------------------------------------------------------------------------------
58  override string GetNodeMiddleText()
59  {
60  string s;
61  s = s + string.Format("m_eStance: %1\n", typename.EnumToString(ECharacterStance, m_eStance));
62  return s;
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  override void OnInit(AIAgent owner)
67  {
68  super.OnInit(owner);
69 
70  if(owner.GetControlledEntity())
71  {
72  m_CharacterController = CharacterControllerComponent.Cast(owner.GetControlledEntity().FindComponent(CharacterControllerComponent));
74  NodeError(this, owner, "Can't find CharacterControllerComponent.");
75  }
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  override void OnAbort(AIAgent owner, Node nodeCausingAbort)
80  {
81  if (!m_bStandupOnAbort)
82  {
83  super.OnAbort(owner, nodeCausingAbort);
84  return;
85  }
86 
87  if (m_AIInfo)
88  m_AIInfo.SetStance(ECharacterStance.STAND);
90  m_CharacterController.SetStanceChange(ConvertStanceToInt(ECharacterStance.STAND));
91  super.OnAbort(owner, nodeCausingAbort);
92  }
93 };
ECharacterStance
ECharacterStance
Definition: ECharacterStance.c:12
SCR_AICharacterStats
Definition: SCR_AICharacterStats.c:1
m_CharacterController
SCR_CharacterPerceivableComponentClass m_CharacterController
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition: NodeError.c:3
m_eStance
SCR_AICombatMoveRequest_ChangeStanceInCover m_eStance
Attribute
typedef Attribute
Post-process effect of scripted camera.
ECharacterStanceChange
ECharacterStanceChange
Definition: ECharacterStanceChange.c:12
m_AIInfo
SCR_AIInfoComponent m_AIInfo
Definition: SCR_AIUtilityComponent.c:11
SCR_AISetStance
Definition: SCR_AISetStance.c:1