DayZ 1.24
Loading...
Searching...
No Matches
WeaponFire.c
Go to the documentation of this file.
1// fire
3{
5
6 override void OnEntry(WeaponEventBase e)
7 {
8 super.OnEntry(e);
9 if (e)
11 m_weapon.ResetBurstCount();
12 }
13
14 override bool IsWaitingForActionFinish() { return true; }
15
16 override void OnUpdate(float dt)
17 {
20 Class.CastTo(p, m_weapon.GetHierarchyParent());
21 if (p)
22 {
23 HumanInputController hic = p.GetInputController();
24
25 int muzzleIndex = m_weapon.GetCurrentMuzzle();
26 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
27 if (hic.IsAttackButton() && m_dtAccumulator >= reloadTime)
28 if (m_weapon.CanProcessWeaponEvents())
29 m_weapon.ProcessWeaponEvent(new WeaponEventDryFireTimeout(p));
30 }
31 }
32
33 override void OnExit(WeaponEventBase e)
34 {
36 super.OnExit(e);
37 }
38
39};
40
41// fire
42class WeaponFire extends WeaponStartAction
43{
44 float m_dtAccumulator;
45
46 override bool IsWaitingForActionFinish() { return true; }
47
48 override void OnEntry(WeaponEventBase e)
49 {
50 if (e)
51 {
53
54 if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang!");
55 //m_weapon.Fire();
56 int mi = m_weapon.GetCurrentMuzzle();
58 {
60 if (Class.CastTo(p, e.m_player))
61 p.GetAimingModel().SetRecoil(m_weapon);
62 m_weapon.OnFire(mi);
63 }
64 }
65 super.OnEntry(e);
66 }
67
68 override void OnUpdate(float dt)
69 {
71
73 Class.CastTo(p, m_weapon.GetHierarchyParent());
74
75 int muzzleIndex = m_weapon.GetCurrentMuzzle();
76 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
78 if (m_weapon.CanProcessWeaponEvents())
79 m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
80 }
81
82 override void OnExit(WeaponEventBase e)
83 {
84 if (e)
86 super.OnExit(e);
87 }
88
89 override void OnAbort(WeaponEventBase e)
90 {
91 m_weapon.ResetBurstCount();
92 super.OnAbort(e);
93 }
94};
95
97{
98 override void OnEntry(WeaponEventBase e)
99 {
100 m_dtAccumulator = 0;
101
102 if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang!");
103 //m_weapon.Fire();
104 int mi = m_weapon.GetCurrentMuzzle();
106 {
108 if (Class.CastTo(p, e.m_player))
109 p.GetAimingModel().SetRecoil(m_weapon);
110 m_weapon.EjectCasing(mi);
111 m_weapon.EffectBulletHide(mi);
112 m_weapon.OnFire(mi);
113 }
114 super.OnEntry(e);
115 }
116}
117
118// fire
120{
122
123 override bool IsWaitingForActionFinish() { return true; }
124
125 override void OnEntry(WeaponEventBase e)
126 {
127 if (e)
128 {
129 m_dtAccumulator = 0;
130
131 if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang bang!");
132
133 int mi = m_weapon.GetCurrentMuzzle();
134 int b = m_weapon.GetCurrentModeBurstSize(mi);
135 if (b > 1)
136 {
137
138 for (int i = 0; i < b; i++)
139 {
141 {
143 if (Class.CastTo(p1, e.m_player))
144 p1.GetAimingModel().SetRecoil(m_weapon);
145 m_weapon.OnFire(i);
146 }
147 }
148 }
149 else
150 {
152 {
154 if (Class.CastTo(p, e.m_player))
155 p.GetAimingModel().SetRecoil(m_weapon);
156 m_weapon.OnFire(mi);
157 }
158 }
159 if (mi >= m_weapon.GetMuzzleCount() - 1)
160 m_weapon.SetCurrentMuzzle(0);
161 else
162 m_weapon.SetCurrentMuzzle(mi + 1);
163 }
164 super.OnEntry(e);
165 }
166
167 override void OnUpdate(float dt)
168 {
170
172 Class.CastTo(p, m_weapon.GetHierarchyParent());
173
174 int muzzleIndex = m_weapon.GetCurrentMuzzle();
175 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
177 if (m_weapon.CanProcessWeaponEvents())
178 m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
179 }
180
181 override void OnExit(WeaponEventBase e)
182 {
183 if (e)
184 m_dtAccumulator = 0;
185 super.OnExit(e);
186 }
187
188 override void OnAbort(WeaponEventBase e)
189 {
190 m_weapon.ResetBurstCount();
191 super.OnAbort(e);
192 }
193};
194
195
197{
198 override void OnEntry(WeaponEventBase e)
199 {
200 super.OnEntry(e);
201 if (e)
202 {
204 Magnum_Ejector ejector = Magnum_Ejector.Cast(m_weapon.GetAttachmentByType(Magnum_Ejector));
205 if (cylinder && ejector)
206 {
207 float a;
208 int mi = m_weapon.GetCurrentMuzzle();
209 switch (mi)
210 {
211 case 0:
213 break;
214 case 1:
216 cylinder.ResetAnimationPhase("Rotate_Cylinder", MAGNUM_ROTATION_POSITION_6);
217 ejector.ResetAnimationPhase("Rotate_Ejector", MAGNUM_ROTATION_POSITION_6);
218 break;
219 case 2:
221 break;
222 case 3:
224 break;
225 case 4:
227 break;
228 case 5:
230 break;
231 }
232 cylinder.SetAnimationPhase("Rotate_Cylinder", a);
233 ejector.SetAnimationPhase("Rotate_Ejector", a);
234 }
235 }
236 }
237
238 override void OnUpdate(float dt)
239 {
241
243 Class.CastTo(p, m_weapon.GetHierarchyParent());
244
245 int muzzleIndex = m_weapon.GetCurrentMuzzle();
246 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
248 if (m_weapon.CanProcessWeaponEvents())
249 m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
250 }
251
252 override void OnExit(WeaponEventBase e)
253 {
254 if (e)
255 m_dtAccumulator = 0;
256 super.OnExit(e);
257 }
258};
259
260
261// fire to jam
263{
264 float m_dtAccumulator;
265
266 override bool IsWaitingForActionFinish() { return true; }
267
268 override void OnEntry(WeaponEventBase e)
269 {
270 if (e)
271 {
272 m_dtAccumulator = 0;
273
274 if (LogManager.IsWeaponLogEnable()) wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang! and jam?");
275 //m_weapon.Fire();
276 int mi = m_weapon.GetCurrentMuzzle();
278 {
279 m_weapon.SetJammed(true);
281 if (Class.CastTo(p, e.m_player))
282 p.GetAimingModel().SetRecoil(m_weapon);
283 m_weapon.OnFire(mi);
284 }
285 }
286 m_weapon.ResetBurstCount();
287 super.OnEntry(e);
288 }
289
290 override void OnUpdate(float dt)
291 {
293
295 Class.CastTo(p, m_weapon.GetHierarchyParent());
296
297 int muzzleIndex = m_weapon.GetCurrentMuzzle();
298 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
300 if (m_weapon.CanProcessWeaponEvents())
301 m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
302 }
303
304 override void OnExit(WeaponEventBase e)
305 {
306 m_dtAccumulator = 0;
307 super.OnExit(e);
308 }
309};
310
311
313{
314 override void OnEntry(WeaponEventBase e)
315 {
316 super.OnEntry(e);
317 if (e)
318 {
319 if (!m_weapon.IsJammed())
320 {
321 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ejected fired out casing");
322 int mi = m_weapon.GetCurrentMuzzle();
323 m_weapon.EjectCasing(mi);
324 m_weapon.EffectBulletHide(mi);
325 m_weapon.SelectionBulletHide();
326
328 }
329 }
330 }
331};
332
334{
335 override void OnEntry(WeaponEventBase e)
336 {
337 super.OnEntry(e);
338
339 if (!m_weapon.IsJammed())
340 {
341 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ejected fired out casing");
342 int mi = m_weapon.GetCurrentMuzzle();
343 m_weapon.EjectCasing(mi);
344 m_weapon.EffectBulletHide(mi);
345 m_weapon.SelectionBulletHide();
346
348 }
349 }
350};
351
void wpnPrint(string s)
Definition Debug.c:1
void wpnDebugPrint(string s)
Definition Debug.c:9
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
HandStateEquipped OnEntry
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_6
Definition Magnum.c:8
const float MAGNUM_ROTATION_POSITION_5
Definition Magnum.c:7
const float MAGNUM_ROTATION_POSITION_0
Definition Magnum.c:2
override void OnAbort()
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
override bool IsWaitingForActionFinish()
Definition WeaponFire.c:123
proto native bool TryFireWeapon(EntityAI weapon, int muzzleIndex)
Super root of all classes in Enforce script.
Definition EnScript.c:11
static bool IsWeaponLogEnable()
Definition Debug.c:799
signalize mechanism manipulation
Definition Events.c:35
override void OnEntry(WeaponEventBase e)
Definition WeaponFire.c:98
override void OnEntry(WeaponEventBase e)
Definition WeaponFire.c:198
override void OnExit(WeaponEventBase e)
Definition WeaponFire.c:252
override void OnUpdate(float dt)
Definition WeaponFire.c:238
simple class starting animation action specified by m_action and m_actionType
override void OnAbort(WeaponEventBase e)
Definition WeaponFire.c:89
override void OnEntry(WeaponEventBase e)
Definition WeaponFire.c:6
float m_dtAccumulator
Definition WeaponFire.c:4
override bool IsWaitingForActionFinish()
Definition WeaponFire.c:14
override void OnExit(WeaponEventBase e)
Definition WeaponFire.c:33
override void OnUpdate(float dt)
Definition WeaponFire.c:16
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native void OnUpdate()
Definition tools.c:333
bool pushToChamberFromInnerMagazine(Weapon_Base weapon, int muzzleIndex)
bool pushToChamberFromAttachedMagazine(Weapon_Base weapon, int muzzleIndex)
Definition weapon_utils.c:1