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