Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
15 class PumpShotgunEmpty extends WeaponStableState
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; }
24  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.E}; }
25 };
26 class PumpShotgunFireout extends WeaponStableState
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; }
35  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
36 };
37 class PumpShotgunLoaded extends WeaponStableState
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; }
46  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.L}; }
47 };
48 class PumpShotgunJammed extends WeaponStateJammed
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; }
58  override void InitMuzzleArray () { m_muzzleHasBullet = {MuzzleState.F}; }
59 };
60 
65 {
66  ref WeaponStableState E;
67  ref WeaponStableState F;
68  ref WeaponStableState L;
69  ref WeaponStableState J;
70 
71  void Mp133Shotgun ()
72  {
73  }
74 
75  override RecoilBase SpawnRecoilObject()
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 
108  WeaponStateBase Unjam_J = new WeaponUnjamming(this, NULL, WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START);
109 
110  WeaponStateBase Trigger_E = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY);
111  WeaponStateBase Trigger_F = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY);
112  WeaponStateBase Trigger_L = new WeaponFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL);
113  WeaponStateBase Trigger_J = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY);
114 
115  WeaponStateBase Trigger_LJ = new WeaponFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM);
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 
214  override bool CanChamberBullet (int muzzleIndex, Magazine mag)
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 
236  EntityAI entity;
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 
E
@ E
EMPTY.
Definition: weaponstablestate.c:19
LogManager
Definition: debug.c:734
OnExit
override void OnExit(WeaponEventBase e)
Definition: mp133.c:18
Jammed
Jammed
Definition: mp133.c:6
Empty
Empty
Definition: mp133.c:3
DEFAULT
@ DEFAULT
default weapon state, closed and discharged
Definition: mp133.c:3
WeaponActionUnjammingTypes
WeaponActionUnjammingTypes
Definition: human.c:904
FirearmActionLoadMultiBullet
Definition: firearmactionloadmultibullet.c:1
GetCurrentStateID
override int GetCurrentStateID()
Definition: mp133.c:19
FirearmActionLoadBulletQuick
FirearmActionLoadMultiBullet FirearmActionLoadBulletQuick
WeaponFire
Definition: weaponfire.c:98
RemoveAction
void RemoveAction(typename actionName)
Definition: advancedcommunication.c:118
FirearmActionLoadMultiBulletQuick
Definition: firearmactionloadmultibullet.c:94
WeaponActionFireTypes
WeaponActionFireTypes
Definition: human.c:912
L
@ L
LOADED.
Definition: weaponstablestate.c:23
Mp133Recoil
Definition: mp133recoil.c:1
WeaponActions
WeaponActions
actions
Definition: human.c:808
UNKNOWN
UNKNOWN
Definition: mp133.c:2
Loaded
Loaded
Definition: mp133.c:5
F
@ F
FIRED.
Definition: weaponstablestate.c:21
PumpShotgunStableStateID
PumpShotgunStableStateID
Definition: mp133.c:6
OnEntry
class PumpShotgunFireout extends WeaponStableState OnEntry
HasMagazine
override bool HasMagazine()
Definition: mp133.c:21
HasBullet
override bool HasBullet()
Definition: mp133.c:20
PumpShotgunAnimState
PumpShotgunAnimState
Definition: mp133.c:1
RecoilBase
Definition: recoilbase.c:1
WeaponUnjamming
unjam submachine
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
m_muzzleHasBullet
ref array< MuzzleState > m_muzzleHasBullet
Definition: weaponstablestate.c:30
Rifle_Base
base for rifles @NOTE name copies config base class
Definition: sks.c:69
WeaponTransition
enum FSMTransition WeaponTransition
IsBoltOpen
override bool IsBoltOpen()
Definition: flaregun.c:23
IsJammed
override bool IsJammed()
Definition: mp133.c:22
AbilityRecord
pair ( action, actionType )
Definition: weapon_base.c:4
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
WeaponStateBase
represent weapon state base
Definition: bullethide.c:1
m_weapon
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition: guards.c:583
WeaponStateJammed
handle jamming state set jam/unjam state for weapon
Definition: sks.c:52
wpnPrint
void wpnPrint(string s)
Definition: debug.c:1
Mp133Shotgun_Base
basic mp5 submachine gun
Definition: mp133.c:64
IsRepairEnabled
override bool IsRepairEnabled()
Definition: mp133.c:23
InitMuzzleArray
override void InitMuzzleArray()
Definition: mp133.c:24
WeaponActionChamberingTypes
WeaponActionChamberingTypes
Definition: human.c:868
WeaponFSM
weapon finite state machine
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EntityAI
Definition: building.c:5
WeaponStableState
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Definition: crossbow.c:26
Fireout
Fireout
Definition: mp133.c:4
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
MuzzleState
MuzzleState
Definition: weaponstablestate.c:14