Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIUnEquipItems.c
Go to the documentation of this file.
1 class SCR_AIUnEquipItems : AITaskScripted
2 {
3  private IEntity m_OwnerEntity;
4  private CharacterControllerComponent controller;
5 
6  [Attribute( defvalue: "1", uiwidget: UIWidgets.CheckBox, desc: "UnEquip on abort or alternatively on simulate" )]
7  private bool m_bKeepRunningUntilAborted;
8  private bool m_bHasAborted;
9 
10  // -----------------------------------------------------------------------------------------------
11  override void OnInit(AIAgent owner)
12  {
13  m_OwnerEntity = owner.GetControlledEntity();
14  if (!m_OwnerEntity)
15  NodeError(this, owner, "Missing owner entity!");
16  }
17 
18  // -----------------------------------------------------------------------------------------------
19  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
20  {
21  if (!m_bKeepRunningUntilAborted)
22  {
23  UnEquip();
24  return ENodeResult.SUCCESS;
25  }
26 
27  return ENodeResult.RUNNING;
28  }
29 
30  // -----------------------------------------------------------------------------------------------
31  override void OnAbort(AIAgent owner, Node nodeCausingAbort)
32  {
33  if (m_bKeepRunningUntilAborted)
34  UnEquip();
35  }
36 
37  // -----------------------------------------------------------------------------------------------
38  protected void UnEquip()
39  {
40  if (m_bHasAborted)
41  return;
42 
43  m_bHasAborted = true;
44 
45  if (!m_OwnerEntity)
46  return;
47 
49  if (gadgetManager && gadgetManager.GetHeldGadgetComponent())
50  {
51  gadgetManager.RemoveHeldGadget();
52  return;
53  }
54 
55  controller = CharacterControllerComponent.Cast(m_OwnerEntity.FindComponent(CharacterControllerComponent));
56  if (controller)
57  controller.RemoveGadgetFromHand();
58  }
59 
60  // -----------------------------------------------------------------------------------------------
61  protected override string GetNodeMiddleText()
62  {
63  if (m_bKeepRunningUntilAborted)
64  return "Item unequiped when this node is aborted";
65  else
66  return "Item unequiped when node starts running";
67  }
68 
69  // -----------------------------------------------------------------------------------------------
70  protected override bool VisibleInPalette()
71  {
72  return true;
73  }
74 
75  // -----------------------------------------------------------------------------------------------
76  override bool CanReturnRunning()
77  {
78  return true;
79  }
80 
81  // -----------------------------------------------------------------------------------------------
82  protected override string GetOnHoverDescription()
83  {
84  return "Scripted Node: UnEquip any generic item or gadget that is currently being held by the character.";
85  }
86 };
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
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_AIUnEquipItems
Definition: SCR_AIUnEquipItems.c:1
m_OwnerEntity
SCR_AIUtilityComponentClass m_OwnerEntity