Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionloadmagazine.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousRepeat(UATimeSpent.MAG_LOAD);
6  }
7 };
8 
10 {
11  void ActionLoadMagazine()
12  {
13  m_CallbackClass = ActionLoadMagazineCB;
14  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_FILLMAG;
15  m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_FILLMAG;
16  m_Text = "#load_magazine";
17  }
18 
19  override bool HasProneException()
20  {
21  return true;
22  }
23 
24  override void CreateConditionComponents()
25  {
28  }
29 
30  bool CanLoadMagazine(ActionTarget target, ItemBase item)
31  {
32  Magazine trg;
33  Magazine itm;
34  return ( Class.CastTo(trg, target.GetObject()) && Class.CastTo(itm, item) && itm.GetAmmoCount() < itm.GetAmmoMax() && trg.GetAmmoCount() != 0 && itm.IsCompatiableAmmo( trg ) );
35  }
36 
37  override bool ActionConditionContinue( ActionData action_data )
38  {
39  return CanLoadMagazine(action_data.m_Target, action_data.m_MainItem);
40  }
41 
42  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
43  {
44  return CanLoadMagazine(target, item);
45  }
46 
47  override bool CanBePerformedFromQuickbar()
48  {
49  return true;
50  }
51 
52  override void OnExecuteServer( ActionData action_data )
53  {
54  //Param1<float> timeSpendParam;
55  //if( !Class.CastTo(timeSpendParam, action_data.m_ActionComponent.GetACData()) ) return;
56 
57  Magazine trg;
58  Magazine itm;
59  if ( Class.CastTo(trg, action_data.m_Target.GetObject()) && Class.CastTo(itm, action_data.m_MainItem) )
60  {
61  float dmg;
62  string ammoType;
63 
64  if ( trg.ServerAcquireCartridge(dmg, ammoType) )
65  {
66  if ( !itm.ServerStoreCartridge(dmg, ammoType) )
67  trg.ServerStoreCartridge(dmg, ammoType);
68  else
69  itm.ApplyManipulationDamage(); //damages magazine
70  }
71 
72  trg.SetSynchDirty();
73  itm.SetSynchDirty();
74  //manipulationDamage
75  //if(trg.GetAmmoCount() > 0 )
76  //trg.SetSynchDirty();
77  //itm.SetSynchDirty();
78  }
79  }
80 };
81 
83 {
84  override void CreateActionComponent()
85  {
86  m_ActionData.m_ActionComponent = new CAContinuousRepeat(UATimeSpent.MAG_LOAD);
87  }
88 };
89 
91 {
93  {
94  m_CallbackClass = ActionLoadMagazineQuickCB;
95  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_FILLMAG;
96  m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_FILLMAG;
97  }
98 
99  override bool HasProneException()
100  {
101  return true;
102  }
103 
104  override typename GetInputType()
105  {
107  }
108 
109  override void CreateConditionComponents()
110  {
113  }
114 
115  override bool HasTarget()
116  {
117  return false;
118  }
119 
120  bool CanLoadMagazine( PlayerBase player, ItemBase item )
121  {
122  Magazine mag = Magazine.Cast( item );
123 
124  return mag && player.GetWeaponManager().GetPreparedMagazine() != null && mag.GetAmmoCount() < mag.GetAmmoMax();
125  }
126 
127  override bool ActionConditionContinue( ActionData action_data )
128  {
129  return CanLoadMagazine(action_data.m_Player, action_data.m_MainItem);
130  }
131 
132  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
133  {
134  return CanLoadMagazine(player, item);
135  }
136 
137  override void OnExecuteServer( ActionData action_data )
138  {
139  //Param1<float> timeSpendParam;
140  //if( !Class.CastTo(timeSpendParam, action_data.m_ActionComponent.GetACData()) ) return;
141 
142  Magazine itm = Magazine.Cast(action_data.m_MainItem);
143  Magazine trg = action_data.m_Player.GetWeaponManager().GetPreparedMagazine();
144 
145  if ( !itm || !trg )
146  return;
147 
148  float dmg;
149  string ammoType;
150 
151  if ( trg.ServerAcquireCartridge(dmg, ammoType) )
152  {
153  if ( !itm.ServerStoreCartridge(dmg, ammoType) )
154  trg.ServerStoreCartridge(dmg, ammoType);
155  else
156  itm.ApplyManipulationDamage(); //damages magazine
157  }
158 
159  trg.SetSynchDirty();
160  itm.SetSynchDirty();
161  //manipulationDamage
162  //if(trg.GetAmmoCount() > 0 )
163  //trg.SetSynchDirty();
164  //itm.SetSynchDirty();
165  }
166 };
ItemBase
Definition: inventoryitem.c:730
ActionLoadMagazineQuick
Definition: actionloadmagazine.c:90
ActionLoadMagazineQuickCB
Definition: actionloadmagazine.c:82
CAContinuousRepeat
Definition: cacontinuousrepeat.c:1
ActionLoadMagazineCB
Definition: actionloadmagazine.c:1
UAMaxDistances
Definition: actionconstants.c:104
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CCTNonRuined
Definition: cctnonruined.c:1
CCTSelf
Definition: cctself.c:1
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
ContinuousWeaponManipulationActionInput
Definition: actioninput.c:907
ActionLoadMagazine
Definition: actionloadmagazine.c:9
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10