DayZ 1.24
Loading...
Searching...
No Matches
MP133.c
Go to the documentation of this file.
2{
3 DEFAULT = 0,
4};
5
7{
8 UNKNOWN = 0,
9 Empty = 1,
10 Fireout = 2,
11 Loaded = 3,
12 Jammed = 4,
13}
14
16{
17 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { Empty E"); super.OnEntry(e); }
18 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } Empty E"); }
19 override int GetCurrentStateID() { return PumpShotgunStableStateID.Empty; }
20 override bool HasBullet() { return false; }
21 override bool HasMagazine() { return false; }
22 override bool IsJammed() { return false; }
23 override bool IsRepairEnabled() { return true; }
25};
27{
28 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { Fireout F"); super.OnEntry(e); }
29 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } Fireout F"); }
30 override int GetCurrentStateID() { return PumpShotgunStableStateID.Fireout; }
31 override bool HasBullet() { return true; }
32 override bool HasMagazine() { return false; }
33 override bool IsJammed() { return false; }
34 override bool IsRepairEnabled() { return true; }
36};
38{
39 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { Loaded C"); super.OnEntry(e); }
40 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } Loaded C"); }
41 override int GetCurrentStateID() { return PumpShotgunStableStateID.Loaded; }
42 override bool HasBullet() { return true; }
43 override bool HasMagazine() { return false; }
44 override bool IsJammed() { return false; }
45 override bool IsRepairEnabled() { return true; }
47};
49{
50 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { Jammed L_J"); super.OnEntry(e); }
51 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } Jammed L_J"); }
52 override int GetCurrentStateID() { return PumpShotgunStableStateID.Jammed; }
53 override bool HasBullet() { return true; }
54 override bool HasMagazine() { return false; }
55 override bool IsJammed() { return true; }
56 override bool IsBoltOpen() { return true; }
57 override bool IsRepairEnabled() { return true; }
59};
60
65{
70
72 {
73 }
74
76 {
77 return new Mp133Recoil(this);
78 }
79
80 override void InitStateMachine()
81 {
82 // setup abilities
83 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
84 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
85 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END));
86
87 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
88 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
89
90 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED));
91 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED));
92 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE));
93
94 // basic weapon states
95 E = new PumpShotgunEmpty(this, NULL, PumpShotgunAnimState.DEFAULT);
96 F = new PumpShotgunFireout(this, NULL, PumpShotgunAnimState.DEFAULT);
97 L = new PumpShotgunLoaded(this, NULL, PumpShotgunAnimState.DEFAULT);
98 J = new PumpShotgunJammed(this, NULL, PumpShotgunAnimState.DEFAULT);
99 //--------------------------------------------------------------------------------------
100 WeaponStateBase Mech_E = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
101 WeaponStateBase Mech_F = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
102 WeaponStateBase Mech_L = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
103
104 LoopedChamberingEjectLast Chamber_E = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
105 LoopedChamberingEjectLast Chamber_F = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
106 LoopedChamberingEjectLast Chamber_L = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
107
109
114
116
117 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
118 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
119 WeaponEventBase __T__ = new WeaponEventTrigger;
120 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
121 WeaponEventBase __U__ = new WeaponEventUnjam;
122 WeaponEventBase __M__ = new WeaponEventMechanism;
123 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
124 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
125 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
126
127 m_fsm = new WeaponFSM();
128
129 // Mechanism
130 m_fsm.AddTransition(new WeaponTransition(E, __M__, Mech_L));
131 //----------------------------------------
132
133 m_fsm.AddTransition(new WeaponTransition(L, __M__, Mech_L));
134 m_fsm.AddTransition(new WeaponTransition(Mech_L, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
135 m_fsm.AddTransition(new WeaponTransition(Mech_L, _fin_, L));
136 m_fsm.AddTransition(new WeaponTransition(Mech_L, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
137 m_fsm.AddTransition(new WeaponTransition(Mech_L, _abt_, L));
138
139 m_fsm.AddTransition(new WeaponTransition(F, __M__, Mech_F));
140 m_fsm.AddTransition(new WeaponTransition(Mech_F, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
141 m_fsm.AddTransition(new WeaponTransition(Mech_F, _fin_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
142 m_fsm.AddTransition(new WeaponTransition(Mech_F, _fin_, L));
143 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
144 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
145 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, L));
146
147 //----------------------------------------
148
149 m_fsm.AddTransition(new WeaponTransition(E, __L__, Chamber_E));
150 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
151 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _fin_, L));
152 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
153 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _abt_, L));
154
155 m_fsm.AddTransition(new WeaponTransition(L, __L__, Chamber_L, NULL, new GuardNot(new WeaponGuardInnerMagazineFull(this))));
156 m_fsm.AddTransition(new WeaponTransition(Chamber_L, _fin_, L));
157 m_fsm.AddTransition(new WeaponTransition(Chamber_L, _abt_, L));
158
159 m_fsm.AddTransition(new WeaponTransition(F, __L__, Chamber_F, NULL, new GuardNot(new WeaponGuardInnerMagazineFull(this))));
160 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _fin_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
161 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _fin_, L));
162 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
163 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, L));
164
165
166 //-------------------------------------------
167
168 m_fsm.AddTransition(new WeaponTransition(J, __U__, Unjam_J));
169 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _fin_, J, NULL, new WeaponGuardJammed(this)));
170 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _fin_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
171 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _fin_, L));
172 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _abt_, J, NULL, new WeaponGuardJammed(this)));
173 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
174 m_fsm.AddTransition(new WeaponTransition(Unjam_J, _abt_, L));
175
176 //-----------------------------------------
177
178 // fire
179 m_fsm.AddTransition(new WeaponTransition(E, __T__, Trigger_E)); // fire.cocked
180 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _fin_, E));
181 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _dto_, E));
182 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _abt_, E));
183
184 m_fsm.AddTransition(new WeaponTransition(L, __T__, Trigger_L)); // fire.cocked
185 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _fin_, F));
186 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _rto_, F));
187 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _abt_, F));
188
189 m_fsm.AddTransition(new WeaponTransition(L, __TJ_, Trigger_LJ)); // fire.cocked
190 m_fsm.AddTransition(new WeaponTransition(Trigger_LJ, _fin_, J));
191 m_fsm.AddTransition(new WeaponTransition(Trigger_LJ, _rto_, J));
192 m_fsm.AddTransition(new WeaponTransition(Trigger_LJ, _abt_, J));
193
194 m_fsm.AddTransition(new WeaponTransition(F, __T__, Trigger_F)); // fire.cocked
195 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _fin_, F));
196 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _dto_, F));
197 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _abt_, F));
198
199 m_fsm.AddTransition(new WeaponTransition(J, __T__, Trigger_J)); // fire.cocked
200 m_fsm.AddTransition(new WeaponTransition(Trigger_J, _fin_, J));
201 m_fsm.AddTransition(new WeaponTransition(Trigger_J, _dto_, J));
202 m_fsm.AddTransition(new WeaponTransition(Trigger_J, _abt_, J));
203
204 //-----------------------------------------
205
206 SetInitialState(E);
207
208 SelectionBulletHide();
209 HideMagazine();
210
211 m_fsm.Start();
212 }
213
215 {
216 return CanChamberFromMag(muzzleIndex, mag) && !IsInternalMagazineFull(muzzleIndex);
217 }
218
219 override void SetActions()
220 {
221 super.SetActions();
223
226 }
227
228 //Debug menu Spawn Ground Special
229 override void OnDebugSpawn()
230 {
231 super.OnDebugSpawn();
232 GameInventory inventory = GetInventory();
233 inventory.CreateInInventory("FNP45_MRDSOptic");
234 inventory.CreateInInventory("Battery9V");
235
237 if (Class.CastTo(entity, this))
238 {
239 entity.SpawnEntityOnGroundPos("Ammo_12gaPellets", entity.GetPosition());
240 entity.SpawnEntityOnGroundPos("Ammo_12gaSlug", entity.GetPosition());
241 entity.SpawnEntityOnGroundPos("Ammo_12gaRubberSlug", entity.GetPosition());
242 }
243 }
244};
245
void wpnPrint(string s)
Definition Debug.c:1
void AddAction(typename actionName)
void RemoveAction(typename actionName)
override bool IsRepairEnabled()
Definition Crossbow.c:23
override bool IsJammed()
Definition Crossbow.c:22
override bool HasBullet()
Definition Crossbow.c:20
override void InitMuzzleArray()
Definition Crossbow.c:24
override bool HasMagazine()
Definition Crossbow.c:21
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
override int GetCurrentStateID()
Definition Hand_States.c:29
override void OnExit(HandEventBase e)
Definition Hand_States.c:28
HandStateEquipped OnEntry
Jammed
Definition MP133.c:22
UNKNOWN
Definition MP133.c:18
Empty
Definition MP133.c:19
Fireout
Definition MP133.c:20
PumpShotgunAnimState
Definition MP133.c:2
@ DEFAULT
default weapon state, closed and discharged
Definition MP133.c:3
PumpShotgunStableStateID
Definition MP133.c:7
Loaded
Definition MP133.c:21
enum FSMTransition WeaponTransition
MuzzleState
ref array< MuzzleState > m_muzzleHasBullet
pair ( action, actionType )
Definition Weapon_Base.c:5
Super root of all classes in Enforce script.
Definition EnScript.c:11
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool IsWeaponLogEnable()
Definition Debug.c:799
basic mp5 submachine gun
Definition MP133.c:65
ref WeaponStableState F
Definition MP133.c:67
override void InitStateMachine()
Definition MP133.c:80
override bool CanChamberBullet(int muzzleIndex, Magazine mag)
Definition MP133.c:214
ref WeaponStableState J
Definition MP133.c:69
override RecoilBase SpawnRecoilObject()
Definition MP133.c:75
ref WeaponStableState L
Definition MP133.c:68
override void SetActions()
Definition MP133.c:219
void Mp133Shotgun()
Definition MP133.c:71
override void OnDebugSpawn()
Definition MP133.c:229
ref WeaponStableState E
Definition MP133.c:66
base for rifles @NOTE name copies config base class
Definition SKS.c:70
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 IsJammed()
Definition MP133.c:33
override void OnExit(WeaponEventBase e)
Definition MP133.c:29
override void InitMuzzleArray()
Definition MP133.c:35
override void OnEntry(WeaponEventBase e)
Definition MP133.c:28
override bool HasBullet()
Definition MP133.c:31
override int GetCurrentStateID()
Definition MP133.c:30
override bool IsRepairEnabled()
Definition MP133.c:34
override bool HasMagazine()
Definition MP133.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 MP133.c:56
override void InitMuzzleArray()
Definition MP133.c:58
override bool HasMagazine()
Definition MP133.c:54
override bool IsRepairEnabled()
Definition MP133.c:57
override void OnEntry(WeaponEventBase e)
Definition MP133.c:50
override int GetCurrentStateID()
Definition MP133.c:52
override bool IsJammed()
Definition MP133.c:55
override bool HasBullet()
Definition MP133.c:53
override void OnExit(WeaponEventBase e)
Definition MP133.c:51
unjam submachine
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionUnjammingTypes
Definition human.c:892
WeaponActionFireTypes
Definition human.c:900