Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetUsedVehicle.c
Go to the documentation of this file.
1 class SCR_AIGetUsedVehicle : AITaskScripted
2 {
3  static const string PORT_VEHICLE = "VehicleOut";
4 
5  //----------------------------------------------------------------------------------------------------------------------------------------
6  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
7  {
8  SCR_AIGroup group = SCR_AIGroup.Cast(owner);
9  if (!group)
10  group = SCR_AIGroup.Cast(owner.GetParentGroup());
11  if (!group)
12  return ENodeResult.FAIL;
13 
14  array<AIAgent> agents = new array<AIAgent>();
15  group.GetAgents(agents);
16 
17  IEntity usedVehicle;
18 
19  foreach (AIAgent agent : agents)
20  {
21  ChimeraCharacter chartacter = ChimeraCharacter.Cast(agent.GetControlledEntity());
22  if (!chartacter || !chartacter.IsInVehicle())
23  continue;
24 
25  CompartmentAccessComponent access = chartacter.GetCompartmentAccessComponent();
26  if (!access || !access.IsInCompartment())
27  continue;
28 
29  BaseCompartmentSlot comp = access.GetCompartment();
30  if (!comp)
31  continue;
32 
33  usedVehicle = comp.GetVehicle();
34 
35  if (usedVehicle)
36  break;
37  }
38 
39  if (usedVehicle)
40  {
41  // Add used vehicle to group's usable vehicles
42  if (!group.IsUsableVehicle(usedVehicle))
43  group.AddUsableVehicle(usedVehicle);
44 
45  SetVariableOut(PORT_VEHICLE, usedVehicle);
46  return ENodeResult.SUCCESS;
47  }
48 
49  ClearVariable(PORT_VEHICLE);
50  return ENodeResult.FAIL;
51  }
52 
53  //----------------------------------------------------------------------------------------------------------------------------------------
54  protected static ref TStringArray s_aVarsIn = {};
55 
56  //----------------------------------------------------------------------------------------------------------------------------------------
57  override TStringArray GetVariablesIn() { return s_aVarsIn; }
58 
59  //----------------------------------------------------------------------------------------------------------------------------------------
60  protected static ref TStringArray s_aVarsOut = { PORT_VEHICLE };
61 
62  //----------------------------------------------------------------------------------------------------------------------------------------
63  override TStringArray GetVariablesOut() { return s_aVarsOut; }
64 
65  //----------------------------------------------------------------------------------------------------------------------------------------
66  override bool VisibleInPalette() { return true; }
67 
68  //----------------------------------------------------------------------------------------------------------------------------------------
69  override string GetOnHoverDescription()
70  {
71  return "GetUsedVehicle: returns vehicle currently used by a group.";
72  }
73 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
SCR_AIGetUsedVehicle
Definition: SCR_AIGetUsedVehicle.c:1
SCR_AIGroup
Definition: SCR_AIGroup.c:68