Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetCoverIdleDuration.c
Go to the documentation of this file.
1 class SCR_AIGetCoverIdleDuration : AITaskScripted
2 {
3  protected static const string PORT_IDLE_DURATION = "IdleDuration";
4 
5  protected SCR_AIUtilityComponent m_Utility;
6 
7  protected static ref TStringArray s_aVarsOut = { PORT_IDLE_DURATION };
8  override TStringArray GetVariablesOut()
9  {
10  return s_aVarsOut;
11  }
12 
13  override bool VisibleInPalette()
14  {
15  return true;
16  }
17 
18  override string GetOnHoverDescription()
19  {
20  return "Returns how many seconds the soldier should stay in cover";
21  }
22 
23  override void OnInit(AIAgent owner)
24  {
25  m_Utility = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
26  if (!m_Utility)
27  NodeError(this, owner, "Utility component not found");
28  }
29 
30  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
31  {
32  if (!m_Utility)
33  return ENodeResult.FAIL;
34 
35  EAIThreatState threat = m_Utility.m_ThreatSystem.GetState();
36  float duration = 0;
37  switch (threat)
38  {
39  case EAIThreatState.SAFE:
40  case EAIThreatState.VIGILANT: duration = Math.RandomFloat(2.0, 4.0); break;
41  case EAIThreatState.ALERTED: duration = Math.RandomFloat(7.0, 11.0); break;
42  case EAIThreatState.THREATENED: duration = Math.RandomFloat(11.0, 16.0); break;
43  }
44  SetVariableOut(PORT_IDLE_DURATION, duration);
45  return ENodeResult.SUCCESS;
46  }
47 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
SCR_AIGetCoverIdleDuration
Definition: SCR_AIGetCoverIdleDuration.c:1
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition: NodeError.c:3