Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
boltactionrifleinnermagazine_base.c
Go to the documentation of this file.
2 {
3  DEFAULT = 0,
4  OPENED = 1,
5  JAMMED = 2,
6 };
7 
9 {
10  UNKNOWN = 0,
11  EmptyDischarged = 1,
12  LoadedCharged = 2,
13  LoadedDischarged = 3,
14  LoadedJammed = 4,
15 }
16 
17 
18 class BARIMEmptyDischarged extends WeaponStableState
19 {
20  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { EmptyDischarged C0"); } super.OnEntry(e); }
21  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } EmptyDischarged C0"); } }
22  override int GetCurrentStateID () { return BARIMStableStateID.EmptyDischarged; }
23  override bool HasBullet () { return false; }
24  override bool HasMagazine () { return false; }
25  override bool IsJammed () { return false; }
26  override bool IsRepairEnabled () { return true; }
27  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
28 };
29 class BARIMLoadedCharged extends WeaponStableState
30 {
31  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { LoadedCharged C1"); } super.OnEntry(e); }
32  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } LoadedCharged C1"); } }
33  override int GetCurrentStateID () { return BARIMStableStateID.LoadedCharged; }
34  override bool HasBullet () { return true; }
35  override bool HasMagazine () { return false; }
36  override bool IsJammed () { return false; }
37  override bool IsRepairEnabled () { return true; }
38  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.L}; }
39 };
40 class BARIMLoadedDischarged extends WeaponStableState
41 {
42  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { LoadedDischarged D1"); } super.OnEntry(e); }
43  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } LoadedDischarged D1"); } }
44  override int GetCurrentStateID () { return BARIMStableStateID.LoadedDischarged; }
45  override bool HasBullet () { return true; }
46  override bool HasMagazine () { return false; }
47  override bool IsJammed () { return false; }
48  override bool IsRepairEnabled () { return true; }
49  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
50 };
51 class BARIMLoadedJammed extends WeaponStateJammed
52 {
53  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { LoadedJammed JF"); } super.OnEntry(e); }
54  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } LoadedJammed JF"); } }
55  override int GetCurrentStateID () { return BARIMStableStateID.LoadedJammed; }
56  override bool HasBullet () { return true; }
57  override bool HasMagazine () { return false; }
58  override bool IsJammed () { return true; }
59  override bool IsRepairEnabled () { return true; }
60  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
61 };
62 
63 
69 {
70  ref WeaponStableState C0;
71  ref WeaponStableState C1;
72  ref WeaponStableState D1;
73  ref WeaponStableState JF;
74 
75 
76  override void InitStateMachine ()
77  {
78  m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
79  m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP));
80  m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED));
81  m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE));
82  m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
83  m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END));
84  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
85  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
86  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
87  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
88 
89 
90  C0 = new BARIMEmptyDischarged(this, NULL, BARIMAnimState.DEFAULT);
91  C1 = new BARIMLoadedCharged(this, NULL, BARIMAnimState.DEFAULT);
92  JF = new BARIMLoadedJammed(this, NULL, BARIMAnimState.JAMMED);
93  D1 = new BARIMLoadedDischarged(this, NULL, BARIMAnimState.DEFAULT);
94 
95  WeaponStateBase Mech_C1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
96  WeaponStateBase Mech_D1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
97 
98 
99  LoopedChambering Chamber_C0 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
100  LoopedChambering Chamber_C1 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
101  LoopedChambering Chamber_D1 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
102 
103  WeaponStateBase Unjam_JF = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START);
104 
105  WeaponStateBase Trigger_C0 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY);
106  WeaponStateBase Trigger_C1 = new WeaponFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL);
107  WeaponStateBase Trigger_D1 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY);
108  WeaponStateBase Trigger_JF = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY);
109 
110  WeaponStateBase Trigger_C1J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM);
111 
112 
113  WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
114  WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
115  WeaponEventBase __T__ = new WeaponEventTrigger;
116  WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
117  WeaponEventBase __U__ = new WeaponEventUnjam;
118  WeaponEventBase __M__ = new WeaponEventMechanism;
119  WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
120  WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
121  WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
122 
123  m_fsm = new WeaponFSM();
124 
125  // Mechanism
126 //----------------------------------------
127  m_fsm.AddTransition(new WeaponTransition( C0, __M__, Mech_C1));
128 
129  m_fsm.AddTransition(new WeaponTransition( C1, __M__, Mech_C1));
130  m_fsm.AddTransition(new WeaponTransition( Mech_C1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
131  m_fsm.AddTransition(new WeaponTransition( Mech_C1, _fin_, C1));
132  m_fsm.AddTransition(new WeaponTransition( Mech_C1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
133  m_fsm.AddTransition(new WeaponTransition( Mech_C1, _abt_, C1));
134 
135  m_fsm.AddTransition(new WeaponTransition( D1, __M__, Mech_D1));
136  m_fsm.AddTransition(new WeaponTransition( Mech_D1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
137  m_fsm.AddTransition(new WeaponTransition( Mech_D1, _fin_, D1, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
138  m_fsm.AddTransition(new WeaponTransition( Mech_D1, _fin_, C1));
139  m_fsm.AddTransition(new WeaponTransition( Mech_D1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
140  m_fsm.AddTransition(new WeaponTransition( Mech_D1, _abt_, D1, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
141  m_fsm.AddTransition(new WeaponTransition( Mech_D1, _abt_, C1));
142 
143 
144 //----------------------------------------
145 
146  m_fsm.AddTransition(new WeaponTransition( C0, __L__, Chamber_C0));
147  m_fsm.AddTransition(new WeaponTransition( Chamber_C0, _fin_, C1));
148  m_fsm.AddTransition(new WeaponTransition( Chamber_C0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
149  m_fsm.AddTransition(new WeaponTransition( Chamber_C0, _abt_, C1));
150 
151  m_fsm.AddTransition(new WeaponTransition( C1, __L__, Chamber_C1, NULL, new GuardNot(new WeaponGuardInnerMagazineFullShareChamber(this))));
152  m_fsm.AddTransition(new WeaponTransition( Chamber_C1, _fin_, C1));
153  m_fsm.AddTransition(new WeaponTransition( Chamber_C1, _abt_, C1));
154 
155  m_fsm.AddTransition(new WeaponTransition( D1, __L__, Chamber_D1));
156  m_fsm.AddTransition(new WeaponTransition( Chamber_D1, _fin_, C1));
157  m_fsm.AddTransition(new WeaponTransition( Chamber_D1, _abt_, D1, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
158  m_fsm.AddTransition(new WeaponTransition( Chamber_D1, _abt_, C1));
159 
160 //------------------------------------------
161 
162  m_fsm.AddTransition(new WeaponTransition( JF, __U__, Unjam_JF));
163  m_fsm.AddTransition(new WeaponTransition( Unjam_JF, _fin_, JF, NULL, new WeaponGuardJammed(this)));
164  m_fsm.AddTransition(new WeaponTransition( Unjam_JF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
165  m_fsm.AddTransition(new WeaponTransition( Unjam_JF, _fin_, C1));
166  m_fsm.AddTransition(new WeaponTransition( Unjam_JF, _abt_, JF, NULL, new WeaponGuardJammed(this)));
167  m_fsm.AddTransition(new WeaponTransition( Unjam_JF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
168  m_fsm.AddTransition(new WeaponTransition( Unjam_JF, _abt_, C1));
169 
170 
171 //-----------------------------------------
172 
173  // fire
174  m_fsm.AddTransition(new WeaponTransition( C0, __T__, Trigger_C0)); // fire.cocked
175  m_fsm.AddTransition(new WeaponTransition( Trigger_C0, _fin_, C0));
176  m_fsm.AddTransition(new WeaponTransition( Trigger_C0, _dto_, C0));
177  m_fsm.AddTransition(new WeaponTransition( Trigger_C0, _abt_, C0));
178 
179  m_fsm.AddTransition(new WeaponTransition( C1, __T__, Trigger_C1)); // fire.cocked
180  m_fsm.AddTransition(new WeaponTransition( Trigger_C1, _fin_, D1));
181  m_fsm.AddTransition(new WeaponTransition( Trigger_C1, _rto_, D1));
182  m_fsm.AddTransition(new WeaponTransition( Trigger_C1, _abt_, D1));
183 
184  m_fsm.AddTransition(new WeaponTransition( D1, __T__, Trigger_D1)); // fire.cocked
185  m_fsm.AddTransition(new WeaponTransition( Trigger_D1, _fin_, D1));
186  m_fsm.AddTransition(new WeaponTransition( Trigger_D1, _dto_, D1));
187  m_fsm.AddTransition(new WeaponTransition( Trigger_D1, _abt_, D1));
188 
189  m_fsm.AddTransition(new WeaponTransition( JF, __T__, Trigger_JF)); // fire.cocked
190  m_fsm.AddTransition(new WeaponTransition( Trigger_JF, _fin_, JF));
191  m_fsm.AddTransition(new WeaponTransition( Trigger_JF, _dto_, JF));
192  m_fsm.AddTransition(new WeaponTransition( Trigger_JF, _abt_, JF));
193 
194 
195  m_fsm.AddTransition(new WeaponTransition( C1, __TJ_, Trigger_C1J)); // fire.cocked
196  m_fsm.AddTransition(new WeaponTransition( Trigger_C1J, _fin_, JF));
197  m_fsm.AddTransition(new WeaponTransition( Trigger_C1J, _rto_, JF));
198  m_fsm.AddTransition(new WeaponTransition( Trigger_C1J, _abt_, JF));
199 
200 //---------------------------------------------
201 
202  SetInitialState(C0);
203 
204  SelectionBulletHide();
205  HideMagazine();
206 
207  m_fsm.Start();
208  }
209 
210  override void SetActions()
211  {
212  super.SetActions();
214 
217 
218  }
219 };
220 
221 
LoadedDischarged
LoadedDischarged
Definition: boltactionrifleinnermagazine_base.c:5
LogManager
Definition: debug.c:734
OPENED
@ OPENED
Definition: boltactionrifleinnermagazine_base.c:4
BARIMStableStateID
BARIMStableStateID
Definition: boltactionrifleinnermagazine_base.c:8
BARIMAnimState
BARIMAnimState
Definition: boltactionrifleinnermagazine_base.c:1
LoadedCharged
LoadedCharged
Definition: boltactionrifleinnermagazine_base.c:4
WeaponActionUnjammingTypes
WeaponActionUnjammingTypes
Definition: human.c:904
FirearmActionLoadMultiBullet
Definition: firearmactionloadmultibullet.c:1
FirearmActionLoadBulletQuick
FirearmActionLoadMultiBullet FirearmActionLoadBulletQuick
IsJammed
override bool IsJammed()
Definition: boltactionrifleinnermagazine_base.c:25
WeaponFire
Definition: weaponfire.c:98
RemoveAction
void RemoveAction(typename actionName)
Definition: advancedcommunication.c:118
DEFAULT
@ DEFAULT
default weapon state, closed and discharged
Definition: boltactionrifleinnermagazine_base.c:3
FirearmActionLoadMultiBulletQuick
Definition: firearmactionloadmultibullet.c:94
JAMMED
@ JAMMED
Definition: boltactionrifleinnermagazine_base.c:5
WeaponActionFireTypes
WeaponActionFireTypes
Definition: human.c:912
EmptyDischarged
EmptyDischarged
Definition: boltactionrifleinnermagazine_base.c:3
IsRepairEnabled
override bool IsRepairEnabled()
Definition: boltactionrifleinnermagazine_base.c:26
LoadedJammed
LoadedJammed
Definition: boltactionrifleinnermagazine_base.c:6
HasBullet
override bool HasBullet()
Definition: boltactionrifleinnermagazine_base.c:23
UNKNOWN
UNKNOWN
Definition: boltactionrifleinnermagazine_base.c:2
OnExit
override void OnExit(WeaponEventBase e)
Definition: boltactionrifleinnermagazine_base.c:21
WeaponActions
WeaponActions
actions
Definition: human.c:808
WeaponUnjamming
unjam submachine
BoltActionRifle_Base
Definition: boltactionrifleinnermagazine_base.c:68
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
m_muzzleHasBullet
ref array< MuzzleState > m_muzzleHasBullet
Definition: weaponstablestate.c:30
SetActions
void SetActions()
Definition: advancedcommunication.c:79
WeaponTransition
enum FSMTransition WeaponTransition
InitMuzzleArray
override void InitMuzzleArray()
Definition: boltactionrifleinnermagazine_base.c:27
HasMagazine
override bool HasMagazine()
Definition: boltactionrifleinnermagazine_base.c:24
AbilityRecord
pair ( action, actionType )
Definition: weapon_base.c:4
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
WeaponStateBase
represent weapon state base
Definition: bullethide.c:1
m_weapon
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition: guards.c:583
WeaponStateJammed
handle jamming state set jam/unjam state for weapon
Definition: sks.c:52
wpnPrint
void wpnPrint(string s)
Definition: debug.c:1
BoltActionRifle_InnerMagazine_Base
Definition: mosin9130.c:5
WeaponActionChamberingTypes
WeaponActionChamberingTypes
Definition: human.c:868
WeaponFSM
weapon finite state machine
OnEntry
class BARIMLoadedCharged extends WeaponStableState OnEntry
WeaponStableState
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Definition: crossbow.c:26
MuzzleState
MuzzleState
Definition: weaponstablestate.c:14
GetCurrentStateID
override int GetCurrentStateID()
Definition: boltactionrifleinnermagazine_base.c:22