Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIRetreatBehavior.c
Go to the documentation of this file.
2 {
3  ref SCR_BTParamAssignable<vector> m_Target = new SCR_BTParamAssignable<vector>("RetreatToPoint");
4  ref SCR_BTParamAssignable<vector> m_LookAt = new SCR_BTParamAssignable<vector>("LookAt");
5 
6  bool m_TimeSet = false;
7  float m_Timestamp = 0;
8  const float m_MaxTime = 3;
9 
10  void SCR_AIRetreatWhileLookAtBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, float priorityLevel = PRIORITY_LEVEL_NORMAL)
11  {
12  vector tempPos;
13  m_Target.Init(this, tempPos);
14  m_LookAt.Init(this, tempPos);
15 
16  m_sBehaviorTree = "{9673533977BD9950}AI/BehaviorTrees/Chimera/Soldier/RetreatWhileLookAt.bt";
17  SetPriority(PRIORITY_BEHAVIOR_RETREAT_MELEE);
18  m_fPriorityLevel.m_Value = priorityLevel;
19  }
20 
21  override float CustomEvaluate()
22  {
23  if(!m_TimeSet)
24  {
25  m_Timestamp = GetGame().GetWorld().GetWorldTime();
26  m_TimeSet = true;
27  }
28 
29  //get timeslice
30  float current = GetGame().GetWorld().GetWorldTime();
31 
32  float secondsPassed = (current - m_Timestamp)/1000;
33 
34  //if the timer has passed, call Fail()
35  if(secondsPassed >= m_MaxTime)
36  {
37  Fail();
38  }
39 
40  return GetPriority();
41  }
42 };
43 
44 
45 
46 //----------------------------------------------------------------------------------------------------------------------------------------------------------
48 {
49  ref SCR_BTParamRef<BaseTarget> m_RetreatFromTarget = new SCR_BTParamRef<BaseTarget>("RetreatFromTarget");
50 
51  void SCR_AIRetreatFromTargetBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, notnull BaseTarget retreatFromTarget, float priorityLevel = PRIORITY_LEVEL_NORMAL)
52  {
53  m_RetreatFromTarget.Init(this, retreatFromTarget);
54  m_sBehaviorTree = "{91B8D5FDB60C1C80}AI/BehaviorTrees/Chimera/Soldier/RetreatFromTarget.bt";
55  SetPriority(PRIORITY_BEHAVIOR_RETREAT_FROM_TARGET);
56  m_fPriorityLevel.m_Value = priorityLevel;
57  }
58 
59  override float CustomEvaluate()
60  {
61  if (m_RetreatFromTarget.m_Value.GetTargetCategory() != ETargetCategory.ENEMY)
62  {
63  Complete();
64  return 0;
65  }
66  else
67  return GetPriority();
68  }
69 }
70 
71 class SCR_AIGetRetreatFromTargetBehaviorParameters: SCR_AIGetActionParameters
72 {
73  static ref TStringArray s_aVarsOut = (new SCR_AIRetreatFromTargetBehavior(null, null, null)).GetPortNames();
74  override TStringArray GetVariablesOut() { return s_aVarsOut; }
75 
76  override bool VisibleInPalette() { return true; }
77 };
GetVariablesOut
override TStringArray GetVariablesOut()
Definition: SCR_AIRetreatBehavior.c:74
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ETargetCategory
ETargetCategory
Definition: ETargetCategory.c:12
m_Target
class SCR_AIPolar m_Target
m_fPriorityLevel
float m_fPriorityLevel
Definition: SendGoalMessage.c:3
BaseTarget
Definition: BaseTarget.c:12
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
GetPriority
int GetPriority()
Definition: SCR_BaseManualCameraComponent.c:107
s_aVarsOut
SCR_AIRetreatFromTargetBehavior s_aVarsOut
SCR_AIGetActionParameters
Definition: SCR_AIGetActionParameters.c:22
SCR_AIRetreatFromTargetBehavior
Definition: SCR_AIRetreatBehavior.c:47
SCR_AIRetreatWhileLookAtBehavior
Definition: SCR_AIRetreatBehavior.c:1
SCR_AIBehaviorBase
Definition: SCR_AIBehavior.c:1
VisibleInPalette
override bool VisibleInPalette()
Definition: SCR_AIRetreatBehavior.c:76