Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIMoveBehavior.c
Go to the documentation of this file.
1class SCR_AIMoveBehaviorBase : SCR_AIBehaviorBase
2{
3 ref SCR_BTParam<vector> m_vPosition = new SCR_BTParam<vector>(SCR_AIActionTask.POSITION_PORT);
4
5 //-----------------------------------------------------------------------------------------------------
6 void SCR_AIMoveBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector pos, float priority = PRIORITY_BEHAVIOR_MOVE, float priorityLevel = PRIORITY_LEVEL_NORMAL)
7 {
8 m_vPosition.Init(this, pos);
9 SetPriority(priority);
10 m_fPriorityLevel.m_Value = priorityLevel;
11 }
12
13 //---------------------------------------------------------------------------------------------------------------------------------
14 override int GetCause()
15 {
16 return SCR_EAIBehaviorCause.SAFE;
17 }
18};
19
20//-----------------------------------------------------------------------------------------------------
21class SCR_AIMoveInFormationBehavior : SCR_AIBehaviorBase
22{
23 //-----------------------------------------------------------------------------------------------------
24 void SCR_AIMoveInFormationBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, float priorityLevel = PRIORITY_LEVEL_NORMAL)
25 {
26 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/KeepInFormation.bt";
27
28 m_bAllowLook = priorityLevel == 0;
29 m_bResetLook = true;
30
31 m_fPriorityLevel.m_Value = priorityLevel;
32 }
33
34 //-----------------------------------------------------------------------------------------------------
35 override float CustomEvaluate()
36 {
37 if (!m_Utility.IsSubformationLeader() && m_Utility.GetNearSubformationLeader() && !m_Utility.GetSubformationLeaderMoving())
38 {
39 // Leader is not moving, and we are close -> lower the priority, we can do something else if it bothers us
40 return PRIORITY_BEHAVIOR_MOVE_IN_FORMATION_LOW_PRIORITY;
41 }
42 else
43 {
44 // We are either far or leader is moving, or we are subformation leader, we should keep moving
45 return PRIORITY_BEHAVIOR_MOVE_IN_FORMATION;
46 }
47 }
48};
49
50//-----------------------------------------------------------------------------------------------------
51class SCR_AIMoveIndividuallyBehavior : SCR_AIMoveBehaviorBase
52{
53 ref SCR_BTParamAssignable<IEntity> m_Entity = new SCR_BTParamAssignable<IEntity>(SCR_AIActionTask.ENTITY_PORT);
54 ref SCR_BTParamAssignable<float> m_Radius = new SCR_BTParamAssignable<float>(SCR_AIActionTask.RADIUS_PORT);
55
56 //-----------------------------------------------------------------------------------------------------
57 void SCR_AIMoveIndividuallyBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector pos, float priority = PRIORITY_BEHAVIOR_MOVE_INDIVIDUALLY, float priorityLevel = PRIORITY_LEVEL_NORMAL, IEntity ent = null, float radius = 1.0)
58 {
59 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/MoveIndividually.bt";
60 m_Entity.Init(this, ent);
61 if (ent)
62 m_vPosition.m_Value = ent.GetOrigin();
63 m_Radius.Init(this, radius);
64 }
65
66 //-----------------------------------------------------------------------------------------------------
67 override string GetActionDebugInfo()
68 {
69 return this.ToString() + " moving to " + m_vPosition.m_Value.ToString();
70 }
71};
72
73//-----------------------------------------------------------------------------------------------------
74class SCR_AIMoveAndInvestigateBehavior : SCR_AIMoveBehaviorBase
75{
76 ref SCR_BTParam<bool> m_bIsDangerous = new SCR_BTParam<bool>(SCR_AIActionTask.IS_DANGEROUS_PORT);
77 ref SCR_BTParam<float> m_fRadius = new SCR_BTParam<float>(SCR_AIActionTask.RADIUS_PORT);
78 ref SCR_BTParam<bool> m_bResetTimer = new SCR_BTParam<bool>(SCR_AIActionTask.RESET_TIMER_PORT);
79 ref SCR_BTParam<float> m_fTimeOut = new SCR_BTParam<float>(SCR_AIActionTask.TIMEOUT_PORT);
80 ref SCR_BTParam<float> m_fDuration = new SCR_BTParam<float>("Duration"); // How much to investigate once we have arrived
81 ref SCR_BTParam<vector> m_vStartPos = new SCR_BTParam<vector>("StartPos"); // Our position when the behavior was created
82
83 EAIUnitType m_eTargetUnitType;
84 float m_fTimeStamp; // world time when constructor of behavior is called
85 bool m_bCanTimeout = true; // can timeout when not executed?
86 protected static const float INVESTIGATION_TIMEOUT_MS = 20000; // how long it can take NOT to investigate before the investigation becomes obsolete in ms
87
88 //-----------------------------------------------------------------------------------------------------
89 void SCR_AIMoveAndInvestigateBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector pos, float priority = PRIORITY_BEHAVIOR_MOVE_AND_INVESTIGATE, float priorityLevel = PRIORITY_LEVEL_NORMAL, float radius = 10, bool isDangerous = true, EAIUnitType targetUnitType = EAIUnitType.UnitType_Infantry, float duration = 10.0)
90 {
91 m_bIsDangerous.Init(this, isDangerous);
92 m_fRadius.Init(this, radius);
93 m_bResetTimer.Init(this, false);
94 //m_fTimeOut.Init(this, Math.RandomFloat(20,50));
95 m_fTimeOut.Init(this, 5.0 * 60.0); // For now it's a reasonable long enough time
96 m_fDuration.Init(this, Math.RandomFloat(0.8*duration, 1.2*duration));
97 m_eTargetUnitType = targetUnitType;
98 m_vStartPos.Init(this, vector.Zero);
99
100 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/MoveAndInvestigate.bt";
101 if (m_Utility)
102 {
103 // marking time of creation of this move and investigate (world time)
104 m_fTimeStamp = GetGame().GetWorld().GetWorldTime();
105 }
106
107 // If target is dangerous, during execution of this action we will increase our threat level
108 // Aim of this is to be in alerted state through the action, so that when we encounter enemy again,
109 // We are not 'surprised' by enemy and there will be no extra delay added
110 if (isDangerous)
111 m_fThreat = 1.01 * SCR_AIThreatSystem.VIGILANT_THRESHOLD;
112 }
113
114 //-----------------------------------------------------------------------------------------------------
115 override void OnActionSelected()
116 {
117 super.OnActionSelected();
118 m_bCanTimeout = false;
119 m_Utility.m_CombatComponent.SetExpectedEnemyType(m_eTargetUnitType);
120
121 // Initialize m_vStartPos value
122 if (m_vStartPos.m_Value == vector.Zero)
123 m_vStartPos.m_Value = m_Utility.m_OwnerEntity.GetOrigin();
124 }
125};
126
127//-----------------------------------------------------------------------------------------------------
129{
130 protected static ref TStringArray s_aVarsIn = (new SCR_AIMoveAndInvestigateBehavior(null, null, vector.Zero)).GetPortNames();
131 override TStringArray GetVariablesIn() { return s_aVarsIn; }
132 static override bool VisibleInPalette() { return true; }
133};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref SCR_BTParam< float > m_fPriorityLevel
enum EAIActionFailReason PRIORITY_LEVEL_NORMAL
TStringArray GetPortNames()
ResourceName m_sBehaviorTree
string GetActionDebugInfo()
int GetCause()
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
float m_fThreat
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
bool m_bResetLook
SCR_EAIBehaviorCause
bool m_bAllowLook
override float CustomEvaluate()
Definition Math.c:13
static const float INVESTIGATION_TIMEOUT_MS
void SCR_AIMoveAndInvestigateBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, vector pos, float priority=PRIORITY_BEHAVIOR_MOVE_AND_INVESTIGATE, float priorityLevel=PRIORITY_LEVEL_NORMAL, float radius=10, bool isDangerous=true, EAIUnitType targetUnitType=EAIUnitType.UnitType_Infantry, float duration=10.0)
EAIUnitType
Definition EAIUnitType.c:13
array< string > TStringArray
Definition Types.c:385
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.