Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
31  Weapon_Base wpn = Weapon_Base.Cast(item);
32  Magazine mag = Magazine.Cast(target.GetObject());
33  return mag && player.GetWeaponManager().CanLoadBullet(wpn,mag);
34  }
35 
36  override void Start( ActionData action_data )
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 
45  override bool CanBePerformedFromInventory()
46  {
47  return false;
48  }
49 
50  override bool CanBeSetFromInventory()
51  {
52  return false;
53  }
54 
55  override void OnEndInput( ActionData action_data )
56  {
57  action_data.m_Player.GetWeaponManager().LoadMultiBulletStop();
58  }
59 
60  override bool CanBePerformedFromQuickbar()
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  //-----------------------------------------------------
100  {
101  }
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 
118  override void CreateConditionComponents()
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 
130  Weapon_Base weapon = Weapon_Base.Cast( item );
131  return player.GetWeaponManager().CanLoadBullet(weapon ,player.GetWeaponManager().GetPreparedMagazine());
132  }
133 
134  override void Start( ActionData action_data )
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 
165  override void OnEndInput( ActionData action_data )
166  {
167  action_data.m_Player.GetWeaponManager().LoadMultiBulletStop();
168  }
169 };
170 
172 {
173  //-----------------------------------------------------
174  // Action events and methods
175  //-----------------------------------------------------
177  {
178  }
179 
180  override bool HasProgress()
181  {
182  return false;
183  }
184 
185  override void CreateConditionComponents()
186  {
189  }
190 
191  override bool CanContinue( ActionData action_data )
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 
204  Weapon_Base wpn = Weapon_Base.Cast(item);
205  Magazine mag = Magazine.Cast(target.GetObject());
206  return mag && player.GetWeaponManager().CanLoadBullet(wpn,mag);
207  }
208 
209  override void OnStart( ActionData action_data )
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 
217  override void OnEnd( ActionData action_data )
218  {
219  action_data.m_Player.GetWeaponManager().LoadMultiBulletStop();
220  }
221 };
222 
ItemBase
Definition: inventoryitem.c:730
FirearmActionLoadMultiBullet
Definition: firearmactionloadmultibullet.c:1
Weapon
script counterpart to engine's class Weapon
Definition: inventoryitem.c:48
AC_CONTINUOUS
const int AC_CONTINUOUS
Definition: _constants.c:3
FirearmActionLoadMultiBulletRadial
Definition: firearmactionloadmultibullet.c:171
FirearmActionLoadMultiBulletQuick
Definition: firearmactionloadmultibullet.c:94
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
CCTSelf
Definition: cctself.c:1
ContinuousWeaponManipulationActionInput
Definition: actioninput.c:907
m_Text
protected string m_Text
Definition: actionbase.c:49
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
FirearmActionBase
Definition: firearmactionbase.c:1
ContinuousDefaultActionInput
void ContinuousDefaultActionInput(PlayerBase player)
Definition: actioninput.c:606
WeaponManager
Definition: weaponmanager.c:1