Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
weaponfireandchambernext.c
Go to the documentation of this file.
1class WeaponFireAndChamberNext extends WeaponStateBase
2{
3 WeaponActions m_action;
4 int m_actionType;
5
6 float m_dtAccumulator;
7 ref WeaponFire m_fire;
8
9 void WeaponFireAndChamberNext (Weapon_Base w = NULL, WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE, int actionType = -1)
10 {
11 m_action = action;
12 m_actionType = actionType;
13
14 // setup nested state machine
15 m_fire = new WeaponFireAndChamber(m_weapon, this, m_action, m_actionType);
16
17 // events
18 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
19 WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
20 WeaponEventReloadTimeout __to_ = new WeaponEventReloadTimeout;
21
22 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
23
24 // transitions
25 m_fsm.AddTransition(new WeaponTransition(m_fire, _fin_, NULL));
26 m_fsm.AddTransition(new WeaponTransition(m_fire, __to_, NULL));
27
28 m_fsm.SetInitialState(m_fire);
29 }
30
31 override void OnEntry (WeaponEventBase e)
32 {
33 super.OnEntry(e);
34 if (e)
36 }
37
38 override void OnUpdate (float dt)
39 {
40 m_dtAccumulator += dt;
42 Class.CastTo(p, m_weapon.GetHierarchyParent());
43 if( p )
44 {
45 HumanInputController hic = p.GetInputController();
46
47 int muzzleIndex = m_weapon.GetCurrentMuzzle();
48 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
49
50 if ( m_dtAccumulator >= reloadTime && ( hic.IsAttackButton() || (m_weapon.GetBurstCount() < m_weapon.GetCurrentModeBurstSize(muzzleIndex))))
51 {
52 if (m_weapon.CanProcessWeaponEvents())
53 {
54 m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
55 }
56 }
57 }
58 }
59
60 override void OnExit (WeaponEventBase e)
61 {
62 //m_weapon.ResetBurstCount();
64 super.OnExit(e);
65 }
66
67 override void OnAbort (WeaponEventBase e)
68 {
69 m_weapon.SetCoolDown(GetCoolDown());
70 m_weapon.ResetBurstCount();
71 super.OnAbort(e);
72 }
73
74 override float GetCoolDown()
75 {
76 int muzzleIndex = m_weapon.GetCurrentMuzzle();
77 float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
78 return reloadTime - m_dtAccumulator;
79 }
80};
81
82
Super root of all classes in Enforce script.
Definition enscript.c:11
signalize mechanism manipulation
Definition events.c:35
weapon finite state machine
represent weapon state base
Definition bullethide.c:2
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition guards.c:604
HandStateEquipped OnEntry
override void OnAbort()
enum FSMTransition WeaponTransition
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
class WeaponEndAction extends WeaponStartAction m_action
class WeaponFireWithEject extends WeaponFire m_dtAccumulator