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