DayZ 1.24
Loading...
Searching...
No Matches
Repeater.c
Go to the documentation of this file.
2{
3 DEFAULT = 0,
4 CHARGED = 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 RPTStableStateID.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 RPTStableStateID.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 RPTStableStateID.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 RPTStableStateID.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
66class Repeater_Base extends Rifle_Base
67{
73
74
75 override void InitStateMachine()
76 {
77 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
78 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
79 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED));
80 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED));
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 D0 = new RPTEmptyDischarged(this, NULL, RPTAnimState.DEFAULT);
90 C0 = new RPTEmptyDischarged(this, NULL, RPTAnimState.CHARGED);
91 DF = new RPTLoadedDischarged(this, NULL, RPTAnimState.DEFAULT);
92 C1 = new RPTLoadedCharged(this, NULL, RPTAnimState.CHARGED);
93 JF = new RPTLoadedJammed(this, NULL, RPTAnimState.JAMMED);
94
95 //WeaponStateBase Mech_D0 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
96 WeaponStateBase Mech_C1 = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED);
97 WeaponStateBase Mech_DF = new WeaponChargingInnerMag(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
98
99 LoopedChamberingEjectLast Chamber_D0 = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
100 LoopedChamberingEjectLast Chamber_C0 = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
101 LoopedChamberingEjectLast Chamber_C1 = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
102 LoopedChamberingEjectLast Chamber_DF = new LoopedChamberingEjectLast(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE);
103
105
111
113
114
115 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
116 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
117 WeaponEventBase __T__ = new WeaponEventTrigger;
118 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
119 WeaponEventBase __U__ = new WeaponEventUnjam;
120 WeaponEventBase __M__ = new WeaponEventMechanism;
121 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
122 WeaponEventBase _rto_ = new WeaponEventReloadTimeout;
123 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
124
125 m_fsm = new WeaponFSM();
126
127 // Mechanism
128 //----------------------------------------
129 m_fsm.AddTransition(new WeaponTransition(D0, __M__, Mech_DF));
130 m_fsm.AddTransition(new WeaponTransition(C0, __M__, Mech_C1));
131
132 m_fsm.AddTransition(new WeaponTransition(C1, __M__, Mech_C1));
133 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
134 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _fin_, C1));
135 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
136 m_fsm.AddTransition(new WeaponTransition(Mech_C1, _abt_, C1));
137
138 m_fsm.AddTransition(new WeaponTransition(DF, __M__, Mech_DF));
139 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
140 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _fin_, DF, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
141 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _fin_, C1));
142 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
143 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _abt_, DF, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
144 m_fsm.AddTransition(new WeaponTransition(Mech_DF, _abt_, C1));
145
146
147 //----------------------------------------
148 m_fsm.AddTransition(new WeaponTransition(C0, __L__, Chamber_D0));
149
150 m_fsm.AddTransition(new WeaponTransition(D0, __L__, Chamber_D0));
151 m_fsm.AddTransition(new WeaponTransition(Chamber_D0, _fin_, C1));
152 m_fsm.AddTransition(new WeaponTransition(Chamber_D0, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
153 m_fsm.AddTransition(new WeaponTransition(Chamber_D0, _abt_, C1));
154
155 m_fsm.AddTransition(new WeaponTransition(C1, __L__, Chamber_C1, NULL, new GuardNot(new WeaponGuardInnerMagazineFull(this))));
156 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _fin_, C1));
157 m_fsm.AddTransition(new WeaponTransition(Chamber_C1, _abt_, C1));
158
159 m_fsm.AddTransition(new WeaponTransition(DF, __L__, Chamber_DF, NULL, new GuardNot(new WeaponGuardInnerMagazineFull(this))));
160 m_fsm.AddTransition(new WeaponTransition(Chamber_DF, _fin_, C1));
161 m_fsm.AddTransition(new WeaponTransition(Chamber_DF, _abt_, DF, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
162 m_fsm.AddTransition(new WeaponTransition(Chamber_DF, _abt_, C1));
163
164 //------------------------------------------
165
166 m_fsm.AddTransition(new WeaponTransition(JF, __U__, Unjam_JF));
167 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, JF, NULL, new WeaponGuardJammed(this)));
168 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
169 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _fin_, C1));
170 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, JF, NULL, new WeaponGuardJammed(this)));
171 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C0, NULL, new WeaponGuardCurrentChamberEmpty(this)));
172 m_fsm.AddTransition(new WeaponTransition(Unjam_JF, _abt_, C1));
173
174
175 //-----------------------------------------
176
177 // fire
178 m_fsm.AddTransition(new WeaponTransition(D0, __T__, Trigger_D0)); // fire.cocked
179 m_fsm.AddTransition(new WeaponTransition(Trigger_D0, _fin_, D0));
180 m_fsm.AddTransition(new WeaponTransition(Trigger_D0, _dto_, D0));
181 m_fsm.AddTransition(new WeaponTransition(Trigger_D0, _abt_, D0));
182
183 m_fsm.AddTransition(new WeaponTransition(C0, __T__, Trigger_C0)); // fire.cocked
184 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _fin_, D0));
185 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _dto_, D0));
186 m_fsm.AddTransition(new WeaponTransition(Trigger_C0, _abt_, D0));
187
188 m_fsm.AddTransition(new WeaponTransition(C1, __T__, Trigger_C1)); // fire.cocked
189 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _fin_, DF));
190 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _rto_, DF));
191 m_fsm.AddTransition(new WeaponTransition(Trigger_C1, _abt_, DF));
192
193 m_fsm.AddTransition(new WeaponTransition(DF, __T__, Trigger_DF)); // fire.cocked
194 m_fsm.AddTransition(new WeaponTransition(Trigger_DF, _fin_, DF));
195 m_fsm.AddTransition(new WeaponTransition(Trigger_DF, _dto_, DF));
196 m_fsm.AddTransition(new WeaponTransition(Trigger_DF, _abt_, DF));
197
198 m_fsm.AddTransition(new WeaponTransition(JF, __T__, Trigger_JF)); // fire.cocked
199 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _fin_, JF));
200 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _dto_, JF));
201 m_fsm.AddTransition(new WeaponTransition(Trigger_JF, _abt_, JF));
202
203
204 m_fsm.AddTransition(new WeaponTransition(JF, __TJ_, Trigger_C1J)); // fire.cocked
205 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _fin_, JF));
206 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _rto_, JF));
207 m_fsm.AddTransition(new WeaponTransition(Trigger_C1J, _abt_, JF));
208
209 //---------------------------------------------
210
211 SetInitialState(D0);
212
213 SelectionBulletHide();
214 HideMagazine();
215
216 m_fsm.Start();
217 }
218
220 {
221 return CanChamberFromMag(muzzleIndex, mag) && !IsInternalMagazineFull(muzzleIndex);
222 }
223
224 override void SetActions()
225 {
226 super.SetActions();
228
231
232 }
233};
234
235class Repeater : Repeater_Base
236{
238 {
239 return new RepeaterRecoil(this);
240 }
241
242
243 //Debug menu Spawn Ground Special
244 override void OnDebugSpawn()
245 {
246 super.OnDebugSpawn();
247
249 if (Class.CastTo(entity, this))
250 entity.SpawnEntityOnGroundPos("Ammo_357", entity.GetPosition());
251 }
252};
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
LoadedJammed
Definition Repeater.c:25
RPTStableStateID
Definition Repeater.c:9
EmptyDischarged
Definition Repeater.c:22
UNKNOWN
Definition Repeater.c:21
RPTAnimState
Definition Repeater.c:2
@ DEFAULT
default weapon state, closed and discharged
Definition Repeater.c:3
@ JAMMED
Definition Repeater.c:5
@ CHARGED
Definition Repeater.c:4
LoadedDischarged
Definition Repeater.c:24
LoadedCharged
Definition Repeater.c:23
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
static bool IsWeaponLogEnable()
Definition Debug.c:799
override void OnDebugSpawn()
Definition Repeater.c:244
override RecoilBase SpawnRecoilObject()
Definition Repeater.c:237
base for rifles @NOTE name copies config base class
Definition SKS.c:70
override bool CanChamberBullet(int muzzleIndex, Magazine mag)
Definition Repeater.c:219
ref WeaponStableState DF
Definition Repeater.c:71
override void SetActions()
Definition Repeater.c:224
ref WeaponStableState D0
Definition Repeater.c:68
override void InitStateMachine()
Definition Repeater.c:75
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 Repeater.c:36
override void OnExit(WeaponEventBase e)
Definition Repeater.c:32
override void InitMuzzleArray()
Definition Repeater.c:38
override void OnEntry(WeaponEventBase e)
Definition Repeater.c:31
override bool HasBullet()
Definition Repeater.c:34
override int GetCurrentStateID()
Definition Repeater.c:33
override bool IsRepairEnabled()
Definition Repeater.c:37
override bool HasMagazine()
Definition Repeater.c:35
represent weapon state base
Definition BulletHide.c:2
handle jamming state set jam/unjam state for weapon
Definition SKS.c:53
override void InitMuzzleArray()
Definition Repeater.c:60
override bool HasMagazine()
Definition Repeater.c:57
override bool IsRepairEnabled()
Definition Repeater.c:59
override void OnEntry(WeaponEventBase e)
Definition Repeater.c:53
override int GetCurrentStateID()
Definition Repeater.c:55
override bool IsJammed()
Definition Repeater.c:58
override bool HasBullet()
Definition Repeater.c:56
override void OnExit(WeaponEventBase e)
Definition Repeater.c:54
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