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_AIPickMagazines.c
Go to the documentation of this file.
1
class
SCR_AIPickMagazines
:
AITaskScripted
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
};
15
override
TStringArray
GetVariablesIn
()
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
};
AITaskScripted
Definition
AITaskScripted.c:13
CharacterVicinityComponent
Definition
CharacterVicinityComponent.c:13
ChimeraCharacter
Definition
ChimeraCharacter.c:13
Debug
Definition
Debug.c:13
IEntity
Definition
IEntity.c:13
MagazineComponent
Definition
MagazineComponent.c:13
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AIPickMagazines
Definition
SCR_AIPickMagazines.c:2
SCR_AIPickMagazines::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIPickMagazines.c:67
SCR_AIPickMagazines::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIPickMagazines.c:72
SCR_AIPickMagazines::m_sMagazineWellType
string m_sMagazineWellType
Definition
SCR_AIPickMagazines.c:6
SCR_AIPickMagazines::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIPickMagazines.c:12
SCR_AIPickMagazines::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIPickMagazines.c:15
SCR_AIPickMagazines::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIPickMagazines.c:28
SCR_AIPickMagazines::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AIPickMagazines.c:20
UIWidgets
Definition
attributes.c:40
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
PrintFormat
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)
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EStoragePurpose
EStoragePurpose
Definition
EStoragePurpose.c:13
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Inventory
SCR_AIPickMagazines.c
Generated by
1.17.0