Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AISwitchMuzzle.c
Go to the documentation of this file.
2 {
3  protected static const string PORT_MUZZLE_ID = "MuzzleId";
4 
5  //--------------------------------------------------------------------------------------------
6  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
7  {
8  if (!m_WeaponMgrComp || !m_ControlComp || !m_InventoryMgr)
9  return ENodeResult.FAIL;
10 
11  int newMuzzleId = -1;
12  GetVariableIn(PORT_MUZZLE_ID, newMuzzleId);
13  if (newMuzzleId == -1)
14  {
15  #ifdef AI_DEBUG
16  AddDebugMessage("Skipped muzzle switch, no muzzle was provided");
17  #endif
18  return ENodeResult.SUCCESS;
19  }
20 
21  BaseCompartmentSlot compartmentSlot = m_CompartmentAccessComp.GetCompartment();
22 
23  // Return success if done
24  // Ignore if we are in compartment. There are no turret weapons where we can choose a muzzle.
25  // And there is no API to switch muzzle in a turret anyway.
26  int currentMuzzleId = SCR_AIWeaponHandling.GetCurrentMuzzleId(m_WeaponMgrComp);
27  if (currentMuzzleId == newMuzzleId || compartmentSlot)
28  {
29  #ifdef AI_DEBUG
30  AddDebugMessage("Muzzle switch completed");
31  #endif
32  return ENodeResult.SUCCESS;
33  }
34 
35  #ifdef AI_DEBUG
36  AddDebugMessage(string.Format("Start Muzzle Switch: %1", newMuzzleId));
37  #endif
38  SCR_AIWeaponHandling.StartMuzzleSwitch(m_ControlComp, newMuzzleId);
39 
40  return ENodeResult.RUNNING;
41  }
42 
43  //--------------------------------------------------------------------------------------------
44  protected static ref TStringArray s_aVarsIn = {PORT_MUZZLE_ID};
45  override TStringArray GetVariablesIn() { return s_aVarsIn; }
46 
47  override bool VisibleInPalette() { return true; }
48 }
SCR_AISwitchMuzzle
Definition: SCR_AISwitchMuzzle.c:1
SCR_AIWeaponHandlingBase
Base class for nodes which handle magazine switching.
Definition: SCR_AIWeaponHandlingBase.c:2