Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AISendMessage.c
Go to the documentation of this file.
1
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 };
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
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
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 };
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};
ArmaReforgerScripted GetGame()
Definition game.c:1398
Base class for all messages related to AI.
Definition AIMessage.c:14
proto bool GetVariableIn(string name, out void val)
Base class for nodes sending message.
override void OnInit(AIAgent owner)
AICommunicationComponent m_Mailbox
ENodeResult SendMessage(AIAgent owner, AIMessage msg)
Calls this in inherited nodes to send the message.
static ref TStringArray s_aVarsInBase
bool InitSendMessageInputs(AIAgent owner)
override TStringArray GetVariablesIn()
Class for generic nodes with extra input ports which send messages.
static ref TStringArray s_aVarsIn
bool InitSendMessageInputs(AIAgent owner)
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
static override bool VisibleInPalette()
override TStringArray GetVariablesIn()
ENodeResult
Definition ENodeResult.c:13
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
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
array< string > TStringArray
Definition Types.c:385