30 if (!super.SaveCurrentFSMState(ctx))
35 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_damage for weapon=" +
m_weapon);
40 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_type for weapon=" +
m_weapon);
45 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_magazineType for weapon=" +
m_weapon);
50 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_srcMagazine for weapon=" +
m_weapon);
58 if (!super.LoadCurrentFSMState(ctx, version))
63 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_damage for weapon=" +
m_weapon);
68 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_type for weapon=" +
m_weapon);
73 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_magazineType for weapon=" +
m_weapon);
78 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
98 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering ShowBullet, error - cannot take cartridge from magazine");
103 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering ShowBullet, error - no magazine to load from (m_srcMagazine=NULL)");
111 m_weapon.EffectBulletHide(muzzleIndex);
155 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering DropBullet, error - cannot drop " +
m_type +
" - lost)");
161 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering DropBullet, error - magazine or bullet type is not set");
172 if (!
m_weapon.IsChamberFull(muzzleIndex))
200 if (!
m_weapon.IsInternalMagazineFull(muzzleIndex))
230 if (
m_weapon.IsChamberFull(muzzleIndex))
232 if(
m_weapon.PopCartridgeFromChamber(muzzleIndex, ammoDamage, ammoTypeName))
234 if (
m_weapon.PushCartridgeToInternalMagazine(muzzleIndex, ammoDamage, ammoTypeName))
241 if (
m_weapon.PushCartridgeToChamber(muzzleIndex, ammoDamage, ammoTypeName))
269 int mi =
m_weapon.GetCurrentMuzzle();
277 int mi =
m_weapon.GetCurrentMuzzle();
278 if(AcquireCartridgeFromMagazine())
284 m_magazineType =
string.Empty;
285 m_type =
string.Empty;
302 int mi =
m_weapon.GetCurrentMuzzle();
303 if(AcquireCartridgeFromMagazine())
305 if(!PushBulletToChamber(mi))
313 m_magazineType =
string.Empty;
314 m_type =
string.Empty;
328 int mi =
m_weapon.GetCurrentMuzzle();
329 if(PushBulletFromChamberToInternalMagazine(mi))
331 if(AcquireCartridgeFromMagazine())
333 if(!PushBulletToChamber(mi))
341 m_magazineType =
string.Empty;
342 m_type =
string.Empty;
355 int mi =
m_weapon.GetCurrentMuzzle();
356 if(AcquireCartridgeFromMagazine())
361 m_magazineType =
string.Empty;
362 m_type =
string.Empty;
369 int mi =
m_weapon.GetCurrentMuzzle();
371 if(AcquireCartridgeFromMagazine())
373 if(PushBulletToChamber(mi))
375 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(
m_weapon.GetAttachmentByType(Magnum_Cylinder));
379 string bullet =
"bullet";
380 string bullet_nose =
"bullet_nose";
384 bullet =
string.
Format(
"bullet_" + ( mi + 1 ));
385 bullet_nose =
string.
Format(
"bullet_nose_" + ( mi + 1 ));
387 cylinder.ShowSelection(bullet);
388 cylinder.ShowSelection(bullet_nose);
397 m_magazineType =
string.Empty;
398 m_type =
string.Empty;
413 for(
int i = 0; i <
m_weapon.GetMuzzleCount(); i++ )
428 int mi =
m_weapon.GetCurrentMuzzle();
429 if(AcquireCartridgeFromMagazine())
435 m_magazineType =
string.Empty;
436 m_type =
string.Empty;
443 for(
int i = 0; i <
m_weapon.GetMuzzleCount(); i++ )
447 if(AcquireCartridgeFromMagazine())
449 if (
m_weapon.PushCartridgeToChamber(i, m_damage, m_type))
459 m_type =
string.Empty;
479 int mi =
m_weapon.GetCurrentMuzzle();
480 if(AcquireCartridgeFromMagazine())
482 if(!PushBulletToInternalMagazine(mi))
489 m_magazineType =
string.Empty;
490 m_type =
string.Empty;
501 int mi =
m_weapon.GetCurrentMuzzle();
502 if(AcquireCartridgeFromMagazine())
504 if(!PushBulletToChamber(mi))
511 m_magazineType =
string.Empty;
512 m_type =
string.Empty;
523 int mi =
m_weapon.GetCurrentMuzzle();
524 if(AcquireCartridgeFromMagazine())
526 if(!PushBulletToInternalMagazine(mi))
533 m_magazineType =
string.Empty;
534 m_type =
string.Empty;
552 ref WeaponChambering_Cartridge
m_chamber;
553 ref WeaponChambering_W4T
m_w4t;
554 ref WeaponCharging_CK
m_onCK;
569 WeaponEventAnimBulletInChamber __bc_ =
new WeaponEventAnimBulletInChamber;
570 WeaponEventAnimBulletShow __bs_ =
new WeaponEventAnimBulletShow;
571 WeaponEventAnimBulletEject __be_ =
new WeaponEventAnimBulletEject;
572 WeaponEventAnimCocked __ck_ =
new WeaponEventAnimCocked;
600 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
612 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot remove ammo pile from inv");
637 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
667 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
677 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot remove ammo pile from wpn - abort");
697 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
727 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
737 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot remove ammo pile from wpn - exit");
751 if (!super.SaveCurrentFSMState(ctx))
756 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" +
m_weapon);
762 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" +
m_weapon);
770 if (!super.LoadCurrentFSMState(ctx, version))
775 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
781 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" +
m_weapon);
810 ref LoopedChambering_Wait4ShowBullet2
m_w4sb2;
832 WeaponEventContinuousLoadBulletStart __lS_ =
new WeaponEventContinuousLoadBulletStart;
833 WeaponEventContinuousLoadBulletEnd __lE_ =
new WeaponEventContinuousLoadBulletEnd;
834 WeaponEventAnimBulletShow __bs_ =
new WeaponEventAnimBulletShow;
835 WeaponEventAnimBulletShow2 _bs2_ =
new WeaponEventAnimBulletShow2;
836 WeaponEventAnimBulletHide __bh_ =
new WeaponEventAnimBulletHide;
837 WeaponEventAnimBulletEject __be_ =
new WeaponEventAnimBulletEject;
838 WeaponEventAnimBulletInChamber __bc_ =
new WeaponEventAnimBulletInChamber;
846 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())));
858 m_fsm.SetInitialState(
m_start);
868 InventoryLocation newSrc =
new InventoryLocation;
869 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
874 InventoryLocation lhand =
new InventoryLocation;
876 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
878 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from inv (inv->LHand)"); }
881 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot remove ammo pile from inv");
887 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet m_srcMagazine = NULL"); }
904 InventoryLocation leftHandIl =
new InventoryLocation;
905 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
916 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from left hand to previous location (LHand->inv) - exit"); }
925 InventoryLocation il =
new InventoryLocation;
932 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - no inventory space for ammo pile - dropped to ground - exit"); }
935 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
940 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
942 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from left hand (LHand->inv) - exit"); }
945 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot remove ammo pile from wpn - exit");
963 InventoryLocation leftHandIl =
new InventoryLocation;
964 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
975 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from left hand to previous location (LHand->inv) - abort"); }
984 InventoryLocation il =
new InventoryLocation;
991 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - no inventory space for ammo pile - dropped to ground - abort"); }
994 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
999 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
1001 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from left hand (LHand->inv) - abort"); }
1004 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot remove ammo pile from wpn - abort");
1018 if (!super.SaveCurrentFSMState(ctx))
1023 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" +
m_weapon);
1029 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" +
m_weapon);
1037 if (!super.LoadCurrentFSMState(ctx, version))
1042 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
1048 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" +
m_weapon);
1061 nextMuzzle = currentMuzzle;
1062 int nMuzzles =
m_weapon.GetMuzzleCount();
1064 for (
int i = 0; i < nMuzzles; ++i)
1067 nextMuzzle =
Math.
WrapInt(nextMuzzle, 0, nMuzzles);
1068 if (
m_weapon.IsChamberEmpty(nextMuzzle))
1081 magnum.SetCylinderRotationAnimationPhase(magnum.GetCylinderRotation(nextMuzzle));
1082 m_weapon.SetCurrentMuzzle(nextMuzzle);
1130 WeaponEventContinuousLoadBulletStart __lS_ =
new WeaponEventContinuousLoadBulletStart;
1131 WeaponEventContinuousLoadBulletEnd __lE_ =
new WeaponEventContinuousLoadBulletEnd;
1132 WeaponEventCylinderRotate __cr_ =
new WeaponEventCylinderRotate;
1133 WeaponEventAnimBulletShow __bs_ =
new WeaponEventAnimBulletShow;
1134 WeaponEventAnimBulletHide __bh_ =
new WeaponEventAnimBulletHide;
1135 WeaponEventAnimBulletEject __be_ =
new WeaponEventAnimBulletEject;
1136 WeaponEventAnimBulletInMagazine __bM_ =
new WeaponEventAnimBulletInMagazine;
1137 WeaponEventAnimBulletShow2 _bs2_ =
new WeaponEventAnimBulletShow2;
1176 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
1188 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering, error - cannot remove ammo pile from inv");
1194 Print(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering m_srcMagazine = NULL");
1213 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
1243 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
1253 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering, error - cannot remove ammo pile from wpn - exit");
1273 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
1303 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" LoopedChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
1313 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" LoopedChambering, error - cannot remove ammo pile from wpn - abort");
1327 if (!super.SaveCurrentFSMState(ctx))
1332 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" +
m_weapon);
1338 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" +
m_weapon);
1347 if (!super.LoadCurrentFSMState(ctx, version))
1352 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
1358 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" +
m_weapon);
void wpnDebugPrint(string s)
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
enum FSMTransition WeaponEventBase
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
ref InventoryLocation m_srcMagazinePrevLocation
source of the cartridge
ref WeaponEndAction m_endLoop
ref WeaponStateBase m_start
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
class WeaponEndAction extends WeaponStartAction m_action
ref WeaponChambering_Base m_chamber
ref WeaponEjectCasingMultiMuzzle m_eject
ref BulletShow_W4T m_showB
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...
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...
script counterpart to engine's class Inventory
override void OnEntry(HandEventBase e)
proto native bool IsValid()
verify current set inventory location
proto native vector GetPos()
returns position of item in world if type is Ground
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()
proto bool Write(void value_out)
proto bool Read(void value_in)
override void OnEntry(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override bool IsWaitingForActionFinish()
override void OnAbort(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override bool IsWaitingForActionFinish()
signalize mechanism manipulation
weapon finite state machine
const float MAX_DROP_MAGAZINE_DISTANCE_SQ
override void OnEntry(WeaponEventBase e)
override bool IsWaitingForActionFinish()
simple class starting animation action specified by m_action and m_actionType
bool PushBulletToInternalMagazine(int muzzleIndex)
ref BulletHide_W4T m_hideB
bool ShowBullet(int muzzleIndex)
bool AcquireCartridgeFromMagazine()
bool DropBullet(WeaponEventBase e)
ref WeaponCylinderRotate m_rotate
int m_actionType
action to be played
ref WeaponChambering_W4T m_w4t
ref WeaponCharging_CK m_onCK
void WeaponStateBase(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
internal state id used for load/restore
ref WeaponStartAction m_endLoop
void WeaponStartAction(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
specific action sub-type
void WeaponEjectCasingMultiMuzzle(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
Magazine m_srcMagazine
destination of the ejected cartridge
ref WeaponFSM m_fsm
hierarchical parent state of this state (or null)
ref LoopedChambering_Wait4ShowBullet2 m_w4sb2
bool FindNextFreeMuzzle(int currentMuzzle, out int nextMuzzle)
void WeaponChambering(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
ref WeaponChambering_Cartridge m_chamber
override bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
void HideBullet(int muzzleIndex)
override void OnEntry(WeaponEventBase e)
ref WeaponStateBase m_start
source of the cartridge
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
bool PushBulletToChamber(int muzzleIndex)
void WeaponMagnumChambering(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int startActionType=-1, int endActionType=-1)
ref WeaponEjectCasing m_eject
ref InventoryLocation m_srcMagazinePrevLocation
source of the cartridge
void WeaponEjectAllMuzzles(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
override void OnAbort(WeaponEventBase e)
void WeaponEjectCasing(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
bool PushBulletFromChamberToInternalMagazine(int muzzleIndex)
override void OnExit(WeaponEventBase e)
override bool SaveCurrentFSMState(ParamsWriteContext ctx)
source of the cartridge
represent weapon state base
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
Serializer ParamsReadContext
proto native CGame GetGame()
Serializer ParamsWriteContext
void Error(string err)
Messagebox with error message.
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.