Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDecoHasMagazineCount.c
Go to the documentation of this file.
2 {
7 };
8 
9 class SCR_AIDecoHasMagazineCount : DecoratorScripted
10 {
11  static const string PORT_MAGAZINE_COUNT = "MagazineCountOut";
12 
13  [Attribute("0", UIWidgets.ComboBox, "Test Type", "", ParamEnumArray.FromEnum(EVariableTestType) )]
14  protected EVariableTestType m_TestType;
15  [Attribute("0", UIWidgets.EditBox, "Test Value" )]
16  protected int m_iNumberOfMagazines;
17 
18  protected SCR_InventoryStorageManagerComponent m_inventoryManager;
19  protected BaseWeaponComponent m_weapon;
20  protected int prevAmmo;
21 
22  IEntity m_entity;
23 
24  protected static ref TStringArray s_aVarsOut = {
25  PORT_MAGAZINE_COUNT
26  };
27  override TStringArray GetVariablesOut()
28  {
29  return s_aVarsOut;
30  }
31 
32  override void OnInit(AIAgent owner)
33  {
34  m_entity = owner.GetControlledEntity();
35  }
36 
37  protected override bool TestFunction(AIAgent owner)
38  {
39  if (m_entity && !m_weapon)
40  {
41  m_inventoryManager = SCR_InventoryStorageManagerComponent.Cast(m_entity.FindComponent(SCR_InventoryStorageManagerComponent));
42  BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(m_entity.FindComponent(BaseWeaponManagerComponent));
43  if (weaponManager)
44  m_weapon = weaponManager.GetCurrent();
45  }
46 
47  if (!m_inventoryManager || !m_weapon)
48  return false;
49  int ammo = m_inventoryManager.GetMagazineCountByWeapon(m_weapon);
50  bool result = false;
51  switch (m_TestType)
52  {
53  case EVariableTestType.EqualsValue:
54  {
55  result = ammo == m_iNumberOfMagazines;
56  break;
57  }
58  case EVariableTestType.BiggerThanValue:
59  {
60  result = ammo > m_iNumberOfMagazines;
61  break;
62  }
63  case EVariableTestType.SmallerThanValue:
64  {
65  result = ammo < m_iNumberOfMagazines;
66  break;
67  }
68  case EVariableTestType.WasChanged:
69  {
70  result = ammo != prevAmmo;
71  prevAmmo = ammo;
72  break;
73  }
74  }
75  SetVariableOut(PORT_MAGAZINE_COUNT, ammo);
76  return result;
77  }
78 
79  protected override bool VisibleInPalette()
80  {
81  return true;
82  }
83 
84  override protected string GetNodeMiddleText()
85  {
86  return "Checks: " + typename.EnumToString(EVariableTestType,m_TestType) + " with value: " + m_iNumberOfMagazines.ToString();
87  }
88 
89  protected override string GetOnHoverDescription()
90  {
91  return "Decorator that tests if entity has a weapon specified in attribute either as weapon type or as magazine well, in that case it returns the weapon type of the weapon";
92  }
93 };
EqualsValue
@ EqualsValue
Definition: SCR_AIDecoHasMagazineCount.c:3
EVariableTestType
EVariableTestType
Definition: SCR_AIDecoHasMagazineCount.c:1
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
Attribute
typedef Attribute
Post-process effect of scripted camera.
BaseWeaponComponent
Definition: BaseWeaponComponent.c:12
SCR_AIDecoHasMagazineCount
Definition: SCR_AIDecoHasMagazineCount.c:9
SmallerThanValue
@ SmallerThanValue
Definition: SCR_AIDecoHasMagazineCount.c:5
BiggerThanValue
@ BiggerThanValue
Definition: SCR_AIDecoHasMagazineCount.c:4
WasChanged
@ WasChanged
Definition: SCR_AIDecoHasMagazineCount.c:6