Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
rifleboltfree_base.c
Go to the documentation of this file.
2 {
3  DEFAULT = 0,
4  JAMMED = 1,
5 };
6 
8 {
9  UNKNOWN = 0,
10  RBF_CLO_BU0_MA0 = 1,
11  RBF_CLO_BU1_MA0 = 2,
12  RBF_CLO_BU1_MA1 = 3,
13  RBF_CLO_BU0_MA1 = 4,
14  RBF_JAM_BU1_MA0 = 5,
15  RBF_JAM_BU1_MA1 = 6
16 }
17 
19 {
20  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { close nobull nomag"); } super.OnEntry(e); }
21  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } close nobull nomag"); } }
22  override int GetCurrentStateID () { return RBFStableStateID.RBF_CLO_BU0_MA0; }
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 };
30 {
31  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { close bullet nomag"); } super.OnEntry(e);}
32  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } close bullet nomag"); } }
33  override int GetCurrentStateID () { return RBFStableStateID.RBF_CLO_BU1_MA0; }
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 };
41 {
42  override void OnEntry (WeaponEventBase e) { /*Print("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { close bullet mag");*/ super.OnEntry(e);}
43  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } close bullet mag"); } }
44  override int GetCurrentStateID () { return RBFStableStateID.RBF_CLO_BU1_MA1; }
45  override bool HasBullet () { return true; }
46  override bool HasMagazine () { return true; }
47  override bool IsJammed () { return false; }
48  override bool IsRepairEnabled () { return true; }
49  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.L}; }
50 };
52 {
53  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { close nobull mag"); } super.OnEntry(e); }
54  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } close nobull mag"); } }
55  override int GetCurrentStateID () { return RBFStableStateID.RBF_CLO_BU0_MA1; }
56  override bool HasBullet () { return false; }
57  override bool HasMagazine () { return true; }
58  override bool IsJammed () { return false; }
59  override bool IsRepairEnabled () { return true; }
60  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
61 };
63 {
64  override void OnEntry (WeaponEventBase e) { Print("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { jammed bullet nomag"); super.OnEntry(e); }
65  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } jammed bullet nomag"); } }
66  override int GetCurrentStateID () { return RBFStableStateID.RBF_JAM_BU1_MA0; }
67  override bool HasBullet () { return true; }
68  override bool HasMagazine () { return false; }
69  override bool IsJammed () { return true; }
70  override bool IsBoltOpen () { return true; }
71  override bool IsRepairEnabled () { return true; }
72  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
73 };
75 {
76  override void OnEntry (WeaponEventBase e) { Print("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { jammed bullet mag"); super.OnEntry(e); }
77  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } jammed bullet mag"); } }
78  override int GetCurrentStateID () { return RBFStableStateID.RBF_JAM_BU1_MA1; }
79  override bool HasBullet () { return true; }
80  override bool HasMagazine () { return true; }
81  override bool IsJammed () { return true; }
82  override bool IsBoltOpen () { return true; }
83  override bool IsRepairEnabled () { return true; }
84  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
85 };
86 
87 
92 class RifleBoltFree_Base extends Rifle_Base
93 {
94  ref WeaponStableState C00;
95  ref WeaponStableState C10;
96  ref WeaponStableState C11;
97  ref WeaponStableState C01;
98  ref WeaponStableState JF0;
99  ref WeaponStableState JF1;
100 
101  void RifleBoltFree_Base ()
102  {
103  }
104 
105 
106  override void InitStateMachine()
107  {
108 
109  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET)));
110  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET)));
111  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET)));
112  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET)));
113  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH)));
114 
115  m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED)));
116 
117  m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED)));
118 
119  m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START)));
120  m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END)));
121 
122  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM)));
123  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL)));
124  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY)));
125 
126  // setup state machine
127  // basic weapon states
128  // close-locked-jammed | nobullet-bullet | nomag-mag
129  // regexp: [CLJ][01][01]
130  C00 = new RBF_CLO_BU0_MA0(this, NULL, RBLAnimState.DEFAULT);
131  C10 = new RBF_CLO_BU1_MA0(this, NULL, RBLAnimState.DEFAULT);
132  C11 = new RBF_CLO_BU1_MA1(this, NULL, RBLAnimState.DEFAULT);
133  C01 = new RBF_CLO_BU0_MA1(this, NULL, RBLAnimState.DEFAULT);
134  JF0 = new RBF_JAM_BU1_MA0(this, NULL, RBLAnimState.JAMMED);
135  JF1 = new RBF_JAM_BU1_MA1(this, NULL, RBLAnimState.JAMMED);
136 
137  // unstable (intermediate) states
138  WeaponCharging Mech_C00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
139  WeaponCharging Mech_C01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
140 
141  WeaponCharging Mech_C10 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
142  WeaponCharging Mech_C11 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
143 
144  WeaponStateBase Trigger_C00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY)); // cock without clip
145  WeaponStateBase Trigger_C10 = new WeaponFireLast(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL)); // cock with clip
146  WeaponFireAndChamberNext Trigger_C11 = new WeaponFireAndChamberNext(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
147  WeaponStateBase Trigger_C11L = new WeaponFireLast(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
148  WeaponStateBase Trigger_C01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
149  WeaponStateBase Trigger_JF0 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
150  WeaponStateBase Trigger_JF1 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
151 
152 
153  //Fire and jammed
154  WeaponStateBase Trigger_C10J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM)); // cock with clip
155  WeaponStateBase Trigger_C11J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM));
156  // Unjam
157  WeaponStateBase Unjam_JF0 = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
158  WeaponStateBase Unjam_JF1 = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
159 
160 
161  WeaponChambering Chamber_C00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
162  WeaponChambering Chamber_C01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
163 
164  WeaponAttachMagazine Attach_C00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET));
165  WeaponAttachMagazine Attach_C10 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET));
166  WeaponAttachMagazine Attach_JF0 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET));
167 
168  WeaponReplacingMagAndChamberNext Reload_C11 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET));
169  WeaponReplacingMagAndChamberNext Reload_C01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET));
170  WeaponReplacingMagAndChamberNext Reload_JF1 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET));
171 
172  WeaponDetachingMag Detach_C11 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
173  WeaponDetachingMag Detach_C01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
174  WeaponDetachingMag Detach_JF1 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
175 
176  // events
177  WeaponEventBase __M__ = new WeaponEventMechanism;
178  WeaponEventBase __T__ = new WeaponEventTrigger;
179  WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
180  WeaponEventBase __U__ = new WeaponEventUnjam;
181  WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
182  WeaponEventBase __A__ = new WeaponEventAttachMagazine;
183  WeaponEventBase __D__ = new WeaponEventDetachMagazine;
184  WeaponEventBase __S__ = new WeaponEventSwapMagazine;
185  WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
186  WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
187  WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
188  WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
189 
190  m_fsm = new WeaponFSM();
191 
192  // order: Discharged-Charged | nobullet-bullet | nomag-mag
193  // charging
194  m_fsm.AddTransition(new WeaponTransition( C00, __M__, Mech_C00)); // charge from dischg nobullet nomag
195  m_fsm.AddTransition(new WeaponTransition( Mech_C00, _fin_, C00));
196  m_fsm.AddTransition(new WeaponTransition( Mech_C00, _abt_, C00));
197 
198  m_fsm.AddTransition(new WeaponTransition( C10, __M__, Mech_C10)); // charge from bullet nomag
199  m_fsm.AddTransition(new WeaponTransition( Mech_C10, _fin_, C00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
200  m_fsm.AddTransition(new WeaponTransition( Mech_C10, _fin_, C10));
201  m_fsm.AddTransition(new WeaponTransition( Mech_C10, _abt_, C00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
202  m_fsm.AddTransition(new WeaponTransition( Mech_C10, _abt_, C10));
203 
204  m_fsm.AddTransition(new WeaponTransition( C11, __M__, Mech_C11)); // charge from dischg nobullet nomag
205  m_fsm.AddTransition(new WeaponTransition( Mech_C11, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
206  m_fsm.AddTransition(new WeaponTransition( Mech_C11, _fin_, C11));
207  m_fsm.AddTransition(new WeaponTransition( Mech_C11, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
208  m_fsm.AddTransition(new WeaponTransition( Mech_C11, _abt_, C11));
209 
210  m_fsm.AddTransition(new WeaponTransition( C01, __M__, Mech_C01)); // charge from dischg nobullet nomag
211  m_fsm.AddTransition(new WeaponTransition( Mech_C01, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
212  m_fsm.AddTransition(new WeaponTransition( Mech_C01, _fin_, C11));
213  m_fsm.AddTransition(new WeaponTransition( Mech_C01, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
214  m_fsm.AddTransition(new WeaponTransition( Mech_C01, _abt_, C11));
215 
216  // fire
217  m_fsm.AddTransition(new WeaponTransition( C00, __T__, Trigger_C00));
218  m_fsm.AddTransition(new WeaponTransition( Trigger_C00, _fin_, C00));
219  m_fsm.AddTransition(new WeaponTransition( Trigger_C00, _dto_, C00));
220  m_fsm.AddTransition(new WeaponTransition( Trigger_C00, _abt_, C00));
221 
222  m_fsm.AddTransition(new WeaponTransition( C01, __T__, Trigger_C01));
223  m_fsm.AddTransition(new WeaponTransition( Trigger_C01, _fin_, C01));
224  m_fsm.AddTransition(new WeaponTransition( Trigger_C01, _dto_, C01));
225  m_fsm.AddTransition(new WeaponTransition( Trigger_C01, _abt_, C01));
226 
227  m_fsm.AddTransition(new WeaponTransition( C10, __T__, Trigger_C10));
228  m_fsm.AddTransition(new WeaponTransition( Trigger_C10, _fin_, C00));
229  m_fsm.AddTransition(new WeaponTransition( Trigger_C10, _rto_, C00));
230  m_fsm.AddTransition(new WeaponTransition( Trigger_C10, _abt_, C00));
231 
232  m_fsm.AddTransition(new WeaponTransition( JF1, __T__, Trigger_JF1));
233  m_fsm.AddTransition(new WeaponTransition( Trigger_JF1, _fin_, JF1));
234  m_fsm.AddTransition(new WeaponTransition( Trigger_JF1, _rto_, JF1));
235  m_fsm.AddTransition(new WeaponTransition( Trigger_JF1, _abt_, JF1));
236 
237  m_fsm.AddTransition(new WeaponTransition( JF0, __T__, Trigger_JF0));
238  m_fsm.AddTransition(new WeaponTransition( Trigger_JF0, _fin_, JF0));
239  m_fsm.AddTransition(new WeaponTransition( Trigger_JF0, _rto_, JF0));
240  m_fsm.AddTransition(new WeaponTransition( Trigger_JF0, _abt_, JF0));
241 
242 
243  m_fsm.AddTransition(new WeaponTransition( C11, __T__, Trigger_C11, NULL, new WeaponGuardHasAmmo(this)));
244  m_fsm.AddTransition(new WeaponTransition( Trigger_C11, _fin_, C11));
245  m_fsm.AddTransition(new WeaponTransition( Trigger_C11, _rto_, C11));
246  m_fsm.AddTransition(new WeaponTransition( Trigger_C11, _abt_, C11));
247 
248  m_fsm.AddTransition(new WeaponTransition( C11, __T__, Trigger_C11L));
249  m_fsm.AddTransition(new WeaponTransition( Trigger_C11L, _fin_, C01));
250  m_fsm.AddTransition(new WeaponTransition( Trigger_C11L, _rto_, C01));
251  m_fsm.AddTransition(new WeaponTransition( Trigger_C11L, _abt_, C01));
252 
253 
254  m_fsm.AddTransition(new WeaponTransition( C11, __TJ_, Trigger_C11J));
255  m_fsm.AddTransition(new WeaponTransition( Trigger_C11J, _fin_, JF1));
256  m_fsm.AddTransition(new WeaponTransition( Trigger_C11J, _rto_, JF1));
257  m_fsm.AddTransition(new WeaponTransition( Trigger_C11J, _abt_, JF1));
258 
259  m_fsm.AddTransition(new WeaponTransition( C10, __TJ_, Trigger_C10J));
260  m_fsm.AddTransition(new WeaponTransition( Trigger_C10J, _fin_, JF0));
261  m_fsm.AddTransition(new WeaponTransition( Trigger_C10J, _rto_, JF0));
262  m_fsm.AddTransition(new WeaponTransition( Trigger_C10J, _abt_, JF0));
263 
264 
265  // load cartridge
266  m_fsm.AddTransition(new WeaponTransition( C00, __L__, Chamber_C00)); // chamber from closed=1
267  m_fsm.AddTransition(new WeaponTransition( Chamber_C00, _fin_, C00, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
268  m_fsm.AddTransition(new WeaponTransition( Chamber_C00, _fin_, C10));
269  m_fsm.AddTransition(new WeaponTransition( Chamber_C00, _abt_, C00, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
270  m_fsm.AddTransition(new WeaponTransition( Chamber_C00, _abt_, C10));
271 
272  m_fsm.AddTransition(new WeaponTransition( C01, __L__, Chamber_C01)); // chamber from closed charged
273  m_fsm.AddTransition(new WeaponTransition( Chamber_C01, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
274  m_fsm.AddTransition(new WeaponTransition( Chamber_C01, _fin_, C11));
275  m_fsm.AddTransition(new WeaponTransition( Chamber_C01, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
276  m_fsm.AddTransition(new WeaponTransition( Chamber_C01, _abt_, C11));
277 
278  // attach magazine (no mag in weapon)
279  m_fsm.AddTransition(new WeaponTransition( C00, __A__, Attach_C00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0
280  m_fsm.AddTransition(new WeaponTransition( Attach_C00, _fin_, C11, NULL, new WeaponGuardCurrentChamberFull(this)));
281  m_fsm.AddTransition(new WeaponTransition( Attach_C00, _fin_, C01, NULL, new WeaponGuardHasMag(this)));
282  m_fsm.AddTransition(new WeaponTransition( Attach_C00, _fin_, C00));
283  m_fsm.AddTransition(new WeaponTransition( Attach_C00, _abt_, C11, NULL, new WeaponGuardCurrentChamberFull(this)));
284  m_fsm.AddTransition(new WeaponTransition( Attach_C00, _abt_, C01, NULL, new WeaponGuardHasMag(this)));
285  m_fsm.AddTransition(new WeaponTransition( Attach_C00, _abt_, C00));
286 
287  m_fsm.AddTransition(new WeaponTransition( C10, __A__, Attach_C10, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b1/m0
288  m_fsm.AddTransition(new WeaponTransition( Attach_C10, _fin_, C11, NULL, new WeaponGuardHasMag(this)));
289  m_fsm.AddTransition(new WeaponTransition( Attach_C10, _fin_, C10));
290  m_fsm.AddTransition(new WeaponTransition( Attach_C10, _abt_, C11, NULL, new WeaponGuardHasMag(this)));
291  m_fsm.AddTransition(new WeaponTransition( Attach_C10, _abt_, C10));
292 
293  m_fsm.AddTransition(new WeaponTransition( JF0, __A__, Attach_JF0, NULL, new WeaponGuardCanAttachMag(this))); // attach from JAM/b1/m0
294  m_fsm.AddTransition(new WeaponTransition( Attach_JF0, _fin_, JF1, NULL, new WeaponGuardHasMag(this)));
295  m_fsm.AddTransition(new WeaponTransition( Attach_JF0, _fin_, JF0));
296  m_fsm.AddTransition(new WeaponTransition( Attach_JF0, _abt_, JF1, NULL, new WeaponGuardHasMag(this)));
297  m_fsm.AddTransition(new WeaponTransition( Attach_JF0, _abt_, JF0));
298 
299  // replace magazine
300  m_fsm.AddTransition(new WeaponTransition( C11, __S__, Reload_C11, NULL, new WeaponGuardCanSwapMag(this))); // swap in Chg/b1/m1
301  m_fsm.AddTransition(new WeaponTransition( Reload_C11, _fin_, C11, NULL, new WeaponGuardHasMag(this)));
302  m_fsm.AddTransition(new WeaponTransition( Reload_C11, _fin_, C10));
303  m_fsm.AddTransition(new WeaponTransition( Reload_C11, _abt_, C11, NULL, new WeaponGuardHasMag(this)));
304  m_fsm.AddTransition(new WeaponTransition( Reload_C11, _abt_, C10));
305 
306  m_fsm.AddTransition(new WeaponTransition( C01, __S__, Reload_C01, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b0/m1
307  m_fsm.AddTransition(new WeaponTransition( Reload_C01, _fin_, C11, NULL, new WeaponGuardCurrentChamberFull(this)));
308  m_fsm.AddTransition(new WeaponTransition( Reload_C01, _fin_, C01, NULL, new WeaponGuardHasMag(this)));
309  m_fsm.AddTransition(new WeaponTransition( Reload_C01, _fin_, C00));
310  m_fsm.AddTransition(new WeaponTransition( Reload_C01, _abt_, C11, NULL, new WeaponGuardCurrentChamberFull(this)));
311  m_fsm.AddTransition(new WeaponTransition( Reload_C01, _abt_, C01, NULL, new WeaponGuardHasMag(this)));
312  m_fsm.AddTransition(new WeaponTransition( Reload_C01, _abt_, C00));
313 
314  m_fsm.AddTransition(new WeaponTransition( JF1, __S__, Reload_JF1, NULL, new WeaponGuardCanSwapMag(this))); // swap in Chg/b1/m1
315  m_fsm.AddTransition(new WeaponTransition( Reload_JF1, _fin_, JF1, NULL, new WeaponGuardHasMag(this)));
316  m_fsm.AddTransition(new WeaponTransition( Reload_JF1, _fin_, JF0));
317  m_fsm.AddTransition(new WeaponTransition( Reload_JF1, _abt_, JF1, NULL, new WeaponGuardHasMag(this)));
318  m_fsm.AddTransition(new WeaponTransition( Reload_JF1, _abt_, JF0));
319 
320 
321  // detach magazine
322  m_fsm.AddTransition(new WeaponTransition( C11, __D__, Detach_C11, NULL, new WeaponGuardCanDetachMag(this))); // detach from Chg/b1/m1
323  m_fsm.AddTransition(new WeaponTransition( Detach_C11, _fin_, C11, NULL, new WeaponGuardHasMag(this)));
324  m_fsm.AddTransition(new WeaponTransition( Detach_C11, _fin_, C10));
325  m_fsm.AddTransition(new WeaponTransition( Detach_C11, _abt_, C11, NULL, new WeaponGuardHasMag(this)));
326  m_fsm.AddTransition(new WeaponTransition( Detach_C11, _abt_, C10));
327 
328 
329  m_fsm.AddTransition(new WeaponTransition( C01, __D__, Detach_C01, NULL, new WeaponGuardCanDetachMag(this))); // detach from Chg/b0/m1
330  m_fsm.AddTransition(new WeaponTransition( Detach_C01, _fin_, C01, NULL, new WeaponGuardHasMag(this)));
331  m_fsm.AddTransition(new WeaponTransition( Detach_C01, _fin_, C00));
332  m_fsm.AddTransition(new WeaponTransition( Detach_C01, _abt_, C01, NULL, new WeaponGuardHasMag(this)));
333  m_fsm.AddTransition(new WeaponTransition( Detach_C01, _abt_, C00));
334 
335  m_fsm.AddTransition(new WeaponTransition( JF1, __D__, Detach_JF1, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b1/m1 jammed
336  m_fsm.AddTransition(new WeaponTransition( Detach_JF1, _fin_, JF1, NULL, new WeaponGuardHasMag(this)));
337  m_fsm.AddTransition(new WeaponTransition( Detach_JF1, _fin_, JF0));
338  m_fsm.AddTransition(new WeaponTransition( Detach_JF1, _abt_, JF1, NULL, new WeaponGuardHasMag(this)));
339  m_fsm.AddTransition(new WeaponTransition( Detach_JF1, _abt_, JF0));
340 
341  // unjam
342  m_fsm.AddTransition(new WeaponTransition( JF0, __U__, Unjam_JF0)); // unjam nomag
343  m_fsm.AddTransition(new WeaponTransition( Unjam_JF0, _fin_, JF0, NULL, new WeaponGuardJammed(this)));
344  m_fsm.AddTransition(new WeaponTransition( Unjam_JF0, _fin_, C00));
345  m_fsm.AddTransition(new WeaponTransition( Unjam_JF0, _abt_, JF0, NULL, new WeaponGuardJammed(this)));
346  m_fsm.AddTransition(new WeaponTransition( Unjam_JF0, _abt_, C00));
347 
348  m_fsm.AddTransition(new WeaponTransition( JF1, __U__, Unjam_JF1)); // unjam with mag with ammo
349  m_fsm.AddTransition(new WeaponTransition( Unjam_JF1, _fin_, JF1, NULL, new WeaponGuardJammed(this)));
350  m_fsm.AddTransition(new WeaponTransition( Unjam_JF1, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
351  m_fsm.AddTransition(new WeaponTransition( Unjam_JF1, _fin_, C11));
352  m_fsm.AddTransition(new WeaponTransition( Unjam_JF1, _abt_, JF1, NULL, new WeaponGuardJammed(this)));
353  m_fsm.AddTransition(new WeaponTransition( Unjam_JF1, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
354  m_fsm.AddTransition(new WeaponTransition( Unjam_JF1, _abt_, C11));
355 
356  SetInitialState(C00);
357 
358  SelectionBulletHide();
359  HideMagazine();
360 
361  m_fsm.Start();
362  }
363 
364  override float GetChanceToJam()
365  {
366  float chanceToJam = super.GetChanceToJam();
367  Magazine mag = GetMagazine(GetCurrentMuzzle());
368 
369  if(mag)
370  {
371  chanceToJam = chanceToJam + ((1.0 - chanceToJam) * mag.GetChanceToJam());
372  }
373  else
374  {
375  chanceToJam = chanceToJam + ((1.0 - chanceToJam) * 0.06);
376  }
377 
378  return chanceToJam;
379  }
380 
381  override void SetActions()
382  {
383  super.SetActions();
385  //AddAction(ActionAdvancedDetachMagazine);
386  }
387 };
388 
389 
RBF_CLO_BU0_MA0
RBF_CLO_BU0_MA0
Definition: rifleboltfree_base.c:3
OnEntry
class RBF_CLO_BU1_MA0 extends WeaponStableState OnEntry
LogManager
Definition: debug.c:734
HasMagazine
override bool HasMagazine()
Definition: rifleboltfree_base.c:24
RBFAnimState
RBFAnimState
Definition: rifleboltfree_base.c:1
WeaponActionUnjammingTypes
WeaponActionUnjammingTypes
Definition: human.c:904
Print
proto void Print(void var)
Prints content of variable to console/log.
InitMuzzleArray
override void InitMuzzleArray()
Definition: rifleboltfree_base.c:27
WeaponActionFireTypes
WeaponActionFireTypes
Definition: human.c:912
WeaponReplacingMagAndChamberNext
replace current magazine with new one
RBF_CLO_BU1_MA0
RBF_CLO_BU1_MA0
Definition: rifleboltfree_base.c:4
WeaponActionReloadTypes
WeaponActionReloadTypes
Definition: human.c:824
RBF_CLO_BU1_MA1
RBF_CLO_BU1_MA1
Definition: rifleboltfree_base.c:5
WeaponActions
WeaponActions
actions
Definition: human.c:808
RBF_CLO_BU0_MA1
RBF_CLO_BU0_MA1
Definition: rifleboltfree_base.c:6
RBLAnimState
RBLAnimState
Definition: rifleboltlock_base.c:1
IsJammed
override bool IsJammed()
Definition: rifleboltfree_base.c:25
WeaponUnjamming
unjam submachine
JAMMED
@ JAMMED
Definition: rifleboltfree_base.c:4
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
DEFAULT
@ DEFAULT
default weapon state, closed and discharged
Definition: rifleboltfree_base.c:3
m_muzzleHasBullet
ref array< MuzzleState > m_muzzleHasBullet
Definition: weaponstablestate.c:30
Rifle_Base
base for rifles @NOTE name copies config base class
Definition: sks.c:69
UNKNOWN
UNKNOWN
Definition: rifleboltfree_base.c:2
SetActions
void SetActions()
Definition: advancedcommunication.c:79
WeaponCharging
charging of weapon without ammo to be chambered
WeaponTransition
enum FSMTransition WeaponTransition
FirearmActionDetachMagazine
Definition: firearmactiondetachmagazine.c:147
WeaponGuardHasAmmo
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition: guards.c:99
IsBoltOpen
override bool IsBoltOpen()
Definition: flaregun.c:23
RBFStableStateID
RBFStableStateID
Definition: rifleboltfree_base.c:7
AbilityRecord
pair ( action, actionType )
Definition: weapon_base.c:4
OnExit
override void OnExit(WeaponEventBase e)
Definition: rifleboltfree_base.c:21
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
RBF_JAM_BU1_MA1
RBF_JAM_BU1_MA1
Definition: rifleboltfree_base.c:8
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
GetCurrentStateID
override int GetCurrentStateID()
Definition: rifleboltfree_base.c:22
wpnPrint
void wpnPrint(string s)
Definition: debug.c:1
HasBullet
override bool HasBullet()
Definition: rifleboltfree_base.c:23
WeaponActionChamberingTypes
WeaponActionChamberingTypes
Definition: human.c:868
WeaponFSM
weapon finite state machine
RBF_JAM_BU1_MA0
RBF_JAM_BU1_MA0
Definition: rifleboltfree_base.c:7
IsRepairEnabled
override bool IsRepairEnabled()
Definition: rifleboltfree_base.c:26
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