DayZ 1.24
Loading...
Searching...
No Matches
Bot_TestSpawnAndOpenCan.c
Go to the documentation of this file.
2
3class BotSpawnEntityInHands extends BotStateBase
4{
5 string m_Type;
6
7 void BotSpawnEntityInHands(Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
8 {
9 if (new_type == string.Empty)
10 m_Type = "TunaCan";
11 else
13 }
14
15 override void OnEntry(BotEventBase e)
16 {
17 super.OnEntry(e);
18
19 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
20 m_Owner.GetHumanInventory().CreateInHands(m_Type);
21 }
22
23 override void OnExit(BotEventBase e) { super.OnExit(e); }
24
25 override void OnUpdate(float dt)
26 {
27 super.OnUpdate(dt);
28
29 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
30 if (inHands)
31 {
32 botDebugPrint("[bot] + " + m_Owner + " hand item=" + inHands + " bot=" + m_Owner);
33 m_Bot.ProcessEvent(new BotEventEntityInHands(m_Owner, inHands));
34 }
35 }
36};
37
39
41{
43
44 override void OnEntry(BotEventBase e)
45 {
46 super.OnEntry(e);
47
48 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
49 {
51 if (ev_ih)
52 {
53 m_Entity = ev_ih.m_Entity;
55 if (b)
56 {
57 botDebugPrint("[bot] + " + m_Owner + " will open edible item=" + b + " bot=" + m_Owner);
58 b.Open();
59 }
60 }
61 }
62 }
63
64 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
65
66 override void OnExit(BotEventBase e)
67 {
68 super.OnExit(e);
69 }
70
71 override void OnUpdate(float dt)
72 {
73 super.OnUpdate(dt);
74
75 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
76 botDebugSpam("[bot] + " + m_Owner + " wait for opened item inHands=" + inHands + " bot=" + m_Owner);
77 if (inHands)
78 {
79 string t_str = inHands.GetType();
80 //string t_str = t.ToString();
81 if (t_str.IndexOf("_Opened") != -1)
82 {
83 botDebugPrint("[bot] + " + m_Owner + " opened item=" + inHands + " bot=" + m_Owner);
84 m_Bot.ProcessEvent(new BotEventEntityInHandsOpened(m_Owner, inHands));
85 }
86 }
87 }
88};
89
90
92{
93 string m_Type;
94 ref BotSpawnEntityInHands m_Spawning;
96
97 void Bot_TestSpawnOpen(Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
98 {
100
101 // setup nested state machine
102 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
103
104 m_Spawning = new BotSpawnEntityInHands(m_Bot, this);
105 m_Opening = new BotOpenEntityInHands(m_Bot, this);
106
107 // events
109
110 // transitions
111 m_FSM.AddTransition(new BotTransition(m_Spawning, __EntInH__, m_Opening));
112 //m_FSM.AddTransition(new BotTransition( m_Opening, __EntAtt__, m_Eating));
113 //m_FSM.AddTransition(new BotTransition( m_Eating, __EntAtt__, m_Eating));
114
115 m_FSM.SetInitialState(m_Spawning);
116 }
117
118 override void OnEntry(BotEventBase e) { super.OnEntry(e); }
119 override void OnExit(BotEventBase e) { super.OnExit(e); }
120 override void OnUpdate(float dt) { super.OnUpdate(dt); }
121};
122
123
125
127{
128 override void OnEntry(BotEventBase e) { super.OnEntry(e); }
129 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
130 override void OnExit(BotEventBase e) { super.OnExit(e); }
131
132 override void OnUpdate(float dt)
133 {
134 super.OnUpdate(dt);
135
136 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
137 botDebugSpam("[bot] + " + m_Owner + " waiting for empty hands, inHands=" + inHands + " bot=" + m_Owner);
138 if (!inHands)
139 {
140 botDebugPrint("[bot] + " + m_Owner + " hand slot empty. bot=" + m_Owner);
141 m_Bot.ProcessEvent(new BotEventHandsEmpty(m_Owner, inHands));
142 }
143 }
144};
145
147{
148 /*override void OnExit (BotEventBase e)
149 {
150 super.OnExit(e);
151 m_Bot.ProcessEvent(new BotEventEndOK(m_Owner));
152 }*/
153};
154
155
157{
159
160 override void OnEntry(BotEventBase e)
161 {
162 super.OnEntry(e);
163
164
165 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
166 if (inHands)
167 {
168 botDebugPrint("[bot] + " + m_Owner + " dropping item=" + inHands + " bot=" + m_Owner);
169 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
170 m_Owner.PredictiveDropEntity(inHands);
171 //m_Owner.LocalDropEntity(inHands);
172 }
173 }
174
175 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
176 override void OnExit(BotEventBase e) { super.OnExit(e); }
177 override void OnUpdate(float dt) { super.OnUpdate(dt); }
178};
179
181{
183
184 override void OnEntry(BotEventBase e)
185 {
186 super.OnEntry(e);
187
188 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
189 if (inHands)
190 {
191 botDebugPrint("[bot] + " + m_Owner + " eating item=" + inHands + " bot=" + m_Owner);
192 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
193 {
194#ifdef BOT
195 ActionManagerBase mgr = m_Owner.GetActionManager();
197 if (cli_mgr)
198 {
199 ActionTarget target;
200 target = new ActionTarget(inHands, null, -1, vector.Zero, -1);
201 cli_mgr.PerformAction(AT_EAT, target, inHands);
202 }
203#endif
204 }
205 }
206 }
207
208 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
209 override void OnExit(BotEventBase e) { super.OnExit(e); }
210 override void OnUpdate(float dt) { super.OnUpdate(dt); }
211};
212
213
215{
217
218 override void OnEntry(BotEventBase e)
219 {
220 super.OnEntry(e);
221
222 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
223 if (inHands)
224 {
225 botDebugPrint("[bot] + " + m_Owner + " deleting item=" + inHands + " bot=" + m_Owner);
226 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
227 inHands.Delete();
228 }
229 }
230
231 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
232 override void OnExit(BotEventBase e) { super.OnExit(e); }
233 override void OnUpdate(float dt) { super.OnUpdate(dt); }
234};
235
236
237class Bot_TestSpawnOpenDrop extends Bot_TestSpawnOpen
238{
240
242 {
243 m_Dropping = new BotDropEntityInHands(m_Bot, this);
244
245 // events
248
249 // transitions
250 m_FSM.AddTransition(new BotTransition(m_Opening, __EntOpn__, m_Dropping));
251 m_FSM.AddTransition(new BotTransition(m_Dropping, __HndChg__, NULL));
252 }
253
254 override void OnEntry(BotEventBase e) { super.OnEntry(e); }
255 override void OnExit(BotEventBase e) { super.OnExit(e); }
256 override void OnUpdate(float dt) { super.OnUpdate(dt); }
257};
258
259class Bot_TestSpawnOpenDestroy extends Bot_TestSpawnOpen
260{
262
264 {
265 m_Destroying = new BotDestroyEntityInHands(m_Bot, this);
266
267 // events
270
271 // transitions
272 m_FSM.AddTransition(new BotTransition(m_Opening, __EntOpn__, m_Destroying));
273 m_FSM.AddTransition(new BotTransition(m_Destroying, __HndChg__, NULL));
274 }
275
276 override void OnEntry(BotEventBase e) { super.OnEntry(e); }
277 override void OnExit(BotEventBase e) { super.OnExit(e); }
278 override void OnUpdate(float dt) { super.OnUpdate(dt); }
279};
280
281class Bot_TestSpawnOpenEat extends Bot_TestSpawnOpen
282{
284
286 {
287 m_Eating = new BotEatEntityInHands(m_Bot, this);
288
289 // events
292
293 // transitions
294 m_FSM.AddTransition(new BotTransition(m_Opening, __EntOpn__, m_Eating));
295 m_FSM.AddTransition(new BotTransition(m_Eating, __HndChg__, NULL));
296 }
297
298 override void OnEntry(BotEventBase e)
299 {
300 super.OnEntry(e);
301 }
302
303 override void OnExit(BotEventBase e)
304 {
305 super.OnExit(e);
306 }
307
308 override void OnUpdate(float dt)
309 {
310 super.OnUpdate(dt);
311 }
312};
313
eBleedingSourceType m_Type
EntityAI m_Entity
Definition ActionDebug.c:11
class ActionTargets ActionTarget
void botDebugSpam(string s)
Definition Bot.c:191
void botDebugPrint(string s)
Definition Bot.c:182
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition BotFSM.c:7
Empty
Definition Hand_States.c:14
enum ProcessDirectDamageFlags m_Owner
void Bot_TestSpawnOpenDestroy(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
ref BotDestroyEntityInHands m_Destroying
override void OnExit(BotEventBase e)
override void OnUpdate(float dt)
void Bot_TestSpawnOpenDrop(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
ref BotEatEntityInHands m_Eating
ref BotDropEntityInHands m_Dropping
void Bot_TestSpawnOpenEat(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
override void OnEntry(BotEventBase e)
represents event that triggers transition from state to state
Definition BotEvents.c:5
Bot Finite State Machine (Hierarchical)
Definition Bot.c:19
represent weapon state base
Definition Bot_Hunt.c:16
void BotSpawnEntityInHands(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
override void OnUpdate(float dt)
ref BotSpawnEntityInHands m_Spawning
override void OnEntry(BotEventBase e)
override void OnAbort(BotEventBase e)
override void OnExit(BotEventBase e)
void Bot_TestSpawnOpen(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
ref BotOpenEntityInHands m_Opening
override void OnExit(BotEventBase e)
override void OnEntry(BotEventBase e)
override void OnUpdate(float dt)
override void OnAbort(BotEventBase e)
static const vector Zero
Definition EnConvert.c:110
DayZPlayerInstanceType
defined in C++