37 if (DayZPlayerUtils.HandleDropMagazine(e.m_player,
m_oldMagazine))
39 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground"); }
42 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine");
48 m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc);
55 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot remove old mag from wpn");
67 if (!super.SaveCurrentFSMState(ctx))
72 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" +
m_weapon);
79 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
88 if (!super.LoadCurrentFSMState(ctx, version))
93 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" +
m_weapon);
99 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
123 Magazine m_newMagazine;
132 if (!m_newMagazine || !m_newDst || !m_newDst.IsValid())
134 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine, error - m_newMagazine(" + m_newMagazine +
") or destination(" +
InventoryLocation.DumpToStringNullSafe(m_newDst) +
") is not set ");
138 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine , m_newDst );
141 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
148 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine, error - cannot remove new mag from LHand");
157 m_newMagazine = NULL;
165 m_newMagazine = NULL;
173 if (!super.SaveCurrentFSMState(ctx))
176 if (!ctx.Write(m_newMagazine))
178 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
184 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
193 if (!super.LoadCurrentFSMState(ctx, version))
196 if (!ctx.Read(m_newMagazine))
198 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
203 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
216 Magazine m_newMagazine;
221 m_newMagazine = NULL;
235 if (m_newMagazine && m_newDst)
238 if (m_newMagazine.GetInventory().GetCurrentInventoryLocation(il))
241 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
253 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine, error - cannot get curr location");
256 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine, error - no magazines configured for replace (m_new=NULL)");
262 if (m_newMagazine && m_newDst)
264 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_newMagazine))
266 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponDetachingMag_Store, ok - aborting, detached magazine dropped to ground"); }
269 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponDetachingMag_Store, error - cannot abort detaching of magazine");
275 m_newMagazine = NULL;
283 m_newMagazine = NULL;
290 if (!super.SaveCurrentFSMState(ctx))
293 if (!ctx.Write(m_newMagazine))
295 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
301 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
309 if (!super.LoadCurrentFSMState(ctx, version))
312 if (!ctx.Read(m_newMagazine))
314 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
319 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
347 ref AttachNewMagazine_W4T m_attach;
348 ref WeaponChamberFromAttMag_W4T
m_chamber;
349 ref WeaponCharging_CK m_onCK;
354 Magazine m_newMagazine;
360 m_actionType = actionType;
361 m_newMagazine = NULL;
369 m_attach =
new AttachNewMagazine_W4T(
m_weapon,
this);
371 m_onCK =
new WeaponCharging_CK(
m_weapon,
this);
403 m_fsm.SetInitialState(
m_start);
410 WeaponEventSwapMagazine se;
411 if (
Class.CastTo(se, e))
413 int mi =
m_weapon.GetCurrentMuzzle();
415 m_newMagazine = se.m_magazine;
423 if (!m_newMagazine.GetInventory().GetCurrentInventoryLocation(newSrc))
425 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNext cannot get curr inv loc of NEW mag=" +
Object.GetDebugName(m_newMagazine));
427 if (!
m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc))
434 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
438 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, ok - new magazine removed from inv (inv->LHand)"); }
441 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, error - cannot new remove mag from inv");
444 m_detach.m_newDst = m_newDst;
446 m_swapMags.m_newMagazine = m_newMagazine;
448 oldSrc.SetItem(m_newMagazine);
449 m_swapMags.m_newDst = oldSrc;
460 Magazine mag = Magazine.Cast(leftHandItem);
465 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine , null );
467 e.m_player.GetInventory().ClearInventoryReservationEx(
m_oldMagazine , null );
475 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
477 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground - exit"); }
480 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine - exit");
486 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
493 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot remove old mag from wpn - exit");
498 m_newMagazine = NULL;
507 Magazine mag = Magazine.Cast(leftHandItem);
512 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine , null );
514 e.m_player.GetInventory().ClearInventoryReservationEx(
m_oldMagazine , null );
522 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
524 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground - abort"); }
527 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine - abort");
533 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
540 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot remove old mag from wpn - abort");
547 if (!super.SaveCurrentFSMState(ctx))
550 if (!ctx.Write(m_newMagazine))
552 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
558 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" +
m_weapon);
562 if (!m_newDst.WriteToContext(ctx))
564 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
573 if (!super.LoadCurrentFSMState(ctx, version))
576 if (!ctx.Read(m_newMagazine))
578 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
583 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" +
m_weapon);
588 if (!m_newDst.ReadFromContext(ctx))
590 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
610 ref WeaponDetachingMag_StoreRemoveChamberBullet m_detach;
613 ref AttachNewMagazine_W4T m_attach;
614 ref WeaponChamberFromAttMagOpenbolt_W4T
m_chamber;
615 ref WeaponChargingOpenBolt_CK m_onCK;
619 Magazine m_newMagazine;
625 m_actionType = actionType;
626 m_newMagazine = NULL;
630 m_detach =
new WeaponDetachingMag_StoreRemoveChamberBullet(
m_weapon,
this);
633 m_attach =
new AttachNewMagazine_W4T(
m_weapon,
this);
635 m_onCK =
new WeaponChargingOpenBolt_CK(
m_weapon,
this);
667 m_fsm.SetInitialState(
m_start);
674 WeaponEventSwapMagazine se;
675 if (
Class.CastTo(se, e))
677 int mi =
m_weapon.GetCurrentMuzzle();
679 m_newMagazine = se.m_magazine;
687 if (!m_newMagazine.GetInventory().GetCurrentInventoryLocation(newSrc))
689 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged cannot get curr inv loc of NEW mag=" +
Object.GetDebugName(m_newMagazine));
691 if (!
m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc))
698 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
702 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, ok - new magazine removed from inv (inv->LHand)"); }
705 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, error - cannot new remove mag from inv");
708 m_detach.m_dst = m_newDst;
710 m_swapMags.m_newMagazine = m_newMagazine;
712 oldSrc.SetItem(m_newMagazine);
713 m_swapMags.m_newDst = oldSrc;
724 Magazine mag = Magazine.Cast(leftHandItem);
729 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine , null );
731 e.m_player.GetInventory().ClearInventoryReservationEx(
m_oldMagazine , null );
739 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
741 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, ok - no inventory space for old magazine - dropped to ground - exit"); }
744 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, error - cannot drop magazine from left hand after not found inventory space for old magazine - exit");
750 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
754 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, ok - old magazine removed from wpn (LHand->inv) - exit"); }
757 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, error - cannot remove old mag from wpn - exit");
762 m_newMagazine = NULL;
771 Magazine mag = Magazine.Cast(leftHandItem);
776 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine , null );
778 e.m_player.GetInventory().ClearInventoryReservationEx(
m_oldMagazine , null );
786 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
788 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, ok - no inventory space for old magazine - dropped to ground - abort"); }
791 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, error - cannot drop magazine from left hand after not found inventory space for old magazine - abort");
797 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
801 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, ok - old magazine removed from wpn (LHand->inv) - abort"); }
804 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged, error - cannot remove old mag from wpn - abort");
811 if (!super.SaveCurrentFSMState(ctx))
814 if (!ctx.Write(m_newMagazine))
816 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
822 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" +
m_weapon);
826 if (!m_newDst.WriteToContext(ctx))
828 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
837 if (!super.LoadCurrentFSMState(ctx, version))
840 if (!ctx.Read(m_newMagazine))
842 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
847 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" +
m_weapon);
852 if (!m_newDst.ReadFromContext(ctx))
854 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNextOpenBoltCharged.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
void wpnDebugPrint(string s)
attach mag in LH into weapon
Super root of all classes in Enforce script.
detaches old magazine from weapon and stores it in left hand (LH)
script counterpart to engine's class Inventory
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...
provides access to slot configuration
hides old magazine, but keep it in LH
Serialization general interface. Serializer API works with:
old magazine to inventory, new to left hand
signalize mechanism manipulation
weapon finite state machine
replace current magazine with new one
replace current magazine with new one for weapon charged with open position bolt
simple class starting animation action specified by m_action and m_actionType
represent weapon state base
void Error(string err)
Messagebox with error message.
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
HandStateEquipped OnEntry
FindInventoryLocationType
flags for searching locations in inventory
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
InventoryLocationType
types of Inventory Location
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
enum FSMTransition WeaponTransition
class WeaponChambering extends WeaponStateBase IsWaitingForActionFinish
ref WeaponStateBase m_start
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
class WeaponEndAction extends WeaponStartAction m_action
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
ref WeaponChambering_Base m_chamber
ref WeaponEjectCasingMultiMuzzle m_eject
override bool SaveCurrentFSMState(ParamsWriteContext ctx)