DayZ 1.24
Loading...
Searching...
No Matches
Rifle_Base Class Reference

base for rifles @NOTE name copies config base class More...

Inheritance diagram for Rifle_Base:
[legend]
Collaboration diagram for Rifle_Base:
[legend]

Private Member Functions

override RecoilBase SpawnRecoilObject ()
 
override void InitStateMachine ()
 
override bool CanEnterIronsights ()
 
override void SetActions ()
 
override void OnDebugSpawn ()
 
override void InitStateMachine ()
 
override bool CanChamberBullet (int muzzleIndex, Magazine mag)
 
override void SetActions ()
 
void RifleBoltFree_Base ()
 
override void InitStateMachine ()
 
override float GetChanceToJam ()
 
override void SetActions ()
 
void RifleBoltLock_Base ()
 
override void InitStateMachine ()
 
override float GetChanceToJam ()
 
override void SetActions ()
 
void RifleSingleShot_Base ()
 
override void InitStateMachine ()
 
override float GetChanceToJam ()
 

Private Attributes

ref WeaponStableState C0
 
ref WeaponStableState C1
 
ref WeaponStableState L0
 
ref WeaponStableState JF
 
ref WeaponStableState D0
 
ref WeaponStableState DF
 
ref WeaponStableState C00
 
ref WeaponStableState C10
 
ref WeaponStableState C11
 
ref WeaponStableState C01
 
ref WeaponStableState JF0
 
ref WeaponStableState JF1
 
ref WeaponStableState O00
 
ref WeaponStableState O01
 

Detailed Description

base for rifles @NOTE name copies config base class

Definition at line 69 of file SKS.c.

Member Function Documentation

◆ CanChamberBullet()

override bool Rifle_Base::CanChamberBullet ( int muzzleIndex,
Magazine mag )
inlineprivate

Definition at line 219 of file Repeater.c.

220 {
221 return CanChamberFromMag(muzzleIndex, mag) && !IsInternalMagazineFull(muzzleIndex);
222 }

◆ CanEnterIronsights()

override bool Rifle_Base::CanEnterIronsights ( )
inlineprivate

Definition at line 248 of file SKS.c.

249 {
250 ItemOptics optic = GetAttachedOptics();
251 if (optic && PUScopeOptic.Cast(optic))
252 return true;
253 return super.CanEnterIronsights();
254 }

◆ GetChanceToJam() [1/3]

override float Rifle_Base::GetChanceToJam ( )
inlineprivate

Definition at line 364 of file RifleBoltFree_Base.c.

365 {
366 float chanceToJam = super.GetChanceToJam();
367 Magazine mag = GetMagazine(GetCurrentMuzzle());
368
369 if (mag)
370 chanceToJam = chanceToJam + ((1.0 - chanceToJam) * mag.GetChanceToJam());
371 else
372 chanceToJam = chanceToJam + ((1.0 - chanceToJam) * 0.06);
373
374 return chanceToJam;
375 }

◆ GetChanceToJam() [2/3]

override float Rifle_Base::GetChanceToJam ( )
inlineprivate

Definition at line 481 of file RifleBoltLock_Base.c.

482 {
483 float chanceToJam = super.GetChanceToJam();
484 Magazine mag = GetMagazine(GetCurrentMuzzle());
485
486 if (mag)
487 chanceToJam = chanceToJam + ((1.0 - chanceToJam) * mag.GetChanceToJam());
488 else
489 chanceToJam = chanceToJam + ((1.0 - chanceToJam) * 0.06);
490
491 return chanceToJam;
492 }

◆ GetChanceToJam() [3/3]

override float Rifle_Base::GetChanceToJam ( )
inlineprivate

Definition at line 190 of file RifleSingleShot_Base.c.

191 {
192 return 0.0;
193 }

◆ InitStateMachine() [1/5]

override void Rifle_Base::InitStateMachine ( )
inlineprivate

Definition at line 81 of file SKS.c.

82 {
83 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP));
84 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED));
85 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_OPENED));
86 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE));
87
88 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD_CLIP, 0));
89
90 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED)));
91 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED)));//????
92
93 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START)));
94 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END)));
95
96 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL)));
97 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST)));
98 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM)));
99 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY)));
100
101 //m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
102
103 // setup state machine
104 // basic weapon states
105 // close-locked-jammed | nobullet-bullet | nomag-mag
106 // regexp: [CLJ][01][01]
107 C0 = new SKS_CLO_BU0(this, NULL, SKSAnimState.DEFAULT);
108 C1 = new SKS_CLO_BU1(this, NULL, SKSAnimState.DEFAULT);
109 L0 = new SKS_OPN_BU0(this, NULL, SKSAnimState.OPENED);
110 JF = new SKS_JAM_BU1(this, NULL, SKSAnimState.JAMMED);
111
112 // unstable (intermediate) states
113 WeaponChargingInnerMag Mech_C0 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
114 WeaponChargingInnerMag Mech_L0 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
115 WeaponChargingInnerMag Mech_C1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
116
117 //Fire
118 WeaponStateBase Trigger_C0 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY)); // cock without clip
120 WeaponStateBase Trigger_C1L = new WeaponFireLast(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST));
121 WeaponStateBase Trigger_L0 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
122 WeaponStateBase Trigger_JF = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
123
125
126 //Unjam
127 WeaponStateBase Unjam_JF = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
128
129 //Chambering
130 LoopedChambering Chamber_C0 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
131 LoopedChambering Chamber_C1 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
132 LoopedChambering Chamber_L0 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_OPENED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
133
134 //WeaponStateBase chmMag = new WeaponChamberFromAttMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
135
136 // events
137 WeaponEventBase __M__ = new WeaponEventMechanism;
138 WeaponEventBase __T__ = new WeaponEventTrigger;
139 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
140 WeaponEventBase __U__ = new WeaponEventUnjam;
141 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
142 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
143 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
144 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
145 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
146
147 m_fsm = new WeaponFSM();
148
149 // order: Discharged-Charged | nobullet-bullet | nomag-mag
150 // charging
151 m_fsm.AddTransition(new WeaponTransition(C0, __M__, Mech_C1)); // charge from dischg nobullet nomag
152
153 m_fsm.AddTransition(new WeaponTransition(C1, __M__, Mech_C1)); // charge from bullet nomag
154 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
155 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C1));
156 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
157 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C1));
158
159 m_fsm.AddTransition(new WeaponTransition(L0, __M__, Mech_L0)); // charge from dischg nobullet nomag
160 m_fsm.AddTransition(new WeaponTransition(Mech_L0, _fin_, L0, NULL, new WeaponGuardWeaponOpen(this)));
161 m_fsm.AddTransition(new WeaponTransition(Mech_L0, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
162 m_fsm.AddTransition(new WeaponTransition(Mech_L0, _fin_, C1));
163 m_fsm.AddTransition(new WeaponTransition(Mech_L0, _abt_, L0, NULL, new WeaponGuardWeaponOpen(this)));
164 m_fsm.AddTransition(new WeaponTransition(Mech_L0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
165 m_fsm.AddTransition(new WeaponTransition(Mech_L0, _abt_, C1));
166
167
168 /*m_start = new WeaponCharging_Start(m_weapon, this, m_action, m_actionType);
169 m_onBE = new WeaponEjectBullet_Cartridge_W4T(m_weapon, this);
170 m_onBEFireOut = new WeaponEjectCasing_W4T(m_weapon, this);
171 m_hideB = new BulletHide_W4T(m_weapon, this);
172 m_onCK = new WeaponCharging_CK(m_weapon, this);
173 m_chamber = new WeaponChamberFromInnerMag_W4T(m_weapon, this);*/
174
175
176 // fire
177 m_fsm.AddTransition(new WeaponTransition(C0, __T__, Trigger_C0));
178 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _fin_, C0));
179 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _dto_, C0));
180 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _abt_, C0));
181
182
183 m_fsm.AddTransition(new WeaponTransition(C1, __T__, Trigger_C1, NULL, new WeaponGuardHasAmmoInnerMagazine(this)));
184 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _fin_, C1));
185 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _rto_, C1));
186 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _abt_, C1));
187
188 m_fsm.AddTransition(new WeaponTransition(C1, __T__, Trigger_C1L));
189 m_fsm.AddTransition(new WeaponTransition(Trigger_C1L, _fin_, L0));
190 m_fsm.AddTransition(new WeaponTransition(Trigger_C1L, _rto_, L0));
191 m_fsm.AddTransition(new WeaponTransition(Trigger_C1L, _abt_, L0));
192
193 m_fsm.AddTransition(new WeaponTransition(C1, __TJ_, Trigger_C1J));
194 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _fin_, JF));
195 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _rto_, JF));
196 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _abt_, JF));
197
198 m_fsm.AddTransition(new WeaponTransition(L0, __T__, Trigger_L0));
199 m_fsm.AddTransition(new WeaponTransition(Trigger_L0, _fin_, L0));
200 m_fsm.AddTransition(new WeaponTransition(Trigger_L0, _dto_, L0));
201 m_fsm.AddTransition(new WeaponTransition(Trigger_L0, _abt_, L0));
202
203 m_fsm.AddTransition(new WeaponTransition(JF, __T__, Trigger_JF)); // opened fire.uncocked w mag
204 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _fin_, JF));
205 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _dto_, JF));
206 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _abt_, JF));
207
208
209 // load cartridge
210 m_fsm.AddTransition(new WeaponTransition(C0, __L__, Chamber_C0));
211 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _fin_, L0, NULL, new WeaponGuardWeaponOpen(this)));
212 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
213 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _fin_, C1));
214 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _abt_, L0, NULL, new WeaponGuardWeaponOpen(this)));
215 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
216 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _abt_, C1));
217
218 m_fsm.AddTransition(new WeaponTransition(C1, __L__, Chamber_C1, NULL, new GuardNot(new WeaponGuardInnerMagazineFullShareChamber(this))));
219 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _fin_, C1));
220 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _abt_, C1));
221
222 m_fsm.AddTransition(new WeaponTransition(L0, __L__, Chamber_L0, NULL, new GuardNot(new WeaponGuardInnerMagazineFullShareChamber(this))));
223 m_fsm.AddTransition(new WeaponTransition(Chamber_L0, _fin_, L0, NULL, new WeaponGuardWeaponOpen(this)));
224 m_fsm.AddTransition(new WeaponTransition(Chamber_L0, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
225 m_fsm.AddTransition(new WeaponTransition(Chamber_L0, _fin_, C1));
226 m_fsm.AddTransition(new WeaponTransition(Chamber_L0, _abt_, L0, NULL, new WeaponGuardWeaponOpen(this)));
227 m_fsm.AddTransition(new WeaponTransition(Chamber_L0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
228 m_fsm.AddTransition(new WeaponTransition(Chamber_L0, _abt_, C1));
229
230
231 // unjam
232 m_fsm.AddTransition(new WeaponTransition(JF, __U__, Unjam_JF)); // unjam nomag
233 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, JF, NULL, new WeaponGuardJammed(this)));
234 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
235 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C1));
236 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, JF, NULL, new WeaponGuardJammed(this)));
237 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
238 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C1));
239
240 SetInitialState(C0);
241
242 SelectionBulletHide();
243 HideMagazine();
244
245 m_fsm.Start();
246 }
void WeaponGuardWeaponOpen(Weapon_Base w=NULL)
Definition Guards.c:604
SKS_JAM_BU1
Definition SKS.c:24
SKS_CLO_BU0
Definition SKS.c:21
SKSAnimState
Definition SKS.c:2
SKS_CLO_BU1
Definition SKS.c:22
SKS_OPN_BU0
Definition SKS.c:23
enum FSMTransition WeaponTransition
pair ( action, actionType )
Definition Weapon_Base.c:5
ref WeaponStableState L0
Definition SKS.c:73
ref WeaponStableState C0
Definition SKS.c:71
ref WeaponStableState JF
Definition SKS.c:74
ref WeaponStableState C1
Definition SKS.c:72
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine
represent weapon state base
Definition BulletHide.c:2
unjam submachine
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionUnjammingTypes
Definition human.c:892
WeaponActionFireTypes
Definition human.c:900

References SKS_CLO_BU0, SKS_CLO_BU1, SKS_JAM_BU1, SKS_OPN_BU0, and WeaponGuardWeaponOpen().

◆ InitStateMachine() [2/5]

override void Rifle_Base::InitStateMachine ( )
inlineprivate

Definition at line 75 of file Repeater.c.

76 {
77 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
78 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
79 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED));
80 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED));
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 D0 = new RPTEmptyDischarged(this, NULL, RPTAnimState.DEFAULT);
90 C0 = new RPTEmptyDischarged(this, NULL, RPTAnimState.CHARGED);
91 DF = new RPTLoadedDischarged(this, NULL, RPTAnimState.DEFAULT);
92 C1 = new RPTLoadedCharged(this, NULL, RPTAnimState.CHARGED);
93 JF = new RPTLoadedJammed(this, NULL, RPTAnimState.JAMMED);
94
95 //WeaponStateBase Mech_D0 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
96 WeaponStateBase Mech_C1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED);
97 WeaponStateBase Mech_DF = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
98
99 LoopedChamberingEjectLast Chamber_D0 = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
100 LoopedChamberingEjectLast Chamber_C0 = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
101 LoopedChamberingEjectLast Chamber_C1 = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
102 LoopedChamberingEjectLast Chamber_DF = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
103
105
111
113
114
115 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
116 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
117 WeaponEventBase __T__ = new WeaponEventTrigger;
118 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
119 WeaponEventBase __U__ = new WeaponEventUnjam;
120 WeaponEventBase __M__ = new WeaponEventMechanism;
121 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
122 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
123 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
124
125 m_fsm = new WeaponFSM();
126
127 // Mechanism
128 //----------------------------------------
129 m_fsm.AddTransition(new WeaponTransition(D0, __M__, Mech_DF));
130 m_fsm.AddTransition(new WeaponTransition(C0, __M__, Mech_C1));
131
132 m_fsm.AddTransition(new WeaponTransition(C1, __M__, Mech_C1));
133 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
134 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C1));
135 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
136 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C1));
137
138 m_fsm.AddTransition(new WeaponTransition(DF, __M__, Mech_DF));
139 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
140 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _fin_, DF, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
141 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _fin_, C1));
142 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
143 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _abt_, DF, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
144 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _abt_, C1));
145
146
147 //----------------------------------------
148 m_fsm.AddTransition(new WeaponTransition(C0, __L__, Chamber_D0));
149
150 m_fsm.AddTransition(new WeaponTransition(D0, __L__, Chamber_D0));
151 m_fsm.AddTransition(new WeaponTransition(Chamber_D0, _fin_, C1));
152 m_fsm.AddTransition(new WeaponTransition(Chamber_D0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
153 m_fsm.AddTransition(new WeaponTransition(Chamber_D0, _abt_, C1));
154
155 m_fsm.AddTransition(new WeaponTransition(C1, __L__, Chamber_C1, NULL, new GuardNot(new WeaponGuardInnerMagazineFull(this))));
156 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _fin_, C1));
157 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _abt_, C1));
158
159 m_fsm.AddTransition(new WeaponTransition(DF, __L__, Chamber_DF, NULL, new GuardNot(new WeaponGuardInnerMagazineFull(this))));
160 m_fsm.AddTransition(new WeaponTransition(Chamber_DF, _fin_, C1));
161 m_fsm.AddTransition(new WeaponTransition(Chamber_DF, _abt_, DF, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
162 m_fsm.AddTransition(new WeaponTransition(Chamber_DF, _abt_, C1));
163
164 //------------------------------------------
165
166 m_fsm.AddTransition(new WeaponTransition(JF, __U__, Unjam_JF));
167 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, JF, NULL, new WeaponGuardJammed(this)));
168 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
169 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C1));
170 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, JF, NULL, new WeaponGuardJammed(this)));
171 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
172 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C1));
173
174
175 //-----------------------------------------
176
177 // fire
178 m_fsm.AddTransition(new WeaponTransition(D0, __T__, Trigger_D0)); // fire.cocked
179 m_fsm.AddTransition(new WeaponTransition(Trigger_D0, _fin_, D0));
180 m_fsm.AddTransition(new WeaponTransition(Trigger_D0, _dto_, D0));
181 m_fsm.AddTransition(new WeaponTransition(Trigger_D0, _abt_, D0));
182
183 m_fsm.AddTransition(new WeaponTransition(C0, __T__, Trigger_C0)); // fire.cocked
184 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _fin_, D0));
185 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _dto_, D0));
186 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _abt_, D0));
187
188 m_fsm.AddTransition(new WeaponTransition(C1, __T__, Trigger_C1)); // fire.cocked
189 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _fin_, DF));
190 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _rto_, DF));
191 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _abt_, DF));
192
193 m_fsm.AddTransition(new WeaponTransition(DF, __T__, Trigger_DF)); // fire.cocked
194 m_fsm.AddTransition(new WeaponTransition(Trigger_DF, _fin_, DF));
195 m_fsm.AddTransition(new WeaponTransition(Trigger_DF, _dto_, DF));
196 m_fsm.AddTransition(new WeaponTransition(Trigger_DF, _abt_, DF));
197
198 m_fsm.AddTransition(new WeaponTransition(JF, __T__, Trigger_JF)); // fire.cocked
199 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _fin_, JF));
200 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _dto_, JF));
201 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _abt_, JF));
202
203
204 m_fsm.AddTransition(new WeaponTransition(JF, __TJ_, Trigger_C1J)); // fire.cocked
205 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _fin_, JF));
206 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _rto_, JF));
207 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _abt_, JF));
208
209 //---------------------------------------------
210
211 SetInitialState(D0);
212
213 SelectionBulletHide();
214 HideMagazine();
215
216 m_fsm.Start();
217 }
RPTAnimState
Definition Repeater.c:2
ref WeaponStableState DF
Definition Repeater.c:71
ref WeaponStableState D0
Definition Repeater.c:68

◆ InitStateMachine() [3/5]

override void Rifle_Base::InitStateMachine ( )
inlineprivate

Definition at line 106 of file RifleBoltFree_Base.c.

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 }
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition Guards.c:99
RBF_JAM_BU1_MA0
RBF_JAM_BU1_MA1
RBF_CLO_BU0_MA0
RBF_CLO_BU1_MA0
RBF_CLO_BU0_MA1
RBF_CLO_BU1_MA1
RBLAnimState
ref WeaponStableState C01
ref WeaponStableState JF1
ref WeaponStableState C11
ref WeaponStableState C10
ref WeaponStableState C00
ref WeaponStableState JF0
charging of weapon without ammo to be chambered
replace current magazine with new one
WeaponActionReloadTypes
Definition human.c:812

References RBF_CLO_BU0_MA0, RBF_CLO_BU0_MA1, RBF_CLO_BU1_MA0, RBF_CLO_BU1_MA1, RBF_JAM_BU1_MA0, RBF_JAM_BU1_MA1, and WeaponGuardHasAmmo().

◆ InitStateMachine() [4/5]

override void Rifle_Base::InitStateMachine ( )
inlineprivate

Definition at line 134 of file RifleBoltLock_Base.c.

135 {
136 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET)));
137 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET)));
138 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET)));
139 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET)));
140 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET_OPEN)));
141 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET_OPEN)));
142 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH)));
143
144 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED)));
145 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_UNIQUE_CLOSED)));
146
147 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED)));
148 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED)));//????
149
150 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START)));
151 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END)));
152
153 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL)));
154 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST)));
155 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM)));
156 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY)));
157
158 //m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
159
160 // setup state machine
161 // basic weapon states
162 // close-locked-jammed | nobullet-bullet | nomag-mag
163 // regexp: [CLJ][01][01]
164 C00 = new RBL_CLO_BU0_MA0(this, NULL, RBLAnimState.DEFAULT);
165 C10 = new RBL_CLO_BU1_MA0(this, NULL, RBLAnimState.DEFAULT);
166 C11 = new RBL_CLO_BU1_MA1(this, NULL, RBLAnimState.DEFAULT);
167 C01 = new RBL_CLO_BU0_MA1(this, NULL, RBLAnimState.DEFAULT);
168 O00 = new RBL_OPN_BU0_MA0(this, NULL, RBLAnimState.OPENED);
169 O01 = new RBL_OPN_BU0_MA1(this, NULL, RBLAnimState.OPENED);
170 JF0 = new RBL_JAM_BU1_MA0(this, NULL, RBLAnimState.JAMMED);
171 JF1 = new RBL_JAM_BU1_MA1(this, NULL, RBLAnimState.JAMMED);
172
173 // unstable (intermediate) states
174 WeaponCharging Mech_C00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
175 WeaponCharging Mech_C01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
176 WeaponCharging Mech_O00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
177 WeaponCharging Mech_O01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
178
179 WeaponCharging Mech_C10 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
180 WeaponCharging Mech_C11 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, GetWeaponSpecificCommand(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
181
182 WeaponStateBase Trigger_C00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY)); // cock without clip
183 WeaponStateBase Trigger_C10 = new WeaponFireLast(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL)); // cock with clip
184 WeaponFireAndChamberNext Trigger_C11 = new WeaponFireAndChamberNext(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
185 WeaponStateBase Trigger_C11L = new WeaponFireLast(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST));
186 WeaponStateBase Trigger_C01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
187 WeaponStateBase Trigger_O00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
188 WeaponStateBase Trigger_O01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
189 WeaponStateBase Trigger_JF0 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
190 WeaponStateBase Trigger_JF1 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
191
192 //Fire and jam
193 WeaponStateBase Trigger_C10J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM)); // cock with clip
194 WeaponStateBase Trigger_C11J = new WeaponFireToJam(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM));
195
196 // WeaponStateBase Trigger_C11J = new WeaponFire(this, NULL, WeaponActions.FIRE, GetWeaponSpecificCommand(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM));
197
198 WeaponStateBase Unjam_JF0 = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
199 WeaponStateBase Unjam_JF1 = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, GetWeaponSpecificCommand(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
200
201 WeaponChambering Chamber_C00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
202 WeaponChambering Chamber_C01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
203 WeaponChambering Chamber_O00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_UNIQUE_CLOSED));
204 WeaponChambering Chamber_O01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, GetWeaponSpecificCommand(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_UNIQUE_CLOSED));
205
206 WeaponAttachMagazine Attach_C00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET));
207 WeaponAttachMagazine Attach_C10 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET));
208 WeaponAttachMagazine Attach_O00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET_OPEN));//TODO Need add open animation
209 WeaponAttachMagazine Attach_JF0 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET));
210
211 WeaponReplacingMagAndChamberNext Reload_C11 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET));
212 WeaponReplacingMagAndChamberNext Reload_C01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET));
213 WeaponReplacingMagAndChamberNext Reload_O01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET_OPEN));//TODO Need add open animation
214 WeaponReplacingMagAndChamberNext Reload_JF1 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET));
215
216 WeaponDetachingMag Detach_C11 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
217 WeaponDetachingMag Detach_C01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
218 WeaponDetachingMag Detach_O01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
219 WeaponDetachingMag Detach_JF1 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, GetWeaponSpecificCommand(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH));
220
221 //WeaponStateBase chmMag = new WeaponChamberFromAttMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
222
223 // events
224 WeaponEventBase __M__ = new WeaponEventMechanism;
225 WeaponEventBase __T__ = new WeaponEventTrigger;
226 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
227 WeaponEventBase __U__ = new WeaponEventUnjam;
228 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
229 WeaponEventBase __A__ = new WeaponEventAttachMagazine;
230 WeaponEventBase __D__ = new WeaponEventDetachMagazine;
231 WeaponEventBase __S__ = new WeaponEventSwapMagazine;
232 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
233 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
234 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
235 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
236
237 m_fsm = new WeaponFSM();
238
239 // order: Discharged-Charged | nobullet-bullet | nomag-mag
240 // charging
241 m_fsm.AddTransition(new WeaponTransition(C00, __M__, Mech_C00)); // charge from dischg nobullet nomag
242 m_fsm.AddTransition(new WeaponTransition(Mech_C00, _fin_, C00));
243 m_fsm.AddTransition(new WeaponTransition(Mech_C00, _abt_, C00));
244
245 m_fsm.AddTransition(new WeaponTransition(C10, __M__, Mech_C10)); // charge from bullet nomag
246 m_fsm.AddTransition(new WeaponTransition(Mech_C10, _fin_, C00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
247 m_fsm.AddTransition(new WeaponTransition(Mech_C10, _fin_, C10));
248 m_fsm.AddTransition(new WeaponTransition(Mech_C10, _abt_, C00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
249 m_fsm.AddTransition(new WeaponTransition(Mech_C10, _abt_, C10));
250
251 m_fsm.AddTransition(new WeaponTransition(C11, __M__, Mech_C11)); // charge from dischg nobullet nomag
252 m_fsm.AddTransition(new WeaponTransition(Mech_C11, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
253 m_fsm.AddTransition(new WeaponTransition(Mech_C11, _fin_, C11));
254 m_fsm.AddTransition(new WeaponTransition(Mech_C11, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
255 m_fsm.AddTransition(new WeaponTransition(Mech_C11, _abt_, C11));
256
257
258 m_fsm.AddTransition(new WeaponTransition(C01, __M__, Mech_C01)); // charge from dischg nobullet nomag
259 m_fsm.AddTransition(new WeaponTransition(Mech_C01, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
260 m_fsm.AddTransition(new WeaponTransition(Mech_C01, _fin_, C11));
261 m_fsm.AddTransition(new WeaponTransition(Mech_C01, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
262 m_fsm.AddTransition(new WeaponTransition(Mech_C01, _abt_, C11));
263
264 m_fsm.AddTransition(new WeaponTransition(O00, __M__, Mech_O00)); // charge from dischg nobullet nomag
265 m_fsm.AddTransition(new WeaponTransition(Mech_O00, _fin_, O00, NULL, new WeaponGuardWeaponOpen(this)));
266 m_fsm.AddTransition(new WeaponTransition(Mech_O00, _fin_, C00));
267 m_fsm.AddTransition(new WeaponTransition(Mech_O00, _abt_, O00, NULL, new WeaponGuardWeaponOpen(this)));
268 m_fsm.AddTransition(new WeaponTransition(Mech_O00, _abt_, C00));
269
270 m_fsm.AddTransition(new WeaponTransition(O01, __M__, Mech_O01)); // charge from dischg nobullet nomag
271 m_fsm.AddTransition(new WeaponTransition(Mech_O01, _fin_, O01, NULL, new WeaponGuardWeaponOpen(this)));
272 m_fsm.AddTransition(new WeaponTransition(Mech_O01, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
273 m_fsm.AddTransition(new WeaponTransition(Mech_O01, _fin_, C11));
274 m_fsm.AddTransition(new WeaponTransition(Mech_O01, _abt_, O01, NULL, new WeaponGuardWeaponOpen(this)));
275 m_fsm.AddTransition(new WeaponTransition(Mech_O01, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
276 m_fsm.AddTransition(new WeaponTransition(Mech_O01, _abt_, C11));
277
278 // fire
279 m_fsm.AddTransition(new WeaponTransition(C00, __T__, Trigger_C00));
280 m_fsm.AddTransition(new WeaponTransition(Trigger_C00, _fin_, C00));
281 m_fsm.AddTransition(new WeaponTransition(Trigger_C00, _dto_, C00));
282 m_fsm.AddTransition(new WeaponTransition(Trigger_C00, _abt_, C00));
283
284 m_fsm.AddTransition(new WeaponTransition(C01, __T__, Trigger_C01));
285 m_fsm.AddTransition(new WeaponTransition(Trigger_C01, _fin_, C01));
286 m_fsm.AddTransition(new WeaponTransition(Trigger_C01, _dto_, C01));
287 m_fsm.AddTransition(new WeaponTransition(Trigger_C01, _abt_, C01));
288
289 m_fsm.AddTransition(new WeaponTransition(C10, __T__, Trigger_C10));
290 m_fsm.AddTransition(new WeaponTransition(Trigger_C10, _fin_, C00));
291 m_fsm.AddTransition(new WeaponTransition(Trigger_C10, _rto_, C00));
292 m_fsm.AddTransition(new WeaponTransition(Trigger_C10, _abt_, C00));
293
294 m_fsm.AddTransition(new WeaponTransition(C11, __T__, Trigger_C11, NULL, new WeaponGuardHasAmmo(this)));
295 m_fsm.AddTransition(new WeaponTransition(Trigger_C11, _fin_, C11));
296 m_fsm.AddTransition(new WeaponTransition(Trigger_C11, _rto_, C11));
297 m_fsm.AddTransition(new WeaponTransition(Trigger_C11, _abt_, C11));
298
299 m_fsm.AddTransition(new WeaponTransition(C11, __T__, Trigger_C11L));
300 m_fsm.AddTransition(new WeaponTransition(Trigger_C11L, _fin_, O01));
301 m_fsm.AddTransition(new WeaponTransition(Trigger_C11L, _rto_, O01));
302 m_fsm.AddTransition(new WeaponTransition(Trigger_C11L, _abt_, O01));
303
304 m_fsm.AddTransition(new WeaponTransition(O00, __T__, Trigger_O00));
305 m_fsm.AddTransition(new WeaponTransition(Trigger_O00, _fin_, O00));
306 m_fsm.AddTransition(new WeaponTransition(Trigger_O00, _dto_, O00));
307 m_fsm.AddTransition(new WeaponTransition(Trigger_O00, _abt_, O00));
308
309 m_fsm.AddTransition(new WeaponTransition(O01, __T__, Trigger_O01));
310 m_fsm.AddTransition(new WeaponTransition(Trigger_O01, _fin_, O01));
311 m_fsm.AddTransition(new WeaponTransition(Trigger_O01, _dto_, O01));
312 m_fsm.AddTransition(new WeaponTransition(Trigger_O01, _abt_, O01));
313
314 m_fsm.AddTransition(new WeaponTransition(JF0, __T__, Trigger_JF0)); // opened fire.uncocked w mag
315 m_fsm.AddTransition(new WeaponTransition(Trigger_JF0, _fin_, JF0));
316 m_fsm.AddTransition(new WeaponTransition(Trigger_JF0, _dto_, JF0));
317 m_fsm.AddTransition(new WeaponTransition(Trigger_JF0, _abt_, JF0));
318
319 m_fsm.AddTransition(new WeaponTransition(JF1, __T__, Trigger_JF1)); // opened fire.uncocked w mag
320 m_fsm.AddTransition(new WeaponTransition(Trigger_JF1, _fin_, JF1));
321 m_fsm.AddTransition(new WeaponTransition(Trigger_JF1, _dto_, JF1));
322 m_fsm.AddTransition(new WeaponTransition(Trigger_JF1, _abt_, JF1));
323
324
325 m_fsm.AddTransition(new WeaponTransition(C10, __TJ_, Trigger_C10J));
326 m_fsm.AddTransition(new WeaponTransition(Trigger_C10J, _fin_, JF0));
327 m_fsm.AddTransition(new WeaponTransition(Trigger_C10J, _rto_, JF0));
328 m_fsm.AddTransition(new WeaponTransition(Trigger_C10J, _abt_, JF0));
329
330 m_fsm.AddTransition(new WeaponTransition(C11, __TJ_, Trigger_C11J));
331 m_fsm.AddTransition(new WeaponTransition(Trigger_C11J, _fin_, JF1));
332 m_fsm.AddTransition(new WeaponTransition(Trigger_C11J, _rto_, JF1));
333 m_fsm.AddTransition(new WeaponTransition(Trigger_C11J, _abt_, JF1));
334
335
336 // load cartridge
337 m_fsm.AddTransition(new WeaponTransition(C00, __L__, Chamber_C00)); // chamber from closed=1
338 m_fsm.AddTransition(new WeaponTransition(Chamber_C00, _fin_, O00, NULL, new WeaponGuardWeaponOpen(this)));
339 m_fsm.AddTransition(new WeaponTransition(Chamber_C00, _fin_, C00, NULL, new WeaponGuardChamberEmpty(this)));
340 m_fsm.AddTransition(new WeaponTransition(Chamber_C00, _fin_, C10));
341 m_fsm.AddTransition(new WeaponTransition(Chamber_C00, _abt_, O00, NULL, new WeaponGuardWeaponOpen(this)));
342 m_fsm.AddTransition(new WeaponTransition(Chamber_C00, _abt_, C00, NULL, new WeaponGuardChamberEmpty(this)));
343 m_fsm.AddTransition(new WeaponTransition(Chamber_C00, _abt_, C10));
344
345 m_fsm.AddTransition(new WeaponTransition(C01, __L__, Chamber_C01)); // chamber from closed charged
346 m_fsm.AddTransition(new WeaponTransition(Chamber_C01, _fin_, O01, NULL, new WeaponGuardWeaponOpen(this)));
347 m_fsm.AddTransition(new WeaponTransition(Chamber_C01, _fin_, C01, NULL, new WeaponGuardChamberEmpty(this)));
348 m_fsm.AddTransition(new WeaponTransition(Chamber_C01, _fin_, C11));
349 m_fsm.AddTransition(new WeaponTransition(Chamber_C01, _abt_, O01, NULL, new WeaponGuardWeaponOpen(this)));
350 m_fsm.AddTransition(new WeaponTransition(Chamber_C01, _abt_, C01, NULL, new WeaponGuardChamberEmpty(this)));
351 m_fsm.AddTransition(new WeaponTransition(Chamber_C01, _abt_, C11));
352
353 m_fsm.AddTransition(new WeaponTransition(O00, __L__, Chamber_O00)); // chamber from closed charged
354 m_fsm.AddTransition(new WeaponTransition(Chamber_O00, _fin_, O00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
355 m_fsm.AddTransition(new WeaponTransition(Chamber_O00, _fin_, C10));
356 m_fsm.AddTransition(new WeaponTransition(Chamber_O00, _abt_, O00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
357 m_fsm.AddTransition(new WeaponTransition(Chamber_O00, _abt_, C10));
358
359 m_fsm.AddTransition(new WeaponTransition(O01, __L__, Chamber_O01)); // chamber from closed charged
360 m_fsm.AddTransition(new WeaponTransition(Chamber_O01, _fin_, O01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
361 m_fsm.AddTransition(new WeaponTransition(Chamber_O01, _fin_, C11));
362 m_fsm.AddTransition(new WeaponTransition(Chamber_O01, _abt_, O01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
363 m_fsm.AddTransition(new WeaponTransition(Chamber_O01, _abt_, C11));
364
365 // attach magazine (no mag in weapon)
366 m_fsm.AddTransition(new WeaponTransition(C00, __A__, Attach_C00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0
367 m_fsm.AddTransition(new WeaponTransition(Attach_C00, _fin_, C00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
368 m_fsm.AddTransition(new WeaponTransition(Attach_C00, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
369 m_fsm.AddTransition(new WeaponTransition(Attach_C00, _fin_, C11));
370 m_fsm.AddTransition(new WeaponTransition(Attach_C00, _abt_, C00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
371 m_fsm.AddTransition(new WeaponTransition(Attach_C00, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
372 m_fsm.AddTransition(new WeaponTransition(Attach_C00, _abt_, C11));
373
374 m_fsm.AddTransition(new WeaponTransition(C10, __A__, Attach_C10, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b1/m0
375 m_fsm.AddTransition(new WeaponTransition(Attach_C10, _fin_, C11, NULL, new WeaponGuardHasMag(this)));
376 m_fsm.AddTransition(new WeaponTransition(Attach_C10, _fin_, C10));
377 m_fsm.AddTransition(new WeaponTransition(Attach_C10, _abt_, C11, NULL, new WeaponGuardHasMag(this)));
378 m_fsm.AddTransition(new WeaponTransition(Attach_C10, _abt_, C10));
379
380 m_fsm.AddTransition(new WeaponTransition(O00, __A__, Attach_O00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0
381 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _fin_, O00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
382 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _fin_, O01, NULL, new WeaponGuardWeaponOpen(this)));
383 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
384 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _fin_, C11));
385 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _abt_, O00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
386 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _abt_, O01, NULL, new WeaponGuardWeaponOpen(this)));
387 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
388 m_fsm.AddTransition(new WeaponTransition(Attach_O00, _abt_, C11));
389
390 m_fsm.AddTransition(new WeaponTransition(JF0, __A__, Attach_JF0, NULL, new WeaponGuardCanAttachMag(this))); // attach from JAM/b1/m0
391 m_fsm.AddTransition(new WeaponTransition(Attach_JF0, _fin_, JF1, NULL, new WeaponGuardHasMag(this)));
392 m_fsm.AddTransition(new WeaponTransition(Attach_JF0, _fin_, JF0));
393 m_fsm.AddTransition(new WeaponTransition(Attach_JF0, _abt_, JF1, NULL, new WeaponGuardHasMag(this)));
394 m_fsm.AddTransition(new WeaponTransition(Attach_JF0, _abt_, JF0));
395
396
397 // replace magazine
398 m_fsm.AddTransition(new WeaponTransition(C11, __S__, Reload_C11, NULL, new WeaponGuardCanSwapMag(this))); // swap in Chg/b1/m1
399 m_fsm.AddTransition(new WeaponTransition(Reload_C11, _fin_, C11, NULL, new WeaponGuardHasMag(this)));
400 m_fsm.AddTransition(new WeaponTransition(Reload_C11, _fin_, C10));
401 m_fsm.AddTransition(new WeaponTransition(Reload_C11, _abt_, C11, NULL, new WeaponGuardHasMag(this)));
402 m_fsm.AddTransition(new WeaponTransition(Reload_C11, _abt_, C10));
403
404
405 m_fsm.AddTransition(new WeaponTransition(C01, __S__, Reload_C01, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b0/m1
406 m_fsm.AddTransition(new WeaponTransition(Reload_C01, _fin_, C11, NULL, new WeaponGuardCurrentChamberFull(this)));
407 m_fsm.AddTransition(new WeaponTransition(Reload_C01, _fin_, C01, NULL, new WeaponGuardHasMag(this)));
408 m_fsm.AddTransition(new WeaponTransition(Reload_C01, _fin_, C00));
409 m_fsm.AddTransition(new WeaponTransition(Reload_C01, _abt_, C11, NULL, new WeaponGuardCurrentChamberFull(this)));
410 m_fsm.AddTransition(new WeaponTransition(Reload_C01, _abt_, C01, NULL, new WeaponGuardHasMag(this)));
411 m_fsm.AddTransition(new WeaponTransition(Reload_C01, _abt_, C00));
412
413
414 m_fsm.AddTransition(new WeaponTransition(O01, __S__, Reload_O01, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b0/m1
415 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _fin_, O00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
416 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _fin_, O01, NULL, new WeaponGuardWeaponOpen(this)));
417 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
418 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _fin_, C11));
419 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _abt_, O00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
420 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _abt_, O01, NULL, new WeaponGuardWeaponOpen(this)));
421 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
422 m_fsm.AddTransition(new WeaponTransition(Reload_O01, _abt_, C11));
423
424 m_fsm.AddTransition(new WeaponTransition(JF1, __S__, Reload_JF1, NULL, new WeaponGuardCanSwapMag(this))); // swap in JAM/b1/m1
425 m_fsm.AddTransition(new WeaponTransition(Reload_JF1, _fin_, JF1, NULL, new WeaponGuardHasMag(this)));
426 m_fsm.AddTransition(new WeaponTransition(Reload_JF1, _fin_, JF0));
427 m_fsm.AddTransition(new WeaponTransition(Reload_JF1, _abt_, JF1, NULL, new WeaponGuardHasMag(this)));
428 m_fsm.AddTransition(new WeaponTransition(Reload_JF1, _abt_, JF0));
429
430 // @TODO: abort in jam
431
432 // detach magazine
433 m_fsm.AddTransition(new WeaponTransition(C11, __D__, Detach_C11, NULL, new WeaponGuardCanDetachMag(this))); // detach from Chg/b1/m1
434 m_fsm.AddTransition(new WeaponTransition(Detach_C11, _fin_, C11, NULL, new WeaponGuardHasMag(this)));
435 m_fsm.AddTransition(new WeaponTransition(Detach_C11, _fin_, C10));
436 m_fsm.AddTransition(new WeaponTransition(Detach_C11, _abt_, C11, NULL, new WeaponGuardHasMag(this)));
437 m_fsm.AddTransition(new WeaponTransition(Detach_C11, _abt_, C10));
438
439 m_fsm.AddTransition(new WeaponTransition(C01, __D__, Detach_C01, NULL, new WeaponGuardCanDetachMag(this))); // detach from Chg/b0/m1
440 m_fsm.AddTransition(new WeaponTransition(Detach_C01, _fin_, C01, NULL, new WeaponGuardHasMag(this)));
441 m_fsm.AddTransition(new WeaponTransition(Detach_C01, _fin_, C00));
442 m_fsm.AddTransition(new WeaponTransition(Detach_C01, _abt_, C01, NULL, new WeaponGuardHasMag(this)));
443 m_fsm.AddTransition(new WeaponTransition(Detach_C01, _abt_, C00));
444
445 m_fsm.AddTransition(new WeaponTransition(O01, __D__, Detach_O01, NULL, new WeaponGuardCanDetachMag(this))); // detach from Dic/b0/m1
446 m_fsm.AddTransition(new WeaponTransition(Detach_O01, _fin_, O01, NULL, new WeaponGuardHasMag(this)));
447 m_fsm.AddTransition(new WeaponTransition(Detach_O01, _fin_, O00));
448 m_fsm.AddTransition(new WeaponTransition(Detach_O01, _abt_, O01, NULL, new WeaponGuardHasMag(this)));
449 m_fsm.AddTransition(new WeaponTransition(Detach_O01, _abt_, O00));
450
451 m_fsm.AddTransition(new WeaponTransition(JF1, __D__, Detach_JF1, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b1/m1 jammed
452 m_fsm.AddTransition(new WeaponTransition(Detach_JF1, _fin_, JF1, NULL, new WeaponGuardHasMag(this)));
453 m_fsm.AddTransition(new WeaponTransition(Detach_JF1, _fin_, JF0));
454 m_fsm.AddTransition(new WeaponTransition(Detach_JF1, _abt_, JF1, NULL, new WeaponGuardHasMag(this)));
455 m_fsm.AddTransition(new WeaponTransition(Detach_JF1, _abt_, JF0));
456
457
458 // unjam
459 m_fsm.AddTransition(new WeaponTransition(JF0, __U__, Unjam_JF0)); // unjam nomag
460 m_fsm.AddTransition(new WeaponTransition(Unjam_JF0, _fin_, JF0, NULL, new WeaponGuardJammed(this)));
461 m_fsm.AddTransition(new WeaponTransition(Unjam_JF0, _fin_, C00));
462 m_fsm.AddTransition(new WeaponTransition(Unjam_JF0, _abt_, JF0, NULL, new WeaponGuardJammed(this)));
463 m_fsm.AddTransition(new WeaponTransition(Unjam_JF0, _abt_, C00));
464
465 m_fsm.AddTransition(new WeaponTransition(JF1, __U__, Unjam_JF1)); // unjam with mag with ammo
466 m_fsm.AddTransition(new WeaponTransition(Unjam_JF1, _fin_, JF1, NULL, new WeaponGuardJammed(this)));
467 m_fsm.AddTransition(new WeaponTransition(Unjam_JF1, _fin_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
468 m_fsm.AddTransition(new WeaponTransition(Unjam_JF1, _fin_, C11));
469 m_fsm.AddTransition(new WeaponTransition(Unjam_JF1, _abt_, JF1, NULL, new WeaponGuardJammed(this)));
470 m_fsm.AddTransition(new WeaponTransition(Unjam_JF1, _abt_, C01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
471 m_fsm.AddTransition(new WeaponTransition(Unjam_JF1, _abt_, C11));
472
473 SetInitialState(C00);
474
475 SelectionBulletHide();
476 HideMagazine();
477
478 m_fsm.Start();
479 }
RBL_CLO_BU0_MA0
RBL_OPN_BU0_MA1
RBL_CLO_BU0_MA1
RBL_JAM_BU1_MA0
RBL_CLO_BU1_MA0
RBL_CLO_BU1_MA1
RBL_OPN_BU0_MA0
RBL_JAM_BU1_MA1
ref WeaponStableState O01
ref WeaponStableState O00

References RBL_CLO_BU0_MA0, RBL_CLO_BU0_MA1, RBL_CLO_BU1_MA0, RBL_CLO_BU1_MA1, RBL_JAM_BU1_MA0, RBL_JAM_BU1_MA1, RBL_OPN_BU0_MA0, RBL_OPN_BU0_MA1, WeaponGuardHasAmmo(), and WeaponGuardWeaponOpen().

◆ InitStateMachine() [5/5]

override void Rifle_Base::InitStateMachine ( )
inlineprivate

Definition at line 71 of file RifleSingleShot_Base.c.

72 {
73 // setup abilities
74 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
75 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
76 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
77 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END));
78 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
79 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
80
81 // setup state machine
82 // basic weapon states
83 WeaponStableState E = new RSSEmpty(this, NULL, RSSAnimState.DEFAULT);
84 WeaponStableState F = new RSSFireout(this, NULL, RSSAnimState.DEFAULT);
85 WeaponStableState J = new RSSJammed(this, NULL, RSSAnimState.DEFAULT);
86 WeaponStableState L = new RSSLoaded(this, NULL, RSSAnimState.DEFAULT);
87 // unstable (intermediate) states
88 WeaponStateBase Mech_F = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
89 WeaponStateBase Mech_L = new WeaponEjectBullet(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
90
91 WeaponChambering Chamber_E = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
92 WeaponChambering Chamber_F = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
93 //WeaponStateBase Chamber_L = new RifleReChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
94
98
100
102
103 // events
104 WeaponEventBase __M__ = new WeaponEventMechanism;
105 WeaponEventBase __T__ = new WeaponEventTrigger;
106 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
107 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
108 WeaponEventBase __U__ = new WeaponEventUnjam;
109 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
110 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
111 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
112
113 m_fsm = new WeaponFSM();
114 // charging
115 m_fsm.AddTransition(new WeaponTransition(E, __M__, Mech_F));
116 m_fsm.AddTransition(new WeaponTransition(F, __M__, Mech_F));
117 m_fsm.AddTransition(new WeaponTransition(Mech_F, _fin_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
118 m_fsm.AddTransition(new WeaponTransition(Mech_F, _fin_, E));
119 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
120 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, E));
121
122 // eject good cartridge
123 m_fsm.AddTransition(new WeaponTransition(L, __M__, Mech_L));
124 m_fsm.AddTransition(new WeaponTransition(Mech_L, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
125 m_fsm.AddTransition(new WeaponTransition(Mech_L, _fin_, L));
126 m_fsm.AddTransition(new WeaponTransition(Mech_L, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
127 m_fsm.AddTransition(new WeaponTransition(Mech_L, _abt_, L));
128
129 // load bullet
130 m_fsm.AddTransition(new WeaponTransition(E, __L__, Chamber_E));
131 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
132 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _fin_, L));
133 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
134 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _abt_, L));
135
136
137 m_fsm.AddTransition(new WeaponTransition(F, __L__, Chamber_F));
138 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _fin_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
139 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
140 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _fin_, L));
141 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
142 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
143 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, L));
144
145
146 // fire
147 m_fsm.AddTransition(new WeaponTransition(E, __T__, Trigger_E)); // fire cocked
148 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _fin_, E));
149 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _dto_, E));
150 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _abt_, E));
151
152 m_fsm.AddTransition(new WeaponTransition(F, __T__, Trigger_F)); // fire uncocked
153 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _fin_, F));
154 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _dto_, F));
155 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _abt_, F));
156
157 m_fsm.AddTransition(new WeaponTransition(L, __T__, Trigger_L)); // a) fire if not jammed
158 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _fin_, F));
159 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _abt_, F));
160
161 m_fsm.AddTransition(new WeaponTransition(L, __TJ_, Trigger_LJ)); // a) fire if not jammed
162 m_fsm.AddTransition(new WeaponTransition(Trigger_LJ, _fin_, J));
163 m_fsm.AddTransition(new WeaponTransition(Trigger_LJ, _abt_, J));
164
165 // unjam
166 m_fsm.AddTransition(new WeaponTransition(J, __U__, Unjam_J));
167 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _fin_, J, NULL, new WeaponGuardJammed(this)));
168 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _fin_, E));
169
170 // initial state setup
171 bool empty = true;
172 bool discharged = false; // @TODO:
174 if (empty)
175 {
176 if (!discharged)
177 init_state = E;
178 }
179 else
180 {
181 init_state = L; // can init state == load/jammed?
182 }
183 SetInitialState(init_state);
184
185 SelectionBulletHide();
186
187 m_fsm.Start();
188 }
@ E
EMPTY.
@ L
LOADED.
@ F
FIRED.
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Definition Crossbow.c:27

References E, F, and L.

◆ OnDebugSpawn()

override void Rifle_Base::OnDebugSpawn ( )
inlineprivate

Definition at line 266 of file SKS.c.

267 {
268 super.OnDebugSpawn();
269
270 GameInventory inventory = GetInventory();
271 inventory.CreateInInventory("PUScopeOptic");
272 inventory.CreateInInventory("SKS_Bayonet");
273 }
script counterpart to engine's class Inventory
Definition Inventory.c:79

◆ RifleBoltFree_Base()

void Rifle_Base::RifleBoltFree_Base ( )
inlineprivate

Definition at line 101 of file RifleBoltFree_Base.c.

102 {
103 }

◆ RifleBoltLock_Base()

void Rifle_Base::RifleBoltLock_Base ( )
inlineprivate

Definition at line 130 of file RifleBoltLock_Base.c.

131 {
132 }

◆ RifleSingleShot_Base()

void Rifle_Base::RifleSingleShot_Base ( )
inlineprivate

Definition at line 67 of file RifleSingleShot_Base.c.

68 {
69 }

◆ SetActions() [1/4]

override void Rifle_Base::SetActions ( )
inlineprivate

Definition at line 256 of file SKS.c.

257 {
258 super.SetActions();
260
263 }
void AddAction(typename actionName)
void RemoveAction(typename actionName)
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()

References AddAction(), FirearmActionLoadBulletQuick(), and RemoveAction().

◆ SetActions() [2/4]

override void Rifle_Base::SetActions ( )
inlineprivate

Definition at line 224 of file Repeater.c.

225 {
226 super.SetActions();
228
231
232 }

References AddAction(), FirearmActionLoadBulletQuick(), and RemoveAction().

◆ SetActions() [3/4]

override void Rifle_Base::SetActions ( )
inlineprivate

Definition at line 377 of file RifleBoltFree_Base.c.

378 {
379 super.SetActions();
381 //AddAction(ActionAdvancedDetachMagazine);
382 }

References AddAction().

◆ SetActions() [4/4]

override void Rifle_Base::SetActions ( )
inlineprivate

Definition at line 494 of file RifleBoltLock_Base.c.

495 {
496 super.SetActions();
498 //AddAction(ActionAdvancedDetachMagazine);
499 }

References AddAction().

◆ SpawnRecoilObject()

override RecoilBase Rifle_Base::SpawnRecoilObject ( )
inlineprivate

Definition at line 76 of file SKS.c.

77 {
78 return new SKSRecoil(this);
79 }

Member Data Documentation

◆ C0

ref WeaponStableState Rifle_Base::C0
private

Definition at line 71 of file SKS.c.

◆ C00

ref WeaponStableState Rifle_Base::C00
private

Definition at line 94 of file RifleBoltFree_Base.c.

◆ C01

ref WeaponStableState Rifle_Base::C01
private

Definition at line 97 of file RifleBoltFree_Base.c.

◆ C1

ref WeaponStableState Rifle_Base::C1
private

Definition at line 72 of file SKS.c.

◆ C10

ref WeaponStableState Rifle_Base::C10
private

Definition at line 95 of file RifleBoltFree_Base.c.

◆ C11

ref WeaponStableState Rifle_Base::C11
private

Definition at line 96 of file RifleBoltFree_Base.c.

◆ D0

ref WeaponStableState Rifle_Base::D0
private

Definition at line 68 of file Repeater.c.

◆ DF

ref WeaponStableState Rifle_Base::DF
private

Definition at line 71 of file Repeater.c.

◆ JF

ref WeaponStableState Rifle_Base::JF
private

Definition at line 74 of file SKS.c.

◆ JF0

ref WeaponStableState Rifle_Base::JF0
private

Definition at line 98 of file RifleBoltFree_Base.c.

◆ JF1

ref WeaponStableState Rifle_Base::JF1
private

Definition at line 99 of file RifleBoltFree_Base.c.

◆ L0

ref WeaponStableState Rifle_Base::L0
private

Definition at line 73 of file SKS.c.

◆ O00

ref WeaponStableState Rifle_Base::O00
private

Definition at line 125 of file RifleBoltLock_Base.c.

◆ O01

ref WeaponStableState Rifle_Base::O01
private

Definition at line 126 of file RifleBoltLock_Base.c.


The documentation for this class was generated from the following files: