DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
WeaponChambering.c
Go to the documentation of this file.
1// load 1 bullet
2class WeaponChambering_Start extends WeaponStartAction
3{
4 override void OnEntry (WeaponEventBase e)
5 {
6 super.OnEntry(e);
7 if (e)
8 {
9 m_weapon.SelectionBulletHide();
10 m_weapon.ForceSyncSelectionState();
11 }
12 }
13
15 {
16 return true;
17 }
18};
19
21{
22 float m_damage;
23 string m_type;
25 Magazine m_srcMagazine;
26
28 {
29 if (!super.SaveCurrentFSMState(ctx))
30 return false;
31
32 if (!ctx.Write(m_damage))
33 {
34 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.SaveCurrentFSMState: cannot write m_damage for weapon=" + m_weapon);
35 return false;
36 }
37 if (!ctx.Write(m_type))
38 {
39 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.SaveCurrentFSMState: cannot write m_type for weapon=" + m_weapon);
40 return false;
41 }
42 if (!ctx.Write(m_magazineType))
43 {
44 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.SaveCurrentFSMState: cannot write m_magazineType for weapon=" + m_weapon);
45 return false;
46 }
47 if (!ctx.Write(m_srcMagazine))
48 {
49 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.SaveCurrentFSMState: cannot write m_srcMagazine for weapon=" + m_weapon);
50 return false;
51 }
52 return true;
53 }
54
55 override bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
56 {
57 if (!super.LoadCurrentFSMState(ctx, version))
58 return false;
59
60 if (!ctx.Read(m_damage))
61 {
62 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.LoadCurrentFSMState: cannot read m_damage for weapon=" + m_weapon);
63 return false;
64 }
65 if (!ctx.Read(m_type))
66 {
67 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.LoadCurrentFSMState: cannot read m_type for weapon=" + m_weapon);
68 return false;
69 }
70 if (!ctx.Read(m_magazineType))
71 {
72 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.LoadCurrentFSMState: cannot read m_magazineType for weapon=" + m_weapon);
73 return false;
74 }
75 if (!ctx.Read(m_srcMagazine))
76 {
77 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" + m_weapon);
78 return false;
79 }
80 return true;
81 }
82};
83
84
86{
87 override void OnEntry (WeaponEventBase e)
88 {
89 super.OnEntry(e);
90 if (e)
91 {
92 if (m_srcMagazine)
93 {
94 m_magazineType = m_srcMagazine.GetType();
95
96 if (m_srcMagazine.ServerAcquireCartridge(m_damage, m_type))
97 {
98 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, ok - cartridge acquired: dmg=" + m_damage + " type=" + m_type); }
99 m_weapon.SelectionBulletShow();
100 m_weapon.ShowBullet(m_weapon.GetCurrentMuzzle());
101 m_weapon.EffectBulletShow( m_weapon.GetCurrentMuzzle(), m_damage, m_type);
102 }
103 else
104 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, error - cannot take cartridge from magazine");
105 }
106 else
107 {
108 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, error - no magazine to load from (m_srcMagazine=NULL)");
109 }
110 }
111 }
112
113 override void OnAbort(WeaponEventBase e)
114 {
115 int mi = m_weapon.GetCurrentMuzzle();
116
117 string magazineTypeName;
118
119 if (m_magazineType.Length() > 0)
120 magazineTypeName = m_magazineType;
121 else
122 magazineTypeName = m_weapon.GetChamberAmmoTypeName(mi);
123
124 if ( GetGame().IsServer() )
125 {
126 if (DayZPlayerUtils.HandleDropCartridge(e.m_player, m_damage, m_type, magazineTypeName))
127 {
128 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, ok - aborting, chambering cartridge dropped to ground"); }
129 }
130 else
131 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, error - cannot abort removal from wpn (of old mag)");
132 }
133
134 m_weapon.EffectBulletHide(mi);
135 m_weapon.SelectionBulletHide(); // force hide on abort
136
137 m_magazineType = string.Empty;
138 m_type = string.Empty;
139 super.OnAbort(e);
140 }
141
142 override void OnExit (WeaponEventBase e)
143 {
144 int mi = m_weapon.GetCurrentMuzzle();
145 //if ( m_weapon.IsChamberFiredOut(mi) )
146 // m_weapon.EjectCasing(mi);
147 if (m_weapon.PushCartridgeToChamber(mi, m_damage, m_type))
148 {
149 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, ok - loaded chamber"); }
150 }
151 else
152 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, error - cannot load chamber chamber!"); }
153
154 m_magazineType = string.Empty;
155 m_type = string.Empty;
156 super.OnExit(e);
157 }
158
159};
160
161class WeaponChambering_Cartridge_ChambToMag extends WeaponChambering_Cartridge
162{
163 override void OnExit (WeaponEventBase e)
164 {
165 float ammoDamage;
166 string ammoTypeName;
167 int mi = m_weapon.GetCurrentMuzzle();
168 if (m_weapon.IsChamberFull(mi))
169 {
170 m_weapon.PopCartridgeFromChamber(mi, ammoDamage, ammoTypeName);
171 if (m_weapon.PushCartridgeToInternalMagazine(mi, ammoDamage, ammoTypeName))
172 {
173 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, ok - loaded chamber"); }
174 }
175 else
176 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, error - cannot load chamber chamber!"); }
177 }
178 super.OnExit(e);
179 }
180}
181
182//-----------MAGNUM-----------
183class WeaponChambering_MultiMuzzleMagnum extends WeaponChambering_Cartridge
184{
185 override bool IsWaitingForActionFinish () { return false; }
186 override void OnEntry(WeaponEventBase e)
187 {
188 super.OnEntry(e);
189
190 /*for(int i = 0; i < m_weapon.GetMuzzleCount(); i++ )
191 {
192 if(!m_weapon.IsChamberFull(i))
193 {
194 m_weapon.ShowBullet(i);
195 m_weapon.EffectBulletShow(i, m_damage, m_type);
196 return;
197 }
198 }*/
199 }
200
201 override void OnExit(WeaponEventBase e)
202 {
203 m_weapon.SelectionBulletHide();
204 int muzzle = m_weapon.GetCurrentMuzzle();
205
206 if (!m_weapon.IsChamberFull(muzzle))
207 {
208 if (m_weapon.PushCartridgeToChamber(muzzle, m_damage, m_type))
209 {
210 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(m_weapon.GetAttachmentByType(Magnum_Cylinder));
211
212 if (cylinder)
213 {
214 string bullet = "bullet";
215 string bullet_nose = "bullet_nose";
216
217 if (muzzle > 0)
218 {
219 bullet = string.Format("bullet_" + ( muzzle + 1 ));
220 bullet_nose = string.Format("bullet_nose_" + ( muzzle + 1 ));
221 }
222 cylinder.ShowSelection(bullet);
223 cylinder.ShowSelection(bullet_nose);
224 }
225 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_MultiMuzzleMagnum, ok - loaded chamber"); }
226 }
227 else
228 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_MultiMuzzleMagnum, error - cannot load chamber chamber!"); }
229 m_type = string.Empty;
230 return;
231 }
232 else
233 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_MultiMuzzleMagnum, error - cannot load chamber chamber!"); }
234
235 //super.OnExit(e);
236 }
237}
238
239
240
241//----------------------------
242
243class WeaponChambering_MultiMuzzle extends WeaponChambering_Cartridge
244{
245 override bool IsWaitingForActionFinish () { return true; }
246 override void OnEntry(WeaponEventBase e)
247 {
248 super.OnEntry(e);
249
250 for(int i = 0; i < m_weapon.GetMuzzleCount(); i++ )
251 {
252 if(!m_weapon.IsChamberFull(i))
253 {
254 m_weapon.ShowBullet(i);
255 m_weapon.EffectBulletShow(i, m_damage, m_type);
256 return;
257 }
258 }
259 }
260
261 override void OnExit (WeaponEventBase e)
262 {
263 for(int i = 0; i < m_weapon.GetMuzzleCount(); i++ )
264 {
265 if(!m_weapon.IsChamberFull(i))
266 {
267 if (m_weapon.PushCartridgeToChamber(i, m_damage, m_type))
268 {
269 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, ok - loaded chamber"); }
270 }
271 else
272 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge, error - cannot load chamber chamber!"); }
273 m_type = string.Empty;
274 return;
275 }
276 }
277
278 super.OnExit(e);
279 }
280}
281
282class WeaponChambering_MultiMuzzle_W4T extends WeaponChambering_MultiMuzzle
283{
284 override bool IsWaitingForActionFinish () { return true; }
285};
287
288class WeaponChambering_Cartridge_InnerMag extends WeaponChambering_Base
289{
290 override void OnEntry (WeaponEventBase e)
291 {
292 super.OnEntry(e);
293 if (e)
294 {
295 if (m_srcMagazine)
296 {
297 m_magazineType = m_srcMagazine.GetType();
298
299 if (m_srcMagazine.ServerAcquireCartridge(m_damage, m_type))
300 {
301 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, ok - cartridge acquired: dmg=" + m_damage + " type=" + m_type); }
302 }
303 else
304 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, error - cannot take cartridge from magazine");
305 }
306 else
307 {
308 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, error - no magazine to load from (m_srcMagazine=NULL)");
309 }
310
311 m_weapon.SelectionBulletShow();
312 m_weapon.EffectBulletShow(m_weapon.GetCurrentMuzzle(),m_damage,m_type);
313 }
314 }
315
316 override void OnAbort(WeaponEventBase e)
317 {
318 int mi = m_weapon.GetCurrentMuzzle();
319 string magazineTypeName;
320
321 if (m_magazineType.Length() > 0)
322 magazineTypeName = m_magazineType;
323 else
324 magazineTypeName = m_weapon.GetChamberAmmoTypeName(mi);
325
326 if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
327 {
328 if (DayZPlayerUtils.HandleDropCartridge(e.m_player, m_damage, m_type, magazineTypeName))
329 {
330 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, ok - aborting, chambering cartridge dropped to ground"); }
331 }
332 else
333 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, error - cannot abort removal from wpn (of old mag)");
334 }
335
336 m_weapon.SelectionBulletHide(); // force hide on abort
337 m_weapon.EffectBulletHide(m_weapon.GetCurrentMuzzle());
338
339 m_magazineType = string.Empty;
340 m_type = string.Empty;
341 super.OnAbort(e);
342 }
343
344 override void OnExit (WeaponEventBase e)
345 {
346 float ammoDamage;
347 string ammoTypeName;
348 int mi = m_weapon.GetCurrentMuzzle();
349 if (!m_weapon.IsInternalMagazineFull(mi))
350 {
351 if (m_weapon.PushCartridgeToInternalMagazine(mi, m_damage, m_type))
352 {
353 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, ok - loaded chamber"); }
354 }
355 else
356 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering_Cartridge_InnerMag, error - cannot load chamber chamber!"); }
357 }
358 m_magazineType = string.Empty;
359 super.OnExit(e);
360 }
361};
362
363class WeaponChambering_W4T extends WeaponStateBase
364{
365 override bool IsWaitingForActionFinish () { return true; }
366};
367
368class WeaponChambering extends WeaponStateBase
369{
371 int m_actionType;
372 Magazine m_srcMagazine;
374
378 ref WeaponChambering_W4T m_w4t;
379 ref WeaponCharging_CK m_onCK;
380
381 void WeaponChambering (Weapon_Base w = NULL, WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE, int actionType = -1)
382 {
383 m_action = action;
384 m_actionType = actionType;
385
386 // setup nested state machine
387 m_start = new WeaponChambering_Start(m_weapon, this, m_action, m_actionType);
389 m_w4t = new WeaponChambering_W4T(m_weapon, this);
391 m_onCK = new WeaponCharging_CK(m_weapon, this);
392 // events
393 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
394 WeaponEventAnimBulletInChamber __bc_ = new WeaponEventAnimBulletInChamber;
395 WeaponEventAnimBulletShow __bs_ = new WeaponEventAnimBulletShow;
396 WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
397 WeaponEventAnimCocked __ck_ = new WeaponEventAnimCocked;
398
399 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
400 m_fsm.AddTransition(new WeaponTransition(m_start , __be_, m_eject));
401 m_fsm.AddTransition(new WeaponTransition(m_start , __ck_, m_onCK));
402 m_fsm.AddTransition(new WeaponTransition(m_start , __bs_, m_chamber));
403 m_fsm.AddTransition(new WeaponTransition(m_onCK , __be_, m_eject));
404 m_fsm.AddTransition(new WeaponTransition(m_onCK , __bs_, m_chamber));
405 m_fsm.AddTransition(new WeaponTransition(m_eject , __bs_, m_chamber));
406 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bc_, m_w4t));
407 m_fsm.AddTransition(new WeaponTransition(m_w4t , _fin_, null));
408
409 // Safety exits
410 m_fsm.AddTransition(new WeaponTransition(m_chamber, _fin_, null));
411 m_fsm.AddTransition(new WeaponTransition(m_eject , _fin_, null));
412 m_fsm.AddTransition(new WeaponTransition(m_start , _fin_, null));
413
414 m_fsm.SetInitialState(m_start);
415 }
416
417 override void OnEntry (WeaponEventBase e)
418 {
419 if (e != NULL)
420 {
422 if (m_srcMagazine != NULL)
423 {
425 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
426
428
429 // move to LH
432 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
433 {
434 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - ammo pile removed from inv (inv->LHand)"); }
435 }
436 else
437 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, error - cannot remove ammo pile from inv");
438
439 m_chamber.m_srcMagazine = m_srcMagazine;
440 }
441 else
442 {
443 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering m_srcMagazine = NULL"); }
444 }
445 }
446 else
447 {
448 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering (e=NULL), m_srcMagazine=" + m_srcMagazine.ToString()); }
449 }
450
451 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
452 }
453
454 override void OnAbort (WeaponEventBase e)
455 {
456 bool done = false;
457 if (m_srcMagazine)
458 {
459 e.m_player.GetInventory().ClearInventoryReservationEx( m_srcMagazine , m_srcMagazinePrevLocation );
460
461 InventoryLocation leftHandIl = new InventoryLocation;
462 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
463 if(leftHandIl.IsValid())
464 {
466 {
468 {
470 {
472 {
473 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - ammo pile removed from left hand to previous location (LHand->inv) - abort"); }
474 done = true;
475 }
476 }
477 }
478 }
479
480 if( !done)
481 {
483 e.m_player.GetInventory().FindFreeLocationFor( m_srcMagazine, FindInventoryLocationType.CARGO, il );
484
485 if(!il || !il.IsValid())
486 {
487 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
488 {
489 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - no inventory space for ammo pile - dropped to ground - abort"); }
490 }
491 else
492 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
493
494 }
495 else
496 {
497 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
498 {
499 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - ammo pile removed from left hand (LHand->inv) - abort"); }
500 }
501 else
502 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, error - cannot remove ammo pile from wpn - abort");
503 }
504 }
505 }
506 }
507
508 super.OnAbort(e);
509 m_srcMagazine = NULL;
510 m_chamber.m_srcMagazine = NULL;
512 }
513
514 override void OnExit (WeaponEventBase e)
515 {
516 bool done = false;
517 if (m_srcMagazine)
518 {
519 e.m_player.GetInventory().ClearInventoryReservationEx( m_srcMagazine , m_srcMagazinePrevLocation );
520
521 InventoryLocation leftHandIl = new InventoryLocation;
522 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
523 if(leftHandIl.IsValid())
524 {
526 {
528 {
530 {
532 {
533 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - ammo pile removed from left hand to previous location (LHand->inv) - exit"); }
534 done = true;
535 }
536 }
537 }
538 }
539
540 if( !done)
541 {
543 e.m_player.GetInventory().FindFreeLocationFor( m_srcMagazine, FindInventoryLocationType.CARGO, il );
544
545 if(!il || !il.IsValid())
546 {
547 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
548 {
549 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - no inventory space for ammo pile - dropped to ground - exit"); }
550 }
551 else
552 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
553
554 }
555 else
556 {
557 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
558 {
559 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, ok - ammo pile removed from left hand (LHand->inv) - exit"); }
560 }
561 else
562 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering, error - cannot remove ammo pile from wpn - exit");
563 }
564 }
565 }
566 }
567
568 super.OnExit(e);
569 m_srcMagazine = NULL;
570 m_chamber.m_srcMagazine = NULL;
572 }
573
575 {
576 if (!super.SaveCurrentFSMState(ctx))
577 return false;
578
579 if (!ctx.Write(m_srcMagazine))
580 {
581 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" + m_weapon);
582 return false;
583 }
584
586 {
587 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" + m_weapon);
588 return false;
589 }
590 return true;
591 }
592
593 override bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
594 {
595 if (!super.LoadCurrentFSMState(ctx, version))
596 return false;
597
598 if (!ctx.Read(m_srcMagazine))
599 {
600 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" + m_weapon);
601 return false;
602 }
603
605 {
606 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" + m_weapon);
607 return false;
608 }
609 return true;
610 }
611};
612
613//----------------------------------------------
614//----------------------------------------------
615//----------------------------------------------
616class WeaponEndAction extends WeaponStartAction
617{
619 {
620 return true;
621 }
622}
623
625{
629 Magazine m_srcMagazine;
631
636 ref LoopedChambering_Wait4ShowBullet2 m_w4sb2;
637 ref WeaponEndAction m_endLoop;
638 ref BulletShow_W4T m_showB;
639 ref BulletShow2_W4T m_showB2;
640
641 void ChamberMultiBullet (Weapon_Base w = NULL, WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE, int startActionType = -1, int endActionType = -1)
642 {
643 m_action = action;
644 m_startActionType = startActionType;
645 m_endActionType = endActionType;
646
647 // setup nested state machine
648 m_start = new WeaponChambering_Start(m_weapon, this, m_action, m_startActionType);
650 m_chamber = new WeaponChambering_MultiMuzzle_W4T(m_weapon, this);
651 m_chamber_end = new WeaponChambering_MultiMuzzle_W4T(m_weapon, this);
652 m_w4sb2 = LoopedChambering_Wait4ShowBullet2(m_weapon, this);
653 m_showB = new BulletShow_W4T(m_weapon, this);
654 m_showB2= new BulletShow2_W4T(m_weapon, this);
655
656 m_endLoop = new WeaponEndAction(m_weapon, this, m_action, m_endActionType); // @NOTE: termination playing action - dummy?
657 // events
658 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
659 WeaponEventContinuousLoadBulletStart __lS_ = new WeaponEventContinuousLoadBulletStart;
660 WeaponEventContinuousLoadBulletEnd __lE_ = new WeaponEventContinuousLoadBulletEnd;
661 WeaponEventAnimBulletShow __bs_ = new WeaponEventAnimBulletShow;
662 WeaponEventAnimBulletShow2 _bs2_ = new WeaponEventAnimBulletShow2;
663 WeaponEventAnimBulletHide __bh_ = new WeaponEventAnimBulletHide;
664 WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
665 WeaponEventAnimBulletInChamber __bc_ = new WeaponEventAnimBulletInChamber;
666
667 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
668 m_fsm.AddTransition(new WeaponTransition(m_start , __be_, m_eject));
669
670 m_fsm.AddTransition(new WeaponTransition(m_start , __bs_, m_chamber));
671 m_fsm.AddTransition(new WeaponTransition(m_eject , __bs_, m_chamber));
672
673 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bc_, m_w4sb2, NULL, new GuardAnd(new GuardAnd(new WeaponGuardHasAmmoInLoopedState(m_chamber), new WeaponGuardChamberMultiHasRoomBulltet(m_weapon)),new WeaponGuardWeaponManagerWantContinue())));
674 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bc_, m_endLoop));
675 m_fsm.AddTransition(new WeaponTransition(m_w4sb2, __bs_, m_chamber));
676
677 m_fsm.AddTransition(new WeaponTransition(m_w4sb2 , _fin_, NULL));
678 m_fsm.AddTransition(new WeaponTransition(m_chamber , _fin_, NULL));
679 m_fsm.AddTransition(new WeaponTransition(m_endLoop , _fin_, NULL));
680
681 // Safety exits
682 m_fsm.AddTransition(new WeaponTransition(m_eject , _fin_, null));
683 m_fsm.AddTransition(new WeaponTransition(m_start , _fin_, null));
684
685 m_fsm.SetInitialState(m_start);
686 }
687
688 override void OnEntry (WeaponEventBase e)
689 {
690 if (e != NULL)
691 {
693 if (m_srcMagazine != NULL)
694 {
696 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
697
699
700 // move to LH
703 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
704 {
705 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from inv (inv->LHand)"); }
706 }
707 else
708 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot remove ammo pile from inv");
709
710 m_chamber.m_srcMagazine = m_srcMagazine;
711 }
712 else
713 {
714 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet m_srcMagazine = NULL"); }
715 }
716 }
717 else
718 {
719 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet (e=NULL), m_srcMagazine=" + m_srcMagazine.ToString()); }
720 }
721
722 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
723 }
724 override void OnExit (WeaponEventBase e)
725 {
726 bool done = false;
727 if (m_srcMagazine)
728 {
729 e.m_player.GetInventory().ClearInventoryReservationEx( m_srcMagazine , m_srcMagazinePrevLocation );
730
731 InventoryLocation leftHandIl = new InventoryLocation;
732 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
733 if(leftHandIl.IsValid())
734 {
736 {
738 {
740 {
742 {
743 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from left hand to previous location (LHand->inv) - exit"); }
744 done = true;
745 }
746 }
747 }
748 }
749
750 if( !done)
751 {
753 e.m_player.GetInventory().FindFreeLocationFor( m_srcMagazine, FindInventoryLocationType.CARGO, il );
754
755 if(!il || !il.IsValid())
756 {
757 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
758 {
759 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - no inventory space for ammo pile - dropped to ground - exit"); }
760 }
761 else
762 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
763
764 }
765 else
766 {
767 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
768 {
769 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from left hand (LHand->inv) - exit"); }
770 }
771 else
772 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot remove ammo pile from wpn - exit");
773 }
774 }
775 }
776 }
777
778 super.OnExit(e);
779 m_srcMagazine = NULL;
780 m_chamber.m_srcMagazine = NULL;
782 }
783 override void OnAbort (WeaponEventBase e)
784 {
785 bool done = false;
786 if (m_srcMagazine)
787 {
788 e.m_player.GetInventory().ClearInventoryReservationEx( m_srcMagazine , m_srcMagazinePrevLocation );
789
790 InventoryLocation leftHandIl = new InventoryLocation;
791 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
792 if(leftHandIl.IsValid())
793 {
795 {
797 {
799 {
801 {
802 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from left hand to previous location (LHand->inv) - abort"); }
803 done = true;
804 }
805 }
806 }
807 }
808
809 if( !done)
810 {
812 e.m_player.GetInventory().FindFreeLocationFor( m_srcMagazine, FindInventoryLocationType.CARGO, il );
813
814 if(!il || !il.IsValid())
815 {
816 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
817 {
818 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - no inventory space for ammo pile - dropped to ground - abort"); }
819 }
820 else
821 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
822
823 }
824 else
825 {
826 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
827 {
828 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from left hand (LHand->inv) - abort"); }
829 }
830 else
831 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot remove ammo pile from wpn - abort");
832 }
833 }
834 }
835 }
836
837 super.OnAbort(e);
838 m_srcMagazine = NULL;
839 m_chamber.m_srcMagazine = NULL;
841 }
842
844 {
845 if (!super.SaveCurrentFSMState(ctx))
846 return false;
847
848 if (!ctx.Write(m_srcMagazine))
849 {
850 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" + m_weapon);
851 return false;
852 }
853
855 {
856 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" + m_weapon);
857 return false;
858 }
859 return true;
860 }
861
862 override bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
863 {
864 if (!super.LoadCurrentFSMState(ctx, version))
865 return false;
866
867 if (!ctx.Read(m_srcMagazine))
868 {
869 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" + m_weapon);
870 return false;
871 }
872
874 {
875 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" + m_weapon);
876 return false;
877 }
878 return true;
879 }
880};
881//------------------------------------------------------
882//------------------ROTATE------------------------------
883//------------------------------------------------------
884class WeaponCylinderRotate extends WeaponStateBase
885{
886 bool FindNextFreeMuzzle(int currentMuzzle, out int nextMuzzle)
887 {
888 nextMuzzle = currentMuzzle;
889 int nMuzzles = m_weapon.GetMuzzleCount();
890
891 for (int i = 0; i < nMuzzles; ++i)
892 {
893 --nextMuzzle;
894 nextMuzzle = Math.WrapInt(nextMuzzle, 0, nMuzzles);
895 if (m_weapon.IsChamberEmpty(nextMuzzle))
896 return true;
897 }
898
899 return false;
900 }
901
902 override void OnEntry(WeaponEventBase e)
903 {
904 int nextMuzzle;
905 if (FindNextFreeMuzzle(m_weapon.GetCurrentMuzzle(), nextMuzzle))
906 {
907 Magnum_Base magnum = Magnum_Base.Cast(m_weapon);
908 magnum.SetCylinderRotationAnimationPhase(magnum.GetCylinderRotation(nextMuzzle));
909 m_weapon.SetCurrentMuzzle(nextMuzzle);
910 }
911 else
912 {
913 Print("WTF");
914 }
915
916 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
917 }
918
919};
920
921
922//------------------------------------------------------
923//------------------MAGNUM------------------------------
924//------------------------------------------------------
925class WeaponMagnumChambering extends WeaponStateBase
926{
930 Magazine m_srcMagazine;
932
934 ref WeaponEjectAllMuzzles m_eject;
935 ref WeaponCylinderRotate m_rotate;
937 ref LoopedChambering_Wait4ShowBullet2 m_w4sb2;
939 ref BulletHide_W4T m_hideB;
940
941 void WeaponMagnumChambering(Weapon_Base w = NULL, WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE, int startActionType = -1, int endActionType = -1)
942 {
943 m_action = action;
944 m_startActionType = startActionType;
945 m_endActionType = endActionType;
946
947 // setup nested state machine
948 m_start = new WeaponChambering_Start(m_weapon, this, m_action, m_startActionType);
950 m_rotate = new WeaponCylinderRotate(m_weapon, this);
951 m_chamber = new WeaponChambering_MultiMuzzleMagnum(m_weapon, this);
952 m_w4sb2 = LoopedChambering_Wait4ShowBullet2(m_weapon, this);
953 m_hideB = new BulletHide_W4T(m_weapon, this);
954 m_endLoop = new LoopedChambering_EndLoop(m_weapon, this, m_action, m_endActionType); // @NOTE: termination playing action - dummy?
955 // events
956 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
957 WeaponEventContinuousLoadBulletStart __lS_ = new WeaponEventContinuousLoadBulletStart;
958 WeaponEventContinuousLoadBulletEnd __lE_ = new WeaponEventContinuousLoadBulletEnd;
959 WeaponEventCylinderRotate __cr_ = new WeaponEventCylinderRotate;
960 WeaponEventAnimBulletShow __bs_ = new WeaponEventAnimBulletShow;
961 WeaponEventAnimBulletHide __bh_ = new WeaponEventAnimBulletHide;
962 WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
963 WeaponEventAnimBulletInMagazine __bM_ = new WeaponEventAnimBulletInMagazine;
964 WeaponEventAnimBulletShow2 _bs2_ = new WeaponEventAnimBulletShow2;
965
966 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
967 m_fsm.AddTransition(new WeaponTransition(m_start, __be_, m_eject));
968 m_fsm.AddTransition(new WeaponTransition(m_start, __cr_, m_rotate));
969
970 m_fsm.AddTransition(new WeaponTransition(m_eject, __cr_, m_rotate));
971 m_fsm.AddTransition(new WeaponTransition(m_rotate, __be_, m_eject));
972
973 m_fsm.AddTransition(new WeaponTransition(m_eject, __bs_, m_chamber));
974 m_fsm.AddTransition(new WeaponTransition(m_rotate, __bs_, m_chamber));
975
976 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bM_, m_w4sb2, null, new GuardAnd(new GuardAnd(new WeaponGuardHasAmmoInLoopedState(m_chamber), new WeaponGuardChamberMultiHasRoomBulltetIgnoreLast(m_weapon)),new WeaponGuardWeaponManagerWantContinue())));
977 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bM_, m_endLoop));
978 //m_fsm.AddTransition(new WeaponTransition(m_rotate, __bh_, m_chamber));
979 //m_fsm.AddTransition(new WeaponTransition(m_w4sb2, __bh_, m_hideB));
980 m_fsm.AddTransition(new WeaponTransition(m_w4sb2, __cr_, m_rotate));
981
982 m_fsm.AddTransition(new WeaponTransition(m_endLoop, _fin_, null));
983
984 // Safety exits
985 m_fsm.AddTransition(new WeaponTransition(m_w4sb2, _fin_, null));
986 m_fsm.AddTransition(new WeaponTransition(m_chamber, _fin_, null));
987 m_fsm.AddTransition(new WeaponTransition(m_rotate, _fin_, null));
988 m_fsm.AddTransition(new WeaponTransition(m_eject , _fin_, null));
989 m_fsm.AddTransition(new WeaponTransition(m_start , _fin_, null));
990
991 m_fsm.SetInitialState(m_start);
992 }
993
994 override void OnEntry(WeaponEventBase e)
995 {
996 if (e != NULL)
997 {
998
1000 if (m_srcMagazine != NULL)
1001 {
1003 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
1004
1006
1007 // move to LH
1010 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
1011 {
1012 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - ammo pile removed from inv (inv->LHand)"); }
1013 }
1014 else
1015 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, error - cannot remove ammo pile from inv");
1016
1017 m_chamber.m_srcMagazine = m_srcMagazine;
1018 }
1019 else
1020 {
1021 Print("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering m_srcMagazine = NULL");
1022 }
1023 }
1024 else
1025 {
1026 Print("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering (e=NULL), m_srcMagazine=" + m_srcMagazine.ToString());
1027 }
1028
1029 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
1030 }
1031
1032 override void OnExit(WeaponEventBase e)
1033 {
1034 bool done = false;
1035 if (m_srcMagazine)
1036 {
1037 e.m_player.GetInventory().ClearInventoryReservationEx( m_srcMagazine , m_srcMagazinePrevLocation );
1038
1039 InventoryLocation leftHandIl = new InventoryLocation;
1040 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
1041 if (leftHandIl.IsValid())
1042 {
1044 {
1046 {
1048 {
1050 {
1051 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - ammo pile removed from left hand to previous location (LHand->inv) - exit"); }
1052 done = true;
1053 }
1054 }
1055 }
1056 }
1057
1058 if ( !done)
1059 {
1061 e.m_player.GetInventory().FindFreeLocationFor( m_srcMagazine, FindInventoryLocationType.CARGO, il );
1062
1063 if (!il || !il.IsValid())
1064 {
1065 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
1066 {
1067 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - no inventory space for ammo pile - dropped to ground - exit"); }
1068 }
1069 else
1070 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
1071
1072 }
1073 else
1074 {
1075 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
1076 {
1077 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - ammo pile removed from left hand (LHand->inv) - exit"); }
1078 }
1079 else
1080 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, error - cannot remove ammo pile from wpn - exit");
1081 }
1082 }
1083 }
1084 }
1085
1086 super.OnExit(e);
1087 m_srcMagazine = NULL;
1088 m_chamber.m_srcMagazine = NULL;
1090 }
1091
1092 override void OnAbort(WeaponEventBase e)
1093 {
1094 bool done = false;
1095 if (m_srcMagazine)
1096 {
1097 e.m_player.GetInventory().ClearInventoryReservationEx( m_srcMagazine , m_srcMagazinePrevLocation );
1098
1099 InventoryLocation leftHandIl = new InventoryLocation;
1100 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
1101 if (leftHandIl.IsValid())
1102 {
1104 {
1106 {
1108 {
1110 {
1111 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - ammo pile removed from left hand to previous location (LHand->inv) - abort"); }
1112 done = true;
1113 }
1114 }
1115 }
1116 }
1117
1118 if ( !done)
1119 {
1121 e.m_player.GetInventory().FindFreeLocationFor( m_srcMagazine, FindInventoryLocationType.CARGO, il );
1122
1123 if (!il || !il.IsValid())
1124 {
1125 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
1126 {
1127 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - no inventory space for ammo pile - dropped to ground - abort"); }
1128 }
1129 else
1130 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " LoopedChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
1131
1132 }
1133 else
1134 {
1135 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
1136 {
1137 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering, ok - ammo pile removed from left hand (LHand->inv) - abort"); }
1138 }
1139 else
1140 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " LoopedChambering, error - cannot remove ammo pile from wpn - abort");
1141 }
1142 }
1143 }
1144 }
1145
1146 super.OnAbort(e);
1147 m_srcMagazine = NULL;
1148 m_chamber.m_srcMagazine = NULL;
1150 }
1151
1153 {
1154 if (!super.SaveCurrentFSMState(ctx))
1155 return false;
1156
1157 if (!ctx.Write(m_srcMagazine))
1158 {
1159 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" + m_weapon);
1160 return false;
1161 }
1162
1164 {
1165 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" + m_weapon);
1166 return false;
1167 }
1168
1169 return true;
1170 }
1171
1172 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
1173 {
1174 if (!super.LoadCurrentFSMState(ctx, version))
1175 return false;
1176
1177 if (!ctx.Read(m_srcMagazine))
1178 {
1179 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" + m_weapon);
1180 return false;
1181 }
1182
1184 {
1185 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponMagnumChambering.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" + m_weapon);
1186 return false;
1187 }
1188 return true;
1189 }
1190};
void wpnDebugPrint(string s)
Definition Debug.c:9
private void DayZPlayerUtils()
cannot be instantiated
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
HandStateEquipped OnEntry
FindInventoryLocationType
flags for searching locations in inventory
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
enum FSMTransition WeaponTransition
void ChamberMultiBullet(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int startActionType=-1, int endActionType=-1)
ref LoopedChambering_Wait4ShowBullet2 m_w4sb2
ref BulletShow2_W4T m_showB2
int m_startActionType
class WeaponChambering_Cartridge_InnerMag extends WeaponChambering_Base IsWaitingForActionFinish
int m_endActionType
Magazine m_srcMagazine
ref InventoryLocation m_srcMagazinePrevLocation
source of the cartridge
ref WeaponEndAction m_endLoop
ref WeaponStateBase m_start
class WeaponEndAction extends WeaponStartAction m_action
ref WeaponChambering_Base m_chamber
ref WeaponChambering_Base m_chamber_end
ref WeaponEjectCasingMultiMuzzle m_eject
ref BulletShow_W4T m_showB
script counterpart to engine's class Inventory
Definition Inventory.c:77
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
override void OnEntry(HandEventBase e)
Definition Hand_States.c:34
InventoryLocation.
proto native vector GetPos()
returns position of item in world if type is Ground
proto native bool IsValid()
verify current set inventory location
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>
provides access to slot configuration
static bool IsWeaponLogEnable()
Definition Debug.c:640
Definition EnMath.c:7
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
override void OnEntry(WeaponEventBase e)
override void OnAbort(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override void OnEntry(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override bool IsWaitingForActionFinish()
signalize mechanism manipulation
Definition Events.c:35
Magazine m_magazine
Definition Events.c:38
DayZPlayer m_player
Definition Events.c:37
weapon finite state machine
const float MAX_DROP_MAGAZINE_DISTANCE_SQ
simple class starting animation action specified by m_action and m_actionType
override void OnEntry(WeaponEventBase e)
override bool IsWaitingForActionFinish()
represent weapon state base
Definition BulletHide.c:2
void WeaponEjectAllMuzzles(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
ref WeaponEjectCasing m_eject
ref WeaponCharging_CK m_onCK
ref LoopedChambering_Wait4ShowBullet2 m_w4sb2
ref WeaponStateBase m_start
source of the cartridge
Magazine m_srcMagazine
destination of the ejected cartridge
ref WeaponEjectAllMuzzles m_eject
ref InventoryLocation m_srcMagazinePrevLocation
source of the cartridge
override void OnEntry(WeaponEventBase e)
override bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
ref WeaponChambering_W4T m_w4t
bool FindNextFreeMuzzle(int currentMuzzle, out int nextMuzzle)
override void OnAbort(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
ref WeaponChambering_Base m_chamber
ref BulletHide_W4T m_hideB
int m_actionType
action to be played
ref WeaponStartAction m_endLoop
WeaponActions m_action
void WeaponMagnumChambering(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int startActionType=-1, int endActionType=-1)
void WeaponChambering(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
ref WeaponCylinderRotate m_rotate
ref WeaponChambering_Cartridge m_chamber
override bool SaveCurrentFSMState(ParamsWriteContext ctx)
source of the cartridge
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto void Print(void var)
Prints content of variable to console/log.
static proto int WrapInt(int i, int min, int max)
Returns wrap number to specified interval [min, max[.
static proto string Format(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)
Gets n-th character from string.
WeaponActions
actions
Definition human.c:798