DayZ 1.24
Loading...
Searching...
No Matches
ActionLoadMagazine.c
Go to the documentation of this file.
8
10{
12 {
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
29
30 bool CanLoadMagazine(ActionTarget target, ItemBase item)
31 {
34 return (Class.CastTo(trg, target.GetObject()) && Class.CastTo(itm, item) && itm.GetAmmoCount() < itm.GetAmmoMax() && trg.GetAmmoCount() != 0 && itm.IsCompatiableAmmo(trg));
35 }
36
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 {
45 }
46
48 {
49 return true;
50 }
51
53 {
54 //Param1<float> timeSpendParam;
55 //if( !Class.CastTo(timeSpendParam, action_data.m_ActionComponent.GetACData()) ) return;
56
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
89
91{
98
99 override bool HasProneException()
100 {
101 return true;
102 }
103
104 override typename GetInputType()
105 {
107 }
108
110 {
113 }
114
115 override bool HasTarget()
116 {
117 return false;
118 }
119
121 {
122 Magazine mag = Magazine.Cast(item);
123
124 return mag && player.GetWeaponManager().GetPreparedMagazine() != null && mag.GetAmmoCount() < mag.GetAmmoMax();
125 }
126
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
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};
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
ActionData m_ActionData
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void CreateActionComponent()
override void OnExecuteServer(ActionData action_data)
override bool ActionConditionContinue(ActionData action_data)
override void CreateConditionComponents()
override bool CanBePerformedFromQuickbar()
override bool HasProneException()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
bool CanLoadMagazine(ActionTarget target, ItemBase item)
override void CreateActionComponent()
override void CreateConditionComponents()
override bool HasProneException()
override bool ActionConditionContinue(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
bool CanLoadMagazine(PlayerBase player, ItemBase item)
override void OnExecuteServer(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
const float DEFAULT
const float MAG_LOAD
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.