DayZ 1.24
Loading...
Searching...
No Matches
SKS.c
Go to the documentation of this file.
2{
3 DEFAULT = 0,
4 OPENED = 1,
5 JAMMED = 2,
6};
7
9{
10 UNKNOWN = 0,
11 SKS_CLO_BU0 = 1,
12 SKS_CLO_BU1 = 2,
13 SKS_OPN_BU0 = 3,
14 SKS_JAM_BU1 = 4
15}
16
18{
19 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { close nobull"); super.OnEntry(e); }
20 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } close nobull"); }
21 override int GetCurrentStateID() { return SKSStableStateID.SKS_CLO_BU0; }
22 override bool HasBullet() { return false; }
23 override bool HasMagazine() { return false; }
24 override bool IsJammed() { return false; }
25 override bool IsRepairEnabled() { return true; }
27
28};
30{
31 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { close bullet"); super.OnEntry(e); }
32 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } close bullet"); }
33 override int GetCurrentStateID() { return SKSStableStateID.SKS_CLO_BU1; }
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) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { open nobull"); m_weapon.SetWeaponOpen(true); super.OnEntry(e); }
43 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } open nobull"); }
44 override int GetCurrentStateID() { return SKSStableStateID.SKS_OPN_BU0; }
45 override bool HasBullet() { return false; }
46 override bool HasMagazine() { return false; }
47 override bool IsJammed() { return false; }
48 override bool IsBoltOpen() { return true; }
49 override bool IsRepairEnabled() { return true; }
51};
53{
54 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { jammed bullet"); super.OnEntry(e); }
55 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } jammed bullet"); }
56 override int GetCurrentStateID() { return SKSStableStateID.SKS_JAM_BU1; }
57 override bool HasBullet() { return true; }
58 override bool HasMagazine() { return false; }
59 override bool IsJammed() { return true; }
60 override bool IsBoltOpen() { return true; }
61 override bool IsRepairEnabled() { return true; }
63};
64
69class SKS_Base extends Rifle_Base
70{
75
77 {
78 return new SKSRecoil(this);
79 }
80
81 override void InitStateMachine()
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 }
247
248 override bool CanEnterIronsights()
249 {
250 ItemOptics optic = GetAttachedOptics();
251 if (optic && PUScopeOptic.Cast(optic))
252 return true;
253 return super.CanEnterIronsights();
254 }
255
256 override void SetActions()
257 {
258 super.SetActions();
260
263 }
264
265 //Debug menu Spawn Ground Special
266 override void OnDebugSpawn()
267 {
268 super.OnDebugSpawn();
269
270 GameInventory inventory = GetInventory();
271 inventory.CreateInInventory("PUScopeOptic");
272 inventory.CreateInInventory("SKS_Bayonet");
273 }
274};
void wpnPrint(string s)
Definition Debug.c:1
void AddAction(typename actionName)
void RemoveAction(typename actionName)
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
void WeaponGuardWeaponOpen(Weapon_Base w=NULL)
Definition Guards.c:604
UNKNOWN
Definition SKS.c:20
SKS_JAM_BU1
Definition SKS.c:24
SKS_CLO_BU0
Definition SKS.c:21
SKSStableStateID
Definition SKS.c:9
SKSAnimState
Definition SKS.c:2
@ OPENED
Definition SKS.c:4
@ DEFAULT
default weapon state, closed and discharged
Definition SKS.c:3
@ JAMMED
Definition SKS.c:5
SKS_CLO_BU1
Definition SKS.c:22
SKS_OPN_BU0
Definition SKS.c:23
class SSPFireout extends WeaponStableState OnEntry
enum FSMTransition WeaponTransition
MuzzleState
ref array< MuzzleState > m_muzzleHasBullet
pair ( action, actionType )
Definition Weapon_Base.c:5
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool IsWeaponLogEnable()
Definition Debug.c:799
base for rifles @NOTE name copies config base class
Definition SKS.c:70
ref WeaponStableState L0
Definition SKS.c:73
override void OnDebugSpawn()
Definition SKS.c:266
ref WeaponStableState C0
Definition SKS.c:71
ref WeaponStableState JF
Definition SKS.c:74
override bool CanEnterIronsights()
Definition SKS.c:248
ref WeaponStableState C1
Definition SKS.c:72
override RecoilBase SpawnRecoilObject()
Definition SKS.c:76
override void SetActions()
Definition SKS.c:256
override void InitStateMachine()
Definition SKS.c:81
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine
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 IsBoltOpen()
Definition SKS.c:48
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)
Definition SKS.c:31
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()
Definition SKS.c:60
override void InitMuzzleArray()
Definition SKS.c:62
override bool HasMagazine()
Definition SKS.c:58
override bool IsRepairEnabled()
Definition SKS.c:61
override void OnEntry(WeaponEventBase e)
Definition SKS.c:54
override int GetCurrentStateID()
Definition SKS.c:56
override bool IsJammed()
Definition SKS.c:59
override bool HasBullet()
Definition SKS.c:57
override void OnExit(WeaponEventBase e)
Definition SKS.c:55
unjam submachine
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionUnjammingTypes
Definition human.c:892
WeaponActionFireTypes
Definition human.c:900