Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetCombatComponentWeaponProperties.c
Go to the documentation of this file.
2 {
3  // Output ports
4  protected static const string PORT_MIN_DISTANCE = "MinDistance";
5  protected static const string PORT_MAX_DISTANCE = "MaxDistance";
6  protected static const string PORT_DIRECT_DAMAGE = "IsDirectDamage";
7 
8  protected SCR_AICombatComponent m_CombatComponent;
9 
10  //------------------------------------------------------------------------------------------------
11  override void OnInit(AIAgent owner)
12  {
13  IEntity controlledEnt = owner.GetControlledEntity();
14  m_CombatComponent = SCR_AICombatComponent.Cast(controlledEnt.FindComponent(SCR_AICombatComponent));
15 
16  if (!m_CombatComponent)
17  {
18  NodeError(this, owner, "SCR_AIGetCombatComponentWeaponProperties didn't find necessary components!");
19  }
20  }
21 
22  //------------------------------------------------------------------------------------------------
23  /*
24  It's not very nice that we are moving weapon properties data all the way through weapon selection, combat component, and then this node.
25  Ideally we should be able to get all this from weapon, muzzle and magazine directly.
26  But ATM this is not possible, therefore it's done this way so that the values are consistent with what weapon selector is using
27  to evaluate weapons and targets.
28  */
29  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
30  {
31  if (!m_CombatComponent)
32  return ENodeResult.FAIL;
33 
34  BaseWeaponComponent weaponComp;
35  BaseMagazineComponent magazineComp;
36  int muzzleId;
37 
38  m_CombatComponent.GetSelectedWeaponAndMagazine(weaponComp, muzzleId, magazineComp);
39 
40  float minDistance;
41  float maxDistance;
42  bool directDamage;
43  m_CombatComponent.GetSelectedWeaponProperties(minDistance, maxDistance, directDamage);
44 
45  SetVariableOut(PORT_DIRECT_DAMAGE, directDamage);
46  SetVariableOut(PORT_MIN_DISTANCE, minDistance);
47  SetVariableOut(PORT_MAX_DISTANCE, maxDistance);
48 
49  return ENodeResult.SUCCESS;
50  }
51 
52  //------------------------------------------------------------------------------------------------
53  override bool VisibleInPalette()
54  {
55  return true;
56  }
57 
58  protected static ref TStringArray s_aVarsOut = {
59  PORT_MIN_DISTANCE,
60  PORT_MAX_DISTANCE,
61  PORT_DIRECT_DAMAGE
62  };
63 
64  //------------------------------------------------------------------------------------------------
65  override TStringArray GetVariablesOut()
66  {
67  return s_aVarsOut;
68  }
69 }
SCR_AIGetCombatComponentWeaponProperties
Definition: SCR_AIGetCombatComponentWeaponProperties.c:1
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
NodeError
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition: NodeError.c:3
BaseWeaponComponent
Definition: BaseWeaponComponent.c:12
m_CombatComponent
SCR_AICombatComponent m_CombatComponent
Definition: SCR_AIUtilityComponent.c:12