DayZ 1.24
Loading...
Searching...
No Matches
BoltActionRifleInnerMagazine_Base.c
Go to the documentation of this file.
2{
3 DEFAULT = 0,
4 OPENED = 1,
5 JAMMED = 2,
6};
7
9{
10 UNKNOWN = 0,
12 LoadedCharged = 2,
14 LoadedJammed = 4,
15}
16
17
19{
20 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { EmptyDischarged C0"); super.OnEntry(e); }
21 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } EmptyDischarged C0"); }
22 override int GetCurrentStateID() { return BARIMStableStateID.EmptyDischarged; }
23 override bool HasBullet() { return false; }
24 override bool HasMagazine() { return false; }
25 override bool IsJammed() { return false; }
26 override bool IsRepairEnabled() { return true; }
28};
30{
31 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { LoadedCharged C1"); super.OnEntry(e); }
32 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } LoadedCharged C1"); }
33 override int GetCurrentStateID() { return BARIMStableStateID.LoadedCharged; }
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) + " { LoadedDischarged D1"); super.OnEntry(e); }
43 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } LoadedDischarged D1"); }
44 override int GetCurrentStateID() { return BARIMStableStateID.LoadedDischarged; }
45 override bool HasBullet() { return true; }
46 override bool HasMagazine() { return false; }
47 override bool IsJammed() { return false; }
48 override bool IsRepairEnabled() { return true; }
50};
52{
53 override void OnEntry(WeaponEventBase e) { if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { LoadedJammed JF"); super.OnEntry(e); }
54 override void OnExit(WeaponEventBase e) { super.OnExit(e); if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } LoadedJammed JF"); }
55 override int GetCurrentStateID() { return BARIMStableStateID.LoadedJammed; }
56 override bool HasBullet() { return true; }
57 override bool HasMagazine() { return false; }
58 override bool IsJammed() { return true; }
59 override bool IsRepairEnabled() { return true; }
61};
62
63
69{
74
75
76 override void InitStateMachine()
77 {
78 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
79 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP));
80 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED));
81 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE));
82 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START));
83 m_abilities.Insert(new AbilityRecord(WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END));
84 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
85 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED));
86 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
87 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_DRY));
88
89
90 C0 = new BARIMEmptyDischarged(this, NULL, BARIMAnimState.DEFAULT);
91 C1 = new BARIMLoadedCharged(this, NULL, BARIMAnimState.DEFAULT);
92 JF = new BARIMLoadedJammed(this, NULL, BARIMAnimState.JAMMED);
93 D1 = new BARIMLoadedDischarged(this, NULL, BARIMAnimState.DEFAULT);
94
95 WeaponStateBase Mech_C1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
96 WeaponStateBase Mech_D1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
97
98
99 LoopedChambering Chamber_C0 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
100 LoopedChambering Chamber_C1 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
101 LoopedChambering Chamber_D1 = new LoopedChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
102
104
109
111
112
113 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
114 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
115 WeaponEventBase __T__ = new WeaponEventTrigger;
116 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
117 WeaponEventBase __U__ = new WeaponEventUnjam;
118 WeaponEventBase __M__ = new WeaponEventMechanism;
119 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
120 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
121 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
122
123 m_fsm = new WeaponFSM();
124
125 // Mechanism
126 //----------------------------------------
127 m_fsm.AddTransition(new WeaponTransition(C0, __M__, Mech_C1));
128
129 m_fsm.AddTransition(new WeaponTransition(C1, __M__, Mech_C1));
130 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
131 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C1));
132 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
133 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C1));
134
135 m_fsm.AddTransition(new WeaponTransition(D1, __M__, Mech_D1));
136 m_fsm.AddTransition(new WeaponTransition(Mech_D1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
137 m_fsm.AddTransition(new WeaponTransition(Mech_D1, _fin_, D1, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
138 m_fsm.AddTransition(new WeaponTransition(Mech_D1, _fin_, C1));
139 m_fsm.AddTransition(new WeaponTransition(Mech_D1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
140 m_fsm.AddTransition(new WeaponTransition(Mech_D1, _abt_, D1, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
141 m_fsm.AddTransition(new WeaponTransition(Mech_D1, _abt_, C1));
142
143
144 //----------------------------------------
145
146 m_fsm.AddTransition(new WeaponTransition(C0, __L__, Chamber_C0));
147 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _fin_, C1));
148 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
149 m_fsm.AddTransition(new WeaponTransition(Chamber_C0, _abt_, C1));
150
151 m_fsm.AddTransition(new WeaponTransition(C1, __L__, Chamber_C1, NULL, new GuardNot(new WeaponGuardInnerMagazineFullShareChamber(this))));
152 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _fin_, C1));
153 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _abt_, C1));
154
155 m_fsm.AddTransition(new WeaponTransition(D1, __L__, Chamber_D1));
156 m_fsm.AddTransition(new WeaponTransition(Chamber_D1, _fin_, C1));
157 m_fsm.AddTransition(new WeaponTransition(Chamber_D1, _abt_, D1, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
158 m_fsm.AddTransition(new WeaponTransition(Chamber_D1, _abt_, C1));
159
160 //------------------------------------------
161
162 m_fsm.AddTransition(new WeaponTransition(JF, __U__, Unjam_JF));
163 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, JF, NULL, new WeaponGuardJammed(this)));
164 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
165 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C1));
166 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, JF, NULL, new WeaponGuardJammed(this)));
167 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
168 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C1));
169
170
171 //-----------------------------------------
172
173 // fire
174 m_fsm.AddTransition(new WeaponTransition(C0, __T__, Trigger_C0)); // fire.cocked
175 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _fin_, C0));
176 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _dto_, C0));
177 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _abt_, C0));
178
179 m_fsm.AddTransition(new WeaponTransition(C1, __T__, Trigger_C1)); // fire.cocked
180 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _fin_, D1));
181 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _rto_, D1));
182 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _abt_, D1));
183
184 m_fsm.AddTransition(new WeaponTransition(D1, __T__, Trigger_D1)); // fire.cocked
185 m_fsm.AddTransition(new WeaponTransition(Trigger_D1, _fin_, D1));
186 m_fsm.AddTransition(new WeaponTransition(Trigger_D1, _dto_, D1));
187 m_fsm.AddTransition(new WeaponTransition(Trigger_D1, _abt_, D1));
188
189 m_fsm.AddTransition(new WeaponTransition(JF, __T__, Trigger_JF)); // fire.cocked
190 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _fin_, JF));
191 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _dto_, JF));
192 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _abt_, JF));
193
194
195 m_fsm.AddTransition(new WeaponTransition(C1, __TJ_, Trigger_C1J)); // fire.cocked
196 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _fin_, JF));
197 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _rto_, JF));
198 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _abt_, JF));
199
200 //---------------------------------------------
201
202 SetInitialState(C0);
203
204 SelectionBulletHide();
205 HideMagazine();
206
207 m_fsm.Start();
208 }
209
210 override void SetActions()
211 {
212 super.SetActions();
214
217
218 }
219};
220
void wpnPrint(string s)
Definition Debug.c:1
void AddAction(typename actionName)
void RemoveAction(typename actionName)
@ DEFAULT
default weapon state, closed and discharged
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
enum FSMTransition WeaponTransition
MuzzleState
ref array< MuzzleState > m_muzzleHasBullet
pair ( action, actionType )
Definition Weapon_Base.c:5
static bool IsWeaponLogEnable()
Definition Debug.c:799
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 void OnExit(WeaponEventBase e)
override void OnEntry(WeaponEventBase e)
represent weapon state base
Definition BulletHide.c:2
handle jamming state set jam/unjam state for weapon
Definition SKS.c:53
override void OnEntry(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
unjam submachine
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionUnjammingTypes
Definition human.c:892
WeaponActionFireTypes
Definition human.c:900