DayZ 1.24
Loading...
Searching...
No Matches
WeaponChambering.c File Reference

Go to the source code of this file.

Classes

class  WeaponStartAction
 simple class starting animation action specified by m_action and m_actionType More...
 
class  WeaponStateBase
 represent weapon state base More...
 
class  WeaponChambering_Base
 
class  WeaponChambering_Cartridge
 

Functions

override void OnExit (WeaponEventBase e)
 
override void OnEntry (WeaponEventBase e)
 
void ChamberMultiBullet (Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int startActionType=-1, int endActionType=-1)
 
override void OnAbort (WeaponEventBase e)
 
override bool SaveCurrentFSMState (ParamsWriteContext ctx)
 
override bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
 

Variables

class WeaponChambering_Cartridge_InnerMag extends WeaponChambering_Base IsWaitingForActionFinish
 
class WeaponEndAction extends WeaponStartAction m_action
 
int m_startActionType
 
int m_endActionType
 
Magazine m_srcMagazine
 
ref InventoryLocation m_srcMagazinePrevLocation
 source of the cartridge
 
ref WeaponStateBase m_start
 
ref WeaponEjectCasingMultiMuzzle m_eject
 
ref WeaponChambering_Base m_chamber
 
ref WeaponChambering_Base m_chamber_end
 
ref LoopedChambering_Wait4ShowBullet2 m_w4sb2
 
ref WeaponEndAction m_endLoop
 
ref BulletShow_W4T m_showB
 
ref BulletShow2_W4T m_showB2
 

Function Documentation

◆ ChamberMultiBullet()

void ChamberMultiBullet ( Weapon_Base w = NULL,
WeaponStateBase parent = NULL,
WeaponActions action = WeaponActions.NONE,
int startActionType = -1,
int endActionType = -1 )

Definition at line 635 of file WeaponChambering.c.

636 {
640
641 // setup nested state machine
647 m_showB = new BulletShow_W4T(m_weapon, this);
648 m_showB2 = new BulletShow2_W4T(m_weapon, this);
649
650 m_endLoop = new WeaponEndAction(m_weapon, this, m_action, m_endActionType); // @NOTE: termination playing action - dummy?
651 // events
652 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
653 WeaponEventContinuousLoadBulletStart __lS_ = new WeaponEventContinuousLoadBulletStart;
654 WeaponEventContinuousLoadBulletEnd __lE_ = new WeaponEventContinuousLoadBulletEnd;
655 WeaponEventAnimBulletShow __bs_ = new WeaponEventAnimBulletShow;
656 WeaponEventAnimBulletShow2 _bs2_ = new WeaponEventAnimBulletShow2;
657 WeaponEventAnimBulletHide __bh_ = new WeaponEventAnimBulletHide;
658 WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
659 WeaponEventAnimBulletInChamber __bc_ = new WeaponEventAnimBulletInChamber;
660
661 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
662 m_fsm.AddTransition(new WeaponTransition(m_start, __be_, m_eject));
663
664 m_fsm.AddTransition(new WeaponTransition(m_start, __bs_, m_chamber));
665 m_fsm.AddTransition(new WeaponTransition(m_eject, __bs_, m_chamber));
666
667 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())));
668 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bc_, m_endLoop));
669 m_fsm.AddTransition(new WeaponTransition(m_w4sb2, __bs_, m_chamber));
670
671 m_fsm.AddTransition(new WeaponTransition(m_w4sb2, _fin_, NULL));
672 m_fsm.AddTransition(new WeaponTransition(m_chamber, _fin_, NULL));
673 m_fsm.AddTransition(new WeaponTransition(m_endLoop, _fin_, NULL));
674
675 // Safety exits
676 m_fsm.AddTransition(new WeaponTransition(m_eject, _fin_, null));
677 m_fsm.AddTransition(new WeaponTransition(m_start, _fin_, null));
678
679 m_fsm.SetInitialState(m_start);
680 }
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
enum FSMTransition WeaponTransition
ref LoopedChambering_Wait4ShowBullet2 m_w4sb2
ref BulletShow2_W4T m_showB2
int m_startActionType
int m_endActionType
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
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine

References m_action, m_chamber, m_chamber_end, m_eject, m_endActionType, m_endLoop, m_showB, m_showB2, m_start, m_startActionType, m_w4sb2, m_weapon, and WeaponStateBase::WeaponEjectCasingMultiMuzzle().

Referenced by DoubleBarrel_Base::InitStateMachine().

◆ LoadCurrentFSMState()

override bool LoadCurrentFSMState ( ParamsReadContext ctx,
int version )

Definition at line 856 of file WeaponChambering.c.

857 {
858 if (!super.LoadCurrentFSMState(ctx, version))
859 return false;
860
861 if (!ctx.Read(m_srcMagazine))
862 {
863 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" + m_weapon);
864 return false;
865 }
866
868 {
869 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.LoadCurrentFSMState: cannot read m_srcMagazinePrevLocation for weapon=" + m_weapon);
870 return false;
871 }
872 return true;
873 }
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
Magazine m_srcMagazine
ref InventoryLocation m_srcMagazinePrevLocation
source of the cartridge
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), m_srcMagazine, m_srcMagazinePrevLocation, m_weapon, and OptionalLocationReadFromContext().

◆ OnAbort()

Definition at line 777 of file WeaponChambering.c.

778 {
779 bool done = false;
780 if (m_srcMagazine)
781 {
782 e.m_player.GetInventory().ClearInventoryReservationEx(m_srcMagazine, m_srcMagazinePrevLocation);
783
785 m_srcMagazine.GetInventory().GetCurrentInventoryLocation(leftHandIl);
786 if (leftHandIl.IsValid())
787 {
789 {
791 {
793 {
795 {
796 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from left hand to previous location (LHand->inv) - abort");
797 done = true;
798 }
799 }
800 }
801 }
802
803 if (!done)
804 {
806 e.m_player.GetInventory().FindFreeLocationFor(m_srcMagazine, FindInventoryLocationType.CARGO, il);
807
808 if (!il || !il.IsValid())
809 {
810 if (DayZPlayerUtils.HandleDropMagazine(e.m_player, m_srcMagazine))
811 {
812 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - no inventory space for ammo pile - dropped to ground - abort");
813 }
814 else
815 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot drop ammo pile from left hand after not found inventory space for ammo pile - abort");
816
817 }
818 else
819 {
821 {
822 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, ok - ammo pile removed from left hand (LHand->inv) - abort");
823 }
824 else
825 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet, error - cannot remove ammo pile from wpn - abort");
826 }
827 }
828 }
829 }
830
831 super.OnAbort(e);
833 m_chamber.m_srcMagazine = NULL;
835 }
void wpnDebugPrint(string s)
Definition Debug.c:9
void DayZPlayerUtils()
cannot be instantiated
FindInventoryLocationType
flags for searching locations in inventory
script counterpart to engine's class Inventory
Definition Inventory.c:79
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...
InventoryLocation.
static bool IsWeaponLogEnable()
Definition Debug.c:799
const float MAX_DROP_MAGAZINE_DISTANCE_SQ
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.

References DayZPlayerUtils(), vector::DistanceSq(), Error(), LogManager::IsWeaponLogEnable(), GameInventory::LocationCanMoveEntity(), GameInventory::LocationSyncMoveEntity(), m_chamber, m_srcMagazine, m_srcMagazinePrevLocation, m_weapon, WeaponManager::MAX_DROP_MAGAZINE_DISTANCE_SQ, and wpnDebugPrint().

◆ OnEntry()

Definition at line 187 of file WeaponChambering.c.

188 {
189 super.OnEntry(e);
190
191 /*for(int i = 0; i < m_weapon.GetMuzzleCount(); i++ )
192 {
193 if(!m_weapon.IsChamberFull(i))
194 {
195 m_weapon.ShowBullet(i);
196 m_weapon.EffectBulletShow(i, m_damage, m_type);
197 return;
198 }
199 }*/
200 }

◆ OnExit()

override void IsWaitingForActionFinish::OnExit ( WeaponEventBase e)

Definition at line 187 of file WeaponChambering.c.

188 {
189 super.OnEntry(e);
190
191 /*for(int i = 0; i < m_weapon.GetMuzzleCount(); i++ )
192 {
193 if(!m_weapon.IsChamberFull(i))
194 {
195 m_weapon.ShowBullet(i);
196 m_weapon.EffectBulletShow(i, m_damage, m_type);
197 return;
198 }
199 }*/
200 }
201
202 override void OnExit(WeaponEventBase e)
203 {
204 m_weapon.SelectionBulletHide();
override void OnExit(WeaponEventBase e)

◆ SaveCurrentFSMState()

override bool SaveCurrentFSMState ( ParamsWriteContext ctx)

Definition at line 837 of file WeaponChambering.c.

838 {
839 if (!super.SaveCurrentFSMState(ctx))
840 return false;
841
842 if (!ctx.Write(m_srcMagazine))
843 {
844 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" + m_weapon);
845 return false;
846 }
847
849 {
850 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ChamberMultiBullet.SaveCurrentFSMState: cannot write m_srcMagazinePrevLocation for weapon=" + m_weapon);
851 return false;
852 }
853 return true;
854 }
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)

References Error(), m_srcMagazine, m_srcMagazinePrevLocation, m_weapon, and OptionalLocationWriteToContext().

Variable Documentation

◆ IsWaitingForActionFinish

override bool IsWaitingForActionFinish

Definition at line 161 of file WeaponChambering.c.

186{ return false; }

◆ m_action

◆ m_chamber

◆ m_chamber_end

ref WeaponChambering_Base m_chamber_end

Definition at line 629 of file WeaponChambering.c.

Referenced by ChamberMultiBullet().

◆ m_eject

◆ m_endActionType

◆ m_endLoop

◆ m_showB

Definition at line 632 of file WeaponChambering.c.

Referenced by ChamberMultiBullet().

◆ m_showB2

ref BulletShow2_W4T m_showB2

Definition at line 633 of file WeaponChambering.c.

Referenced by ChamberMultiBullet().

◆ m_srcMagazine

◆ m_srcMagazinePrevLocation

◆ m_start

◆ m_startActionType

◆ m_w4sb2