DayZ 1.24
Loading...
Searching...
No Matches
FirearmActionLoadMultiBullet.c
Go to the documentation of this file.
2{
3 //-----------------------------------------------------
4 // Action events and methods
5 //-----------------------------------------------------
7 {
8 m_Text = "#load_bullets";
9 }
10
11 override int GetActionCategory()
12 {
13 return AC_CONTINUOUS;
14 }
15
16 /*string GetTargetDescription()
17 {
18 return "default target description";
19 }*/
20
21 /*protected bool ActionConditionContinue( ActionData action_data ) //condition for action
22 {
23 return true;
24 }*/
25
26 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item) //condition for action
27 {
28 if (!super.ActionCondition(player, target, item))
29 return false;
30
32 Magazine mag = Magazine.Cast(target.GetObject());
33 return mag && player.GetWeaponManager().CanLoadBullet(wpn, mag);
34 }
35
37 {
38 super.Start(action_data);
39 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
40
41 action_data.m_Player.GetWeaponManager().LoadMultiBullet(mag, this);
42
43 }
44
46 {
47 return false;
48 }
49
50 override bool CanBeSetFromInventory()
51 {
52 return false;
53 }
54
56 {
57 action_data.m_Player.GetWeaponManager().LoadMultiBulletStop();
58 }
59
61 {
62 return true;
63 }
64
65 override bool HasProgress()
66 {
67 return false;
68 }
69
70 // action need first have permission from server before can start
71 /*bool UseAcknowledgment()
72 {
73 return true;
74 }*/
75
76
77 /*override int GetState( ActionData action_data )
78 {
79 return UA_PROCESSING;
80 }*/
81
82 /*override float GetProgress( ActionData action_data )
83 {
84 return -1;
85 }*/
86
87 override typename GetInputType()
88 {
90 }
91};
92
93
95{
96 //-----------------------------------------------------
97 // Action events and methods
98 //-----------------------------------------------------
102
103 override bool HasTarget()
104 {
105 return false;
106 }
107
108 override bool HasProgress()
109 {
110 return false;
111 }
112
113 override typename GetInputType()
114 {
116 }
117
119 {
122 }
123
124
125 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item) //condition for action
126 {
127 if (!super.ActionCondition(player, target, item))
128 return false;
129
131 return player.GetWeaponManager().CanLoadBullet(weapon, player.GetWeaponManager().GetPreparedMagazine());
132 }
133
135 {
136 super.Start(action_data);
137
138 WeaponManager weaponManager = action_data.m_Player.GetWeaponManager();
139 int idx = 0;
140 Magazine mag = weaponManager.GetNextPreparedMagazine(idx);
141 Weapon weapon = Weapon.Cast(action_data.m_Player.GetItemInHands());
142
143 int internalCount = weapon.GetInternalMagazineCartridgeCount(0);
144 int maxCount = weapon.GetInternalMagazineMaxCartridgeCount(0) + 1;
145 int total = mag.GetAmmoCount() + internalCount;
146
147 if (total < maxCount)
148 {
149 //Increment index for the first additional mag find, since GetNextPreparedMagazine does not do that
150 //Normally the mag at found index is combined right after, removing it from the suitable magazine array
151 ++idx;
152 Magazine additionalMag = weaponManager.GetNextPreparedMagazine(idx);
153
154 while ((additionalMag != null) && (total < maxCount))
155 {
156 total += additionalMag.GetAmmoCount();
157 mag.CombineItems(additionalMag);
158 additionalMag = weaponManager.GetNextPreparedMagazine(idx);
159 }
160 }
161
162 action_data.m_Player.GetWeaponManager().LoadMultiBullet(mag, this);
163 }
164
166 {
167 action_data.m_Player.GetWeaponManager().LoadMultiBulletStop();
168 }
169};
170
172{
173 //-----------------------------------------------------
174 // Action events and methods
175 //-----------------------------------------------------
179
180 override bool HasProgress()
181 {
182 return false;
183 }
184
186 {
189 }
190
192 {
193 if (!super.CanContinue(action_data))
194 return false;
195
196 return ActionCondition(action_data.m_Player, action_data.m_Target, action_data.m_MainItem);
197 }
198
199 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item) //condition for action
200 {
201 if (!super.ActionCondition(player, target, item))
202 return false;
203
205 Magazine mag = Magazine.Cast(target.GetObject());
206 return mag && player.GetWeaponManager().CanLoadBullet(wpn, mag);
207 }
208
210 {
211 super.OnStart(action_data);
212
213 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
214 action_data.m_Player.GetWeaponManager().LoadMultiBullet(mag, this);
215 }
216
218 {
219 action_data.m_Player.GetWeaponManager().LoadMultiBulletStop();
220 }
221};
222
const int AC_CONTINUOUS
Definition _constants.c:3
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
void ContinuousDefaultActionInput(PlayerBase player)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnEndInput(ActionData action_data)
override void Start(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnEndInput(ActionData action_data)
override void Start(ActionData action_data)
override bool CanContinue(ActionData action_data)
override void OnEnd(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnStart(ActionData action_data)
script counterpart to engine's class Weapon