29 if (!super.SaveCurrentFSMState(ctx))
34 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_damage for weapon=" +
m_weapon);
39 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_type for weapon=" +
m_weapon);
44 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_magazineType for weapon=" +
m_weapon);
49 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_srcMagazine for weapon=" +
m_weapon);
57 if (!super.LoadCurrentFSMState(ctx, version))
62 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_damage for weapon=" +
m_weapon);
67 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_type for weapon=" +
m_weapon);
72 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_magazineType for weapon=" +
m_weapon);
77 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
106 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_Cartridge, error - cannot take cartridge from magazine");
110 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_Cartridge, error - no magazine to load from (m_srcMagazine=NULL)");
117 int mi =
m_weapon.GetCurrentMuzzle();
119 string magazineTypeName;
121 if (m_magazineType.Length() > 0)
122 magazineTypeName = m_magazineType;
124 magazineTypeName =
m_weapon.GetChamberAmmoTypeName(mi);
133 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_Cartridge, error - cannot abort removal from wpn (of old mag)");
139 m_magazineType =
string.Empty;
140 m_type =
string.Empty;
146 int mi =
m_weapon.GetCurrentMuzzle();
149 if (
m_weapon.PushCartridgeToChamber(mi, m_damage, m_type))
157 m_magazineType =
string.Empty;
158 m_type =
string.Empty;
170 int mi =
m_weapon.GetCurrentMuzzle();
173 m_weapon.PopCartridgeFromChamber(mi, ammoDamage, ammoTypeName);
174 if (
m_weapon.PushCartridgeToInternalMagazine(mi, ammoDamage, ammoTypeName))
209 int muzzle =
m_weapon.GetCurrentMuzzle();
211 if (!
m_weapon.IsChamberFull(muzzle))
213 if (
m_weapon.PushCartridgeToChamber(muzzle, m_damage, m_type))
215 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(
m_weapon.GetAttachmentByType(Magnum_Cylinder));
219 string bullet =
"bullet";
220 string bullet_nose =
"bullet_nose";
224 bullet =
string.
Format(
"bullet_" + ( muzzle + 1 ));
225 bullet_nose =
string.
Format(
"bullet_nose_" + ( muzzle + 1 ));
227 cylinder.ShowSelection(bullet);
228 cylinder.ShowSelection(bullet_nose);
230 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_MultiMuzzleMagnum, ok - loaded chamber"); }
233 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_MultiMuzzleMagnum, error - cannot load chamber chamber!"); }
234 m_type =
string.Empty;
238 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_MultiMuzzleMagnum, error - cannot load chamber chamber!"); }
255 for(
int i = 0; i <
m_weapon.GetMuzzleCount(); i++ )
260 m_weapon.EffectBulletShow(i, m_damage, m_type);
268 for(
int i = 0; i <
m_weapon.GetMuzzleCount(); i++ )
272 if (
m_weapon.PushCartridgeToChamber(i, m_damage, m_type))
278 m_type =
string.Empty;
287class WeaponChambering_MultiMuzzle_W4T
extends WeaponChambering_MultiMuzzle
309 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_Cartridge_InnerMag, error - cannot take cartridge from magazine");
313 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_Cartridge_InnerMag, error - no magazine to load from (m_srcMagazine=NULL)");
323 int mi =
m_weapon.GetCurrentMuzzle();
324 string magazineTypeName;
326 if (m_magazineType.Length() > 0)
327 magazineTypeName = m_magazineType;
329 magazineTypeName =
m_weapon.GetChamberAmmoTypeName(mi);
338 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering_Cartridge_InnerMag, error - cannot abort removal from wpn (of old mag)");
344 m_magazineType =
string.Empty;
345 m_type =
string.Empty;
353 int mi =
m_weapon.GetCurrentMuzzle();
354 if (!
m_weapon.IsInternalMagazineFull(mi))
356 if (
m_weapon.PushCartridgeToInternalMagazine(mi, m_damage, m_type))
363 m_magazineType =
string.Empty;
383 ref WeaponChambering_W4T
m_w4t;
384 ref WeaponCharging_CK
m_onCK;
399 WeaponEventAnimBulletInChamber __bc_ =
new WeaponEventAnimBulletInChamber;
400 WeaponEventAnimBulletShow __bs_ =
new WeaponEventAnimBulletShow;
401 WeaponEventAnimBulletEject __be_ =
new WeaponEventAnimBulletEject;
402 WeaponEventAnimCocked __ck_ =
new WeaponEventAnimCocked;
430 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
442 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot remove ammo pile from inv");
467 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
497 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
507 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot remove ammo pile from wpn - abort");
527 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
557 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
567 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering, error - cannot remove ammo pile from wpn - exit");
581 if (!super.SaveCurrentFSMState(ctx))
586 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" +
m_weapon);
592 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" +
m_weapon);
600 if (!super.LoadCurrentFSMState(ctx, version))
605 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
611 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponChambering.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" +
m_weapon);
641 ref LoopedChambering_Wait4ShowBullet2
m_w4sb2;
664 WeaponEventContinuousLoadBulletStart __lS_ =
new WeaponEventContinuousLoadBulletStart;
665 WeaponEventContinuousLoadBulletEnd __lE_ =
new WeaponEventContinuousLoadBulletEnd;
666 WeaponEventAnimBulletShow __bs_ =
new WeaponEventAnimBulletShow;
667 WeaponEventAnimBulletShow2 _bs2_ =
new WeaponEventAnimBulletShow2;
668 WeaponEventAnimBulletHide __bh_ =
new WeaponEventAnimBulletHide;
669 WeaponEventAnimBulletEject __be_ =
new WeaponEventAnimBulletEject;
670 WeaponEventAnimBulletInChamber __bc_ =
new WeaponEventAnimBulletInChamber;
678 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())));
690 m_fsm.SetInitialState(
m_start);
700 InventoryLocation newSrc =
new InventoryLocation;
701 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
706 InventoryLocation lhand =
new InventoryLocation;
708 if (GameInventory.LocationSyncMoveEntity(newSrc, lhand))
710 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from inv (inv->LHand)"); }
713 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot remove ammo pile from inv");
719 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet m_srcMagazine = NULL"); }
736 InventoryLocation leftHandIl =
new InventoryLocation;
737 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
748 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from left hand to previous location (LHand->inv) - exit"); }
757 InventoryLocation il =
new InventoryLocation;
764 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - no inventory space for ammo pile - dropped to ground - exit"); }
767 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
772 if (GameInventory.LocationSyncMoveEntity(leftHandIl, il))
774 if (LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, ok - ammo pile removed from left hand (LHand->inv) - exit"); }
777 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot remove ammo pile from wpn - exit");
796 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
826 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
836 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet, error - cannot remove ammo pile from wpn - abort");
850 if (!super.SaveCurrentFSMState(ctx))
855 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" +
m_weapon);
861 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" +
m_weapon);
869 if (!super.LoadCurrentFSMState(ctx, version))
874 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
880 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" +
m_weapon);
893 nextMuzzle = currentMuzzle;
894 int nMuzzles =
m_weapon.GetMuzzleCount();
896 for (
int i = 0; i < nMuzzles; ++i)
899 nextMuzzle =
Math.
WrapInt(nextMuzzle, 0, nMuzzles);
900 if (
m_weapon.IsChamberEmpty(nextMuzzle))
913 magnum.SetCylinderRotationAnimationPhase(magnum.GetCylinderRotation(nextMuzzle));
914 m_weapon.SetCurrentMuzzle(nextMuzzle);
942 ref LoopedChambering_Wait4ShowBullet2
m_w4sb2;
962 WeaponEventContinuousLoadBulletStart __lS_ =
new WeaponEventContinuousLoadBulletStart;
963 WeaponEventContinuousLoadBulletEnd __lE_ =
new WeaponEventContinuousLoadBulletEnd;
964 WeaponEventCylinderRotate __cr_ =
new WeaponEventCylinderRotate;
965 WeaponEventAnimBulletShow __bs_ =
new WeaponEventAnimBulletShow;
966 WeaponEventAnimBulletHide __bh_ =
new WeaponEventAnimBulletHide;
967 WeaponEventAnimBulletEject __be_ =
new WeaponEventAnimBulletEject;
968 WeaponEventAnimBulletInMagazine __bM_ =
new WeaponEventAnimBulletInMagazine;
969 WeaponEventAnimBulletShow2 _bs2_ =
new WeaponEventAnimBulletShow2;
1008 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(newSrc);
1020 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering, error - cannot remove ammo pile from inv");
1026 Print(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering m_srcMagazine = NULL");
1045 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
1075 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - exit");
1085 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering, error - cannot remove ammo pile from wpn - exit");
1105 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
1135 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" LoopedChambering, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
1145 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" LoopedChambering, error - cannot remove ammo pile from wpn - abort");
1159 if (!super.SaveCurrentFSMState(ctx))
1164 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" +
m_weapon);
1170 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" +
m_weapon);
1179 if (!super.LoadCurrentFSMState(ctx, version))
1184 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponMagnumChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" +
m_weapon);
1190 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
class WeaponChambering_Cartridge_InnerMag extends WeaponChambering_Base IsWaitingForActionFinish
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
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 void OnEntry(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
ref BulletHide_W4T m_hideB
ref WeaponCylinderRotate m_rotate
int m_actionType
action to be played
ref WeaponChambering_W4T m_w4t
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
override void OnEntry(WeaponEventBase e)
ref WeaponCharging_CK m_onCK
ref WeaponStateBase m_start
source of the cartridge
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
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)
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.