Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AISpawnMagazines.c
Go to the documentation of this file.
1 class SCR_AISpawnMagazines : AITaskScripted
2 {
3  static const string PORT_MAGAZINE_WELL = "MagazineWell";
4 
5  ref map<string, string> m_mTypenameToResourceName;
6 
7  [Attribute("", UIWidgets.EditBox, "Name of magazine well" )]
8  protected string m_sMagazineWellType;
9 
10  [Attribute("4", UIWidgets.Slider, "Amount of magazines", "0 10 1" )]
11  protected int m_iMagazineCount;
12 
13  private typename m_oMagazineWell;
14 
15  protected static ref TStringArray s_aVarsIn = {
16  PORT_MAGAZINE_WELL
17  };
18  override TStringArray GetVariablesIn()
19  {
20  return s_aVarsIn;
21  }
22 
23  override void OnInit(AIAgent owner)
24  {
25  m_mTypenameToResourceName = new map<string, string>;
26  m_mTypenameToResourceName.Insert("MagazineWellAK545","{E5912E45754CD421}Prefabs/Weapons/Magazines/Magazine_545x39_AK_30rnd_Tracer.et");
27  m_mTypenameToResourceName.Insert("MagazineWellStanag556","{A9A385FE1F7BF4BD}Prefabs/Weapons/Magazines/Magazine_556x45_STANAG_30rnd_Tracer.et");
28  m_mTypenameToResourceName.Insert("MagazineWellPKM","{BEEA49E27174B224}Prefabs/Weapons/Magazines/Box_762x54_PK_100rnd_Tracer.et");
29  m_mTypenameToResourceName.Insert("MagazineWellM60","{AD8AB93729348C3E}Prefabs/Weapons/Magazines/Box_762x51_M60_100rnd_Tracer.et");
30  m_mTypenameToResourceName.Insert("MagazineWellM14","{6D18CC33708EE712}Prefabs/Weapons/Magazines/Magazine_762x51_M14_20rnd_Base.et");
31  m_mTypenameToResourceName.Insert("MagazineWellSVD","{9CCB46C6EE632C1A}Prefabs/Weapons/Magazines/Magazine_762x54_SVD_10rnd_Sniper.et");
32  m_mTypenameToResourceName.Insert("MagazineWellVZ58_762","{FAFA0D71E75CEBE2}Prefabs/Weapons/Magazines/Vz58/Magazine_762x39_Vz58_30rnd_Tracer.et");
33  m_mTypenameToResourceName.Insert("MagazineWellM9Beretta","{9C05543A503DB80E}Prefabs/Weapons/Magazines/Magazine_9x19_M9_15rnd_Ball.et");
34  m_mTypenameToResourceName.Insert("MagazineWellMakarovPM","{8B853CDD11BA916E}Prefabs/Weapons/Magazines/Magazine_9x18_PM_8rnd_Ball.et");
35  m_mTypenameToResourceName.Insert("MagazineWellM249","{06D722FC2666EB83}Prefabs/Weapons/Magazines/Box_556x45_M249_200rnd_4Ball_1Tracer.et");
36  m_mTypenameToResourceName.Insert("MagazineWellRPG7","{32E12D322E107F1C}Prefabs/Weapons/Ammo/Ammo_Rocket_PG7VM.et");
37  }
38 
39  override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
40  {
41  if (!GetVariableIn(PORT_MAGAZINE_WELL,m_oMagazineWell))
42  m_oMagazineWell = m_sMagazineWellType.ToType();
43 
44  ResourceName resourceName;
45  if (m_mTypenameToResourceName.Find(m_oMagazineWell.ToString(),resourceName))
46  {
47  EntitySpawnParams params = EntitySpawnParams();
48  params.TransformMode = ETransformMode.WORLD;
49  params.Transform[3] = owner.GetControlledEntity().GetOrigin();
50  Resource res = Resource.Load(resourceName);
51 
52  for (int i = 0; i < m_iMagazineCount; i++)
53  GetGame().SpawnEntityPrefab(res, null, params);
54  return ENodeResult.SUCCESS;
55  }
56  return ENodeResult.FAIL;
57  }
58 
59  protected override bool VisibleInPalette()
60  {
61  return true;
62  }
63 
64  protected override string GetOnHoverDescription()
65  {
66  return "AI task that picks up all magazines of provided MagazineWell type in the vicinity of its inventory.";
67  }
68 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_AISpawnMagazines
Definition: SCR_AISpawnMagazines.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24