Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDecoTestIsOutVehicleCondition.c
Go to the documentation of this file.
1 class SCR_AIDecoTestIsOutVehicleCondition : DecoratorTestScripted
2 {
3  // this tests AIWaypoint waypoint completion condition: either characters are out of vehicles
4  protected override bool TestFunction(AIAgent agent, IEntity controlled)
5  {
6  AIWaypoint waypoint = AIWaypoint.Cast(controlled);
7  if (!waypoint)
8  return false;
9 
10  SCR_AIGroup group = SCR_AIGroup.Cast(agent);
11  if (!group)
12  {
13  Debug.Error("Running on AIAgent that is not a SCR_AIGroup group!");
14  return false;
15  }
16 
17  array<AIAgent> agents = {};
18 
19  EAIWaypointCompletionType completionType = waypoint.GetCompletionType();
20 
21  switch (completionType)
22  {
23  case EAIWaypointCompletionType.All :
24  {
25  group.GetAgents(agents);
26  foreach (AIAgent a: agents)
27  {
28  ChimeraCharacter character = ChimeraCharacter.Cast(a.GetControlledEntity());
29  if (character && character.IsInVehicle())
30  {
31  return false;
32  break;
33  }
34  }
35  return true;
36  }
37  case EAIWaypointCompletionType.Leader :
38  {
39  ChimeraCharacter character = ChimeraCharacter.Cast(group.GetLeaderEntity());
40  if (!character)
41  return false;
42  return !character.IsInVehicle(); // leader is outside the vehicle --> condition is true
43  }
44  case EAIWaypointCompletionType.Any :
45  {
46  group.GetAgents(agents);
47  foreach (AIAgent a: agents)
48  {
49  ChimeraCharacter character = ChimeraCharacter.Cast(a.GetControlledEntity());
50  if (!character) // same logic as leader's
51  return false;
52  if (character.!IsInVehicle())
53  return true;
54  }
55  return false;
56  }
57  }
58  return false;
59  }
60 };
SCR_AIGroup
Definition: SCR_AIGroup.c:68
IsInVehicle
proto external bool IsInVehicle()
Returns true if the character is inside a vehicle.
SCR_AIDecoTestIsOutVehicleCondition
Definition: SCR_AIDecoTestIsOutVehicleCondition.c:1