Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
weaponfire.c
Go to the documentation of this file.
1 // fire
2 class WeaponDryFire extends WeaponStartAction
3 {
4  float m_dtAccumulator;
5 
6  override void OnEntry (WeaponEventBase e)
7  {
8  super.OnEntry(e);
9  if (e)
10  {
11  m_dtAccumulator = 0;
12  }
13  m_weapon.ResetBurstCount();
14  }
15 
16  override bool IsWaitingForActionFinish () { return true; }
17 
18  override void OnUpdate (float dt)
19  {
20  m_dtAccumulator += dt;
21  DayZPlayer p;
22  Class.CastTo(p, m_weapon.GetHierarchyParent());
23  if (p)
24  {
25  HumanInputController hic = p.GetInputController();
26 
27  int muzzleIndex = m_weapon.GetCurrentMuzzle();
28  float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
29  if ( hic.IsAttackButton() && m_dtAccumulator >= reloadTime)
30  if (m_weapon.CanProcessWeaponEvents())
31  m_weapon.ProcessWeaponEvent(new WeaponEventDryFireTimeout(p));
32  }
33  }
34 
35  override void OnExit (WeaponEventBase e)
36  {
37  m_dtAccumulator = 0;
38  super.OnExit(e);
39  }
40 
41 };
42 
43 // fire
44 class WeaponFire extends WeaponStartAction
45 {
46  float m_dtAccumulator;
47 
48  override bool IsWaitingForActionFinish () { return true; }
49 
50  override void OnEntry (WeaponEventBase e)
51  {
52  if (e)
53  {
54  m_dtAccumulator = 0;
55 
56  if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang!"); }
57  //m_weapon.Fire();
58  int mi = m_weapon.GetCurrentMuzzle();
59  if (TryFireWeapon(m_weapon, mi))
60  {
62  if (Class.CastTo(p, e.m_player))
63  p.GetAimingModel().SetRecoil(m_weapon);
64  m_weapon.OnFire(mi);
65  }
66  }
67  super.OnEntry(e);
68  }
69 
70  override void OnUpdate (float dt)
71  {
72  m_dtAccumulator += dt;
73 
74  DayZPlayer p;
75  Class.CastTo(p, m_weapon.GetHierarchyParent());
76 
77  int muzzleIndex = m_weapon.GetCurrentMuzzle();
78  float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
79  if (m_dtAccumulator >= reloadTime)
80  if (m_weapon.CanProcessWeaponEvents())
81  m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
82  }
83 
84  override void OnExit (WeaponEventBase e)
85  {
86  if (e)
87  m_dtAccumulator = 0;
88  super.OnExit(e);
89  }
90 
91  override void OnAbort (WeaponEventBase e)
92  {
93  m_weapon.ResetBurstCount();
94  super.OnAbort(e);
95  }
96 };
97 
98 class WeaponFireWithEject extends WeaponFire
99 {
100  override void OnEntry (WeaponEventBase e)
101  {
102  m_dtAccumulator = 0;
103 
104  if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang!"); }
105  //m_weapon.Fire();
106  int mi = m_weapon.GetCurrentMuzzle();
107  if (TryFireWeapon(m_weapon, mi))
108  {
110  if (Class.CastTo(p, e.m_player))
111  p.GetAimingModel().SetRecoil(m_weapon);
112  m_weapon.EjectCasing(mi);
113  m_weapon.EffectBulletHide(mi);
114  m_weapon.OnFire(mi);
115  }
116  super.OnEntry(e);
117  }
118 }
119 
120 // fire
122 {
123  float m_dtAccumulator;
124 
125  override bool IsWaitingForActionFinish () { return true; }
126 
127  override void OnEntry (WeaponEventBase e)
128  {
129  if (e)
130  {
131  m_dtAccumulator = 0;
132 
133  if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang bang!"); }
134 
135  int mi = m_weapon.GetCurrentMuzzle();
136  int b = m_weapon.GetCurrentModeBurstSize(mi);
137  if (b > 1)
138  {
139 
140  for (int i = 0; i < b; i++)
141  {
142  if (TryFireWeapon(m_weapon, i))
143  {
145  if (Class.CastTo(p1, e.m_player))
146  p1.GetAimingModel().SetRecoil(m_weapon);
147  m_weapon.OnFire(i);
148  }
149  }
150  }
151  else
152  {
153  if (TryFireWeapon(m_weapon, mi))
154  {
156  if (Class.CastTo(p, e.m_player))
157  p.GetAimingModel().SetRecoil(m_weapon);
158  m_weapon.OnFire(mi);
159  }
160  }
161  if(mi >= m_weapon.GetMuzzleCount() - 1 )
162  m_weapon.SetCurrentMuzzle(0);
163  else
164  m_weapon.SetCurrentMuzzle(mi + 1);
165  }
166  super.OnEntry(e);
167  }
168 
169  override void OnUpdate (float dt)
170  {
171  m_dtAccumulator += dt;
172 
173  DayZPlayer p;
174  Class.CastTo(p, m_weapon.GetHierarchyParent());
175 
176  int muzzleIndex = m_weapon.GetCurrentMuzzle();
177  float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
178  if (m_dtAccumulator >= reloadTime)
179  if (m_weapon.CanProcessWeaponEvents())
180  m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
181  }
182 
183  override void OnExit (WeaponEventBase e)
184  {
185  if (e)
186  m_dtAccumulator = 0;
187  super.OnExit(e);
188  }
189 
190  override void OnAbort (WeaponEventBase e)
191  {
192  m_weapon.ResetBurstCount();
193  super.OnAbort(e);
194  }
195 };
196 
197 
198 class WeaponFireMagnum extends WeaponFireMultiMuzzle
199 {
200  override void OnEntry (WeaponEventBase e)
201  {
202  super.OnEntry(e);
203  if (e)
204  {
205  Magnum_Cylinder cylinder = Magnum_Cylinder.Cast(m_weapon.GetAttachmentByType(Magnum_Cylinder));
206  Magnum_Ejector ejector = Magnum_Ejector.Cast(m_weapon.GetAttachmentByType(Magnum_Ejector));
207  if(cylinder && ejector)
208  {
209  float a;
210  int mi = m_weapon.GetCurrentMuzzle();
211  switch(mi)
212  {
213  case 0:
215  break;
216  case 1:
218  cylinder.ResetAnimationPhase("Rotate_Cylinder", MAGNUM_ROTATION_POSITION_6 );
219  ejector.ResetAnimationPhase("Rotate_Ejector", MAGNUM_ROTATION_POSITION_6 );
220  break;
221  case 2:
223  break;
224  case 3:
226  break;
227  case 4:
229  break;
230  case 5:
232  break;
233  }
234  cylinder.SetAnimationPhase("Rotate_Cylinder", a );
235  ejector.SetAnimationPhase("Rotate_Ejector", a );
236  }
237  }
238  }
239 
240  override void OnUpdate (float dt)
241  {
242  m_dtAccumulator += dt;
243 
244  DayZPlayer p;
245  Class.CastTo(p, m_weapon.GetHierarchyParent());
246 
247  int muzzleIndex = m_weapon.GetCurrentMuzzle();
248  float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
249  if (m_dtAccumulator >= reloadTime)
250  if (m_weapon.CanProcessWeaponEvents())
251  m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
252  }
253 
254  override void OnExit (WeaponEventBase e)
255  {
256  if (e)
257  m_dtAccumulator = 0;
258  super.OnExit(e);
259  }
260 };
261 
262 
263 
264 // fire to jam
265 class WeaponFireToJam extends WeaponStartAction
266 {
267  float m_dtAccumulator;
268 
269  override bool IsWaitingForActionFinish () { return true; }
270 
271  override void OnEntry (WeaponEventBase e)
272  {
273  if (e)
274  {
275  m_dtAccumulator = 0;
276 
277  if (LogManager.IsWeaponLogEnable()) { wpnPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponFire bang! and jam?"); }
278  //m_weapon.Fire();
279  int mi = m_weapon.GetCurrentMuzzle();
280  if (TryFireWeapon(m_weapon, mi))
281  {
282  m_weapon.SetJammed(true);
284  if (Class.CastTo(p, e.m_player))
285  p.GetAimingModel().SetRecoil(m_weapon);
286  m_weapon.OnFire(mi);
287  }
288  }
289  m_weapon.ResetBurstCount();
290  super.OnEntry(e);
291  }
292 
293  override void OnUpdate (float dt)
294  {
295  m_dtAccumulator += dt;
296 
297  DayZPlayer p;
298  Class.CastTo(p, m_weapon.GetHierarchyParent());
299 
300  int muzzleIndex = m_weapon.GetCurrentMuzzle();
301  float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
302  if (m_dtAccumulator >= reloadTime)
303  if (m_weapon.CanProcessWeaponEvents())
304  m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
305  }
306 
307  override void OnExit (WeaponEventBase e)
308  {
309  m_dtAccumulator = 0;
310  super.OnExit(e);
311  }
312 };
313 
314 
315 class WeaponFireAndChamber extends WeaponFire
316 {
317  override void OnEntry (WeaponEventBase e)
318  {
319  super.OnEntry(e);
320  if (e)
321  {
322  if (!m_weapon.IsJammed())
323  {
324  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ejected fired out casing"); }
325  int mi = m_weapon.GetCurrentMuzzle();
326  m_weapon.EjectCasing(mi);
327  m_weapon.EffectBulletHide(mi);
328  m_weapon.SelectionBulletHide();
329 
331  }
332  }
333  }
334 };
335 
336 class WeaponFireAndChamberFromInnerMagazine extends WeaponFire
337 {
338  override void OnEntry (WeaponEventBase e)
339  {
340  super.OnEntry(e);
341 
342  if (!m_weapon.IsJammed())
343  {
344  if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " ejected fired out casing"); }
345  int mi = m_weapon.GetCurrentMuzzle();
346  m_weapon.EjectCasing(mi);
347  m_weapon.EffectBulletHide(mi);
348  m_weapon.SelectionBulletHide();
349 
351  }
352  }
353 };
354 
IsWaitingForActionFinish
override bool IsWaitingForActionFinish()
Definition: weaponfire.c:125
LogManager
Definition: debug.c:734
MAGNUM_ROTATION_POSITION_0
const float MAGNUM_ROTATION_POSITION_0
Definition: magnum.c:2
WeaponFireMultiMuzzle
Definition: weaponfire.c:198
MAGNUM_ROTATION_POSITION_5
const float MAGNUM_ROTATION_POSITION_5
Definition: magnum.c:7
wpnDebugPrint
void wpnDebugPrint(string s)
Definition: debug.c:9
WeaponFire
Definition: weaponfire.c:98
MAGNUM_ROTATION_POSITION_2
const float MAGNUM_ROTATION_POSITION_2
Definition: magnum.c:4
m_dtAccumulator
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
OnExit
override void OnExit(WeaponEventBase e)
Definition: weaponfire.c:183
MAGNUM_ROTATION_POSITION_4
const float MAGNUM_ROTATION_POSITION_4
Definition: magnum.c:6
WeaponStartAction
simple class starting animation action specified by m_action and m_actionType
Definition: weaponchambering.c:2
DayZPlayer
Definition: dayzplayerimplement.c:72
OnAbort
override void OnAbort(WeaponEventBase e)
Definition: weaponfire.c:190
OnUpdate
override void OnUpdate(float dt)
Definition: weaponfire.c:169
OnEntry
override void OnEntry(WeaponEventBase e)
Definition: weaponfire.c:127
Object
Definition: objecttyped.c:1
pushToChamberFromAttachedMagazine
bool pushToChamberFromAttachedMagazine(Weapon_Base weapon, int muzzleIndex)
Definition: weapon_utils.c:1
DayZPlayerImplement
Definition: manbase.c:1
MAGNUM_ROTATION_POSITION_6
const float MAGNUM_ROTATION_POSITION_6
Definition: magnum.c:8
HumanInputController
Definition: human.c:17
MAGNUM_ROTATION_POSITION_3
const float MAGNUM_ROTATION_POSITION_3
Definition: magnum.c:5
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
TryFireWeapon
proto native bool TryFireWeapon(EntityAI weapon, int muzzleIndex)
m_weapon
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition: guards.c:583
wpnPrint
void wpnPrint(string s)
Definition: debug.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
MAGNUM_ROTATION_POSITION_1
const float MAGNUM_ROTATION_POSITION_1
Definition: magnum.c:3
pushToChamberFromInnerMagazine
bool pushToChamberFromInnerMagazine(Weapon_Base weapon, int muzzleIndex)
Definition: weapon_utils.c:33