DayZ 1.24
Loading...
Searching...
No Matches
SingleShotPistol_Base Class Reference
Inheritance diagram for SingleShotPistol_Base:
[legend]
Collaboration diagram for SingleShotPistol_Base:
[legend]

Private Member Functions

override void InitStateMachine ()
 

Detailed Description

Definition at line 52 of file SingleShotPistol_Base.c.

Member Function Documentation

◆ InitStateMachine()

override void SingleShotPistol_Base::InitStateMachine ( )
inlineprivate

Definition at line 54 of file SingleShotPistol_Base.c.

55 {
56 // setup abilities
57 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
58 m_abilities.Insert(new AbilityRecord(WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED));
59 m_abilities.Insert(new AbilityRecord(WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED));
60 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_NORMAL));
61 m_abilities.Insert(new AbilityRecord(WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED));
62
63 // setup state machine
64 // basic weapon states
65 WeaponStableState E = new SSPEmpty(this, NULL, SSPAnimState.UNCOCKED);
66 WeaponStableState F = new SSPFireout(this, NULL, SSPAnimState.UNCOCKED);
67 WeaponStableState L = new SSPLoaded(this, NULL, SSPAnimState.COCKED);
68 // unstable (intermediate) states
69 WeaponStateBase Mech_F = new WeaponCharging(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED);
70 WeaponStateBase Mech_L = new WeaponEjectBullet(this, NULL, WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED);
71
72 WeaponStateBase Chamber_E = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
73 WeaponStateBase Chamber_F = new WeaponChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
74 //WeaponStateBase Chamber_L = new RifleReChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
75
79
80
81 // events
82 WeaponEventBase __M__ = new WeaponEventMechanism;
83 WeaponEventBase __T__ = new WeaponEventTrigger;
84 WeaponEventBase __TJ_ = new WeaponEventTriggerToJam;
85 WeaponEventBase __L__ = new WeaponEventLoad1Bullet;
86 WeaponEventBase __U__ = new WeaponEventUnjam;
87 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
88 WeaponEventBase _abt_ = new WeaponEventHumanCommandActionAborted;
89 WeaponEventBase _dto_ = new WeaponEventDryFireTimeout;
90
91 m_fsm = new WeaponFSM();
92 // charging
93 m_fsm.AddTransition(new WeaponTransition(E, __M__, Mech_F));
94 m_fsm.AddTransition(new WeaponTransition(F, __M__, Mech_F));
95 m_fsm.AddTransition(new WeaponTransition(Mech_F, _fin_, E));
96 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
97 m_fsm.AddTransition(new WeaponTransition(Mech_F, _abt_, E));
98
99 // eject good cartridge
100 m_fsm.AddTransition(new WeaponTransition(L, __M__, Mech_L));
101 m_fsm.AddTransition(new WeaponTransition(Mech_L, _fin_, E));
102 m_fsm.AddTransition(new WeaponTransition(Mech_L, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
103 m_fsm.AddTransition(new WeaponTransition(Mech_L, _abt_, L));
104
105 m_fsm.AddTransition(new WeaponTransition(E, __L__, Chamber_F));
106 m_fsm.AddTransition(new WeaponTransition(F, __L__, Chamber_F));
107 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _fin_, L));
108 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, F, NULL, new WeaponGuardCurrentChamberFiredOut(this)));
109 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, E, NULL, new WeaponGuardCurrentChamberEmpty(this)));
110 m_fsm.AddTransition(new WeaponTransition(Chamber_F, _abt_, L));
111
112 // fire
113 m_fsm.AddTransition(new WeaponTransition(E, __T__, Trigger_E)); // fire cocked
114 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _fin_, E));
115 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _dto_, E));
116 m_fsm.AddTransition(new WeaponTransition(Trigger_E, _abt_, E));
117
118 m_fsm.AddTransition(new WeaponTransition(F, __T__, Trigger_F)); // fire uncocked
119 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _fin_, F));
120 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _dto_, F));
121 m_fsm.AddTransition(new WeaponTransition(Trigger_F, _abt_, F));
122
123 m_fsm.AddTransition(new WeaponTransition(L, __T__, Trigger_L)); // a) fire if not jammed
124 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _fin_, F));
125 m_fsm.AddTransition(new WeaponTransition(Trigger_L, _abt_, F));
126
127
128 // initial state setup
129 bool empty = true;
130 bool discharged = false; // @TODO:
132 if (empty)
133 {
134 if (!discharged)
135 init_state = E;
136 }
137 else
138 {
139 init_state = L; // can init state == load/jammed?
140 }
141 SetInitialState(init_state);
142
143 SelectionBulletHide();
144
145 m_fsm.Start();
146 }
enum FSMTransition WeaponTransition
@ E
EMPTY.
@ L
LOADED.
@ F
FIRED.
pair ( action, actionType )
Definition Weapon_Base.c:5
charging of weapon without ammo to be chambered
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
represent weapon state base
Definition BulletHide.c:2
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionFireTypes
Definition human.c:900

References E, F, and L.


The documentation for this class was generated from the following file: