Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIRemoveVehicleFromGroup.c
Go to the documentation of this file.
1 class SCR_AIRemoveVehicleFromGroup : AITaskScripted
2 {
3  static const string PORT_VEHICLE = "VehicleIn";
4 
5  [Attribute("1", UIWidgets.CheckBox, "Remove all vehicles used by any group member?")]
6  bool m_bRemoveAllUsedVehicles;
7 
8  //------------------------------------------------------------------------------------------------
9  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
10  {
11  SCR_AIGroup group = SCR_AIGroup.Cast(owner);
12  if (!group)
13  {
14  return NodeError(this,owner, "Node must be run on SCR_AIGroup agent!");
15  }
16 
17  IEntity agentEntity, vehicleEntity;
18 
19  if (GetVariableIn(PORT_VEHICLE, vehicleEntity))
20  {
21  group.RemoveUsableVehicle(vehicleEntity);
22  return ENodeResult.SUCCESS;
23  };
24 
25  if (!m_bRemoveAllUsedVehicles)
26  {
27  return ENodeResult.FAIL;
28  };
29 
30  ref array<AIAgent> agents = {};
31  group.GetAgents(agents);
32  CompartmentAccessComponent compartmentAccess;
33  BaseCompartmentSlot compartment;
34  ENodeResult nodeResult = ENodeResult.FAIL;
35 
36 
37  foreach (AIAgent agent : agents)
38  {
39  agentEntity = agent.GetControlledEntity();
40  if (!agentEntity)
41  continue;
42  compartmentAccess = CompartmentAccessComponent.Cast(agentEntity.FindComponent(CompartmentAccessComponent));
43  if (!compartmentAccess)
44  continue;
45  compartment = compartmentAccess.GetCompartment();
46  if (!compartment)
47  continue;
48  vehicleEntity = compartment.GetOwner();
49  if (vehicleEntity)
50  {
51  group.RemoveUsableVehicle(vehicleEntity);
52  nodeResult = ENodeResult.SUCCESS;
53  }
54  }
55  // if noone of the group is inside a vehicle and no vehicle provided => wrong use of the node? -> fail
56  return nodeResult;
57 
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  protected static ref TStringArray s_aVarsIn = {
62  PORT_VEHICLE
63  };
64  override TStringArray GetVariablesIn()
65  {
66  return s_aVarsIn;
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  protected override bool VisibleInPalette()
71  {
72  return true;
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  protected override string GetOnHoverDescription()
77  {
78  return "Removes vehicle from the list of usable vehicles of the group. Provide either a vehicle entity or removes all vehicles used by any group member";
79  }
80 
81 };
SCR_AIRemoveVehicleFromGroup
Definition: SCR_AIRemoveVehicleFromGroup.c:1
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition: NodeError.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_AIGroup
Definition: SCR_AIGroup.c:68