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_AISendMessage.c
Go to the documentation of this file.
1
2
class
SCR_AISendMessageBase
:
AITaskScripted
3
{
4
// Constants
5
static
const
string
PORT_RECEIVER =
"Receiver"
;
6
static
const
string
PORT_STRING =
"StringIn"
;
7
8
// Variables
9
protected
AICommunicationComponent
m_Mailbox
;
10
AIAgent
m_Receiver
;
11
12
[
Attribute
(
""
,
UIWidgets
.EditBox,
"String value"
,
""
)]
13
string
m_string
;
14
15
16
protected
static
ref
TStringArray
s_aVarsInBase
= {
17
PORT_RECEIVER,
18
PORT_STRING
19
};
20
override
TStringArray
GetVariablesIn
()
21
{
22
return
s_aVarsInBase
;
23
}
24
25
override
void
OnInit
(AIAgent owner)
26
{
27
m_Mailbox
= owner.GetCommunicationComponent();
28
}
29
30
// Validates owner, mailbox, reads RECEIVER port.
31
protected
bool
InitSendMessageInputs
(AIAgent owner)
32
{
33
if
(! owner)
34
{
35
Print
(
"No owner of the task send message! Something wrong!"
,
LogLevel
.ERROR);
36
return
false
;
37
};
38
39
if
(!
m_Mailbox
)
40
{
41
Print
(
"Owner of the task has no AICommunicationComponent!"
,
LogLevel
.ERROR);
42
return
false
;
43
};
44
45
GetVariableIn
(PORT_RECEIVER,
m_Receiver
);
46
if
(!
m_Receiver
)
47
{
48
m_Receiver
= owner;
49
};
50
return
true
;
51
}
52
54
protected
ENodeResult
SendMessage
(AIAgent owner,
AIMessage
msg)
55
{
56
#ifdef AI_DEBUG
57
SCR_MailboxComponent mailboxComp = SCR_MailboxComponent.Cast(
m_Mailbox
);
58
if
(mailboxComp)
59
mailboxComp.DebugLogBroadcastMessage(msg);
60
#endif
61
62
if
(
m_Mailbox
.RequestBroadcast(msg,
m_Receiver
))
63
return
ENodeResult
.SUCCESS;
64
else
65
{
66
PrintFormat
(
"Unable to send message from %1 to %2"
, owner,
m_Receiver
);
67
return
ENodeResult
.FAIL;
68
};
69
}
70
};
71
73
class
SCR_AISendMessageGeneric
:
SCR_AISendMessageBase
74
{
75
static
const
string
PORT_ENTITY =
"EntityIn"
;
76
static
const
string
PORT_INTEGER =
"IntegerIn"
;
77
static
const
string
PORT_VECTOR =
"VectorIn"
;
78
static
const
string
PORT_BOOL =
"BoolIn"
;
79
static
const
string
PORT_FLOAT =
"FloatIn"
;
80
static
const
string
PORT_TYPENAME =
"TypenameIn"
;
81
static
const
string
PORT_SMARTACTION =
"SmartActionComponent"
;
82
static
const
string
PORT_PRIORITY_LEVEL =
"PriorityLevel"
;
83
84
85
[
Attribute
(
"0"
,
UIWidgets
.EditBox,
"Integer value"
,
""
)]
86
int
m_integer;
87
88
[
Attribute
(
"0"
,
UIWidgets
.EditBox,
"Vector value"
,
""
)]
89
vector
m_vector;
90
91
[
Attribute
(
"0"
,
UIWidgets
.CheckBox,
"Bool value"
,
""
)]
92
bool
m_bool;
93
94
protected
SCR_AIWorld
m_aiWorld
;
95
96
// Sets up input variables, as array of strings
97
protected
static
ref
TStringArray
s_aVarsIn
= {
98
PORT_RECEIVER,
99
PORT_STRING,
100
PORT_ENTITY,
101
PORT_INTEGER,
102
PORT_VECTOR,
103
PORT_BOOL,
104
PORT_FLOAT,
105
PORT_TYPENAME,
106
PORT_PRIORITY_LEVEL
107
};
108
override
TStringArray
GetVariablesIn
()
109
{
110
return
s_aVarsIn
;
111
}
112
113
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
114
{
115
if
(
InitSendMessageInputs
(owner))
116
return
ENodeResult
.SUCCESS;
117
118
return
ENodeResult
.FAIL;
119
}
120
121
// Also validates AIWorld
122
override
protected
bool
InitSendMessageInputs
(AIAgent owner)
123
{
124
if
(!super.InitSendMessageInputs(owner))
125
return
false
;
126
127
if
(!
m_aiWorld
)
128
{
129
m_aiWorld
=
SCR_AIWorld
.Cast(
GetGame
().GetAIWorld());
130
if
(!
m_aiWorld
)
131
{
132
Print
(
"Cannot find AIWorld to read config of messages!"
,
LogLevel
.ERROR);
133
return
false
;
134
}
135
};
136
137
return
true
;
138
}
139
140
static
override
bool
VisibleInPalette
()
141
{
142
return
false
;
143
}
144
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
AIMessage
Base class for all messages related to AI.
Definition
AIMessage.c:14
AITaskScripted
Definition
AITaskScripted.c:13
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AISendMessageBase
Base class for nodes sending message.
Definition
SCR_AISendMessage.c:3
SCR_AISendMessageBase::OnInit
override void OnInit(AIAgent owner)
Definition
SCR_AISendMessage.c:25
SCR_AISendMessageBase::m_Receiver
AIAgent m_Receiver
Definition
SCR_AISendMessage.c:10
SCR_AISendMessageBase::m_string
string m_string
Definition
SCR_AISendMessage.c:13
SCR_AISendMessageBase::m_Mailbox
AICommunicationComponent m_Mailbox
Definition
SCR_AISendMessage.c:9
SCR_AISendMessageBase::SendMessage
ENodeResult SendMessage(AIAgent owner, AIMessage msg)
Calls this in inherited nodes to send the message.
Definition
SCR_AISendMessage.c:54
SCR_AISendMessageBase::s_aVarsInBase
static ref TStringArray s_aVarsInBase
Definition
SCR_AISendMessage.c:16
SCR_AISendMessageBase::InitSendMessageInputs
bool InitSendMessageInputs(AIAgent owner)
Definition
SCR_AISendMessage.c:31
SCR_AISendMessageBase::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AISendMessage.c:20
SCR_AISendMessageGeneric
Class for generic nodes with extra input ports which send messages.
Definition
SCR_AISendMessage.c:74
SCR_AISendMessageGeneric::m_aiWorld
SCR_AIWorld m_aiWorld
Definition
SCR_AISendMessage.c:94
SCR_AISendMessageGeneric::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AISendMessage.c:97
SCR_AISendMessageGeneric::InitSendMessageInputs
bool InitSendMessageInputs(AIAgent owner)
Definition
SCR_AISendMessage.c:122
SCR_AISendMessageGeneric::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AISendMessage.c:113
SCR_AISendMessageGeneric::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AISendMessage.c:140
SCR_AISendMessageGeneric::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AISendMessage.c:108
SCR_AIWorld
Definition
SCR_AIWorld.c:24
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
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
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Messages
SCR_AISendMessage.c
Generated by
1.17.0