Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
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{
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
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 }
75 }
76};
77
79{
80 override void CreateActionComponent()
81 {
82 m_ActionData.m_ActionComponent = new CAContinuousRepeat(UATimeSpent.MAG_LOAD);
83 }
84};
85
87{
89 {
91 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_FILLMAG;
92 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_FILLMAG;
93 }
94
95 override bool HasProneException()
96 {
97 return true;
98 }
99
100 override typename GetInputType()
101 {
103 }
104
105 override void CreateConditionComponents()
106 {
109 }
110
111 override bool HasTarget()
112 {
113 return false;
114 }
115
116 bool CanLoadMagazine( PlayerBase player, ItemBase item )
117 {
118 Magazine mag = Magazine.Cast( item );
119
120 return mag && player.GetWeaponManager().GetPreparedMagazine() != null && mag.GetAmmoCount() < mag.GetAmmoMax();
121 }
122
123 override bool ActionConditionContinue( ActionData action_data )
124 {
125 return CanLoadMagazine(action_data.m_Player, action_data.m_MainItem);
126 }
127
128 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
129 {
130 return CanLoadMagazine(player, item);
131 }
132
133 override void OnExecuteServer( ActionData action_data )
134 {
135 //Param1<float> timeSpendParam;
136 //if( !Class.CastTo(timeSpendParam, action_data.m_ActionComponent.GetACData()) ) return;
137
138 Magazine itm = Magazine.Cast(action_data.m_MainItem);
139 Magazine trg = action_data.m_Player.GetWeaponManager().GetPreparedMagazine();
140
141 if ( !itm || !trg )
142 return;
143
144 float dmg;
145 string ammoType;
146
147 if ( trg.ServerAcquireCartridge(dmg, ammoType) )
148 {
149 if ( !itm.ServerStoreCartridge(dmg, ammoType) )
150 trg.ServerStoreCartridge(dmg, ammoType);
151 else
152 itm.ApplyManipulationDamage(); //damages magazine
153 }
154
155 trg.SetSynchDirty();
156 itm.SetSynchDirty();
157 //manipulationDamage
158 //if(trg.GetAmmoCount() > 0 )
159 //trg.SetSynchDirty();
160 //itm.SetSynchDirty();
161 }
162};
ActionData m_ActionData
string m_Text
Definition actionbase.c:58
ref CCIBase m_ConditionItem
Definition actionbase.c:64
ref CCTBase m_ConditionTarget
Definition actionbase.c:65
Super root of all classes in Enforce script.
Definition enscript.c:11
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602