DayZ
1.24
Loading...
Searching...
No Matches
RifleSingleShotManual_Base.c
Go to the documentation of this file.
1
5
class
RifleSingleShotManual_Base
extends
RifleSingleShot_Base
6
{
7
void
RifleSingleShotManual_Base
()
8
{
9
}
10
11
override
void
InitStateMachine
()
12
{
13
// setup abilities
14
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.MECHANISM,
WeaponActionMechanismTypes
.MECHANISM_CLOSED));
15
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.MECHANISM,
WeaponActionMechanismTypes
.MECHANISM_OPENED));
16
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.CHAMBERING,
WeaponActionChamberingTypes
.CHAMBERING_ONEBULLET_CLOSED));
17
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.CHAMBERING,
WeaponActionChamberingTypes
.CHAMBERING_ONEBULLET_OPENED));
18
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.UNJAMMING,
WeaponActionUnjammingTypes
.UNJAMMING_START));
19
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.UNJAMMING,
WeaponActionUnjammingTypes
.UNJAMMING_END));
20
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.FIRE,
WeaponActionFireTypes
.FIRE_NORMAL));
21
m_abilities.Insert(
new
AbilityRecord
(
WeaponActions
.FIRE,
WeaponActionFireTypes
.FIRE_COCKED));
22
23
// setup state machine
24
// basic weapon states
25
WeaponStableState
E
=
new
RSSEmpty
(
this
,
NULL
,
RSSAnimState
.DEFAULT);
26
WeaponStableState
F
=
new
RSSFireout
(
this
,
NULL
,
RSSAnimState
.DEFAULT);
27
WeaponStableState
J =
new
RSSJammed
(
this
,
NULL
,
RSSAnimState
.DEFAULT);
28
WeaponStableState
L
=
new
RSSLoaded
(
this
,
NULL
,
RSSAnimState
.DEFAULT);
29
// unstable (intermediate) states
30
WeaponStateBase
Mech_E
=
new
WeaponCharging
(
this
,
NULL
,
WeaponActions
.MECHANISM,
WeaponActionMechanismTypes
.MECHANISM_OPENED);
31
WeaponStateBase
Mech_F
=
new
WeaponCharging
(
this
,
NULL
,
WeaponActions
.MECHANISM,
WeaponActionMechanismTypes
.MECHANISM_CLOSED);
32
WeaponStateBase
Mech_L
=
new
WeaponEjectBullet(
this
,
NULL
,
WeaponActions
.MECHANISM,
WeaponActionMechanismTypes
.MECHANISM_CLOSED);
33
34
WeaponChambering
Chamber_E
=
new
WeaponChambering(
this
,
NULL
,
WeaponActions
.CHAMBERING,
WeaponActionChamberingTypes
.CHAMBERING_ONEBULLET_CLOSED);
35
WeaponChambering
Chamber_F
=
new
WeaponChambering(
this
,
NULL
,
WeaponActions
.CHAMBERING,
WeaponActionChamberingTypes
.CHAMBERING_ONEBULLET_OPENED);
36
//WeaponStateBase Chamber_L = new RifleReChambering(this, NULL, WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED);
37
38
WeaponStateBase
Trigger_E
=
new
WeaponDryFire
(
this
,
NULL
,
WeaponActions
.FIRE,
WeaponActionFireTypes
.FIRE_COCKED);
39
WeaponStateBase
Trigger_L
=
new
WeaponFire
(
this
,
NULL
,
WeaponActions
.FIRE,
WeaponActionFireTypes
.FIRE_NORMAL);
40
WeaponStateBase
Trigger_F
=
new
WeaponDryFire
(
this
,
NULL
,
WeaponActions
.FIRE,
WeaponActionFireTypes
.FIRE_COCKED);
41
42
WeaponStateBase
Trigger_LJ
=
new
WeaponFireToJam
(
this
,
NULL
,
WeaponActions
.FIRE,
WeaponActionFireTypes
.FIRE_JAM);
43
44
WeaponStateBase
Unjam_J
=
new
WeaponUnjamming
(
this
,
NULL
,
WeaponActions
.UNJAMMING,
WeaponActionUnjammingTypes
.UNJAMMING_START);
45
46
// events
47
WeaponEventBase
__M__
=
new
WeaponEventMechanism;
48
WeaponEventBase
__T__
=
new
WeaponEventTrigger;
49
WeaponEventBase
__TJ_
=
new
WeaponEventTriggerToJam;
50
WeaponEventBase
__L__
=
new
WeaponEventLoad1Bullet;
51
WeaponEventBase
__U__
=
new
WeaponEventUnjam;
52
WeaponEventBase
_fin_
=
new
WeaponEventHumanCommandActionFinished;
53
WeaponEventBase
_abt_
=
new
WeaponEventHumanCommandActionAborted;
54
WeaponEventBase
_dto_
=
new
WeaponEventDryFireTimeout;
55
56
m_fsm =
new
WeaponFSM
();
57
// charging
58
m_fsm.AddTransition(
new
WeaponTransition
(
E
,
__M__
,
Mech_E
));
59
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_E
,
_fin_
,
E
));
60
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_E
,
_abt_
,
E
));
61
62
m_fsm.AddTransition(
new
WeaponTransition
(
F
,
__M__
,
Mech_F
));
63
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_F
,
_fin_
,
F
,
NULL
,
new
WeaponGuardCurrentChamberFiredOut(
this
)));
64
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_F
,
_fin_
,
E
));
65
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_F
,
_abt_
,
F
,
NULL
,
new
WeaponGuardCurrentChamberFiredOut(
this
)));
66
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_F
,
_abt_
,
E
));
67
68
// eject good cartridge
69
m_fsm.AddTransition(
new
WeaponTransition
(
L
,
__M__
,
Mech_L
));
70
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_L
,
_fin_
,
E
,
NULL
,
new
WeaponGuardCurrentChamberEmpty(
this
)));
71
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_L
,
_fin_
,
L
));
72
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_L
,
_abt_
,
E
,
NULL
,
new
WeaponGuardCurrentChamberEmpty(
this
)));
73
m_fsm.AddTransition(
new
WeaponTransition
(
Mech_L
,
_abt_
,
L
));
74
75
// load bullet
76
m_fsm.AddTransition(
new
WeaponTransition
(
E
,
__L__
,
Chamber_E
));
77
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_E
,
_fin_
,
E
,
NULL
,
new
WeaponGuardCurrentChamberEmpty(
this
)));
78
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_E
,
_fin_
,
L
));
79
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_E
,
_abt_
,
E
,
NULL
,
new
WeaponGuardCurrentChamberEmpty(
this
)));
80
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_E
,
_abt_
,
L
));
81
82
m_fsm.AddTransition(
new
WeaponTransition
(
F
,
__L__
,
Chamber_F
));
83
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_F
,
_fin_
,
F
,
NULL
,
new
WeaponGuardCurrentChamberFiredOut(
this
)));
84
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_F
,
_fin_
,
E
,
NULL
,
new
WeaponGuardCurrentChamberEmpty(
this
)));
85
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_F
,
_fin_
,
L
));
86
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_F
,
_abt_
,
F
,
NULL
,
new
WeaponGuardCurrentChamberFiredOut(
this
)));
87
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_F
,
_abt_
,
E
,
NULL
,
new
WeaponGuardCurrentChamberEmpty(
this
)));
88
m_fsm.AddTransition(
new
WeaponTransition
(
Chamber_F
,
_abt_
,
L
));
89
90
// fire
91
m_fsm.AddTransition(
new
WeaponTransition
(
E
,
__T__
,
Trigger_E
));
// fire cocked
92
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_E
,
_fin_
,
E
));
93
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_E
,
_dto_
,
E
));
94
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_E
,
_abt_
,
E
));
95
96
m_fsm.AddTransition(
new
WeaponTransition
(
F
,
__T__
,
Trigger_F
));
// fire uncocked
97
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_F
,
_fin_
,
F
));
98
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_F
,
_dto_
,
F
));
99
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_F
,
_abt_
,
F
));
100
101
m_fsm.AddTransition(
new
WeaponTransition
(
L
,
__T__
,
Trigger_L
));
// a) fire if not jammed
102
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_L
,
_fin_
,
F
));
103
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_L
,
_abt_
,
F
));
104
105
m_fsm.AddTransition(
new
WeaponTransition
(
L
,
__TJ_
,
Trigger_LJ
));
// a) fire if not jammed
106
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_LJ
,
_fin_
, J));
107
m_fsm.AddTransition(
new
WeaponTransition
(
Trigger_LJ
,
_abt_
, J));
108
109
// unjam
110
m_fsm.AddTransition(
new
WeaponTransition
(J,
__U__
,
Unjam_J
));
111
m_fsm.AddTransition(
new
WeaponTransition
(
Unjam_J
,
_fin_
, J,
NULL
,
new
WeaponGuardJammed(
this
)));
112
m_fsm.AddTransition(
new
WeaponTransition
(
Unjam_J
,
_fin_
,
E
));
113
114
// initial state setup
115
bool
empty
=
true
;
116
bool
discharged
=
false
;
// @TODO:
117
WeaponStableState
init_state
=
E
;
118
if
(
empty
)
119
{
120
if
(!
discharged
)
121
init_state
=
E
;
122
}
123
else
124
{
125
init_state
=
L
;
// can init state == load/jammed?
126
}
127
SetInitialState(
init_state
);
128
129
SelectionBulletHide();
130
131
m_fsm.Start();
132
}
133
};
RSSAnimState
RSSAnimState
Definition
RifleSingleShot_Base.c:2
WeaponTransition
enum FSMTransition WeaponTransition
E
@ E
EMPTY.
Definition
WeaponStableState.c:19
L
@ L
LOADED.
Definition
WeaponStableState.c:23
F
@ F
FIRED.
Definition
WeaponStableState.c:21
AbilityRecord
pair ( action, actionType )
Definition
Weapon_Base.c:5
Param3
Definition
EntityAI.c:95
RifleSingleShot_Base
Definition
Izh18.c:6
RifleSingleShot_Base::RifleSingleShotManual_Base
void RifleSingleShotManual_Base()
Definition
RifleSingleShotManual_Base.c:7
RifleSingleShot_Base::InitStateMachine
override void InitStateMachine()
Definition
RifleSingleShotManual_Base.c:11
RifleSingleShotManual_Base
Definition
M79.c:2
WeaponCharging
charging of weapon without ammo to be chambered
WeaponEventBase
signalize mechanism manipulation
Definition
Events.c:35
WeaponFSM
weapon finite state machine
WeaponFire
Definition
WeaponFire.c:97
WeaponStableState
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Definition
Crossbow.c:27
WeaponStateBase
represent weapon state base
Definition
BulletHide.c:2
WeaponUnjamming
unjam submachine
WeaponActionChamberingTypes
WeaponActionChamberingTypes
Definition
human.c:856
WeaponActions
WeaponActions
actions
Definition
human.c:796
WeaponActionUnjammingTypes
WeaponActionUnjammingTypes
Definition
human.c:892
WeaponActionFireTypes
WeaponActionFireTypes
Definition
human.c:900
scripts
4_World
Entities
Firearms
RifleSingleShotManual_Base.c
Generated by
1.10.0