Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetCombatMovementParameters.c
Go to the documentation of this file.
1 class SCR_AIGetCombatMovementParameters : AITaskScripted
2 {
3  protected static const string PORT_STANCE = "Stance";
4  protected static const string PORT_MOVEMENT_TYPE = "MovementType";
5 
6  protected SCR_AIUtilityComponent m_Utility;
7 
8  protected static ref TStringArray s_aVarsOut = {
10  PORT_MOVEMENT_TYPE
11  };
12  override TStringArray GetVariablesOut()
13  {
14  return s_aVarsOut;
15  }
16 
17  override bool VisibleInPalette()
18  {
19  return true;
20  }
21 
22  override string GetOnHoverDescription()
23  {
24  return "Returns stance and movement type while advancing towards enemy";
25  }
26 
27  override void OnInit(AIAgent owner)
28  {
29  m_Utility = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
30  if (!m_Utility)
31  NodeError(this, owner, "Utility component not found");
32  }
33 
34  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
35  {
36  SCR_AIUtilityComponent utility = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
37 
38  if (!m_Utility)
39  return ENodeResult.FAIL;
40 
41  EAIThreatState threat = m_Utility.m_ThreatSystem.GetState();
42  ECharacterStance stance = ECharacterStance.STAND;
43  EMovementType moveType = EMovementType.RUN;
44 
45  switch (threat)
46  {
47  case EAIThreatState.VIGILANT:
48  case EAIThreatState.SAFE:
49  {
50  stance = ECharacterStance.STAND;
51  moveType = EMovementType.RUN; // SPRINT Temporary disabled because sometimes soldiers don't sprint but walk instead
52  break;
53  }
54 
55  case EAIThreatState.ALERTED:
56  case EAIThreatState.THREATENED:
57  {
58  stance = ECharacterStance.CROUCH;
59  moveType = EMovementType.RUN;
60  break;
61  }
62  }
63 
64  SetVariableOut(PORT_STANCE, stance);
65  SetVariableOut(PORT_MOVEMENT_TYPE, moveType);
66  return ENodeResult.SUCCESS;
67  }
68 };
EMovementType
EMovementType
Definition: EMovementType.c:12
ECharacterStance
ECharacterStance
Definition: ECharacterStance.c:12
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
SCR_AIGetCombatMovementParameters
Definition: SCR_AIGetCombatMovementParameters.c:1
PORT_STANCE
SCR_AIGetCombatMoveRequestParameters_ChangeStanceInCover PORT_STANCE