Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetUsableVehicle.c
Go to the documentation of this file.
1 class SCR_AIGetUsableVehicle : AITaskScripted
2 {
3  static const string PORT_COMPARTMENT_TYPE = "CompartmentTypeIn";
4  static const string PORT_VEHICLE = "VehicleOut";
5  static const string PORT_COMPARTMENT = "CompartmentOut";
6 
7  [Attribute("0", UIWidgets.ComboBox, "Find vehicle for:", "", ParamEnumArray.FromEnum(ECompartmentType) )]
8  protected ECompartmentType m_eCompartmentType;
9 
10  [Attribute("0", UIWidgets.CheckBox, "Reserve compartment?" )]
11  protected bool m_bReserveCompartment;
12 
13  protected ref array<BaseCompartmentSlot> m_aOutCompartments = {};
14 
15  //----------------------------------------------------------------------------------------------------------------------------------------
16  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
17  {
18  BaseCompartmentSlot compartmentOut;
19  ECompartmentType compType;
20  SCR_AIGroup group = SCR_AIGroup.Cast(owner);
21  if (!group)
22  group = SCR_AIGroup.Cast(owner.GetParentGroup());
23  if (!group)
24  return ENodeResult.FAIL;
25 
26  if (!GetVariableIn(PORT_COMPARTMENT_TYPE,compType))
27  compType = m_eCompartmentType;
28 
29  array<IEntity> vehicles = {};
30  group.GetUsableVehicles(vehicles);
31  if (!vehicles)
32  return ENodeResult.FAIL;
33  IEntity vehicle;
34 
35  if (SCR_AICompartmentHandling.FindAvailableCompartmentInVehicles(vehicles, compType, compartmentOut, vehicle))
36  {
37  if (m_bReserveCompartment)
38  group.AllocateCompartment(compartmentOut);
39  SetVariableOut(PORT_COMPARTMENT, compartmentOut);
40  SetVariableOut(PORT_VEHICLE, vehicle);
41  return ENodeResult.SUCCESS;
42  }
43  ClearVariable(PORT_VEHICLE);
44  return ENodeResult.FAIL;
45  }
46 
47  //----------------------------------------------------------------------------------------------------------------------------------------
48  protected static ref TStringArray s_aVarsIn = {
49  PORT_COMPARTMENT_TYPE
50  };
51 
52  //----------------------------------------------------------------------------------------------------------------------------------------
53  override TStringArray GetVariablesIn()
54  {
55  return s_aVarsIn;
56  }
57 
58  //----------------------------------------------------------------------------------------------------------------------------------------
59  protected static ref TStringArray s_aVarsOut = {
60  PORT_VEHICLE,PORT_COMPARTMENT
61  };
62 
63  //----------------------------------------------------------------------------------------------------------------------------------------
64  override TStringArray GetVariablesOut()
65  {
66  return s_aVarsOut;
67  }
68 
69  //----------------------------------------------------------------------------------------------------------------------------------------
70  override bool VisibleInPalette()
71  {
72  return true;
73  }
74 
75  //----------------------------------------------------------------------------------------------------------------------------------------
76  override string GetOnHoverDescription()
77  {
78  return "GetUsableVehicle: takes vehicles from the list of known vehicles of group and checks if the slot of m_compartmentType is available.\n It does not relaese reservation the found compartment!";
79  }
80 };
SCR_AIGetUsableVehicle
Definition: SCR_AIGetUsableVehicle.c:1
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
ECompartmentType
ECompartmentType
Definition: ECompartmentType.c:7
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_AICompartmentHandling
Definition: SCR_AIUtils.c:76