Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AIDecoTestIsInVehicleCondition.c
Go to the documentation of this file.
1
class
SCR_AIDecoTestIsInVehicleCondition
:
DecoratorTestScripted
2
{
3
// this tests SCR_BoardingWaypoint waypoint completion condition: either characters are in vehicles or group usable vehicles are fully occupied
4
protected
override
bool
TestFunction
(AIAgent agent,
IEntity
controlled)
5
{
6
SCR_AIBoardingParameters
allowance =
new
SCR_AIBoardingParameters
();
7
EAIWaypointCompletionType
completionType;
8
AIWaypoint wp = AIWaypoint.Cast(controlled);
9
if
(!wp)
10
return
false
;
11
completionType = wp.GetCompletionType();
12
SCR_BoardingWaypoint
bwp =
SCR_BoardingWaypoint
.Cast(controlled);
13
if
(bwp)
14
allowance = bwp.GetAllowance();
15
else
16
{
17
allowance.m_bIsCargoAllowed =
true
;
18
allowance.m_bIsGunnerAllowed =
true
;
19
allowance.m_bIsDriverAllowed =
true
;
20
}
21
22
SCR_AIGroup
group =
SCR_AIGroup
.Cast(agent);
23
if
(!group)
24
{
25
Debug
.Error(
"Running on AIAgent that is not a SCR_AIGroup group!"
);
26
return
false
;
27
}
28
29
30
31
array<AIAgent> agents = {};
32
33
ref array<IEntity> vehicles = {};
34
group.
GetGroupUtilityComponent
().
m_VehicleMgr
.
GetAllVehicleEntities
(vehicles);
35
bool
noAvailableVehicles =
true
;
36
foreach
(
IEntity
vehicle: vehicles)
37
{
38
if
(vehicle &&
VehicleHasEmptyCompartments
(vehicle, allowance))
39
{
40
noAvailableVehicles =
false
;
41
break
;
42
}
43
};
44
45
switch
(completionType)
46
{
47
case
EAIWaypointCompletionType
.All :
48
{
49
group.GetAgents(agents);
50
bool
completeWaypoint =
true
;
51
foreach
(AIAgent a: agents)
52
{
53
ChimeraCharacter
character =
ChimeraCharacter
.Cast(a.GetControlledEntity());
54
if
(character && !character.IsInVehicle())
55
{
56
if
(vehicles.IsEmpty())
// i have character outside a vehicle, no known vehicles to use -> not complete waypoint
57
return
false
;
58
completeWaypoint = noAvailableVehicles;
// i have character outside the vehicle, no available vehicles to use --> complete waypoint
59
break
;
60
}
61
}
62
return
completeWaypoint;
63
}
64
case
EAIWaypointCompletionType
.Leader :
65
{
66
ChimeraCharacter
character =
ChimeraCharacter
.Cast(group.GetLeaderEntity());
67
if
(!character)
68
return
false
;
69
if
(character.IsInVehicle())
// leader is inside the vehicle --> complete waypoint
70
return
true
;
71
if
(vehicles.IsEmpty())
// leader is outside, no known vehicles --> not complete waypoint
72
return
false
;
73
return
noAvailableVehicles;
74
}
75
case
EAIWaypointCompletionType
.Any :
76
{
77
group.GetAgents(agents);
78
foreach
(AIAgent a: agents)
79
{
80
ChimeraCharacter
character =
ChimeraCharacter
.Cast(a.GetControlledEntity());
81
if
(!character)
// same logic as leader's
82
return
false
;
83
if
(character.IsInVehicle())
84
return
true
;
85
if
(vehicles.IsEmpty())
86
return
false
;
87
return
noAvailableVehicles;
88
}
89
return
false
;
90
}
91
}
92
return
false
;
93
}
94
95
// returns true if there is compartment of required type that is yet unoccupied
96
bool
VehicleHasEmptyCompartments
(notnull
IEntity
vehicle,
SCR_AIBoardingParameters
allowedCompartmentTypes)
97
{
98
BaseCompartmentManagerComponent
compComp =
BaseCompartmentManagerComponent
.Cast(vehicle.FindComponent(
BaseCompartmentManagerComponent
));
99
if
(!compComp)
100
return
false
;
101
102
array<BaseCompartmentSlot> compartmentSlots = {};
103
compComp.GetCompartments(compartmentSlots);
104
ECompartmentType
compartmentType;
105
foreach
(
BaseCompartmentSlot
slot : compartmentSlots)
106
{
107
if
(allowedCompartmentTypes.m_bIsDriverAllowed &&
PilotCompartmentSlot
.Cast(slot))
108
compartmentType =
ECompartmentType
.PILOT;
109
else
if
(allowedCompartmentTypes.m_bIsGunnerAllowed &&
TurretCompartmentSlot
.Cast(slot))
110
compartmentType =
ECompartmentType
.TURRET;
111
else
if
(allowedCompartmentTypes.m_bIsCargoAllowed &&
CargoCompartmentSlot
.Cast(slot))
112
compartmentType =
ECompartmentType
.CARGO;
113
else
114
continue
;
115
116
if
(!slot.IsOccupied())
117
{
118
// PrintFormat("Found empty compartment %1 of type %2", slot, compartmentType);
119
return
true
;
120
}
121
}
122
123
return
false
;
124
}
125
};
ECompartmentType
ECompartmentType
Definition
ECompartmentType.c:8
BaseCompartmentManagerComponent
Definition
BaseCompartmentManagerComponent.c:13
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
CargoCompartmentSlot
Definition
CargoCompartmentSlot.c:13
ChimeraCharacter
Definition
ChimeraCharacter.c:13
Debug
Definition
Debug.c:13
DecoratorTestScripted
Definition
DecoratorTestScripted.c:13
IEntity
Definition
IEntity.c:13
PilotCompartmentSlot
Definition
PilotCompartmentSlot.c:13
SCR_AIBoardingParameters
Definition
SCR_BoardingWaypoint.c:6
SCR_AIDecoTestIsInVehicleCondition
Definition
SCR_AIDecoTestIsInVehicleCondition.c:2
SCR_AIDecoTestIsInVehicleCondition::VehicleHasEmptyCompartments
bool VehicleHasEmptyCompartments(notnull IEntity vehicle, SCR_AIBoardingParameters allowedCompartmentTypes)
Definition
SCR_AIDecoTestIsInVehicleCondition.c:96
SCR_AIDecoTestIsInVehicleCondition::TestFunction
override bool TestFunction(AIAgent agent, IEntity controlled)
Definition
SCR_AIDecoTestIsInVehicleCondition.c:4
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroup::GetGroupUtilityComponent
SCR_AIGroupUtilityComponent GetGroupUtilityComponent()
Definition
SCR_AIGroup.c:208
SCR_AIGroupUtilityComponent::m_VehicleMgr
ref SCR_AIGroupVehicleManager m_VehicleMgr
Definition
SCR_AIGroupUtilityComponent.c:63
SCR_AIGroupVehicleManager::GetAllVehicleEntities
void GetAllVehicleEntities(array< IEntity > outAllVehicles)
Definition
SCR_AIGroupVehicleManager.c:47
SCR_BoardingWaypoint
Definition
SCR_BoardingWaypoint.c:48
TurretCompartmentSlot
Definition
TurretCompartmentSlot.c:13
EAIWaypointCompletionType
EAIWaypointCompletionType
Definition
EAIWaypointCompletionType.c:13
scripts
Game
AI
ScriptedNodes
Vehicles
SCR_AIDecoTestIsInVehicleCondition.c
Generated by
1.17.0