Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIVehicleBehavior.c
Go to the documentation of this file.
2 {
3  None = -1,
7 }
8 
10 {
11  ref SCR_BTParam<IEntity> m_Vehicle = new SCR_BTParam<IEntity>(SCR_AIActionTask.ENTITY_PORT);
12 
13  void SCR_AIVehicleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity)
14  {
15  m_Vehicle.Init(m_aParams, vehicleEntity);
16  }
17 
18  override void OnActionSelected()
19  {
20  super.OnActionSelected();
21  m_Utility.m_AIInfo.SetAIState(EUnitAIState.BUSY);
22  }
23 
24  override void OnActionCompleted()
25  {
26  m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
27  super.OnActionCompleted();
28  }
29 
30  override void OnActionFailed()
31  {
32  m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
33  super.OnActionFailed();
34  }
35 };
36 
38 {
39  ref SCR_BTParam<EAICompartmentType> m_eRoleInVehicle = new SCR_BTParam<EAICompartmentType>(SCR_AIActionTask.ROLEINVEHICLE_PORT);
40  ref SCR_BTParam<BaseCompartmentSlot> m_CompartmentToGetIn = new SCR_BTParam<BaseCompartmentSlot>(SCR_AIActionTask.COMPARTMENT_PORT);
41 
42  void InitParameters(ECompartmentType role, BaseCompartmentSlot slot)
43  {
44  m_eRoleInVehicle.Init(this, role);
45  m_CompartmentToGetIn.Init(this, slot);
46  }
47 
48  void SCR_AIGetInVehicle(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity, EAICompartmentType role = ECompartmentType.Cargo, float priority = PRIORITY_BEHAVIOR_VEHICLE, float priorityLevel = PRIORITY_LEVEL_NORMAL)
49  {
50  BaseCompartmentSlot slot;
51  InitParameters(role, slot);
52 
53  m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/GetInVehicle.bt";
54  SetPriority(priority);
55  m_fPriorityLevel.m_Value = priorityLevel;
56  if (!vehicleEntity)
57  return;
58 
59  BaseCompartmentManagerComponent compManager = BaseCompartmentManagerComponent.Cast(vehicleEntity.FindComponent(BaseCompartmentManagerComponent));
60  if (!compManager)
61  {
62  Fail();
63  return;
64  };
65 
66  IEntity agentEntity = m_Utility.m_OwnerEntity;
67  if (!agentEntity)
68  {
69  Fail();
70  return;
71  }
72 
73  array<BaseCompartmentSlot> compartments = {};
74  compManager.GetCompartments(compartments);
75 
76  foreach (BaseCompartmentSlot comp: compartments)
77  {
78  if (comp.IsReserved() || comp.IsCompartmentAccessible() || SCR_AICompartmentHandling.CompartmentClassToType(comp.Type()) != m_eRoleInVehicle.m_Value)
79  continue;
80 
81  IEntity occupant = comp.GetOccupant();
82  if (occupant && occupant != agentEntity)
83  continue;
84 
85  comp.SetReserved(agentEntity);
86  comp.SetCompartmentAccessible(true);
87  m_CompartmentToGetIn.m_Value = comp;
88  break;
89  }
90  }
91 
92  override void OnActionCompleted()
93  {
94  if (m_CompartmentToGetIn.m_Value)
95  {
96  m_CompartmentToGetIn.m_Value.SetCompartmentAccessible(true);
97  m_CompartmentToGetIn.m_Value.SetReserved(null);
98  };
99  super.OnActionCompleted();
100  }
101 
102  override void OnActionFailed()
103  {
104  if (m_CompartmentToGetIn.m_Value)
105  {
106  m_CompartmentToGetIn.m_Value.SetCompartmentAccessible(true);
107  m_CompartmentToGetIn.m_Value.SetReserved(null);
108  };
109  super.OnActionFailed();
110  }
111 
112  override string GetActionDebugInfo()
113  {
114  return this.ToString() + " moving to " + m_Vehicle.ValueToString() + " as " + m_eRoleInVehicle.ValueToString();
115  }
116 };
117 
119 {
120 
121  void SCR_AIGetOutVehicle(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity, float priority = PRIORITY_BEHAVIOR_GET_OUT_VEHICLE, float priorityLevel = PRIORITY_LEVEL_NORMAL)
122  {
123  m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/GetOutVehicle.bt";
124  SetPriority(priority);
125  m_fPriorityLevel.m_Value = priorityLevel;
126  }
127 
128  override string GetActionDebugInfo()
129  {
130  return this.ToString() + " leaving " + m_Vehicle.ValueToString();
131  }
132 };
SCR_AIVehicleBehavior
void SCR_AIVehicleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity)
Definition: SCR_AIVehicleBehavior.c:13
m_eRoleInVehicle
EAICompartmentType m_eRoleInVehicle
Definition: SendGoalMessage.c:989
Turret
@ Turret
Definition: SCR_AIVehicleBehavior.c:5
m_fPriorityLevel
float m_fPriorityLevel
Definition: SendGoalMessage.c:3
ECompartmentType
ECompartmentType
Definition: ECompartmentType.c:7
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
OnActionSelected
override void OnActionSelected()
Definition: SCR_AIVehicleBehavior.c:18
None
@ None
Definition: SCR_AIVehicleBehavior.c:3
SCR_AIGetOutVehicle
Definition: SCR_AIVehicleBehavior.c:118
m_Vehicle
enum EAICompartmentType m_Vehicle
OnActionCompleted
override void OnActionCompleted()
Definition: SCR_AIVehicleBehavior.c:24
EAICompartmentType
EAICompartmentType
Definition: SCR_AIVehicleBehavior.c:1
Cargo
@ Cargo
Definition: SCR_AIVehicleBehavior.c:6
m_aParams
protected ref array< ref SCR_BaseFormatParam > m_aParams
Definition: SCR_FormatUIInfo.c:3
Pilot
@ Pilot
Definition: SCR_AIVehicleBehavior.c:4
OnActionFailed
override void OnActionFailed()
Definition: SCR_AIVehicleBehavior.c:30
SCR_AIActionTask
Definition: SCR_AIBehaviorTask.c:1
SCR_AIGetInVehicle
Definition: SCR_AIVehicleBehavior.c:37
SCR_AIBehaviorBase
Definition: SCR_AIBehavior.c:1
SCR_AICompartmentHandling
Definition: SCR_AIUtils.c:76