Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIVehicleBehavior.c
Go to the documentation of this file.
8
10{
11 ref SCR_BTParam<IEntity> m_Vehicle = new SCR_BTParam<IEntity>(SCR_AIActionTask.ENTITY_PORT);
12
13 //------------------------------------------------------------------------------------------------
14 void SCR_AIVehicleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity)
15 {
16 m_Vehicle.Init(m_aParams, vehicleEntity);
17 }
18
19 //---------------------------------------------------------------------------------------------------------------------------------
20 override int GetCause()
21 {
22 // Most of the time we get into vehicle because group told so
23 return SCR_EAIBehaviorCause.GROUP_GOAL;
24 }
25
26 //------------------------------------------------------------------------------------------------
27 override void OnActionSelected()
28 {
29 super.OnActionSelected();
30 m_Utility.m_AIInfo.SetAIState(EUnitAIState.BUSY);
31 }
32
33 //------------------------------------------------------------------------------------------------
34 override void OnActionCompleted()
35 {
36 m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
37 super.OnActionCompleted();
38 }
39
40 //------------------------------------------------------------------------------------------------
41 override void OnActionFailed()
42 {
43 m_Utility.m_AIInfo.SetAIState(EUnitAIState.AVAILABLE);
44 super.OnActionFailed();
45 }
46};
47
48class SCR_AIGetInVehicle : SCR_AIVehicleBehavior
49{
50 ref SCR_BTParam<EAICompartmentType> m_eRoleInVehicle = new SCR_BTParam<EAICompartmentType>(SCR_AIActionTask.ROLEINVEHICLE_PORT);
51 ref SCR_BTParam<BaseCompartmentSlot> m_CompartmentToGetIn = new SCR_BTParam<BaseCompartmentSlot>(SCR_AIActionTask.COMPARTMENT_PORT);
52
53 //------------------------------------------------------------------------------------------------
54 void SCR_AIGetInVehicle(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity, BaseCompartmentSlot compartmentSlot, EAICompartmentType roleInVehicle = EAICompartmentType.Cargo, float priority = PRIORITY_BEHAVIOR_GET_IN_VEHICLE, float priorityLevel = PRIORITY_LEVEL_NORMAL)
55 {
56 m_CompartmentToGetIn.Init(this, compartmentSlot);
57 m_eRoleInVehicle.Init(this, roleInVehicle);
58 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/GetInVehicle.bt";
59 SetPriority(priority);
60 m_fPriorityLevel.m_Value = priorityLevel;
61 }
62
63 //------------------------------------------------------------------------------------------------
64 override void OnActionCompleted()
65 {
66 if (m_CompartmentToGetIn.m_Value)
67 {
68 m_CompartmentToGetIn.m_Value.SetCompartmentAccessible(true);
69 m_CompartmentToGetIn.m_Value.SetReserved(null);
70 };
71 super.OnActionCompleted();
72 }
73
74 //------------------------------------------------------------------------------------------------
75 override void OnActionFailed()
76 {
77 if (m_CompartmentToGetIn.m_Value)
78 {
79 ChimeraCharacter chimchar = ChimeraCharacter.Cast(m_Utility.m_OwnerEntity);
80 CompartmentAccessComponent compMan = chimchar.GetCompartmentAccessComponent();
81 IEntity vehicle = m_CompartmentToGetIn.m_Value.GetVehicle();
82 if (compMan.IsGettingIn())
83 {
84 SCR_AIGetOutVehicle getOutBehavior = new SCR_AIGetOutVehicle(m_Utility, null , vehicle,
85 priority : PRIORITY_BEHAVIOR_GET_OUT_VEHICLE_HIGH_PRIORITY, priorityLevel : EvaluatePriorityLevel());
86 m_Utility.AddAction(getOutBehavior);
87 }
88 else if (vehicle && vehicle == compMan.GetVehicleIn(chimchar))
89 compMan.GetOutVehicle(EGetOutType.TELEPORT, 0, ECloseDoorAfterActions.LEAVE_OPEN, true);
90 else
91 compMan.InterruptVehicleActionQueue(true, true, true);
92 m_CompartmentToGetIn.m_Value.SetCompartmentAccessible(true);
93 m_CompartmentToGetIn.m_Value.SetReserved(null);
94 };
95 super.OnActionFailed();
96 }
97
98 //------------------------------------------------------------------------------------------------
99 override string GetActionDebugInfo()
100 {
101 return this.ToString() + " moving to " + m_Vehicle.m_Value.ToString() + " inside " + m_CompartmentToGetIn.m_Value.ToString();
102 }
103};
104
105class SCR_AIGetOutVehicle : SCR_AIVehicleBehavior
106{
107 ref SCR_BTParam<float> m_fDelay = new SCR_BTParam<float>("Delay");
108
109 //------------------------------------------------------------------------------------------------
110 void SCR_AIGetOutVehicle(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity, float delay_s = 0, float priority = PRIORITY_BEHAVIOR_GET_OUT_VEHICLE, float priorityLevel = PRIORITY_LEVEL_NORMAL)
111 {
112 m_sBehaviorTree = "AI/BehaviorTrees/Chimera/Soldier/GetOutVehicle.bt";
113 SetPriority(priority);
114 m_fPriorityLevel.m_Value = priorityLevel;
115 m_fDelay.Init(this, delay_s);
116 }
117
118 //------------------------------------------------------------------------------------------------
119 override string GetActionDebugInfo()
120 {
121 return this.ToString() + " leaving " + m_Vehicle.m_Value.ToString();
122 }
123};
ref array< SCR_BTParamBase > m_aParams
ref SCR_BTParam< float > m_fPriorityLevel
void OnActionCompleted()
enum EAIActionFailReason PRIORITY_LEVEL_NORMAL
override float EvaluatePriorityLevel()
ResourceName m_sBehaviorTree
override void OnActionSelected()
void OnActionFailed()
string GetActionDebugInfo()
int GetCause()
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
enum SCR_EAIActivityCause m_Utility
void SCR_AIBehaviorBase(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity)
SCR_EAIBehaviorCause
EAICompartmentType
enum EAICompartmentType m_Vehicle
void SCR_AIVehicleBehavior(SCR_AIUtilityComponent utility, SCR_AIActivityBase groupActivity, IEntity vehicleEntity)
override void OnActionCompleted()
override void OnActionFailed()
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
ECloseDoorAfterActions
EGetOutType
Definition EGetOutType.c:13