Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGetMagazineWell.c
Go to the documentation of this file.
1 class SCR_AIGetMagazineWell: AITaskScripted
2 {
3  static const string PORT_MAGAZINE_WELL_OUT = "MagazineWellOut";
4 
5  private IEntity m_ownerEntity;
6  private BaseWeaponManagerComponent m_weaponManager;
7 
8  //------------------------------------------------------------------------------------------------
9  override bool VisibleInPalette() {return true;}
10 
11  //------------------------------------------------------------------------------------------------
12  override void OnInit(AIAgent owner)
13  {
14  m_ownerEntity = owner.GetControlledEntity();
15  if (!m_ownerEntity)
16  Debug.Error("Must be run on ai agent that has owner entity!");
17  }
18 
19  //------------------------------------------------------------------------------------------------
20  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
21  {
22  if (!m_weaponManager)
23  {
24  if ( !m_ownerEntity )
25  return ENodeResult.FAIL;
26  m_weaponManager = BaseWeaponManagerComponent.Cast(m_ownerEntity.FindComponent(BaseWeaponManagerComponent));
27  if (!m_weaponManager)
28  return ENodeResult.FAIL;
29  }
30  BaseWeaponComponent weapon = m_weaponManager.GetCurrent();
31  if (!weapon)
32  return ENodeResult.FAIL;
33 
34  SetVariableOut(PORT_MAGAZINE_WELL_OUT, GetWeaponMainMagazineWell(weapon));
35  return ENodeResult.SUCCESS;
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  protected static ref TStringArray s_aVarsOut = {
40  PORT_MAGAZINE_WELL_OUT
41  };
42  override TStringArray GetVariablesOut()
43  {
44  return s_aVarsOut;
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  override string GetOnHoverDescription()
49  {
50  return "Returns MagazineWell of current weapon on Owner's controlled entity";
51  };
52 
53  //------------------------------------------------------------------------------------------------
54  static typename GetWeaponMainMagazineWell(BaseWeaponComponent weapon)
55  {
56  ref array<BaseMuzzleComponent> outMuzzles = new array<BaseMuzzleComponent>;
57  weapon.GetMuzzlesList(outMuzzles);
58  if (!outMuzzles.IsEmpty())
59  return outMuzzles[0].GetMagazineWell().Type();
60  else
61  return BaseWeaponComponent;
62  }
63 };
s_aVarsOut
SCR_AIPickupInventoryItemsBehavior s_aVarsOut
Definition: SCR_AIGetCombatMoveRequestParameters.c:149
BaseWeaponComponent
Definition: BaseWeaponComponent.c:12
SCR_AIGetMagazineWell
Definition: SCR_AIGetMagazineWell.c:1