Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIDecoTestIsOutVehicleCondition.c
Go to the documentation of this file.
2{
3 // this tests AIWaypoint waypoint completion condition: either characters are out of vehicles
4 protected override bool TestFunction(AIAgent agent, IEntity controlled)
5 {
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
16 SCR_AIGroup group = SCR_AIGroup.Cast(agent);
17 if (!group)
18 {
19 Debug.Error("Running on AIAgent that is not a SCR_AIGroup group!");
20 return false;
21 }
22
23 array<AIAgent> agents = {};
24
25 switch (completionType)
26 {
28 {
29 group.GetAgents(agents);
30 foreach (AIAgent a: agents)
31 {
32 ChimeraCharacter character = ChimeraCharacter.Cast(a.GetControlledEntity());
33 if (!character)
34 continue;
35 CompartmentAccessComponent acc = character.GetCompartmentAccessComponent();
36 if (!acc)
37 continue;
38 BaseCompartmentSlot slot = acc.GetCompartment();
39 if (slot && IsCompartmentAllowedToLeave(slot, allowance))
40 return false;
41 }
42 return true;
43 }
44 case EAIWaypointCompletionType.Leader :
45 {
46 ChimeraCharacter character = ChimeraCharacter.Cast(group.GetLeaderEntity());
47 if (!character)
48 return false;
49 CompartmentAccessComponent acc = character.GetCompartmentAccessComponent();
50 if (!acc)
51 return false;
52 BaseCompartmentSlot slot = acc.GetCompartment();
53 if (!slot)
54 return true;
55 return !IsCompartmentAllowedToLeave(slot, allowance); // leader is not allowed to leave compartment --> condition is true
56 }
58 {
59 group.GetAgents(agents);
60 foreach (AIAgent a: agents)
61 {
62 ChimeraCharacter character = ChimeraCharacter.Cast(a.GetControlledEntity());
63 if (!character)
64 continue;
65 if (!character.IsInVehicle())
66 return true;
67 }
68 return false;
69 }
70 }
71 return false;
72 }
73
74 //---------------------------------------------------------------------------------------------------
76 {
77 if(!allowance)
78 return true;
79 else if (PilotCompartmentSlot.Cast(slot) && allowance.m_bIsDriverAllowed)
80 return true;
81 else if (TurretCompartmentSlot.Cast(slot) && allowance.m_bIsGunnerAllowed)
82 return true;
83 else if (CargoCompartmentSlot.Cast(slot) && allowance.m_bIsCargoAllowed)
84 return true;
85 return false;
86 }
87};
Definition Debug.c:13
override bool TestFunction(AIAgent agent, IEntity controlled)
bool IsCompartmentAllowedToLeave(notnull BaseCompartmentSlot slot, SCR_AIBoardingParameters allowance)