DayZ 1.24
Loading...
Searching...
No Matches
WeaponFireAndChamberNext.c
Go to the documentation of this file.
1class WeaponFireAndChamberNext extends WeaponStateBase
2{
4 int m_actionType;
5
8
10 {
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 {
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 m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
54 }
55 }
56 }
57
58 override void OnExit(WeaponEventBase e)
59 {
60 //m_weapon.ResetBurstCount();
62 super.OnExit(e);
63 }
64
65 override void OnAbort(WeaponEventBase e)
66 {
67 m_weapon.ResetBurstCount();
68 super.OnAbort(e);
69 }
70};
71
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
enum FSMTransition WeaponTransition
class WeaponEndAction extends WeaponStartAction m_action
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
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
int m_actionType
action to be played
void WeaponFireAndChamberNext(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
WeaponActions m_action
override void OnEntry(WeaponEventBase e)
override void OnUpdate(float dt)
override void OnAbort(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
WeaponActions
actions
Definition human.c:796