Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIPickMagazines.c
Go to the documentation of this file.
2{
3 static const string PORT_MAGAZINE_WELL = "MagazineWell";
4
5 [Attribute("", UIWidgets.EditBox, "Name of magazine well" )]
6 protected string m_sMagazineWellType;
7
8 private IEntity m_OwnerEntity;
9 private SCR_InventoryStorageManagerComponent m_Inventory;
10 private typename m_oMagazineWell;
11
12 protected static ref TStringArray s_aVarsIn = {
13 PORT_MAGAZINE_WELL
14 };
16 {
17 return s_aVarsIn;
18 }
19
20 override void OnInit(AIAgent owner)
21 {
22 m_OwnerEntity = owner.GetControlledEntity();
23 if (!m_OwnerEntity)
24 Debug.Error("Owner must be a character!");
25 m_Inventory = SCR_InventoryStorageManagerComponent.Cast(m_OwnerEntity.FindComponent(SCR_InventoryStorageManagerComponent));
26 }
27
28 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
29 {
30 if (!m_Inventory)
31 ENodeResult.FAIL;
32
33 if (!GetVariableIn(PORT_MAGAZINE_WELL,m_oMagazineWell))
34 m_oMagazineWell = m_sMagazineWellType.ToType();
35
36 CharacterVicinityComponent vicinity = CharacterVicinityComponent.Cast(m_OwnerEntity.FindComponent(CharacterVicinityComponent));
37 if (vicinity)
38 {
39 array<IEntity> items = {};
40 vicinity.GetAvailableItems(items);
41
42 MagazineComponent magComp;
43 foreach (IEntity item : items)
44 {
45 magComp = MagazineComponent.Cast(item.FindComponent(MagazineComponent));
46 if (!magComp)
47 continue;
48
49 if (magComp.GetMagazineWell().Type() == m_oMagazineWell && !m_Inventory.TryInsertItem(item,EStoragePurpose.PURPOSE_DEPOSIT))
50 ChimeraCharacter.Cast(m_OwnerEntity).GetCharacterController().ReloadWeaponWith(item);
51 }
52
53 if (items.IsEmpty())
54 {
55 PrintFormat("No items found to pick up by %1!",m_OwnerEntity);
56 return ENodeResult.FAIL;
57 }
58 else
59 {
60 return ENodeResult.SUCCESS;
61 }
62 }
63
64 return ENodeResult.FAIL;
65 }
66
67 protected static override bool VisibleInPalette()
68 {
69 return true;
70 }
71
72 protected static override string GetOnHoverDescription()
73 {
74 return "AI task that picks up all magazines of provided MagazineWell type in the vicinity of its inventory.";
75 }
76};
Definition Debug.c:13
proto bool GetVariableIn(string name, out void val)
static override bool VisibleInPalette()
static override string GetOnHoverDescription()
static ref TStringArray s_aVarsIn
override TStringArray GetVariablesIn()
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
override void OnInit(AIAgent owner)
ENodeResult
Definition ENodeResult.c:13
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
EStoragePurpose
array< string > TStringArray
Definition Types.c:385