Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AIDropMagazines.c
Go to the documentation of this file.
1
class
SCR_AIDropMagazines
:
AITaskScripted
2
{
3
static
const
string
PORT_MAGAZINE_WELL =
"MagazineWell"
;
4
5
[
Attribute
(
"0.5"
,
UIWidgets
.Slider,
"Fraction of magazines to drop"
,
"0 1 1"
)]
6
protected
float
m_FractionOfMagazines
;
7
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Name of magazine well"
)]
8
protected
string
m_sMagazineWellType
;
9
10
private
SCR_InventoryStorageManagerComponent m_Inventory;
11
private
typename
m_oMagazineWell;
12
13
//--------------------------------------------------------------------------------------------------------------------------
14
protected
static
ref
TStringArray
s_aVarsIn
= {
15
PORT_MAGAZINE_WELL
16
};
17
override
TStringArray
GetVariablesIn
()
18
{
19
return
s_aVarsIn
;
20
}
21
22
//--------------------------------------------------------------------------------------------------------------------------
23
override
void
OnInit
(AIAgent owner)
24
{
25
IEntity
ent = owner.GetControlledEntity();
26
if
(ent)
27
{
28
m_Inventory = SCR_InventoryStorageManagerComponent.Cast(ent.
FindComponent
(SCR_InventoryStorageManagerComponent));
29
}
30
}
31
32
//--------------------------------------------------------------------------------------------------------------------------
33
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
34
{
35
if
(!m_Inventory)
36
return
ENodeResult
.FAIL;
37
38
if
(!
GetVariableIn
(PORT_MAGAZINE_WELL,m_oMagazineWell))
39
m_oMagazineWell =
m_sMagazineWellType
.ToType();
40
41
array<typename> components = {};
42
array<IEntity> foundItems = {};
43
components.Insert(
MagazineComponent
);
44
45
for
(
int
i = m_Inventory.FindItemsWithComponents(foundItems,components,
EStoragePurpose
.PURPOSE_DEPOSIT)-1; i> -1; i--)
46
{
47
MagazineComponent
magComp =
MagazineComponent
.Cast(foundItems[i].FindComponent(
MagazineComponent
));
48
if
(magComp && magComp.GetMagazineWell().Type() != m_oMagazineWell)
49
{
50
foundItems.Remove(i);
51
}
52
}
53
// now I have only items that are magazines and have same well type
54
55
for
(
int
i = 0, length =
Math
.Floor((foundItems.Count()-1) *
m_FractionOfMagazines
); i <= length; i++)
56
{
57
InventoryItemComponent
pInvComp =
InventoryItemComponent
.Cast(foundItems[i].FindComponent(
InventoryItemComponent
));
58
InventoryStorageSlot
parentSlot = pInvComp.GetParentSlot();
59
bool
removed = m_Inventory.TryRemoveItemFromStorage(foundItems[i],parentSlot.GetStorage());
60
}
61
return
ENodeResult
.SUCCESS;
62
}
63
64
//--------------------------------------------------------------------------------------------------------------------------
65
protected
static
override
bool
VisibleInPalette
()
66
{
67
return
true
;
68
}
69
70
//--------------------------------------------------------------------------------------------------------------------------
71
override
protected
string
GetNodeMiddleText
()
72
{
73
return
"Drop "
+ (
m_FractionOfMagazines
*100).
ToString
() +
"% of magazines to ground."
;
74
}
75
76
//--------------------------------------------------------------------------------------------------------------------------
77
protected
static
override
string
GetOnHoverDescription
()
78
{
79
return
"AI task that drops all magazines of specified MagazineWell type."
;
80
}
81
};
AITaskScripted
Definition
AITaskScripted.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
InventoryItemComponent
Definition
InventoryItemComponent.c:13
InventoryStorageSlot
Definition
InventoryStorageSlot.c:13
MagazineComponent
Definition
MagazineComponent.c:13
Math
Definition
Math.c:13
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AIDropMagazines
Definition
SCR_AIDropMagazines.c:2
SCR_AIDropMagazines::m_FractionOfMagazines
float m_FractionOfMagazines
Definition
SCR_AIDropMagazines.c:6
SCR_AIDropMagazines::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AIDropMagazines.c:23
SCR_AIDropMagazines::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIDropMagazines.c:14
SCR_AIDropMagazines::m_sMagazineWellType
string m_sMagazineWellType
Definition
SCR_AIDropMagazines.c:8
SCR_AIDropMagazines::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIDropMagazines.c:65
SCR_AIDropMagazines::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIDropMagazines.c:77
SCR_AIDropMagazines::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIDropMagazines.c:33
SCR_AIDropMagazines::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIDropMagazines.c:17
SCR_AIDropMagazines::GetNodeMiddleText
string GetNodeMiddleText()
Definition
SCR_AIDropMagazines.c:71
UIWidgets
Definition
attributes.c:40
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EStoragePurpose
EStoragePurpose
Definition
EStoragePurpose.c:13
TStringArray
array< string > TStringArray
Definition
Types.c:385
ToString
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
scripts
Game
AI
ScriptedNodes
Inventory
SCR_AIDropMagazines.c
Generated by
1.17.0