3 Magazine m_newMagazine;
4 ref InventoryLocation m_newSrc;
6 void RemoveNewMagazineFromInventory (Weapon_Base w = NULL, WeaponStateBase parent = NULL)
16 if (!m_newSrc.IsValid())
17 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory m_newSrc=invalid, item not in bubble?");
19 if (m_newMagazine && m_newSrc && m_newSrc.IsValid())
21 InventoryLocation curr =
new InventoryLocation;
22 m_newMagazine.GetInventory().GetCurrentInventoryLocation(curr);
30 InventoryLocation lhand =
new InventoryLocation;
31 lhand.SetAttachment(e.m_player, m_newMagazine, InventorySlots.LEFTHAND);
32 if (GameInventory.LocationSyncMoveEntity(m_newSrc, lhand))
34 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, ok - new magazine removed from inv (inv->LHand)"); }
37 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, error - cannot new remove mag from inv");
41 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, error - no magazines configured for replace (m_old=m_new=NULL)");
65 if (!super.SaveCurrentFSMState(ctx))
68 if (!ctx.Write(m_newMagazine))
70 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
76 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory.SaveCurrentFSMState: cannot write m_newSrc for weapon=" +
m_weapon);
84 if (!super.LoadCurrentFSMState(ctx, version))
87 if (!ctx.Read(m_newMagazine))
89 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
95 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory.LoadCurrentFSMState: cannot read m_newSrc for weapon=" +
m_weapon);
121 ref WeaponChamberFromAttMag_W4T
m_chamber;
122 ref WeaponCharging_CK m_onCK;
125 void WeaponAttachMagazine (
Weapon_Base w = NULL,
WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE,
int actionType = -1)
128 m_actionType = actionType;
135 m_onCK =
new WeaponCharging_CK(
m_weapon,
this);
160 m_fsm.SetInitialState(
m_start);
167 Magazine mag = e.m_magazine;
169 InventoryLocation newSrc =
new InventoryLocation;
170 mag.GetInventory().GetCurrentInventoryLocation(newSrc);
173 InventoryLocation lhand =
new InventoryLocation;
174 lhand.SetAttachment(e.m_player, mag, InventorySlots.LEFTHAND);
175 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
177 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, ok - new magazine removed from inv (inv->LHand)"); }
180 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, error - cannot new remove mag from inv");
182 InventoryLocation il =
new InventoryLocation;
183 il.SetAttachment(
m_weapon, mag, InventorySlots.MAGAZINE);
184 m_attach.m_newMagazine = mag;
185 m_attach.m_newDst = il;
192 EntityAI leftHandItem = e.m_player.GetInventory().FindAttachment(InventorySlots.LEFTHAND);
193 Magazine mag = Magazine.Cast(leftHandItem);
197 e.m_player.GetInventory().ClearInventoryReservationEx( mag , null );
198 InventoryLocation il =
new InventoryLocation;
201 if(!il || !il.IsValid())
203 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
205 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, ok - no inventory space for old magazine - dropped to ground"); }
208 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine");
213 InventoryLocation oldSrc =
new InventoryLocation;
214 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
216 if (GameInventory.LocationSyncMoveEntity(oldSrc, il))
218 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, ok - old magazine removed from wpn (LHand->inv)"); }
221 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, error - cannot remove old mag from wpn");
234 ref AttachNewMagazine m_attach;
235 ref WeaponStateBase m_attach_W;
236 ref WeaponChamberFromAttMagOpenbolt_W4T
m_chamber;
237 ref WeaponChargingOpenBolt_CK m_onCK;
239 void WeaponAttachMagazineOpenBoltCharged (Weapon_Base w = NULL, WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE,
int actionType = -1)
242 m_actionType = actionType;
246 m_attach =
new AttachNewMagazine(
m_weapon,
this);
247 m_attach_W =
new WeaponStateBase(
m_weapon,
this);
249 m_onCK =
new WeaponChargingOpenBolt_CK(
m_weapon,
this);
260 m_fsm =
new WeaponFSM(
this);
277 m_fsm.SetInitialState(
m_start);
284 Magazine mag = e.m_magazine;
286 InventoryLocation newSrc =
new InventoryLocation;
287 mag.GetInventory().GetCurrentInventoryLocation(newSrc);
290 InventoryLocation lhand =
new InventoryLocation;
291 lhand.SetAttachment(e.m_player, mag, InventorySlots.LEFTHAND);
292 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
294 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, ok - new magazine removed from inv (inv->LHand)"); }
297 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazineOpenBoltCharged, error - cannot new remove mag from inv");
299 InventoryLocation il =
new InventoryLocation;
300 il.SetAttachment(
m_weapon, mag, InventorySlots.MAGAZINE);
301 m_attach.m_newMagazine = mag;
302 m_attach.m_newDst = il;
309 EntityAI leftHandItem = e.m_player.GetInventory().FindAttachment(InventorySlots.LEFTHAND);
310 Magazine mag = Magazine.Cast(leftHandItem);
314 e.m_player.GetInventory().ClearInventoryReservationEx( mag , null );
315 InventoryLocation il =
new InventoryLocation;
318 if(!il || !il.IsValid())
320 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, mag))
322 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, ok - no inventory space for old magazine - dropped to ground"); }
325 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazineOpenBoltCharged, error - cannot drop magazine from left hand after not found inventory space for old magazine");
330 InventoryLocation oldSrc =
new InventoryLocation;
331 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
333 if (GameInventory.LocationSyncMoveEntity(oldSrc, il))
335 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazine, ok - old magazine removed from wpn (LHand->inv)"); }
338 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponAttachMagazineOpenBoltCharged, error - cannot remove old mag from wpn");
void wpnDebugPrint(string s)
attach mag in LH into weapon
signalize mechanism manipulation
weapon finite state machine
simple class starting animation action specified by m_action and m_actionType
represent weapon state base
Serializer ParamsReadContext
Serializer ParamsWriteContext
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
enum FSMTransition WeaponEventBase
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)