Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
guards.c
Go to the documentation of this file.
1 
5 {
11  bool GuardCondition (WeaponEventBase e) { return true; }
12 };
13 
14 class GuardAnd extends WeaponGuardBase
15 {
16  ref WeaponGuardBase m_arg0;
17  ref WeaponGuardBase m_arg1;
18 
19  void GuardAnd (WeaponGuardBase arg0 = NULL, WeaponGuardBase arg1 = NULL) { m_arg0 = arg0; m_arg1 = arg1; }
20 
21  override bool GuardCondition (WeaponEventBase e)
22  {
23  bool result = m_arg0.GuardCondition(e) && m_arg1.GuardCondition(e);
24  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - " + m_arg0.Type() + " && " + m_arg1.Type() + " = " + result); }
25  return result;
26  }
27 };
28 
29 class GuardNot extends WeaponGuardBase
30 {
31  ref WeaponGuardBase m_arg0;
32 
33  void GuardNot (WeaponGuardBase arg0 = NULL) { m_arg0 = arg0; }
34 
35  override bool GuardCondition (WeaponEventBase e)
36  {
37  bool result = !m_arg0.GuardCondition(e);
38  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - ! " + m_arg0.Type() + " = " + result); }
39  return result;
40  }
41 };
42 
43 class GuardOr extends WeaponGuardBase
44 {
45  ref WeaponGuardBase m_arg0;
46  ref WeaponGuardBase m_arg1;
47 
48  void GuardOr (WeaponGuardBase arg0 = NULL, WeaponGuardBase arg1 = NULL) { m_arg0 = arg0; m_arg1 = arg1; }
49 
50  override bool GuardCondition (WeaponEventBase e)
51  {
52  bool result = m_arg0.GuardCondition(e) || m_arg1.GuardCondition(e);
53  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - " + m_arg0.Type() + " || " + m_arg1.Type() + " = " + result); }
54  return result;
55  }
56 };
57 
58 // guards /////////////////////////////////////////////////////////////////////////////////////////////////////////////
59 
60 class WeaponGuardJammed extends WeaponGuardBase
61 {
62  protected Weapon_Base m_weapon;
63  void WeaponGuardJammed (Weapon_Base w = NULL) { m_weapon = w; }
64 
65  override bool GuardCondition (WeaponEventBase e)
66  {
67  /*int mi = m_weapon.GetCurrentMuzzle();
68  if (m_weapon.IsChamberJammed(mi))*/
69  if (m_weapon.IsJammed())
70  {
71  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - jammed"); }
72  return true;
73  }
74  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - not jammed"); }
75  return false;
76  }
77 };
78 
79 class WeaponGuardIsDestroyed extends WeaponGuardBase
80 {
81  protected Weapon_Base m_weapon;
82  void WeaponGuardIsDestroyed (Weapon_Base w = NULL) { m_weapon = w; }
83 
84  override bool GuardCondition (WeaponEventBase e)
85  {
86  if (m_weapon.IsDamageDestroyed())
87  {
88  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - weapon destroyed"); }
89  return true;
90  }
91  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - weapon not destroyed"); }
92  return false;
93  }
94 }
95 
97 {
98  protected Weapon_Base m_weapon;
99  void WeaponGuardHasAmmo (Weapon_Base w = NULL) { m_weapon = w; }
100 
101  override bool GuardCondition (WeaponEventBase e)
102  {
103  int mi = m_weapon.GetCurrentMuzzle();
104  Magazine mag = m_weapon.GetMagazine(mi);
105  if (mag != NULL && mag.GetAmmoCount() > 0)
106  {
107  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has ammo"); }
108  return true;
109  }
110  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no ammo"); }
111  return false;
112  }
113 };
114 
115 class WeaponGuardHasAmmoInnerMagazine extends WeaponGuardBase
116 {
117  protected Weapon_Base m_weapon;
118  void WeaponGuardHasAmmoInnerMagazine (Weapon_Base w = NULL) { m_weapon = w; }
119 
120  override bool GuardCondition (WeaponEventBase e)
121  {
122  int mi = m_weapon.GetCurrentMuzzle();
123  if (m_weapon.GetInternalMagazineCartridgeCount(mi) >= 1)
124  {
125  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has ammo in inner magazine"); }
126  return true;
127  }
128  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no ammo in inner magazine"); }
129  return false;
130  }
131 };
132 
133 class WeaponGuardHasAmmoInEvent extends WeaponGuardBase
134 {
135  protected Weapon_Base m_weapon;
136  void WeaponGuardHasAmmoInEvent (Weapon_Base w = NULL) { m_weapon = w; }
137 
138  override bool GuardCondition (WeaponEventBase e)
139  {
140  Magazine mag = e.m_magazine;
141  if (mag != NULL && mag.GetAmmoCount() > 0)
142  {
143  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has ammo in event"); }
144  return true;
145  }
146  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no ammo in event"); }
147  return false;
148  }
149 };
150 
151 
152 class WeaponGuardHasMag extends WeaponGuardBase
153 {
154  protected Weapon_Base m_weapon;
155  void WeaponGuardHasMag (Weapon_Base w = NULL) { m_weapon = w; }
156 
157  override bool GuardCondition (WeaponEventBase e)
158  {
159  int mi = m_weapon.GetCurrentMuzzle();
160  Magazine mag = m_weapon.GetMagazine(mi);
161  if (mag != NULL)
162  {
163  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has magazine"); }
164  return true;
165  }
166  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no magazine"); }
167  return false;
168  }
169 };
170 
171 class WeaponGuardChamberEmpty extends WeaponGuardBase
172 {
173  protected Weapon_Base m_weapon;
174  protected int m_muzzle;
175  void WeaponGuardChamberEmpty (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
176 
177  override bool GuardCondition (WeaponEventBase e)
178  {
179  if (m_weapon.IsChamberEmpty(m_muzzle))
180  {
181  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") empty"); }
182  return true;
183  }
184  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") not empty"); }
185  return false;
186  }
187 };
188 
189 class WeaponGuardCurrentChamberEmpty extends WeaponGuardBase
190 {
191  protected Weapon_Base m_weapon;
192  void WeaponGuardCurrentChamberEmpty (Weapon_Base w = NULL) { m_weapon = w; }
193 
194  override bool GuardCondition (WeaponEventBase e)
195  {
196  int mi = m_weapon.GetCurrentMuzzle();
197  if (m_weapon.IsChamberEmpty(mi))
198  {
199  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber empty"); }
200  return true;
201  }
202  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber not empty"); }
203  return false;
204  }
205 };
206 
207 class WeaponGuardAnyChamberEmpty extends WeaponGuardBase
208 {
209  protected Weapon_Base m_weapon;
210  protected int m_muzzle;
211  void WeaponGuardAnyChamberEmpty (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
212 
213  override bool GuardCondition (WeaponEventBase e)
214  {
215  for (int i = 0; i < m_weapon.GetMuzzleCount(); i++)
216  {
217  if (m_weapon.IsChamberEmpty(i))
218  {
219  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - multi chamber (" + i + ") empty"); }
220  return true;
221  }
222  }
223  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no chamber empty"); }
224  return false;
225  }
226 };
227 
228 class WeaponGuardChamberFull extends WeaponGuardBase
229 {
230  protected Weapon_Base m_weapon;
231  protected int m_muzzle;
232  void WeaponGuardChamberFull (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
233 
234  override bool GuardCondition (WeaponEventBase e)
235  {
236  if (m_weapon.IsChamberFull(m_muzzle))
237  {
238  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") full"); }
239  return true;
240  }
241  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") not full"); }
242  return false;
243  }
244 };
245 
246 class WeaponGuardCurrentChamberFull extends WeaponGuardBase
247 {
248  protected Weapon_Base m_weapon;
249  void WeaponGuardCurrentChamberFull (Weapon_Base w = NULL) { m_weapon = w; }
250 
251  override bool GuardCondition (WeaponEventBase e)
252  {
253  int mi = m_weapon.GetCurrentMuzzle();
254  if (m_weapon.IsChamberFull(mi))
255  {
256  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber full"); }
257  return true;
258  }
259  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber not full"); }
260  return false;
261  }
262 };
263 
264 
265 class WeaponGuardInnerMagazineFull extends WeaponGuardBase
266 {
267  protected Weapon_Base m_weapon;
268  void WeaponGuardInnerMagazineFull (Weapon_Base w = NULL) { m_weapon = w; }
269 
270  override bool GuardCondition (WeaponEventBase e)
271  {
272  int mi = m_weapon.GetCurrentMuzzle();
273  if (m_weapon.IsInternalMagazineFull(mi))
274  {
275  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine full"); }
276  return true;
277  }
278  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine not full"); }
279  return false;
280  }
281 };
282 
283 class WeaponGuardInnerMagazineFullShareChamber extends WeaponGuardBase
284 {
285  protected Weapon_Base m_weapon;
286  void WeaponGuardInnerMagazineFullShareChamber (Weapon_Base w = NULL) { m_weapon = w; }
287 
288  override bool GuardCondition (WeaponEventBase e)
289  {
290  int mi = m_weapon.GetCurrentMuzzle();
291 
292  if ( m_weapon.IsChamberFull(mi) && m_weapon.IsInternalMagazineFull(mi))
293  {
294  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine with share chamber is full"); }
295  return true;
296  }
297  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine with share chamber is not full"); }
298  return false;
299  }
300 };
301 
302 class WeaponGuardChamberFiredOut extends WeaponGuardBase
303 {
304  protected Weapon_Base m_weapon;
305  protected int m_muzzle;
306  void WeaponGuardChamberFiredOut (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
307 
308  override bool GuardCondition (WeaponEventBase e)
309  {
310  if (m_weapon.IsChamberFiredOut(m_muzzle))
311  {
312  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") fireout"); }
313  return true;
314  }
315  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") not fireout"); }
316  return false;
317  }
318 };
319 
320 class WeaponGuardCurrentChamberFiredOut extends WeaponGuardBase
321 {
322  protected Weapon_Base m_weapon;
323  void WeaponGuardCurrentChamberFiredOut (Weapon_Base w = NULL) { m_weapon = w; }
324 
325  override bool GuardCondition (WeaponEventBase e)
326  {
327  int mi = m_weapon.GetCurrentMuzzle();
328  if (m_weapon.IsChamberFiredOut(mi))
329  {
330  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber fired out"); }
331  return true;
332  }
333  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber not fired out"); }
334  return false;
335  }
336 };
337 
338 class WeaponGuardAnyChamberFiredOut extends WeaponGuardBase
339 {
340  protected Weapon_Base m_weapon;
341  void WeaponGuardAnyChamberFiredOut (Weapon_Base w = NULL) { m_weapon = w; }
342 
343  override bool GuardCondition (WeaponEventBase e)
344  {
345  for (int i = 0; i < m_weapon.GetMuzzleCount(); i++)
346  {
347  if (m_weapon.IsChamberFiredOut(i))
348  {
349  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - multi chamber (" + i + ") fired out"); }
350  return true;
351  }
352  }
353 
354  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - any chamber has not fired out"); }
355  return false;
356  }
357 };
358 
359 class WeaponGuardCanAttachMag extends WeaponGuardBase
360 {
361  protected Weapon_Base m_weapon;
362  void WeaponGuardCanAttachMag (Weapon_Base w = NULL) { m_weapon = w; }
363 
364  override bool GuardCondition (WeaponEventBase e)
365  {
366  int mi = m_weapon.GetCurrentMuzzle();
367  if (m_weapon && e.m_magazine && m_weapon.CanAttachMagazine(mi, e.m_magazine))
368  {
369  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - can attach magazine"); }
370  return true;
371  }
372  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - cannot attach magazine"); }
373  return false;
374  }
375 };
376 
377 class WeaponGuardCanSwapMag extends WeaponGuardBase
378 {
379  protected Weapon_Base m_weapon;
380  void WeaponGuardCanSwapMag (Weapon_Base w = NULL) { m_weapon = w; }
381 
382  override bool GuardCondition (WeaponEventBase e)
383  {
384  int mi = m_weapon.GetCurrentMuzzle();
385  Magazine attached_mag = m_weapon.GetMagazine(mi);
386  if (m_weapon && e.m_magazine && e.m_magazine != attached_mag /*&& m_weapon.CanSwapMagazine(mi, e.m_magazine)*/)
387  {
388  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - can swap magazine"); }
389  return true;
390  }
391  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - cannot swap magazine"); }
392  return false;
393  }
394 };
395 
396 class WeaponGuardCanDetachMag extends WeaponGuardBase
397 {
398  protected Weapon_Base m_weapon;
399  void WeaponGuardCanDetachMag (Weapon_Base w = NULL) { m_weapon = w; }
400 
401  override bool GuardCondition (WeaponEventBase e)
402  {
403  int mi = m_weapon.GetCurrentMuzzle();
404  if (m_weapon && e.m_magazine && m_weapon.GetMagazine(mi)/* && m_weapon.CanDetachMagazine(mi, e.m_magazine)*/)
405  {
406  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - can detach magazine"); }
407  return true;
408  }
409  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - cannot detach magazine"); }
410  return false;
411  }
412 };
413 
414 class WeaponGuardChamberHasRoomForMoreThanOne extends WeaponGuardBase
415 {
416  protected Weapon_Base m_weapon;
417  void WeaponGuardChamberHasRoomForMoreThanOne (Weapon_Base w = NULL) { m_weapon = w; }
418 
419  override bool GuardCondition (WeaponEventBase e)
420  {
421  int mi = m_weapon.GetCurrentMuzzle();
422  if (m_weapon.GetInternalMagazineMaxCartridgeCount(mi) - m_weapon.GetInternalMagazineCartridgeCount(mi) > 1)
423  {
424  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for more than 1b"); }
425  return true;
426  }
427  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for more than 1b"); }
428  return false;
429  }
430 };
431 
432 class WeaponGuardInternalMagazineHasRoomForBullet extends WeaponGuardBase
433 {
434  protected Weapon_Base m_weapon;
435  void WeaponGuardInternalMagazineHasRoomForBullet (Weapon_Base w = NULL) { m_weapon = w; }
436 
437  override bool GuardCondition (WeaponEventBase e)
438  {
439  int mi = m_weapon.GetCurrentMuzzle();
440  if (m_weapon.GetInternalMagazineMaxCartridgeCount(mi) - m_weapon.GetInternalMagazineCartridgeCount(mi) >= 1)
441  {
442  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for bullet"); }
443  return true;
444  }
445  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for bullet"); }
446  return false;
447  }
448 };
449 
450 class WeaponGuardChamberHasRoomForOne extends WeaponGuardBase
451 {
452  protected Weapon_Base m_weapon;
453  void WeaponGuardChamberHasRoomForOne (Weapon_Base w = NULL) { m_weapon = w; }
454 
455  override bool GuardCondition (WeaponEventBase e)
456  {
457  int mi = m_weapon.GetCurrentMuzzle();
458  if (m_weapon.GetTotalMaxCartridgeCount(mi) - m_weapon.GetTotalCartridgeCount(mi) == 1)
459  {
460  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for 1b"); }
461  return true;
462  }
463  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for 1b"); }
464  return false;
465  }
466 };
467 
468 class WeaponGuardChamberMultiHasRoomBulltet extends WeaponGuardBase
469 {
470  protected Weapon_Base m_weapon;
471  void WeaponGuardChamberMultiHasRoomBulltet (Weapon_Base w = NULL) { m_weapon = w; }
472 
473  override bool GuardCondition (WeaponEventBase e)
474  {
475  int i = m_weapon.GetMuzzleCount() - 1;
476  for ( ; i >= 0; i--)
477  {
478  if (m_weapon.GetTotalMaxCartridgeCount(i) - m_weapon.GetTotalCartridgeCount(i) >= 1)
479  {
480  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for 1b"); }
481  return true;
482  }
483  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for 1b"); }
484  }
485  return false;
486  }
487 };
488 
489 class WeaponGuardChamberMultiHasRoomBulltetIgnoreLast extends WeaponGuardBase
490 {
491  protected Weapon_Base m_weapon;
492  void WeaponGuardChamberMultiHasRoomBulltetIgnoreLast (Weapon_Base w = NULL) { m_weapon = w; }
493 
494  override bool GuardCondition (WeaponEventBase e)
495  {
496  int i = m_weapon.GetMuzzleCount() - 1;
497  bool emty_one = false;
498  for ( ; i >= 0; i--)
499  {
500  if (m_weapon.GetTotalMaxCartridgeCount(i) - m_weapon.GetTotalCartridgeCount(i) >= 1)
501  {
502  if ( !emty_one )
503  {
504  emty_one = true;
505  }
506  else
507  {
508  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for 1b"); }
509  return true;
510  }
511  }
512  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for 1b"); }
513  }
514  return false;
515  }
516 };
517 
518 
519 class WeaponGuardHasAmmoInLoopedState extends WeaponGuardBase
520 {
521  WeaponChambering_Base m_state;
522  void WeaponGuardHasAmmoInLoopedState (WeaponChambering_Base state) { m_state = state; }
523 
524  override bool GuardCondition (WeaponEventBase e)
525  {
526  Magazine mag = m_state.m_srcMagazine;
527  if (mag != NULL && mag.GetAmmoCount() > 0)
528  {
529  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - has ammo in looped state"); }
530  return true;
531  }
532  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - no ammo in looped state"); }
533  return false;
534  }
535 };
536 
537 class WeaponGuardMagazinesHaveEqualSizes extends WeaponGuardBase
538 {
539  protected Weapon_Base m_weapon;
540  void WeaponGuardMagazinesHaveEqualSizes (Weapon_Base w = NULL) { m_weapon = w; }
541 
542  override bool GuardCondition (WeaponEventBase e)
543  {
544  int mi = m_weapon.GetCurrentMuzzle();
545  Magazine mag = m_weapon.GetMagazine(mi);
546  Magazine mag2 = e.m_magazine;
547  if (mag != NULL && mag2 != NULL)
548  {
549  bool eq = magazinesHaveEqualSizes(mag, mag2);
550  if (eq)
551  {
552  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - same inventory sizes"); }
553  return true;
554  }
555 
556  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - different inventory sizes"); }
557  return false;
558  }
559  Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - mag == NULL or mag2 == NULL, cannot perform comparison");
560  return false;
561  }
562 };
563 
564 class WeaponGuardWeaponCharged extends WeaponGuardBase
565 {
566  protected Weapon_Base m_weapon;
567 
568  void WeaponGuardWeaponCharged (Weapon_Base w = NULL) { m_weapon = w; }
569 
570  override bool GuardCondition (WeaponEventBase e)
571  {
572  return m_weapon.IsCharged();
573  }
574 }
575 
577 {
578  protected Weapon_Base m_weapon;
579 
581 
582  override bool GuardCondition (WeaponEventBase e)
583  {
584  return !m_weapon.IsCharged();
585  }
586 }
587 
589 {
590  protected Weapon_Base m_weapon;
591 
592  void WeaponGuardWeaponOpen (Weapon_Base w = NULL) { m_weapon = w; }
593 
594  override bool GuardCondition (WeaponEventBase e)
595  {
596  return m_weapon.IsWeaponOpen();
597  }
598 }
599 
600 
601 class WeaponGuardWeaponManagerWantContinue extends WeaponGuardBase
602 {
603  override bool GuardCondition (WeaponEventBase e)
604  {
605  PlayerBase player = PlayerBase.Cast(e.m_player);
606  return player.GetWeaponManager().WantContinue();
607  }
608 };
609 
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
LogManager
Definition: debug.c:734
wpnDebugPrint
void wpnDebugPrint(string s)
Definition: debug.c:9
GuardCondition
override bool GuardCondition(WeaponEventBase e)
Definition: guards.c:101
WeaponGuardWeaponDischarged
void WeaponGuardWeaponDischarged(Weapon_Base w=NULL)
Definition: guards.c:580
WeaponGuardWeaponOpen
void WeaponGuardWeaponOpen(Weapon_Base w=NULL)
Definition: guards.c:585
WeaponChambering_Base
Definition: weaponchambering.c:85
PlayerBase
Definition: playerbaseclient.c:1
WeaponGuardBase
represents guard on a transition from state to state
Definition: guards.c:4
Object
Definition: objecttyped.c:1
magazinesHaveEqualSizes
bool magazinesHaveEqualSizes(notnull Magazine mag, notnull Magazine mag2)
Definition: weapon_utils.c:98
WeaponGuardHasAmmo
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition: guards.c:99
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
m_weapon
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition: guards.c:583
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5