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

shorthand More...

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

Private Member Functions

override float GetChanceToJam ()
 
override void SetActions ()
 
override RecoilBase SpawnRecoilObject ()
 
void Magnum_Base ()
 
override void InitStateMachine ()
 
override bool CanChamberBullet (int muzzleIndex, Magazine mag)
 
override void AssembleGun ()
 
void SetCylinderRotationAnimationPhase (float rot, bool reset=false)
 
void SyncCylinderRotation (bool reset=true)
 
override void EEHealthLevelChanged (int oldLevel, int newLevel, string zone)
 
void SetAttachmentsHealth ()
 
override void OnFire (int muzzle_index)
 
override bool IsShowingChamberedBullet ()
 
override bool CanEjectBullet ()
 
override void ShowBullet (int muzzleIndex)
 
override void HideBullet (int muzzleIndex)
 
override void OnDebugSpawn ()
 
override bool CanChamberBullet (int muzzleIndex, Magazine mag)
 
void Pistol_Base ()
 
override void InitStateMachine ()
 
override float GetChanceToJam ()
 
override void SetActions ()
 
void Rifle_Base ()
 
override void InitStateMachine ()
 

Static Private Member Functions

static float GetCylinderRotation (int muzzleIndex)
 

Private Attributes

ref WeaponStableState C
 
int m_LastMuzzleloaded
 
int m_ActiveMuzzle
 
const string ATT_SLOT_CYLINDER = "RevolverCylinder"
 
const string ATT_SLOT_EJECTOR = "RevolverEjector"
 
ref WeaponStableState CD00
 
ref WeaponStableState CC00
 
ref WeaponStableState CC10
 
ref WeaponStableState CJF0
 
ref WeaponStableState OD00
 
ref WeaponStableState CD01
 
ref WeaponStableState CC01
 
ref WeaponStableState CC11
 
ref WeaponStableState CJF1
 
ref WeaponStableState OD01
 

Detailed Description

shorthand

script base for all weapons

@NOTE: this class is bound to core-config "Weapon_Base" config class

Definition at line 5 of file BoltActionRifle_Base.c.

Member Function Documentation

◆ AssembleGun()

override void Weapon_Base::AssembleGun ( )
inlineprivate

Definition at line 178 of file Magnum.c.

179 {
180 super.AssembleGun();
181
182 if (!FindAttachmentBySlotName(ATT_SLOT_EJECTOR))
183 GetInventory().CreateAttachment("Magnum_Ejector");
184
185 if (!FindAttachmentBySlotName(ATT_SLOT_CYLINDER))
186 GetInventory().CreateAttachment("Magnum_Cylinder");
187
188 ForceSyncSelectionState();
190 }
const string ATT_SLOT_EJECTOR
Definition Magnum.c:55
void SyncCylinderRotation(bool reset=true)
Definition Magnum.c:241
const string ATT_SLOT_CYLINDER
Definition Magnum.c:54

Referenced by Weapon::EEInit().

◆ CanChamberBullet() [1/2]

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

Definition at line 162 of file Magnum.c.

163 {
164 for (int i = 0; i < GetMuzzleCount(); i++)
165 {
166 if (CanChamberFromMag(i, mag))
167 {
168 if (IsChamberEmpty(i))
169 return true;
170
171 if (IsChamberFiredOut(i))
172 return true;
173 }
174 }
175 return false;
176 }
bool IsChamberFiredOut(int idx)

References IsChamberFiredOut().

◆ CanChamberBullet() [2/2]

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

Definition at line 162 of file Pistol_Base.c.

163 {
164 return super.CanChamberBullet(muzzleIndex, mag) && IsChamberEmpty(muzzleIndex);
165 }

◆ CanEjectBullet()

override bool Weapon_Base::CanEjectBullet ( )
inlineprivate

Definition at line 287 of file Magnum.c.

288 {
289 for (int i = 0; i < GetMuzzleCount(); i++)
290 {
291 if (IsChamberFull(i))
292 return true;
293 }
294 return false;
295 }
bool IsChamberFull(int idx)

References IsChamberFull().

◆ EEHealthLevelChanged()

override void Weapon_Base::EEHealthLevelChanged ( int oldLevel,
int newLevel,
string zone )
inlineprivate

Definition at line 246 of file Magnum.c.

247 {
248 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
249
250 if (GetGame().IsClient())
251 return;
252
254 }
void SetAttachmentsHealth()
Definition Magnum.c:257
proto native CGame GetGame()

References GetGame().

◆ GetChanceToJam() [1/2]

override float Weapon_Base::GetChanceToJam ( )
inlineprivate

Definition at line 7 of file BoltActionRifle_Base.c.

8 {
9 return 0.0;
10 }

Referenced by WeaponManager::Update().

◆ GetChanceToJam() [2/2]

override float Weapon_Base::GetChanceToJam ( )
inlineprivate

Definition at line 594 of file Pistol_Base.c.

595 {
596 float chanceToJam = super.GetChanceToJam();
597 Magazine mag = GetMagazine(GetCurrentMuzzle());
598
599 if (mag)
600 chanceToJam = chanceToJam + ((1.0 - chanceToJam) * mag.GetChanceToJam());
601 else
602 chanceToJam = chanceToJam + ((1.0 - chanceToJam) * 0.06);
603
604 return chanceToJam;
605 }

◆ GetCylinderRotation()

static float Weapon_Base::GetCylinderRotation ( int muzzleIndex)
inlinestaticprivate

Definition at line 192 of file Magnum.c.

193 {
194 switch (muzzleIndex)
195 {
196 case 0:
198 case 1:
200 case 2:
202 case 3:
204 case 4:
206 case 5:
208 }
209
210 ErrorEx(string.Format("Invalid muzzle index: %1", muzzleIndex));
211
213 }
const float MAGNUM_ROTATION_POSITION_2
Definition Magnum.c:4
const float MAGNUM_ROTATION_POSITION_1
Definition Magnum.c:3
const float MAGNUM_ROTATION_POSITION_3
Definition Magnum.c:5
const float MAGNUM_ROTATION_POSITION_4
Definition Magnum.c:6
const float MAGNUM_ROTATION_POSITION_5
Definition Magnum.c:7
const float MAGNUM_ROTATION_POSITION_0
Definition Magnum.c:2
enum ShapeType ErrorEx

References ErrorEx, MAGNUM_ROTATION_POSITION_0, MAGNUM_ROTATION_POSITION_1, MAGNUM_ROTATION_POSITION_2, MAGNUM_ROTATION_POSITION_3, MAGNUM_ROTATION_POSITION_4, and MAGNUM_ROTATION_POSITION_5.

◆ HideBullet()

override void Weapon_Base::HideBullet ( int muzzleIndex)
inlineprivate

Definition at line 320 of file Magnum.c.

321 {
322 super.HideBullet(muzzleIndex);
323
324 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
325 if (cylinder)
326 {
327 string bullet = "bullet";
328 if (muzzleIndex > 0)
329 bullet = string.Format("bullet_" + (muzzleIndex + 1));
330
331 cylinder.HideSelection(bullet);
332
333 string bullet_nose = "bullet_nose";
334 if (muzzleIndex > 0)
335 bullet_nose = string.Format("bullet_nose_" + (muzzleIndex + 1));
336 cylinder.HideSelection(bullet_nose);
337 }
338 }

Referenced by Weapon::ForceSyncSelectionState().

◆ InitStateMachine() [1/3]

override void Weapon_Base::InitStateMachine ( )
inlineprivate

Definition at line 87 of file Magnum.c.

88 {
89 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED));
90 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP));
91 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE));
92 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
93 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_SPECIAL));
94 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
95 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
96 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
97
98
99 // setup state machine
100 // basic weapon state
101 C = new Magnum_Static_State(this, NULL, MagnumAnimState.DEFAULT);
102
103
104 WeaponMagnumChambering Chamber = new WeaponMagnumChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
105 WeaponMagnumChambering Chamber_E = new WeaponMagnumChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
106 //WeaponMagnumChambering Chamber_CC00 = new WeaponMagnumChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_END);
107
108 WeaponCharging Mech = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
109
112
113 // events
114
115 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
116 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
117 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
118 WeaponEventBase __M__ = new WeaponEventMechanism;
119 WeaponEventBase __T__ = new WeaponEventTrigger;
120
121
122 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
123 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
124
125
126 m_fsm = new WeaponFSM();
127
128
129 m_fsm.AddTransition(new WeaponTransition(C, __L__, Chamber, null, new WeaponGuardAnyChamberFiredOut(this))); // chamber from closed charged
130 m_fsm.AddTransition(new WeaponTransition(Chamber, _fin_, C));
131 m_fsm.AddTransition(new WeaponTransition(Chamber, _abt_, C));
132
133
134 m_fsm.AddTransition(new WeaponTransition(C, __L__, Chamber_E)); // chamber from closed charged
135 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _fin_, C));
136 m_fsm.AddTransition(new WeaponTransition(Chamber_E, _abt_, C));
137
138
139 m_fsm.AddTransition(new WeaponTransition(C, __M__, Mech)); // charge from closed
140 m_fsm.AddTransition(new WeaponTransition(Mech, _fin_, C));
141 m_fsm.AddTransition(new WeaponTransition(Mech, _abt_, C));
142
143
144 m_fsm.AddTransition(new WeaponTransition(C, __T__, Trigger_normal, null, new GuardAnd(new WeaponGuardCurrentChamberFull(this), new GuardNot(new WeaponGuardCurrentChamberFiredOut(this))))); // fire.cocked
145 m_fsm.AddTransition(new WeaponTransition(Trigger_normal, _fin_, C));
146 m_fsm.AddTransition(new WeaponTransition(Trigger_normal, _dto_, C));
147 m_fsm.AddTransition(new WeaponTransition(Trigger_normal, _abt_, C));
148
149 m_fsm.AddTransition(new WeaponTransition(C, __T__, Trigger_dry)); // fire.cocked
150 m_fsm.AddTransition(new WeaponTransition(Trigger_dry, _fin_, C));
151 m_fsm.AddTransition(new WeaponTransition(Trigger_dry, _dto_, C));
152 m_fsm.AddTransition(new WeaponTransition(Trigger_dry, _abt_, C));
153
154
155 SetInitialState(C);
156 SelectionBulletHide();
157 SetCurrentMuzzle(0);
158 //HideMagazine();
159 m_fsm.Start();
160 }
MagnumAnimState
Definition Magnum.c:12
enum FSMTransition WeaponTransition
pair ( action, actionType )
Definition Weapon_Base.c:5
ref WeaponStableState C
Definition Magnum.c:51
charging of weapon without ammo to be chambered
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine
represent weapon state base
Definition BulletHide.c:2
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionFireTypes
Definition human.c:900

Referenced by Weapon::Weapon_Base().

◆ InitStateMachine() [2/3]

override void Weapon_Base::InitStateMachine ( )
inlineprivate

Definition at line 171 of file Pistol_Base.c.

172 {
173 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_BULLET_CLOSED));
174 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED));
175 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_COCKED));
176 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_COCKED));
177 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_UNCOCKED));
178 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_UNCOCKED));
179 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_OPENED));
180 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_OPENED));
181 m_abilities.Insert(new AbilityRecord(WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH));
182
183 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
184 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED));
185
186 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
187 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
188 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED));
189
190 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
191 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END));
192
193 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
194 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST));
195 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
196 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
197 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_JAM));
198
199 // setup state machine
200 // basic weapon states
201 // open-closed | discharged-charged | nobullet-bullet | nomag-mag
202 // regexp: [OC][CDJ][01][01]
203 CD00 = new Pistol_CLO_DIS_BU0_MA0(this, NULL, PistolAnimState.DEFAULT);
204 CC00 = new Pistol_CLO_CHG_BU0_MA0(this, NULL, PistolAnimState.CLOSED_CHARGED);
205 CC10 = new Pistol_CLO_CHG_BU1_MA0(this, NULL, PistolAnimState.CLOSED_CHARGED);
206 CJF0 = new Pistol_CLO_JAM_BU1_MA0(this, NULL, PistolAnimState.JAMMED);
207 OD00 = new Pistol_OPE_DIS_BU0_MA0(this, NULL, PistolAnimState.OPENED_DISCHARGED);
208 CD01 = new Pistol_CLO_DIS_BU0_MA1(this, NULL, PistolAnimState.DEFAULT);
209 CC01 = new Pistol_CLO_CHG_BU0_MA1(this, NULL, PistolAnimState.CLOSED_CHARGED);
210 CC11 = new Pistol_CLO_CHG_BU1_MA1(this, NULL, PistolAnimState.CLOSED_CHARGED);
211 CJF1 = new Pistol_CLO_JAM_BU1_MA1(this, NULL, PistolAnimState.JAMMED);
212 OD01 = new Pistol_OPE_DIS_BU0_MA1(this, NULL, PistolAnimState.OPENED_DISCHARGED);
213
214 // unstable (intermediate) states
215 WeaponCharging Mech_CD00 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED);
217 WeaponCharging Mech_CD01 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED);
221
222 WeaponCharging Mech_CC10 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED); // eject with no mag
223 WeaponCharging Mech_CC11 = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED); // eject with mag
224
225
226 WeaponDryFire Trigger_CC00 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED); // cock without clip
231 WeaponDryFire Trigger_CC01 = new WeaponDryFire(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED); // cock with clip
234
235 WeaponFireAndChamberNext Trigger_CC11 = new WeaponFireAndChamberNext(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL);
236 WeaponStateBase Trigger_CC10 = new WeaponFireLast(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL); // fire last no mag
237 WeaponStateBase Trigger_CC11L = new WeaponFireLast(this, NULL, WeaponActions.FIRE, WeaponActionFireTypes.FIRE_LAST); // fire last with mag
238
241
244
245 WeaponChambering Chamber_CD00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED_UNCOCKED);
246 WeaponChambering Chamber_CC00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
247 WeaponChambering Chamber_OD00 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED);
248 WeaponChambering Chamber_CD01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED_UNCOCKED);
249 WeaponChambering Chamber_CC01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
250 WeaponChambering Chamber_OD01 = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED);
251
252 WeaponAttachMagazine Attach_CC10 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED);
253 WeaponAttachMagazine Attach_CJF0 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED);
254 WeaponAttachMagazine Attach_CD00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_UNCOCKED);
255 WeaponAttachMagazine Attach_CC00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_COCKED);
256 WeaponAttachMagazine Attach_OD00 = new WeaponAttachMagazine(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_OPENED);
257
258 WeaponReplacingMagAndChamberNext Reload_CD01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_UNCOCKED);
259 WeaponReplacingMagAndChamberNext Reload_CC01 = new WeaponReplacingMagAndChamberNext(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_COCKED);
263
264 WeaponDetachingMag Detach_CC11 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
265 WeaponDetachingMag Detach_CC01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
266 WeaponDetachingMag Detach_CD01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
267 WeaponDetachingMag Detach_OD01 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
268 WeaponDetachingMag Detach_CJF1 = new WeaponDetachingMag(this, NULL, WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH);
269
270 // events
271 WeaponEventBase __M__ = new WeaponEventMechanism;
272 WeaponEventBase __T__ = new WeaponEventTrigger;
273 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
274 WeaponEventBase __U__ = new WeaponEventUnjam;
275 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
276 WeaponEventBase __A__ = new WeaponEventAttachMagazine;
277 WeaponEventBase __D__ = new WeaponEventDetachMagazine;
278 WeaponEventBase __S__ = new WeaponEventSwapMagazine;
279 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
280 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
281 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
282 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
283
284 m_fsm = new WeaponFSM();
285
286 //WeaponGuardWeaponDischarged
287 //WeaponGuardWeaponOpen
288
289 // charging
290 m_fsm.AddTransition(new WeaponTransition(CD00, __M__, Mech_CD00)); // charge from closed
291 m_fsm.AddTransition(new WeaponTransition(Mech_CD00, _fin_, CC00, NULL, new WeaponGuardWeaponDischarged(this)));
292 m_fsm.AddTransition(new WeaponTransition(Mech_CD00, _fin_, CD00));
293 m_fsm.AddTransition(new WeaponTransition(Mech_CD00, _abt_, CC00, NULL, new WeaponGuardWeaponDischarged(this)));
294 m_fsm.AddTransition(new WeaponTransition(Mech_CD00, _abt_, CD00));
295
296 m_fsm.AddTransition(new WeaponTransition(CC00, __M__, Mech_CC00)); // charge from charged
297 m_fsm.AddTransition(new WeaponTransition(Mech_CC00, _fin_, CC00));
298 m_fsm.AddTransition(new WeaponTransition(Mech_CC00, _abt_, CC00));
299
300 m_fsm.AddTransition(new WeaponTransition(OD00, __M__, Mech_OD00)); // charge from opened
301 m_fsm.AddTransition(new WeaponTransition(Mech_OD00, _fin_, CD00, NULL, new WeaponGuardWeaponOpen(this)));
302 m_fsm.AddTransition(new WeaponTransition(Mech_OD00, _fin_, CC00));
303 m_fsm.AddTransition(new WeaponTransition(Mech_OD00, _abt_, CD00, NULL, new WeaponGuardWeaponOpen(this)));
304 m_fsm.AddTransition(new WeaponTransition(Mech_OD00, _abt_, CC00));
305
306 m_fsm.AddTransition(new WeaponTransition(OD01, __M__, Mech_OD01)); // charge from opened with mag
307 m_fsm.AddTransition(new WeaponTransition(Mech_OD01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
308 m_fsm.AddTransition(new WeaponTransition(Mech_OD01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
309 m_fsm.AddTransition(new WeaponTransition(Mech_OD01, _fin_, CC11));
310 m_fsm.AddTransition(new WeaponTransition(Mech_OD01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
311 m_fsm.AddTransition(new WeaponTransition(Mech_OD01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
312 m_fsm.AddTransition(new WeaponTransition(Mech_OD01, _abt_, CC11));
313
314 m_fsm.AddTransition(new WeaponTransition(CD01, __M__, Mech_CD01)); // charge from closed=1 with mag
315 m_fsm.AddTransition(new WeaponTransition(Mech_CD01, _fin_, CD01, NULL, new WeaponGuardWeaponDischarged(this)));
316 m_fsm.AddTransition(new WeaponTransition(Mech_CD01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
317 m_fsm.AddTransition(new WeaponTransition(Mech_CD01, _fin_, CC11));
318 m_fsm.AddTransition(new WeaponTransition(Mech_CD01, _abt_, CD01, NULL, new WeaponGuardWeaponDischarged(this)));
319 m_fsm.AddTransition(new WeaponTransition(Mech_CD01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
320 m_fsm.AddTransition(new WeaponTransition(Mech_CD01, _abt_, CC11));
321
322 m_fsm.AddTransition(new WeaponTransition(CC01, __M__, Mech_CC01)); // charge from closed/charged with mag
323 m_fsm.AddTransition(new WeaponTransition(Mech_CC01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
324 m_fsm.AddTransition(new WeaponTransition(Mech_CC01, _fin_, CC11));
325 m_fsm.AddTransition(new WeaponTransition(Mech_CC01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
326 m_fsm.AddTransition(new WeaponTransition(Mech_CC01, _abt_, CC11));
327
328 // eject good cartridge
329 m_fsm.AddTransition(new WeaponTransition(CC10, __M__, Mech_CC10)); // eject chamber nomag
330 m_fsm.AddTransition(new WeaponTransition(Mech_CC10, _fin_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
331 m_fsm.AddTransition(new WeaponTransition(Mech_CC10, _fin_, CC10));
332 m_fsm.AddTransition(new WeaponTransition(Mech_CC10, _abt_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
333 m_fsm.AddTransition(new WeaponTransition(Mech_CC10, _abt_, CC10));
334
335 m_fsm.AddTransition(new WeaponTransition(CC11, __M__, Mech_CC11)); // eject with mag with ammo
336 m_fsm.AddTransition(new WeaponTransition(Mech_CC11, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
337 m_fsm.AddTransition(new WeaponTransition(Mech_CC11, _fin_, CC11));
338 m_fsm.AddTransition(new WeaponTransition(Mech_CC11, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
339 m_fsm.AddTransition(new WeaponTransition(Mech_CC11, _abt_, CC11));
340
341 // Trigger_CC11e
342 m_fsm.AddTransition(new WeaponTransition(CC00, __T__, Trigger_CC00)); // fire.cocked
343 m_fsm.AddTransition(new WeaponTransition(Trigger_CC00, _fin_, CD00));
344 m_fsm.AddTransition(new WeaponTransition(Trigger_CC00, _dto_, CD00));
345 m_fsm.AddTransition(new WeaponTransition(Trigger_CC00, _abt_, CD00));
346
347 m_fsm.AddTransition(new WeaponTransition(CD00, __T__, Trigger_CD00)); // fire.uncocked
348 m_fsm.AddTransition(new WeaponTransition(Trigger_CD00, _fin_, CD00));
349 m_fsm.AddTransition(new WeaponTransition(Trigger_CD00, _dto_, CD00));
350 m_fsm.AddTransition(new WeaponTransition(Trigger_CD00, _abt_, CD00));
351
352 m_fsm.AddTransition(new WeaponTransition(OD00, __T__, Trigger_OD00)); // opened fire.uncocked
353 m_fsm.AddTransition(new WeaponTransition(Trigger_OD00, _fin_, OD00));
354 m_fsm.AddTransition(new WeaponTransition(Trigger_OD00, _dto_, OD00));
355 m_fsm.AddTransition(new WeaponTransition(Trigger_OD00, _abt_, OD00));
356
357 m_fsm.AddTransition(new WeaponTransition(CD01, __T__, Trigger_CD01)); // fire.uncocked w mag
358 m_fsm.AddTransition(new WeaponTransition(Trigger_CD01, _fin_, CD01));
359 m_fsm.AddTransition(new WeaponTransition(Trigger_CD01, _dto_, CD01));
360 m_fsm.AddTransition(new WeaponTransition(Trigger_CD01, _abt_, CD01));
361
362 m_fsm.AddTransition(new WeaponTransition(OD01, __T__, Trigger_OD01)); // opened fire.uncocked w mag
363 m_fsm.AddTransition(new WeaponTransition(Trigger_OD01, _fin_, OD01));
364 m_fsm.AddTransition(new WeaponTransition(Trigger_OD01, _dto_, OD01));
365 m_fsm.AddTransition(new WeaponTransition(Trigger_OD01, _abt_, OD01));
366
367 m_fsm.AddTransition(new WeaponTransition(CJF0, __T__, Trigger_CJF0)); // opened fire.uncocked w mag
368 m_fsm.AddTransition(new WeaponTransition(Trigger_CJF0, _fin_, CJF0));
369 m_fsm.AddTransition(new WeaponTransition(Trigger_CJF0, _dto_, CJF0));
370 m_fsm.AddTransition(new WeaponTransition(Trigger_CJF0, _abt_, CJF0));
371
372 m_fsm.AddTransition(new WeaponTransition(CJF1, __T__, Trigger_CJF1)); // opened fire.uncocked w mag
373 m_fsm.AddTransition(new WeaponTransition(Trigger_CJF1, _fin_, CJF1));
374 m_fsm.AddTransition(new WeaponTransition(Trigger_CJF1, _dto_, CJF1));
375 m_fsm.AddTransition(new WeaponTransition(Trigger_CJF1, _abt_, CJF1));
376
377
378 m_fsm.AddTransition(new WeaponTransition(CC10, __T__, Trigger_CC10)); // or fire.last (if not jammed)
379 m_fsm.AddTransition(new WeaponTransition(Trigger_CC10, _fin_, CC00));
380 m_fsm.AddTransition(new WeaponTransition(Trigger_CC10, _rto_, CC00));
381 m_fsm.AddTransition(new WeaponTransition(Trigger_CC10, _abt_, CC00));
382
383 m_fsm.AddTransition(new WeaponTransition(CC10, __TJ_, Trigger_CC10J)); // or fire.last (if not jammed)
384 m_fsm.AddTransition(new WeaponTransition(Trigger_CC10J, _fin_, CJF0));
385 m_fsm.AddTransition(new WeaponTransition(Trigger_CC10J, _rto_, CJF0));
386 m_fsm.AddTransition(new WeaponTransition(Trigger_CC10J, _abt_, CJF0));
387
388
389 m_fsm.AddTransition(new WeaponTransition(CC11, __T__, Trigger_CC11, NULL, new WeaponGuardHasAmmo(this))); // fire.normal + chamber next
390 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11, _fin_, CC11));
391 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11, _rto_, CC11));
392 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11, _abt_, CC11));
393
394 m_fsm.AddTransition(new WeaponTransition(CC11, __T__, Trigger_CC11L, NULL, new GuardNot(new WeaponGuardHasAmmo(this)))); // fire.last with mag
395 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11L, _fin_, OD01));
396 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11L, _rto_, OD01));
397 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11L, _abt_, OD01));
398
399 m_fsm.AddTransition(new WeaponTransition(CC11, __TJ_, Trigger_CC11J)); // fire.last with mag
400 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11J, _fin_, CJF1));
401 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11J, _rto_, CJF1));
402 m_fsm.AddTransition(new WeaponTransition(Trigger_CC11J, _abt_, CJF1));
403
404 m_fsm.AddTransition(new WeaponTransition(CC01, __T__, Trigger_CC01)); // fire.cocked with mag
405 m_fsm.AddTransition(new WeaponTransition(Trigger_CC01, _fin_, CD01));
406 m_fsm.AddTransition(new WeaponTransition(Trigger_CC01, _dto_, CD01));
407 m_fsm.AddTransition(new WeaponTransition(Trigger_CC01, _abt_, CD01));
408
409 // load cartridge
410 m_fsm.AddTransition(new WeaponTransition(CD00, __L__, Chamber_CD00)); // chamber from closed=1
411 m_fsm.AddTransition(new WeaponTransition(Chamber_CD00, _fin_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
412 m_fsm.AddTransition(new WeaponTransition(Chamber_CD00, _fin_, CD00, NULL, new WeaponGuardWeaponDischarged(this)));
413 m_fsm.AddTransition(new WeaponTransition(Chamber_CD00, _fin_, CC10));
414 m_fsm.AddTransition(new WeaponTransition(Chamber_CD00, _abt_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
415 m_fsm.AddTransition(new WeaponTransition(Chamber_CD00, _abt_, CD00, NULL, new WeaponGuardWeaponDischarged(this)));
416 m_fsm.AddTransition(new WeaponTransition(Chamber_CD00, _abt_, CC10));
417
418 m_fsm.AddTransition(new WeaponTransition(OD00, __L__, Chamber_OD00)); // chamber from opened
419 m_fsm.AddTransition(new WeaponTransition(Chamber_OD00, _fin_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
420 m_fsm.AddTransition(new WeaponTransition(Chamber_OD00, _fin_, CC10));
421 m_fsm.AddTransition(new WeaponTransition(Chamber_OD00, _abt_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
422 m_fsm.AddTransition(new WeaponTransition(Chamber_OD00, _abt_, CC10));
423
424 m_fsm.AddTransition(new WeaponTransition(CC00, __L__, Chamber_CC00)); // chamber from closed charged
425 m_fsm.AddTransition(new WeaponTransition(Chamber_CC00, _fin_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
426 m_fsm.AddTransition(new WeaponTransition(Chamber_CC00, _fin_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
427 m_fsm.AddTransition(new WeaponTransition(Chamber_CC00, _fin_, CC10));
428 m_fsm.AddTransition(new WeaponTransition(Chamber_CC00, _abt_, OD00, NULL, new WeaponGuardWeaponOpen(this)));
429 m_fsm.AddTransition(new WeaponTransition(Chamber_CC00, _abt_, CC00, NULL, new WeaponGuardCurrentChamberEmpty(this)));
430 m_fsm.AddTransition(new WeaponTransition(Chamber_CC00, _abt_, CC10));
431
432 // load cartridge with mag
433 m_fsm.AddTransition(new WeaponTransition(CD01, __L__, Chamber_CD01, NULL, new WeaponGuardHasMag(this))); // chamber from closed=1 with mag
434 m_fsm.AddTransition(new WeaponTransition(Chamber_CD01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
435 m_fsm.AddTransition(new WeaponTransition(Chamber_CD01, _fin_, CD01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
436 m_fsm.AddTransition(new WeaponTransition(Chamber_CD01, _fin_, CC11));
437 m_fsm.AddTransition(new WeaponTransition(Chamber_CD01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
438 m_fsm.AddTransition(new WeaponTransition(Chamber_CD01, _abt_, CD01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
439 m_fsm.AddTransition(new WeaponTransition(Chamber_CD01, _abt_, CC11));
440
441 m_fsm.AddTransition(new WeaponTransition(CC01, __L__, Chamber_CC01, NULL, new WeaponGuardHasMag(this))); // chamber from closed=1 with mag
442 m_fsm.AddTransition(new WeaponTransition(Chamber_CC01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
443 m_fsm.AddTransition(new WeaponTransition(Chamber_CC01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
444 m_fsm.AddTransition(new WeaponTransition(Chamber_CC01, _fin_, CC11));
445 m_fsm.AddTransition(new WeaponTransition(Chamber_CC01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
446 m_fsm.AddTransition(new WeaponTransition(Chamber_CC01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
447 m_fsm.AddTransition(new WeaponTransition(Chamber_CC01, _abt_, CC11));
448
449 m_fsm.AddTransition(new WeaponTransition(OD01, __L__, Chamber_OD01, NULL, new WeaponGuardHasMag(this))); // chamber from opened with mag
450 m_fsm.AddTransition(new WeaponTransition(Chamber_OD01, _fin_, OD01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
451 m_fsm.AddTransition(new WeaponTransition(Chamber_OD01, _fin_, CC11));
452 m_fsm.AddTransition(new WeaponTransition(Chamber_OD01, _abt_, OD01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
453 m_fsm.AddTransition(new WeaponTransition(Chamber_OD01, _abt_, CC11));
454
455 m_fsm.AddTransition(new WeaponTransition(CJF0, __A__, Attach_CJF0, NULL, new WeaponGuardCanAttachMag(this))); // attach from JAM/b1/m0
456 m_fsm.AddTransition(new WeaponTransition(Attach_CJF0, _fin_, CJF1, NULL, new WeaponGuardHasMag(this)));
457 m_fsm.AddTransition(new WeaponTransition(Attach_CJF0, _fin_, CJF0));
458 m_fsm.AddTransition(new WeaponTransition(Attach_CJF0, _abt_, CJF1, NULL, new WeaponGuardHasMag(this)));
459 m_fsm.AddTransition(new WeaponTransition(Attach_CJF0, _abt_, CJF0));;
460
461 // zdokumentovano az sem
462 // attach mag with no ammo
463 m_fsm.AddTransition(new WeaponTransition(CD00, __A__, Attach_CD00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0
464 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _fin_, CD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
465 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _fin_, CD01, NULL, new WeaponGuardWeaponDischarged(this)));
466 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
467 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _fin_, CC11));
468 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _abt_, CD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
469 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _abt_, CD00, NULL, new WeaponGuardWeaponDischarged(this)));
470 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
471 m_fsm.AddTransition(new WeaponTransition(Attach_CD00, _abt_, CC11));
472
473 m_fsm.AddTransition(new WeaponTransition(CC10, __A__, Attach_CC10, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b1/m0
474 m_fsm.AddTransition(new WeaponTransition(Attach_CC10, _fin_, CC11, NULL, new WeaponGuardHasMag(this)));
475 m_fsm.AddTransition(new WeaponTransition(Attach_CC10, _fin_, CC10));
476 m_fsm.AddTransition(new WeaponTransition(Attach_CC10, _abt_, CC11, NULL, new WeaponGuardHasMag(this)));
477 m_fsm.AddTransition(new WeaponTransition(Attach_CC10, _abt_, CC10));
478
479 m_fsm.AddTransition(new WeaponTransition(OD00, __A__, Attach_OD00, NULL, new WeaponGuardCanAttachMag(this))); // attach from OPE/b0/m0
480 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _fin_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
481 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
482 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
483 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _fin_, CC11));
484 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _abt_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
485 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
486 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
487 m_fsm.AddTransition(new WeaponTransition(Attach_OD00, _abt_, CC11));
488
489 m_fsm.AddTransition(new WeaponTransition(CC00, __A__, Attach_CC00, NULL, new WeaponGuardCanAttachMag(this))); // attach from CLO/b0/m0 charged
490 m_fsm.AddTransition(new WeaponTransition(Attach_CC00, _fin_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
491 m_fsm.AddTransition(new WeaponTransition(Attach_CC00, _fin_, CC01, NULL, new WeaponGuardHasMag(this)));
492 m_fsm.AddTransition(new WeaponTransition(Attach_CC00, _fin_, CC00));
493 m_fsm.AddTransition(new WeaponTransition(Attach_CC00, _abt_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
494 m_fsm.AddTransition(new WeaponTransition(Attach_CC00, _abt_, CC01, NULL, new WeaponGuardHasMag(this)));
495 m_fsm.AddTransition(new WeaponTransition(Attach_CC00, _abt_, CC00));
496
497 // replace magazine
498 m_fsm.AddTransition(new WeaponTransition(CD01, __S__, Reload_CD01, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b0/m1
499 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _fin_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
500 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _fin_, CC01, NULL, new WeaponGuardWeaponCharged(this)));
501 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _fin_, CD01, NULL, new WeaponGuardHasMag(this)));
502 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _fin_, CD00));
503 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _abt_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
504 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _abt_, CC01, NULL, new WeaponGuardWeaponCharged(this)));
505 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _abt_, CD01, NULL, new WeaponGuardHasMag(this)));
506 m_fsm.AddTransition(new WeaponTransition(Reload_CD01, _abt_, CD00));
507
508
509 m_fsm.AddTransition(new WeaponTransition(CC11, __S__, Reload_CC11, NULL, new WeaponGuardCanSwapMag(this))); // swap in CLO/b1/m1
510 m_fsm.AddTransition(new WeaponTransition(Reload_CC11, _fin_, CC11, NULL, new WeaponGuardHasMag(this)));
511 m_fsm.AddTransition(new WeaponTransition(Reload_CC11, _fin_, CC10));
512 m_fsm.AddTransition(new WeaponTransition(Reload_CC11, _abt_, CC11, NULL, new WeaponGuardHasMag(this)));
513 m_fsm.AddTransition(new WeaponTransition(Reload_CC11, _abt_, CC10));
514
515 m_fsm.AddTransition(new WeaponTransition(CC01, __S__, Reload_CC01, NULL, new WeaponGuardCanSwapMag(this))); // CLO/b0/m1 swap with empty mag (no chamber)
516 m_fsm.AddTransition(new WeaponTransition(Reload_CC01, _fin_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
517 m_fsm.AddTransition(new WeaponTransition(Reload_CC01, _fin_, CC01, NULL, new WeaponGuardHasMag(this)));
518 m_fsm.AddTransition(new WeaponTransition(Reload_CC01, _fin_, CC00));
519 m_fsm.AddTransition(new WeaponTransition(Reload_CC01, _abt_, CC11, NULL, new WeaponGuardCurrentChamberFull(this)));
520 m_fsm.AddTransition(new WeaponTransition(Reload_CC01, _abt_, CC01, NULL, new WeaponGuardHasMag(this)));
521 m_fsm.AddTransition(new WeaponTransition(Reload_CC01, _abt_, CC00));
522
523 m_fsm.AddTransition(new WeaponTransition(OD01, __S__, Reload_OD01, NULL, new WeaponGuardCanSwapMag(this))); // OPE/b0/m1 swap with empty mag (no chamber)
524 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _fin_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
525 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _fin_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
526 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
527 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _fin_, CC11));
528 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _abt_, OD00, NULL, new GuardNot(new WeaponGuardHasMag(this))));
529 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _abt_, OD01, NULL, new WeaponGuardWeaponOpen(this)));
530 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
531 m_fsm.AddTransition(new WeaponTransition(Reload_OD01, _abt_, CC11));
532
533 m_fsm.AddTransition(new WeaponTransition(CJF1, __S__, Reload_CJF1, NULL, new WeaponGuardCanSwapMag(this))); // swap in JAM/b1/m1
534 m_fsm.AddTransition(new WeaponTransition(Reload_CJF1, _fin_, CJF1, NULL, new WeaponGuardHasMag(this)));
535 m_fsm.AddTransition(new WeaponTransition(Reload_CJF1, _fin_, CJF0));
536 m_fsm.AddTransition(new WeaponTransition(Reload_CJF1, _abt_, CJF1, NULL, new WeaponGuardHasMag(this)));
537 m_fsm.AddTransition(new WeaponTransition(Reload_CJF1, _abt_, CJF0));
538
539
540 // detach magazine
541 m_fsm.AddTransition(new WeaponTransition(OD01, __D__, Detach_OD01, NULL, new WeaponGuardCanDetachMag(this))); // detach from OPE/b0/m1
542 m_fsm.AddTransition(new WeaponTransition(Detach_OD01, _fin_, OD01, NULL, new WeaponGuardHasMag(this)));
543 m_fsm.AddTransition(new WeaponTransition(Detach_OD01, _fin_, OD00));
544 m_fsm.AddTransition(new WeaponTransition(Detach_OD01, _abt_, OD01, NULL, new WeaponGuardHasMag(this)));
545 m_fsm.AddTransition(new WeaponTransition(Detach_OD01, _abt_, OD00));
546
547 m_fsm.AddTransition(new WeaponTransition(CC11, __D__, Detach_CC11, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b1/m1
548 m_fsm.AddTransition(new WeaponTransition(Detach_CC11, _fin_, CC11, NULL, new WeaponGuardHasMag(this)));
549 m_fsm.AddTransition(new WeaponTransition(Detach_CC11, _fin_, CC10));
550 m_fsm.AddTransition(new WeaponTransition(Detach_CC11, _abt_, CC11, NULL, new WeaponGuardHasMag(this)));
551 m_fsm.AddTransition(new WeaponTransition(Detach_CC11, _abt_, CC10));
552
553 m_fsm.AddTransition(new WeaponTransition(CC01, __D__, Detach_CC01, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b0/m1
554 m_fsm.AddTransition(new WeaponTransition(Detach_CC01, _fin_, CC01, NULL, new WeaponGuardHasMag(this)));
555 m_fsm.AddTransition(new WeaponTransition(Detach_CC01, _fin_, CC00));
556 m_fsm.AddTransition(new WeaponTransition(Detach_CC01, _abt_, CC01, NULL, new WeaponGuardHasMag(this)));
557 m_fsm.AddTransition(new WeaponTransition(Detach_CC01, _abt_, CC00));
558
559 m_fsm.AddTransition(new WeaponTransition(CD01, __D__, Detach_CD01, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b0/m1 dischg
560 m_fsm.AddTransition(new WeaponTransition(Detach_CD01, _fin_, CD01, NULL, new WeaponGuardHasMag(this)));
561 m_fsm.AddTransition(new WeaponTransition(Detach_CD01, _fin_, CD00));
562 m_fsm.AddTransition(new WeaponTransition(Detach_CD01, _abt_, CD01, NULL, new WeaponGuardHasMag(this)));
563 m_fsm.AddTransition(new WeaponTransition(Detach_CD01, _abt_, CD00));
564
565 m_fsm.AddTransition(new WeaponTransition(CJF1, __D__, Detach_CJF1, NULL, new WeaponGuardCanDetachMag(this))); // detach from CLO/b1/m1 jammed
566 m_fsm.AddTransition(new WeaponTransition(Detach_CJF1, _fin_, CJF1, NULL, new WeaponGuardHasMag(this)));
567 m_fsm.AddTransition(new WeaponTransition(Detach_CJF1, _fin_, CJF0));
568 m_fsm.AddTransition(new WeaponTransition(Detach_CJF1, _abt_, CJF1, NULL, new WeaponGuardHasMag(this)));
569 m_fsm.AddTransition(new WeaponTransition(Detach_CJF1, _abt_, CJF0));
570
571
572 // unjam
573 m_fsm.AddTransition(new WeaponTransition(CJF0, __U__, Unjam_CJF0)); // unjam nomag
574 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF0, _fin_, CJF0, NULL, new WeaponGuardJammed(this)));
575 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF0, _fin_, CC00));
576 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF0, _abt_, CJF0, NULL, new WeaponGuardJammed(this)));
577 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF0, _abt_, CC00));
578
579 m_fsm.AddTransition(new WeaponTransition(CJF1, __U__, Unjam_CJF1)); // unjam with mag with ammo
580 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF1, _fin_, CJF1, NULL, new WeaponGuardJammed(this)));
581 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF1, _fin_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
582 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF1, _fin_, CC11));
583 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF1, _abt_, CJF1, NULL, new WeaponGuardJammed(this)));
584 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF1, _abt_, CC01, NULL, new WeaponGuardCurrentChamberEmpty(this)));
585 m_fsm.AddTransition(new WeaponTransition(Unjam_CJF1, _abt_, CC11));
586
587
588 SetInitialState(CD00);
589 SelectionBulletHide();
590 HideMagazine();
591 m_fsm.Start();
592 }
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition Guards.c:99
void WeaponGuardWeaponDischarged(Weapon_Base w=NULL)
Definition Guards.c:578
void WeaponGuardWeaponOpen(Weapon_Base w=NULL)
Definition Guards.c:604
PistolAnimState
Definition Pistol_Base.c:3
ref WeaponStableState CD00
ref WeaponStableState CC11
ref WeaponStableState CC01
ref WeaponStableState OD00
ref WeaponStableState CC10
ref WeaponStableState CD01
ref WeaponStableState CJF0
ref WeaponStableState CJF1
ref WeaponStableState OD01
ref WeaponStableState CC00
replace current magazine with new one
unjam submachine
WeaponActionReloadTypes
Definition human.c:812
WeaponActionUnjammingTypes
Definition human.c:892

References WeaponGuardHasAmmo(), WeaponGuardWeaponDischarged(), and WeaponGuardWeaponOpen().

◆ InitStateMachine() [3/3]

override void Weapon_Base::InitStateMachine ( )
inlineprivate

Definition at line 16 of file Rifle_Base.c.

17 {
18 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
19
20 // setup state machine
21 // basic weapon states
23
24 WeaponStateBase Mech = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
25
26 // events
27 WeaponEventBase __M__ = new WeaponEventMechanism;
28 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
29 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
30
31 m_fsm = new WeaponFSM();
32 // charging
33 m_fsm.AddTransition(new WeaponTransition(E, __M__, Mech));
34 m_fsm.AddTransition(new WeaponTransition(Mech, _fin_, E));
35 m_fsm.AddTransition(new WeaponTransition(Mech, _abt_, E));
36
37 SetInitialState(E);
38
39 SelectionBulletHide();
40
41 m_fsm.Start();
42 }
DefaultAnimState
Definition Rifle_Base.c:2
@ E
EMPTY.
void WeaponStableState(Weapon_Base w=NULL, WeaponStateBase parent=NULL, int anim_state=-1)
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, and WeaponStableState().

◆ IsShowingChamberedBullet()

override bool Weapon_Base::IsShowingChamberedBullet ( )
inlineprivate

Definition at line 282 of file Magnum.c.

283 {
284 return false;
285 }

◆ Magnum_Base()

void Weapon_Base::Magnum_Base ( )
inlineprivate

Definition at line 72 of file Magnum.c.

73 {
76
77 /*m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionTypes.CHAMBERING_STARTLOOPABLE_CLOSED));
78 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionTypes.CHAMBERING_ENDLOOPABLE));
79 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionTypes.MECHANISM_CLOSED));
80 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionTypes.MECHANISM_SPECIAL));
81 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionTypes.UNJAMMING_START));
82 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionTypes.UNJAMMING_END));
83 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionTypes.FIRE_NORMAL));
84 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionTypes.FIRE_COCKED));*/
85 }
int m_LastMuzzleloaded
Definition Magnum.c:52
int m_ActiveMuzzle
Definition Magnum.c:53

◆ OnDebugSpawn()

override void Weapon_Base::OnDebugSpawn ( )
inlineprivate

Definition at line 341 of file Magnum.c.

342 {
343 super.OnDebugSpawn();
344
346 if (Class.CastTo(entity, this))
347 entity.SpawnEntityOnGroundPos("Ammo_357", entity.GetPosition());
348 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo().

◆ OnFire()

override void Weapon_Base::OnFire ( int muzzle_index)
inlineprivate

Definition at line 269 of file Magnum.c.

270 {
271 super.OnFire(muzzle_index);
272 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
273 if (cylinder)
274 {
275 string bullet_nose = "bullet_nose";
276 if (muzzle_index > 0)
277 bullet_nose = string.Format("bullet_nose_" + (muzzle_index + 1));
278 cylinder.HideSelection(bullet_nose);
279 }
280 }

◆ Pistol_Base()

void Weapon_Base::Pistol_Base ( )
inlineprivate

Definition at line 167 of file Pistol_Base.c.

168 {
169 }

◆ Rifle_Base()

void Weapon_Base::Rifle_Base ( )
inlineprivate

Definition at line 12 of file Rifle_Base.c.

13 {
14 }

◆ SetActions() [1/2]

override void Weapon_Base::SetActions ( )
inlineprivate

Definition at line 57 of file Magnum.c.

58 {
59 super.SetActions();
61
64
65 }
void AddAction(typename actionName)
void RemoveAction(typename actionName)
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()

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

◆ SetActions() [2/2]

override void Weapon_Base::SetActions ( )
inlineprivate

Definition at line 621 of file Pistol_Base.c.

622 {
623 super.SetActions();
625 //AddAction(ActionAdvancedDetachMagazine);
626 }

References AddAction().

◆ SetAttachmentsHealth()

void Weapon_Base::SetAttachmentsHealth ( )
inlineprivate

Definition at line 257 of file Magnum.c.

258 {
261 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
262 {
263 entity = GetInventory().GetAttachmentFromIndex(i);
265 attachment.SetHealth01("", "Health", GetHealth01());
266 }
267 }

References Class::CastTo().

◆ SetCylinderRotationAnimationPhase()

void Weapon_Base::SetCylinderRotationAnimationPhase ( float rot,
bool reset = false )
inlineprivate

Definition at line 215 of file Magnum.c.

216 {
217 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
218 Magnum_Ejector ejector = Magnum_Ejector.Cast(GetAttachmentByType(Magnum_Ejector));
219 if (cylinder && ejector)
220 {
221 float anim_phase = cylinder.GetAnimationPhase("Rotate_Cylinder");
222 if (Math.AbsFloat(anim_phase - rot) > 0.1)
223 {
224 if (reset)
225 {
226 cylinder.ResetAnimationPhase("Rotate_Cylinder", rot);
227 ejector.ResetAnimationPhase("Rotate_Ejector", rot);
228 }
230 {
231 cylinder.ResetAnimationPhase("Rotate_Cylinder", MAGNUM_ROTATION_POSITION_M1);
232 ejector.ResetAnimationPhase("Rotate_Ejector", MAGNUM_ROTATION_POSITION_M1);
233 }
234
235 cylinder.SetAnimationPhase("Rotate_Cylinder", rot);
236 ejector.SetAnimationPhase("Rotate_Ejector", rot);
237 }
238 }
239 }
const float MAGNUM_ROTATION_POSITION_M1
Definition Magnum.c:1
Definition EnMath.c:7
static proto float AbsFloat(float f)
Returns absolute value.

References Math::AbsFloat(), MAGNUM_ROTATION_POSITION_0, and MAGNUM_ROTATION_POSITION_M1.

◆ ShowBullet()

override void Weapon_Base::ShowBullet ( int muzzleIndex)
inlineprivate

Definition at line 297 of file Magnum.c.

298 {
299 super.ShowBullet(muzzleIndex);
300
301 Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(GetAttachmentByType(Magnum_Cylinder));
302 if (cylinder)
303 {
304 string bullet = "bullet";
305 if (muzzleIndex > 0)
306 bullet = string.Format("bullet_" + (muzzleIndex + 1));
307
308 cylinder.ShowSelection(bullet);
309
311 {
312 string bullet_nose = "bullet_nose";
313 if (muzzleIndex > 0)
314 bullet_nose = string.Format("bullet_nose_" + (muzzleIndex + 1));
315 cylinder.ShowSelection(bullet_nose);
316 }
317 }
318 }

References IsChamberFiredOut().

Referenced by Weapon::ForceSyncSelectionState().

◆ SpawnRecoilObject()

override RecoilBase Weapon_Base::SpawnRecoilObject ( )
inlineprivate

Definition at line 67 of file Magnum.c.

68 {
69 return new MagnumRecoil(this);
70 }

◆ SyncCylinderRotation()

void Weapon_Base::SyncCylinderRotation ( bool reset = true)
inlineprivate

Definition at line 241 of file Magnum.c.

242 {
243 SetCylinderRotationAnimationPhase(GetCylinderRotation(GetCurrentMuzzle()), reset);
244 }
static float GetCylinderRotation(int muzzleIndex)
Definition Magnum.c:192
void SetCylinderRotationAnimationPhase(float rot, bool reset=false)
Definition Magnum.c:215

Member Data Documentation

◆ ATT_SLOT_CYLINDER

const string Weapon_Base::ATT_SLOT_CYLINDER = "RevolverCylinder"
private

Definition at line 54 of file Magnum.c.

◆ ATT_SLOT_EJECTOR

const string Weapon_Base::ATT_SLOT_EJECTOR = "RevolverEjector"
private

Definition at line 55 of file Magnum.c.

◆ C

ref WeaponStableState Weapon_Base::C
private

Definition at line 51 of file Magnum.c.

Referenced by Crossbow_Base::InitStateMachine().

◆ CC00

ref WeaponStableState Weapon_Base::CC00
private

Definition at line 152 of file Pistol_Base.c.

◆ CC01

ref WeaponStableState Weapon_Base::CC01
private

Definition at line 157 of file Pistol_Base.c.

◆ CC10

ref WeaponStableState Weapon_Base::CC10
private

Definition at line 153 of file Pistol_Base.c.

◆ CC11

ref WeaponStableState Weapon_Base::CC11
private

Definition at line 158 of file Pistol_Base.c.

◆ CD00

ref WeaponStableState Weapon_Base::CD00
private

Definition at line 151 of file Pistol_Base.c.

◆ CD01

ref WeaponStableState Weapon_Base::CD01
private

Definition at line 156 of file Pistol_Base.c.

◆ CJF0

ref WeaponStableState Weapon_Base::CJF0
private

Definition at line 154 of file Pistol_Base.c.

◆ CJF1

ref WeaponStableState Weapon_Base::CJF1
private

Definition at line 159 of file Pistol_Base.c.

◆ m_ActiveMuzzle

int Weapon_Base::m_ActiveMuzzle
private

Definition at line 53 of file Magnum.c.

◆ m_LastMuzzleloaded

int Weapon_Base::m_LastMuzzleloaded
private

Definition at line 52 of file Magnum.c.

◆ OD00

ref WeaponStableState Weapon_Base::OD00
private

Definition at line 155 of file Pistol_Base.c.

◆ OD01

ref WeaponStableState Weapon_Base::OD01
private

Definition at line 160 of file Pistol_Base.c.


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