Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pistol_base.c
Go to the documentation of this file.
1 
3 {
4  DEFAULT = 0,
7  JAMMED = 3
8 };
9 
10 // naming convention of the states respect following order:
11 // closed/opened | charged/discharged | bullet/nobullet | magazine/nomag
13 {
14  UNKNOWN = 0,
15  CLO_DIS_BU0_MA0 = 1,
16  CLO_CHG_BU0_MA0 = 2,
17  CLO_CHG_BU1_MA0 = 3,
18  CLO_JAM_BU1_MA0 = 4,
19  OPE_DIS_BU0_MA0 = 5,
20  CLO_CHG_BU0_MA1 = 6,
21  CLO_DIS_BU0_MA1 = 7,
22  CLO_JAM_BU1_MA1 = 8,
23  CLO_CHG_BU1_MA1 = 9,
24  OPE_DIS_BU0_MA1 = 10,
25 }
26 
27 class Pistol_CLO_DIS_BU0_MA0 extends WeaponStableState
28 {
29  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CD00 closed dischgd nobull nomag"); } super.OnEntry(e); }
30  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CD00 closed dischgd nobull nomag"); } }
31  override int GetCurrentStateID () { return PistolStableStateID.CLO_DIS_BU0_MA0; }
32  override bool HasBullet () { return false; }
33  override bool HasMagazine () { return false; }
34  override bool IsJammed () { return false; }
35  override bool IsDischarged () { return true; }
36  override bool IsRepairEnabled () { return true; }
37  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
38 };
39 class Pistol_CLO_CHG_BU0_MA0 extends WeaponStableState
40 {
41  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CC00 closed charged nobull nomag"); } super.OnEntry(e); }
42  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CC00 closed charged nobull nomag"); } }
43  override int GetCurrentStateID () { return PistolStableStateID.CLO_CHG_BU0_MA0; }
44  override bool HasBullet () { return false; }
45  override bool HasMagazine () { return false; }
46  override bool IsJammed () { return false; }
47  override bool IsRepairEnabled () { return true; }
48  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
49 };
50 class Pistol_CLO_CHG_BU1_MA0 extends WeaponStableState
51 {
52  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CC10 closed charged bullet nomag"); } super.OnEntry(e); }
53  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CC10 closed charged bullet nomag"); } }
54  override int GetCurrentStateID () { return PistolStableStateID.CLO_CHG_BU1_MA0; }
55  override bool HasBullet () { return true; }
56  override bool HasMagazine () { return false; }
57  override bool IsJammed () { return false; }
58  override bool IsRepairEnabled () { return true; }
59  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.L}; }
60 };
61 class Pistol_CLO_JAM_BU1_MA0 extends WeaponStateJammed
62 {
63  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CJF0 closed jammed bullet nomag"); } super.OnEntry(e); }
64  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CJF0 closed jammed bullet nomag"); } }
65  override int GetCurrentStateID () { return PistolStableStateID.CLO_JAM_BU1_MA0; }
66  override bool HasBullet () { return true; }
67  override bool HasMagazine () { return false; }
68  override bool IsJammed () { return true; }
69  override bool IsBoltOpen () { return true; }
70  override bool IsRepairEnabled () { return true; }
71  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
72 };
73 class Pistol_OPE_DIS_BU0_MA0 extends WeaponStableState
74 {
75  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { OD00 opened dischgd nobullet nomag"); } m_weapon.SetCharged(false); m_weapon.SetWeaponOpen(true); super.OnEntry(e); }
76  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } 0D00 opened dischgd nobullet nomag"); } }
77  override int GetCurrentStateID () { return PistolStableStateID.OPE_DIS_BU0_MA0; }
78  override bool HasBullet () { return false; }
79  override bool HasMagazine () { return false; }
80  override bool IsJammed () { return false; }
81  override bool IsBoltOpen () { return true; }
82  override bool IsDischarged () { return true; }
83  override bool IsRepairEnabled () { return true; }
84  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
85 };
86 class Pistol_CLO_CHG_BU0_MA1 extends WeaponStableState
87 {
88  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CC01 closed charged nobullet mag"); } super.OnEntry(e); }
89  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CC01 closed charged nobullet mag"); } }
90  override int GetCurrentStateID () { return PistolStableStateID.CLO_CHG_BU0_MA1; }
91  override bool HasBullet () { return false; }
92  override bool HasMagazine () { return true; }
93  override bool IsJammed () { return false; }
94  override bool IsRepairEnabled () { return true; }
95  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
96 };
97 class Pistol_CLO_DIS_BU0_MA1 extends WeaponStableState
98 {
99  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CD01 closed dischgd nobullet mag"); } m_weapon.SetCharged(false); super.OnEntry(e); }
100  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CD01 closed dischgd nobullet mag"); } }
101  override int GetCurrentStateID () { return PistolStableStateID.CLO_DIS_BU0_MA1; }
102  override bool HasBullet () { return false; }
103  override bool HasMagazine () { return true; }
104  override bool IsJammed () { return false; }
105  override bool IsRepairEnabled () { return true; }
106  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
107 };
108 class Pistol_CLO_JAM_BU1_MA1 extends WeaponStateJammed
109 {
110  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CJF1 closed jammed bullet mag"); } super.OnEntry(e); }
111  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CJF1 closed jammed bullet mag"); } }
112  override int GetCurrentStateID () { return PistolStableStateID.CLO_JAM_BU1_MA1; }
113  override bool HasBullet () { return true; }
114  override bool HasMagazine () { return true; }
115  override bool IsJammed () { return true; }
116  override bool IsBoltOpen () { return true; }
117  override bool IsRepairEnabled () { return true; }
118  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.L}; }
119 };
120 class Pistol_CLO_CHG_BU1_MA1 extends WeaponStableState
121 {
122  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { CC11 closed charged bullet mag"); } super.OnEntry(e); }
123  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } CC11 closed charged bullet mag"); } }
124  override int GetCurrentStateID () { return PistolStableStateID.CLO_CHG_BU1_MA1; }
125  override bool HasBullet () { return true; }
126  override bool HasMagazine () { return true; }
127  override bool IsJammed () { return false; }
128  override bool IsRepairEnabled () { return true; }
129  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.L}; }
130 };
131 class Pistol_OPE_DIS_BU0_MA1 extends WeaponStableState
132 {
133  override void OnEntry (WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] { OD01 opened dischgd nobullet mag"); } m_weapon.SetWeaponOpen(true); super.OnEntry(e); }
134  override void OnExit (WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnstate] } 0D01 opened dischgd nobullet mag"); } }
135  override int GetCurrentStateID () { return PistolStableStateID.OPE_DIS_BU0_MA1; }
136  override bool HasBullet () { return false; }
137  override bool HasMagazine () { return true; }
138  override bool IsJammed () { return false; }
139  override bool IsBoltOpen () { return true; }
140  override bool IsRepairEnabled () { return true; }
141  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
142 };
143 
144 
149 class Pistol_Base extends Weapon_Base
150 {
151  ref WeaponStableState CD00;
152  ref WeaponStableState CC00;
153  ref WeaponStableState CC10;
154  ref WeaponStableState CJF0;
155  ref WeaponStableState OD00;
156  ref WeaponStableState CD01;
157  ref WeaponStableState CC01;
158  ref WeaponStableState CC11;
159  ref WeaponStableState CJF1;
160  ref WeaponStableState OD01;
161 
162  override bool CanChamberBullet (int muzzleIndex, Magazine mag)
163  {
164  return super.CanChamberBullet(muzzleIndex,mag) && IsChamberEmpty(muzzleIndex);
165  }
166 
167  void Pistol_Base ()
168  {
169  }
170 
171  override void InitStateMachine ()
172  {
173  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_BULLET_CLOSED));
174  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED));
175  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_COCKED));
176  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_COCKED));
177  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_UNCOCKED));
178  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_UNCOCKED));
179  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_OPENED));
180  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_OPENED));
181  m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH));
182 
183  m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
184  m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED));
185 
186  m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
187  m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
188  m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED));
189 
190  m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
191  m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END));
192 
193  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
194  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST));
195  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
196  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
197  m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM));
198 
199  // setup state machine
200  // basic weapon states
201  // open-closed | discharged-charged | nobullet-bullet | nomag-mag
202  // regexp: [OC][CDJ][01][01]
203  CD00 = new Pistol_CLO_DIS_BU0_MA0(this, NULL, PistolAnimState.DEFAULT);
204  CC00 = new Pistol_CLO_CHG_BU0_MA0(this, NULL, PistolAnimState.CLOSED_CHARGED);
205  CC10 = new Pistol_CLO_CHG_BU1_MA0(this, NULL, PistolAnimState.CLOSED_CHARGED);
206  CJF0 = new Pistol_CLO_JAM_BU1_MA0(this, NULL, PistolAnimState.JAMMED);
207  OD00 = new Pistol_OPE_DIS_BU0_MA0(this, NULL, PistolAnimState.OPENED_DISCHARGED);
208  CD01 = new Pistol_CLO_DIS_BU0_MA1(this, NULL, PistolAnimState.DEFAULT);
209  CC01 = new Pistol_CLO_CHG_BU0_MA1(this, NULL, PistolAnimState.CLOSED_CHARGED);
210  CC11 = new Pistol_CLO_CHG_BU1_MA1(this, NULL, PistolAnimState.CLOSED_CHARGED);
211  CJF1 = new Pistol_CLO_JAM_BU1_MA1(this, NULL, PistolAnimState.JAMMED);
212  OD01 = new Pistol_OPE_DIS_BU0_MA1(this, NULL, PistolAnimState.OPENED_DISCHARGED);
213 
214  // unstable (intermediate) states
215  WeaponCharging Mech_CD00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED);
216  WeaponCharging Mech_CC00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
217  WeaponCharging Mech_CD01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED);
218  WeaponCharging Mech_CC01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
219  WeaponCharging Mech_OD00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED);
220  WeaponCharging Mech_OD01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED);
221 
222  WeaponCharging Mech_CC10 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED); // eject with no mag
223  WeaponCharging Mech_CC11 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED); // eject with mag
224 
225 
226  WeaponDryFire Trigger_CC00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED); // cock without clip
227  WeaponDryFire Trigger_CD00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED);
228  WeaponDryFire Trigger_OD00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED);
229  WeaponDryFire Trigger_CD01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED);
230  WeaponDryFire Trigger_OD01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED);
231  WeaponDryFire Trigger_CC01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED); // cock with clip
232  WeaponDryFire Trigger_CJF0 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED);
233  WeaponDryFire Trigger_CJF1 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED);
234 
235  WeaponFireAndChamberNext Trigger_CC11 = new WeaponFireAndChamberNext(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL);
236  WeaponStateBase Trigger_CC10 = new WeaponFireLast(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL); // fire last no mag
237  WeaponStateBase Trigger_CC11L = new WeaponFireLast(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST); // fire last with mag
238 
239  WeaponStateBase Trigger_CC10J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM);
240  WeaponStateBase Trigger_CC11J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM);
241 
242  WeaponStateBase Unjam_CJF0 = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START);
243  WeaponStateBase Unjam_CJF1 = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START);
244 
245  WeaponChambering Chamber_CD00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED_UNCOCKED);
246  WeaponChambering Chamber_CC00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
247  WeaponChambering Chamber_OD00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED);
248  WeaponChambering Chamber_CD01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED_UNCOCKED);
249  WeaponChambering Chamber_CC01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
250  WeaponChambering Chamber_OD01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED);
251 
252  WeaponAttachMagazine Attach_CC10 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED);
253  WeaponAttachMagazine Attach_CJF0 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED);
254  WeaponAttachMagazine Attach_CD00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_UNCOCKED);
255  WeaponAttachMagazine Attach_CC00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_COCKED);
256  WeaponAttachMagazine Attach_OD00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_OPENED);
257 
258  WeaponReplacingMagAndChamberNext Reload_CD01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_UNCOCKED);
259  WeaponReplacingMagAndChamberNext Reload_CC01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_COCKED);
260  WeaponReplacingMagAndChamberNext Reload_CC11 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_BULLET_CLOSED);
261  WeaponReplacingMagAndChamberNext Reload_CJF1 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_BULLET_CLOSED);
262  WeaponReplacingMagAndChamberNext Reload_OD01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_OPENED);
263 
264  WeaponDetachingMag Detach_CC11 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
265  WeaponDetachingMag Detach_CC01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
266  WeaponDetachingMag Detach_CD01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
267  WeaponDetachingMag Detach_OD01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
268  WeaponDetachingMag Detach_CJF1 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
269 
270  // events
271  WeaponEventBase __M__ = new WeaponEventMechanism;
272  WeaponEventBase __T__ = new WeaponEventTrigger;
273  WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
274  WeaponEventBase __U__ = new WeaponEventUnjam;
275  WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
276  WeaponEventBase __A__ = new WeaponEventAttachMagazine;
277  WeaponEventBase __D__ = new WeaponEventDetachMagazine;
278  WeaponEventBase __S__ = new WeaponEventSwapMagazine;
279  WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
280  WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
281  WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
282  WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
283 
284  m_fsm = new WeaponFSM();
285 
286  //WeaponGuardWeaponDischarged
287  //WeaponGuardWeaponOpen
288 
289  // charging
290  m_fsm.AddTransition(new WeaponTransition( CD00, __M__, Mech_CD00)); // charge from closed
291  m_fsm.AddTransition(new WeaponTransition( Mech_CD00, _fin_, CC00, NULL, new WeaponGuardWeaponDischarged(this) ));
292  m_fsm.AddTransition(new WeaponTransition( Mech_CD00, _fin_, CD00));
293  m_fsm.AddTransition(new WeaponTransition( Mech_CD00, _abt_, CC00, NULL, new WeaponGuardWeaponDischarged(this) ));
294  m_fsm.AddTransition(new WeaponTransition( Mech_CD00, _abt_, CD00));
295 
296  m_fsm.AddTransition(new WeaponTransition( CC00, __M__, Mech_CC00)); // charge from charged
297  m_fsm.AddTransition(new WeaponTransition( Mech_CC00, _fin_, CC00));
298  m_fsm.AddTransition(new WeaponTransition( Mech_CC00, _abt_, CC00));
299 
300  m_fsm.AddTransition(new WeaponTransition( OD00, __M__, Mech_OD00)); // charge from opened
301  m_fsm.AddTransition(new WeaponTransition( Mech_OD00, _fin_, CD00, NULL, new WeaponGuardWeaponOpen(this) ));
302  m_fsm.AddTransition(new WeaponTransition( Mech_OD00, _fin_, CC00));
303  m_fsm.AddTransition(new WeaponTransition( Mech_OD00, _abt_, CD00, NULL, new WeaponGuardWeaponOpen(this) ));
304  m_fsm.AddTransition(new WeaponTransition( Mech_OD00, _abt_, CC00));
305 
306  m_fsm.AddTransition(new WeaponTransition( OD01, __M__, Mech_OD01)); // charge from opened with mag
307  m_fsm.AddTransition(new WeaponTransition( Mech_OD01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this) ));
308  m_fsm.AddTransition(new WeaponTransition( Mech_OD01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
309  m_fsm.AddTransition(new WeaponTransition( Mech_OD01, _fin_, CC11));
310  m_fsm.AddTransition(new WeaponTransition( Mech_OD01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this) ));
311  m_fsm.AddTransition(new WeaponTransition( Mech_OD01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
312  m_fsm.AddTransition(new WeaponTransition( Mech_OD01, _abt_, CC11));
313 
314  m_fsm.AddTransition(new WeaponTransition( CD01, __M__, Mech_CD01)); // charge from closed=1 with mag
315  m_fsm.AddTransition(new WeaponTransition( Mech_CD01, _fin_, CD01, NULL, new WeaponGuardWeaponDischarged(this)));
316  m_fsm.AddTransition(new WeaponTransition( Mech_CD01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
317  m_fsm.AddTransition(new WeaponTransition( Mech_CD01, _fin_, CC11));
318  m_fsm.AddTransition(new WeaponTransition( Mech_CD01, _abt_, CD01, NULL, new WeaponGuardWeaponDischarged(this)));
319  m_fsm.AddTransition(new WeaponTransition( Mech_CD01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
320  m_fsm.AddTransition(new WeaponTransition( Mech_CD01, _abt_, CC11));
321 
322  m_fsm.AddTransition(new WeaponTransition( CC01, __M__, Mech_CC01)); // charge from closed/charged with mag
323  m_fsm.AddTransition(new WeaponTransition( Mech_CC01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
324  m_fsm.AddTransition(new WeaponTransition( Mech_CC01, _fin_, CC11));
325  m_fsm.AddTransition(new WeaponTransition( Mech_CC01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
326  m_fsm.AddTransition(new WeaponTransition( Mech_CC01, _abt_, CC11));
327 
328  // eject good cartridge
329  m_fsm.AddTransition(new WeaponTransition( CC10, __M__, Mech_CC10)); // eject chamber nomag
330  m_fsm.AddTransition(new WeaponTransition( Mech_CC10, _fin_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
331  m_fsm.AddTransition(new WeaponTransition( Mech_CC10, _fin_, CC10));
332  m_fsm.AddTransition(new WeaponTransition( Mech_CC10, _abt_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
333  m_fsm.AddTransition(new WeaponTransition( Mech_CC10, _abt_, CC10));
334 
335  m_fsm.AddTransition(new WeaponTransition( CC11, __M__, Mech_CC11 )); // eject with mag with ammo
336  m_fsm.AddTransition(new WeaponTransition( Mech_CC11, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
337  m_fsm.AddTransition(new WeaponTransition( Mech_CC11, _fin_, CC11));
338  m_fsm.AddTransition(new WeaponTransition( Mech_CC11, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
339  m_fsm.AddTransition(new WeaponTransition( Mech_CC11, _abt_, CC11));
340 
341  // Trigger_CC11e
342  m_fsm.AddTransition(new WeaponTransition( CC00, __T__, Trigger_CC00)); // fire.cocked
343  m_fsm.AddTransition(new WeaponTransition( Trigger_CC00, _fin_, CD00));
344  m_fsm.AddTransition(new WeaponTransition( Trigger_CC00, _dto_, CD00));
345  m_fsm.AddTransition(new WeaponTransition( Trigger_CC00, _abt_, CD00));
346 
347  m_fsm.AddTransition(new WeaponTransition( CD00, __T__, Trigger_CD00)); // fire.uncocked
348  m_fsm.AddTransition(new WeaponTransition( Trigger_CD00, _fin_, CD00));
349  m_fsm.AddTransition(new WeaponTransition( Trigger_CD00, _dto_, CD00));
350  m_fsm.AddTransition(new WeaponTransition( Trigger_CD00, _abt_, CD00));
351 
352  m_fsm.AddTransition(new WeaponTransition( OD00, __T__, Trigger_OD00)); // opened fire.uncocked
353  m_fsm.AddTransition(new WeaponTransition( Trigger_OD00, _fin_, OD00));
354  m_fsm.AddTransition(new WeaponTransition( Trigger_OD00, _dto_, OD00));
355  m_fsm.AddTransition(new WeaponTransition( Trigger_OD00, _abt_, OD00));
356 
357  m_fsm.AddTransition(new WeaponTransition( CD01, __T__, Trigger_CD01)); // fire.uncocked w mag
358  m_fsm.AddTransition(new WeaponTransition( Trigger_CD01, _fin_, CD01));
359  m_fsm.AddTransition(new WeaponTransition( Trigger_CD01, _dto_, CD01));
360  m_fsm.AddTransition(new WeaponTransition( Trigger_CD01, _abt_, CD01));
361 
362  m_fsm.AddTransition(new WeaponTransition( OD01, __T__, Trigger_OD01)); // opened fire.uncocked w mag
363  m_fsm.AddTransition(new WeaponTransition( Trigger_OD01, _fin_, OD01));
364  m_fsm.AddTransition(new WeaponTransition( Trigger_OD01, _dto_, OD01));
365  m_fsm.AddTransition(new WeaponTransition( Trigger_OD01, _abt_, OD01));
366 
367  m_fsm.AddTransition(new WeaponTransition( CJF0, __T__, Trigger_CJF0)); // opened fire.uncocked w mag
368  m_fsm.AddTransition(new WeaponTransition( Trigger_CJF0, _fin_, CJF0));
369  m_fsm.AddTransition(new WeaponTransition( Trigger_CJF0, _dto_, CJF0));
370  m_fsm.AddTransition(new WeaponTransition( Trigger_CJF0, _abt_, CJF0));
371 
372  m_fsm.AddTransition(new WeaponTransition( CJF1, __T__, Trigger_CJF1)); // opened fire.uncocked w mag
373  m_fsm.AddTransition(new WeaponTransition( Trigger_CJF1, _fin_, CJF1));
374  m_fsm.AddTransition(new WeaponTransition( Trigger_CJF1, _dto_, CJF1));
375  m_fsm.AddTransition(new WeaponTransition( Trigger_CJF1, _abt_, CJF1));
376 
377 
378  m_fsm.AddTransition(new WeaponTransition( CC10, __T__, Trigger_CC10)); // or fire.last (if not jammed)
379  m_fsm.AddTransition(new WeaponTransition( Trigger_CC10, _fin_, CC00));
380  m_fsm.AddTransition(new WeaponTransition( Trigger_CC10, _rto_, CC00));
381  m_fsm.AddTransition(new WeaponTransition( Trigger_CC10, _abt_, CC00));
382 
383  m_fsm.AddTransition(new WeaponTransition( CC10, __TJ_, Trigger_CC10J)); // or fire.last (if not jammed)
384  m_fsm.AddTransition(new WeaponTransition( Trigger_CC10J, _fin_, CJF0 ));
385  m_fsm.AddTransition(new WeaponTransition( Trigger_CC10J, _rto_, CJF0 ));
386  m_fsm.AddTransition(new WeaponTransition( Trigger_CC10J, _abt_, CJF0 ));
387 
388 
389  m_fsm.AddTransition(new WeaponTransition( CC11, __T__, Trigger_CC11, NULL, new WeaponGuardHasAmmo(this))); // fire.normal + chamber next
390  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11, _fin_, CC11));
391  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11, _rto_, CC11));
392  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11, _abt_, CC11));
393 
394  m_fsm.AddTransition(new WeaponTransition( CC11, __T__, Trigger_CC11L, NULL, new GuardNot(new WeaponGuardHasAmmo(this)))); // fire.last with mag
395  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11L, _fin_, OD01));
396  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11L, _rto_, OD01));
397  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11L, _abt_, OD01));
398 
399  m_fsm.AddTransition(new WeaponTransition( CC11, __TJ_, Trigger_CC11J )); // fire.last with mag
400  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11J, _fin_, CJF1 ));
401  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11J, _rto_, CJF1 ));
402  m_fsm.AddTransition(new WeaponTransition( Trigger_CC11J, _abt_, CJF1 ));
403 
404  m_fsm.AddTransition(new WeaponTransition( CC01, __T__, Trigger_CC01)); // fire.cocked with mag
405  m_fsm.AddTransition(new WeaponTransition( Trigger_CC01, _fin_, CD01));
406  m_fsm.AddTransition(new WeaponTransition( Trigger_CC01, _dto_, CD01));
407  m_fsm.AddTransition(new WeaponTransition( Trigger_CC01, _abt_, CD01));
408 
409  // load cartridge
410  m_fsm.AddTransition(new WeaponTransition( CD00, __L__, Chamber_CD00)); // chamber from closed=1
411  m_fsm.AddTransition(new WeaponTransition( Chamber_CD00, _fin_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
412  m_fsm.AddTransition(new WeaponTransition( Chamber_CD00, _fin_, CD00, NULL, new WeaponGuardWeaponDischarged(this)));
413  m_fsm.AddTransition(new WeaponTransition( Chamber_CD00, _fin_, CC10));
414  m_fsm.AddTransition(new WeaponTransition( Chamber_CD00, _abt_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
415  m_fsm.AddTransition(new WeaponTransition( Chamber_CD00, _abt_, CD00, NULL, new WeaponGuardWeaponDischarged(this)));
416  m_fsm.AddTransition(new WeaponTransition( Chamber_CD00, _abt_, CC10));
417 
418  m_fsm.AddTransition(new WeaponTransition( OD00, __L__, Chamber_OD00)); // chamber from opened
419  m_fsm.AddTransition(new WeaponTransition( Chamber_OD00, _fin_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
420  m_fsm.AddTransition(new WeaponTransition( Chamber_OD00, _fin_, CC10));
421  m_fsm.AddTransition(new WeaponTransition( Chamber_OD00, _abt_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
422  m_fsm.AddTransition(new WeaponTransition( Chamber_OD00, _abt_, CC10));
423 
424  m_fsm.AddTransition(new WeaponTransition( CC00, __L__, Chamber_CC00)); // chamber from closed charged
425  m_fsm.AddTransition(new WeaponTransition( Chamber_CC00, _fin_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
426  m_fsm.AddTransition(new WeaponTransition( Chamber_CC00, _fin_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
427  m_fsm.AddTransition(new WeaponTransition( Chamber_CC00, _fin_, CC10));
428  m_fsm.AddTransition(new WeaponTransition( Chamber_CC00, _abt_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
429  m_fsm.AddTransition(new WeaponTransition( Chamber_CC00, _abt_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
430  m_fsm.AddTransition(new WeaponTransition( Chamber_CC00, _abt_, CC10));
431 
432  // load cartridge with mag
433  m_fsm.AddTransition(new WeaponTransition( CD01, __L__, Chamber_CD01, NULL, new WeaponGuardHasMag(this))); // chamber from closed=1 with mag
434  m_fsm.AddTransition(new WeaponTransition( Chamber_CD01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
435  m_fsm.AddTransition(new WeaponTransition( Chamber_CD01, _fin_, CD01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
436  m_fsm.AddTransition(new WeaponTransition( Chamber_CD01, _fin_, CC11));
437  m_fsm.AddTransition(new WeaponTransition( Chamber_CD01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
438  m_fsm.AddTransition(new WeaponTransition( Chamber_CD01, _abt_, CD01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
439  m_fsm.AddTransition(new WeaponTransition( Chamber_CD01, _abt_, CC11));
440 
441  m_fsm.AddTransition(new WeaponTransition( CC01, __L__, Chamber_CC01, NULL, new WeaponGuardHasMag(this))); // chamber from closed=1 with mag
442  m_fsm.AddTransition(new WeaponTransition( Chamber_CC01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
443  m_fsm.AddTransition(new WeaponTransition( Chamber_CC01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
444  m_fsm.AddTransition(new WeaponTransition( Chamber_CC01, _fin_, CC11));
445  m_fsm.AddTransition(new WeaponTransition( Chamber_CC01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
446  m_fsm.AddTransition(new WeaponTransition( Chamber_CC01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
447  m_fsm.AddTransition(new WeaponTransition( Chamber_CC01, _abt_, CC11));
448 
449  m_fsm.AddTransition(new WeaponTransition( OD01, __L__, Chamber_OD01, NULL, new WeaponGuardHasMag(this))); // chamber from opened with mag
450  m_fsm.AddTransition(new WeaponTransition( Chamber_OD01, _fin_, OD01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
451  m_fsm.AddTransition(new WeaponTransition( Chamber_OD01, _fin_, CC11));
452  m_fsm.AddTransition(new WeaponTransition( Chamber_OD01, _abt_, OD01, NULL, new WeaponGuardCurrentChamberEmpty(this) ));
453  m_fsm.AddTransition(new WeaponTransition( Chamber_OD01, _abt_, CC11));
454 
455  m_fsm.AddTransition(new WeaponTransition( CJF0, __A__, Attach_CJF0, NULL, new WeaponGuardCanAttachMag(this))); // attach from JAM/b1/m0
456  m_fsm.AddTransition(new WeaponTransition( Attach_CJF0, _fin_, CJF1, NULL, new WeaponGuardHasMag(this)));
457  m_fsm.AddTransition(new WeaponTransition( Attach_CJF0, _fin_, CJF0));
458  m_fsm.AddTransition(new WeaponTransition( Attach_CJF0, _abt_, CJF1, NULL, new WeaponGuardHasMag(this)));
459  m_fsm.AddTransition(new WeaponTransition( Attach_CJF0, _abt_, CJF0));;
460 
461 // zdokumentovano az sem
462  // attach mag with no ammo
463  m_fsm.AddTransition(new WeaponTransition( CD00, __A__, Attach_CD00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0
464  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _fin_, CD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
465  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _fin_, CD01, NULL, new WeaponGuardWeaponDischarged(this)));
466  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
467  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _fin_, CC11));
468  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _abt_, CD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
469  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _abt_, CD00, NULL, new WeaponGuardWeaponDischarged(this)));
470  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
471  m_fsm.AddTransition(new WeaponTransition( Attach_CD00, _abt_, CC11));
472 
473  m_fsm.AddTransition(new WeaponTransition( CC10, __A__, Attach_CC10, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b1/m0
474  m_fsm.AddTransition(new WeaponTransition( Attach_CC10, _fin_, CC11, NULL, new WeaponGuardHasMag(this)));
475  m_fsm.AddTransition(new WeaponTransition( Attach_CC10, _fin_, CC10));
476  m_fsm.AddTransition(new WeaponTransition( Attach_CC10, _abt_, CC11, NULL, new WeaponGuardHasMag(this)));
477  m_fsm.AddTransition(new WeaponTransition( Attach_CC10, _abt_, CC10));
478 
479  m_fsm.AddTransition(new WeaponTransition( OD00, __A__, Attach_OD00, NULL, new WeaponGuardCanAttachMag(this))); // attach from OPE/b0/m0
480  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _fin_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
481  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
482  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
483  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _fin_, CC11));
484  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _abt_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
485  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
486  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
487  m_fsm.AddTransition(new WeaponTransition( Attach_OD00, _abt_, CC11));
488 
489  m_fsm.AddTransition(new WeaponTransition( CC00, __A__, Attach_CC00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0 charged
490  m_fsm.AddTransition(new WeaponTransition( Attach_CC00, _fin_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
491  m_fsm.AddTransition(new WeaponTransition( Attach_CC00, _fin_, CC01, NULL, new WeaponGuardHasMag(this)));
492  m_fsm.AddTransition(new WeaponTransition( Attach_CC00, _fin_, CC00));
493  m_fsm.AddTransition(new WeaponTransition( Attach_CC00, _abt_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
494  m_fsm.AddTransition(new WeaponTransition( Attach_CC00, _abt_, CC01, NULL, new WeaponGuardHasMag(this)));
495  m_fsm.AddTransition(new WeaponTransition( Attach_CC00, _abt_, CC00));
496 
497  // replace magazine
498  m_fsm.AddTransition(new WeaponTransition( CD01, __S__, Reload_CD01, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b0/m1
499  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _fin_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
500  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _fin_, CC01, NULL, new WeaponGuardWeaponCharged(this)));
501  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _fin_, CD01, NULL, new WeaponGuardHasMag(this)));
502  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _fin_, CD00));
503  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _abt_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
504  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _abt_, CC01, NULL, new WeaponGuardWeaponCharged(this)));
505  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _abt_, CD01, NULL, new WeaponGuardHasMag(this)));
506  m_fsm.AddTransition(new WeaponTransition( Reload_CD01, _abt_, CD00));
507 
508 
509  m_fsm.AddTransition(new WeaponTransition( CC11, __S__, Reload_CC11, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b1/m1
510  m_fsm.AddTransition(new WeaponTransition( Reload_CC11, _fin_, CC11, NULL, new WeaponGuardHasMag(this)));
511  m_fsm.AddTransition(new WeaponTransition( Reload_CC11, _fin_, CC10));
512  m_fsm.AddTransition(new WeaponTransition( Reload_CC11, _abt_, CC11, NULL, new WeaponGuardHasMag(this)));
513  m_fsm.AddTransition(new WeaponTransition( Reload_CC11, _abt_, CC10));
514 
515  m_fsm.AddTransition(new WeaponTransition( CC01, __S__, Reload_CC01, NULL, new WeaponGuardCanSwapMag(this))); // CLO/b0/m1 swap with empty mag (no chamber)
516  m_fsm.AddTransition(new WeaponTransition( Reload_CC01, _fin_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)) );
517  m_fsm.AddTransition(new WeaponTransition( Reload_CC01, _fin_, CC01, NULL, new WeaponGuardHasMag(this)) );
518  m_fsm.AddTransition(new WeaponTransition( Reload_CC01, _fin_, CC00));
519  m_fsm.AddTransition(new WeaponTransition( Reload_CC01, _abt_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)) );
520  m_fsm.AddTransition(new WeaponTransition( Reload_CC01, _abt_, CC01, NULL, new WeaponGuardHasMag(this)) );
521  m_fsm.AddTransition(new WeaponTransition( Reload_CC01, _abt_, CC00));
522 
523  m_fsm.AddTransition(new WeaponTransition( OD01, __S__, Reload_OD01, NULL, new WeaponGuardCanSwapMag(this))); // OPE/b0/m1 swap with empty mag (no chamber)
524  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _fin_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
525  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
526  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
527  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _fin_, CC11));
528  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _abt_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
529  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
530  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
531  m_fsm.AddTransition(new WeaponTransition( Reload_OD01, _abt_, CC11));
532 
533  m_fsm.AddTransition(new WeaponTransition( CJF1, __S__, Reload_CJF1, NULL, new WeaponGuardCanSwapMag(this))); // swap in JAM/b1/m1
534  m_fsm.AddTransition(new WeaponTransition( Reload_CJF1, _fin_, CJF1, NULL, new WeaponGuardHasMag(this)));
535  m_fsm.AddTransition(new WeaponTransition( Reload_CJF1, _fin_, CJF0));
536  m_fsm.AddTransition(new WeaponTransition( Reload_CJF1, _abt_, CJF1, NULL, new WeaponGuardHasMag(this)));
537  m_fsm.AddTransition(new WeaponTransition( Reload_CJF1, _abt_, CJF0));
538 
539 
540  // detach magazine
541  m_fsm.AddTransition(new WeaponTransition( OD01, __D__, Detach_OD01, NULL, new WeaponGuardCanDetachMag(this))); // detach from OPE/b0/m1
542  m_fsm.AddTransition(new WeaponTransition( Detach_OD01, _fin_, OD01, NULL, new WeaponGuardHasMag(this)));
543  m_fsm.AddTransition(new WeaponTransition( Detach_OD01, _fin_, OD00));
544  m_fsm.AddTransition(new WeaponTransition( Detach_OD01, _abt_, OD01, NULL, new WeaponGuardHasMag(this)));
545  m_fsm.AddTransition(new WeaponTransition( Detach_OD01, _abt_, OD00));
546 
547  m_fsm.AddTransition(new WeaponTransition( CC11, __D__, Detach_CC11, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b1/m1
548  m_fsm.AddTransition(new WeaponTransition( Detach_CC11, _fin_, CC11, NULL, new WeaponGuardHasMag(this)));
549  m_fsm.AddTransition(new WeaponTransition( Detach_CC11, _fin_, CC10));
550  m_fsm.AddTransition(new WeaponTransition( Detach_CC11, _abt_, CC11, NULL, new WeaponGuardHasMag(this)));
551  m_fsm.AddTransition(new WeaponTransition( Detach_CC11, _abt_, CC10));
552 
553  m_fsm.AddTransition(new WeaponTransition( CC01, __D__, Detach_CC01, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b0/m1
554  m_fsm.AddTransition(new WeaponTransition( Detach_CC01, _fin_, CC01, NULL, new WeaponGuardHasMag(this)));
555  m_fsm.AddTransition(new WeaponTransition( Detach_CC01, _fin_, CC00));
556  m_fsm.AddTransition(new WeaponTransition( Detach_CC01, _abt_, CC01, NULL, new WeaponGuardHasMag(this)));
557  m_fsm.AddTransition(new WeaponTransition( Detach_CC01, _abt_, CC00));
558 
559  m_fsm.AddTransition(new WeaponTransition( CD01, __D__, Detach_CD01, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b0/m1 dischg
560  m_fsm.AddTransition(new WeaponTransition( Detach_CD01, _fin_, CD01, NULL, new WeaponGuardHasMag(this)));
561  m_fsm.AddTransition(new WeaponTransition( Detach_CD01, _fin_, CD00));
562  m_fsm.AddTransition(new WeaponTransition( Detach_CD01, _abt_, CD01, NULL, new WeaponGuardHasMag(this)));
563  m_fsm.AddTransition(new WeaponTransition( Detach_CD01, _abt_, CD00));
564 
565  m_fsm.AddTransition(new WeaponTransition( CJF1, __D__, Detach_CJF1, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b1/m1 jammed
566  m_fsm.AddTransition(new WeaponTransition( Detach_CJF1, _fin_, CJF1, NULL, new WeaponGuardHasMag(this)));
567  m_fsm.AddTransition(new WeaponTransition( Detach_CJF1, _fin_, CJF0));
568  m_fsm.AddTransition(new WeaponTransition( Detach_CJF1, _abt_, CJF1, NULL, new WeaponGuardHasMag(this)));
569  m_fsm.AddTransition(new WeaponTransition( Detach_CJF1, _abt_, CJF0));
570 
571 
572  // unjam
573  m_fsm.AddTransition(new WeaponTransition( CJF0, __U__, Unjam_CJF0)); // unjam nomag
574  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF0, _fin_, CJF0, NULL, new WeaponGuardJammed(this)));
575  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF0, _fin_, CC00));
576  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF0, _abt_, CJF0, NULL, new WeaponGuardJammed(this)));
577  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF0, _abt_, CC00));
578 
579  m_fsm.AddTransition(new WeaponTransition( CJF1, __U__, Unjam_CJF1)); // unjam with mag with ammo
580  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF1, _fin_, CJF1, NULL, new WeaponGuardJammed(this)));
581  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF1, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
582  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF1, _fin_, CC11));
583  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF1, _abt_, CJF1, NULL, new WeaponGuardJammed(this)));
584  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF1, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
585  m_fsm.AddTransition(new WeaponTransition( Unjam_CJF1, _abt_, CC11));
586 
587 
588  SetInitialState(CD00);
589  SelectionBulletHide();
590  HideMagazine();
591  m_fsm.Start();
592  }
593 
594  override float GetChanceToJam()
595  {
596  float chanceToJam = super.GetChanceToJam();
597  Magazine mag = GetMagazine(GetCurrentMuzzle());
598 
599  if(mag)
600  {
601  chanceToJam = chanceToJam + ((1.0 - chanceToJam) * mag.GetChanceToJam());
602  }
603  else
604  {
605  chanceToJam = chanceToJam + ((1.0 - chanceToJam) * 0.06);
606  }
607 
608  return chanceToJam;
609  }
610 
611  /*override bool GetInventoryHandAnimation(notnull InventoryLocation loc, out int value)
612  {
613  int id;
614  string name = "";
615  if ( loc.GetParent() && loc.GetParent().GetInventory().GetCurrentAttachmentSlotInfo(id,name) && name == "Hips" )
616  {
617  //value = WeaponHideShowTypes.HIDESHOW_SLOT_2HDRIGHTBACK;
618  value = WeaponHideShowTypes.HIDESHOW_SLOT_PISTOLBELT;
619  return true;
620  }
621 
622  return false;
623  }*/
624 
625  override void SetActions()
626  {
627  super.SetActions();
629  //AddAction(ActionAdvancedDetachMagazine);
630  }
631 };
632 
PistolAnimState
PistolAnimState
Definition: pistol_base.c:2
GetCurrentStateID
override int GetCurrentStateID()
Definition: pistol_base.c:31
CLOSED_CHARGED
@ CLOSED_CHARGED
closed and charged
Definition: pistol_base.c:6
CLO_CHG_BU1_MA1
CLO_CHG_BU1_MA1
Definition: pistol_base.c:11
LogManager
Definition: debug.c:734
WeaponActionUnjammingTypes
WeaponActionUnjammingTypes
Definition: human.c:904
OPE_DIS_BU0_MA0
OPE_DIS_BU0_MA0
Definition: pistol_base.c:7
WeaponActionFireTypes
WeaponActionFireTypes
Definition: human.c:912
IsDischarged
override bool IsDischarged()
Definition: pistol_base.c:35
WeaponReplacingMagAndChamberNext
replace current magazine with new one
WeaponGuardWeaponDischarged
void WeaponGuardWeaponDischarged(Weapon_Base w=NULL)
Definition: guards.c:580
WeaponGuardWeaponOpen
void WeaponGuardWeaponOpen(Weapon_Base w=NULL)
Definition: guards.c:585
CLO_DIS_BU0_MA1
CLO_DIS_BU0_MA1
Definition: pistol_base.c:9
WeaponActionReloadTypes
WeaponActionReloadTypes
Definition: human.c:824
IsJammed
override bool IsJammed()
Definition: pistol_base.c:34
WeaponActions
WeaponActions
actions
Definition: human.c:808
OPE_DIS_BU0_MA1
OPE_DIS_BU0_MA1
Definition: pistol_base.c:12
CLO_CHG_BU1_MA0
CLO_CHG_BU1_MA0
Definition: pistol_base.c:5
CLO_JAM_BU1_MA1
CLO_JAM_BU1_MA1
Definition: pistol_base.c:10
CLO_CHG_BU0_MA1
CLO_CHG_BU0_MA1
Definition: pistol_base.c:8
WeaponUnjamming
unjam submachine
PistolStableStateID
PistolStableStateID
Definition: pistol_base.c:12
JAMMED
@ JAMMED
jammed weapon
Definition: pistol_base.c:7
HasMagazine
override bool HasMagazine()
Definition: pistol_base.c:33
InitMuzzleArray
override void InitMuzzleArray()
Definition: pistol_base.c:37
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
DEFAULT
@ DEFAULT
default weapon state, closed and discharged
Definition: pistol_base.c:4
m_muzzleHasBullet
ref array< MuzzleState > m_muzzleHasBullet
Definition: weaponstablestate.c:30
SetActions
void SetActions()
Definition: advancedcommunication.c:79
WeaponCharging
charging of weapon without ammo to be chambered
WeaponTransition
enum FSMTransition WeaponTransition
CLO_JAM_BU1_MA0
CLO_JAM_BU1_MA0
Definition: pistol_base.c:6
IsRepairEnabled
override bool IsRepairEnabled()
Definition: pistol_base.c:36
Pistol_Base
base for semi auto weapons @NOTE name copies config base class
Definition: pistolalt_base.c:1
HasBullet
override bool HasBullet()
Definition: pistol_base.c:32
FirearmActionDetachMagazine
Definition: firearmactiondetachmagazine.c:147
WeaponGuardHasAmmo
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition: guards.c:99
IsBoltOpen
override bool IsBoltOpen()
Definition: flaregun.c:23
OPENED_DISCHARGED
@ OPENED_DISCHARGED
opened and discharged
Definition: pistol_base.c:5
CLO_DIS_BU0_MA0
CLO_DIS_BU0_MA0
Definition: pistol_base.c:3
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
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
WeaponStateJammed
handle jamming state set jam/unjam state for weapon
Definition: sks.c:52
wpnPrint
void wpnPrint(string s)
Definition: debug.c:1
OnEntry
class Pistol_CLO_CHG_BU0_MA0 extends WeaponStableState OnEntry
WeaponActionChamberingTypes
WeaponActionChamberingTypes
Definition: human.c:868
WeaponFSM
weapon finite state machine
OnExit
override void OnExit(WeaponEventBase e)
Definition: pistol_base.c:30
UNKNOWN
UNKNOWN
Definition: pistol_base.c:2
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
CLO_CHG_BU0_MA0
CLO_CHG_BU0_MA0
Definition: pistol_base.c:4