DayZ 1.24
Loading...
Searching...
No Matches
WeaponEjectBullet.c
Go to the documentation of this file.
1// eject
2//TODO MW delete this file
4{ };
5/*
6 class WeaponEjectBullet_Cartridge extends WeaponStateBase
7 {
8 Magazine m_dstMagazine; /// destination of the cartridge
9
10 override void OnEntry (WeaponEventBase e)
11 {
12 super.OnEntry(e);
13
14 DayZPlayer p = e.m_player;
15 int mi = m_weapon.GetCurrentMuzzle();
16
17 ejectBulletAndStoreInMagazine(m_weapon, mi, m_dstMagazine, p); // MP-safe
18 }
19
20 override void OnAbort (WeaponEventBase e)
21 {
22 m_dstMagazine = NULL;
23 super.OnAbort(e);
24 }
25
26 override void OnExit (WeaponEventBase e)
27 {
28 m_dstMagazine = NULL;
29 super.OnExit(e);
30 }
31 };
32*/
33/*
34 class WeaponEjectBullet_Cartridge_W4T extends WeaponEjectBullet_Cartridge
35 {
36 override bool IsWaitingForActionFinish () { return true; }
37 };
38*/
39class WeaponEjectBullet extends WeaponStateBase
40{
42 int m_actionType;
44
46 ref WeaponEjectBullet_Cartridge_W4T m_eject; // @TODO: workaround for missing BH event
49
51 {
53 m_actionType = actionType;
54
55 // setup nested state machine
56 m_start = new WeaponEjectBullet_Start(m_weapon, this, m_action, m_actionType);
57 m_eject = new WeaponEjectBullet_Cartridge_W4T(m_weapon, this); // @TODO: workaround for missing BH event (_W4T)
58 m_hideB = new BulletHide_W4T(m_weapon, this);
60
61 // events
62 WeaponEventBase __be_ = new WeaponEventAnimBulletEject;
63 WeaponEventBase __bh_ = new WeaponEventAnimBulletHide;
64 WeaponEventBase __ck_ = new WeaponEventAnimCocked;
65 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
66
67 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
68 // transitions
69 m_fsm.AddTransition(new WeaponTransition(m_start, __be_, m_eject));
70 m_fsm.AddTransition(new WeaponTransition(m_eject, __bh_, m_hideB));
71
72 m_fsm.AddTransition(new WeaponTransition(m_eject, __ck_, m_chamber, NULL, new WeaponGuardHasAmmo(m_weapon)));
73 m_fsm.AddTransition(new WeaponTransition(m_hideB, __ck_, m_chamber, NULL, new WeaponGuardHasAmmo(m_weapon)));
74
75 m_fsm.AddTransition(new WeaponTransition(m_hideB, _fin_, NULL));
76 m_fsm.AddTransition(new WeaponTransition(m_eject, _fin_, NULL)); // @TODO: workaround for missing BH event
77 m_fsm.AddTransition(new WeaponTransition(m_chamber, _fin_, NULL));
78
79 // Safety exits
80 m_fsm.AddTransition(new WeaponTransition(m_start, _fin_, null));
81
82 m_fsm.SetInitialState(m_start);
83 }
84
85 override void OnEntry(WeaponEventBase e)
86 {
87 if (e)
88 {
89 if (e.m_magazine)
90 m_dstMagazine = e.m_magazine;
91 m_eject.m_dstMagazine = m_dstMagazine;
92
93 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponEjectBullet m_mag=" + m_dstMagazine.ToString() + ", e.mag=" + e.m_magazine.ToString());
94 }
95
96 super.OnEntry(e); // @NOTE: super after submachine init (prevent override from submachine start)
97
98 }
99
100 override void OnAbort(WeaponEventBase e)
101 {
102 m_dstMagazine = NULL;
103 super.OnAbort(e);
104 }
105
106 override void OnExit(WeaponEventBase e)
107 {
108 m_dstMagazine = NULL;
109 super.OnExit(e);
110 }
111
113 {
114 if (!super.SaveCurrentFSMState(ctx))
115 return false;
116
117 if (!ctx.Write(m_dstMagazine))
118 {
119 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponEjectBullet.LoadCurrentFSMState: cannot write m_dstMagazine for weapon=" + m_weapon);
120 return false;
121 }
122 return true;
123 }
124
125 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
126 {
127 if (!super.LoadCurrentFSMState(ctx, version))
128 return false;
129
130 if (!ctx.Read(m_dstMagazine))
131 {
132 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponEjectBullet.LoadCurrentFSMState: cannot read m_dstMagazine for weapon=" + m_weapon);
133 return false;
134 }
135 return true;
136 }
137};
138
void wpnDebugPrint(string s)
Definition Debug.c:9
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
void WeaponGuardHasAmmo(Weapon_Base w=NULL)
Definition Guards.c:99
enum FSMTransition WeaponTransition
ref WeaponStateBase m_start
class WeaponEndAction extends WeaponStartAction m_action
ref WeaponChambering_Base m_chamber
ref WeaponEjectCasingMultiMuzzle m_eject
static bool IsWeaponLogEnable()
Definition Debug.c:799
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine
simple class starting animation action specified by m_action and m_actionType
represent weapon state base
Definition BulletHide.c:2
ref BulletHide_W4T m_hideB
int m_actionType
action to be played
void WeaponEjectBullet(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
ref WeaponEjectBullet_Cartridge_W4T m_eject
WeaponActions m_action
ref WeaponEjectBullet_Start m_start
destination of the cartridge
ref WeaponChambering_Cartridge m_chamber
override void OnEntry(WeaponEventBase e)
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
override void OnAbort(WeaponEventBase e)
override void OnExit(WeaponEventBase e)
override bool SaveCurrentFSMState(ParamsWriteContext ctx)
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
WeaponActions
actions
Definition human.c:796