DayZ 1.24
Loading...
Searching...
No Matches
PluginDayzPlayerDebug_Weapons.c
Go to the documentation of this file.
2// *************************************************************************************
3// ! PluginDayzPlayerWeaponsDebugUserData
4// *************************************************************************************
6{
12
13
15 {
16 return m_iAction;
17 }
18
20 {
21 return m_iActionT;
22 }
23
24
25 protected int m_iAction;
26 protected int m_iActionT;
27}
28
29
30// *************************************************************************************
31// ! PluginDayzPlayerDebug_AbilityConfig
32// *************************************************************************************
34{
36 {
37 m_Name = pName;
40 }
41
42 string m_Name;
44 int m_iActionT;
45};
46
47
48// *************************************************************************************
49// ! PluginDayzPlayerDebug
50// *************************************************************************************
52{
68
69 // command handler properties
76
80
81 //---------------------------------------------------
82 //
83
86 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload Mag Bullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_BULLET),
87 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload NoMag Buller", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_BULLET),
88 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload Mag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET),
89 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload NoMag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET),
90 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload Mag NoBullet lock", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_NOBULLET_OPEN),
91 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload NoMag NoBullet lock", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_NOMAGAZINE_NOBULLET_OPEN),
92 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload Clip NoBullet", WeaponActions.RELOAD_CLIP, WeaponActionReloadClipTypes.RELOADRIFLE_CLIP_NOBULLET),
93 PluginDayzPlayerDebug_AbilityConfig("Rifle - Reload Clip Bullet", WeaponActions.RELOAD_CLIP, WeaponActionReloadClipTypes.RELOADRIFLE_CLIP_BULLET),
94
95 PluginDayzPlayerDebug_AbilityConfig("Pistol Closed - Reload Mag Bullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_BULLET_CLOSED),
96 PluginDayzPlayerDebug_AbilityConfig("Pistol Closed - Reload NoMag Bullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED),
97 PluginDayzPlayerDebug_AbilityConfig("Pistol Closed Charged - Reload Mag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_COCKED),
98 PluginDayzPlayerDebug_AbilityConfig("Pistol Closed Charged - Reload NoMag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_COCKED),
99 PluginDayzPlayerDebug_AbilityConfig("Pistol Closed Discharged - Reload Mag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_UNCOCKED),
100 PluginDayzPlayerDebug_AbilityConfig("Pistol Closed Discharged - Reload NoMag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_UNCOCKED),
101 PluginDayzPlayerDebug_AbilityConfig("Pistol Opened - Reload NoMag ", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_NOMAGAZINE_NOBULLET_OPENED),
102 PluginDayzPlayerDebug_AbilityConfig("Pistol Opened - Reload Mag ", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADPISTOL_MAGAZINE_NOBULLET_OPENED),
103
104 PluginDayzPlayerDebug_AbilityConfig("Pistol Detach Magazine", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOAD_MAGAZINE_DETACH),
105 PluginDayzPlayerDebug_AbilityConfig("Rifle Detach Magazine", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADRIFLE_MAGAZINE_DETACH),
106
107 PluginDayzPlayerDebug_AbilityConfig("Sp Rifle - Reload Mag Bullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADSRIFLE_MAGAZINE_BULLET),
108 PluginDayzPlayerDebug_AbilityConfig("Sp Rifle - Reload NoMag Buller", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADSRIFLE_NOMAGAZINE_BULLET),
109 PluginDayzPlayerDebug_AbilityConfig("Sp Rifle - Reload Mag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADSRIFLE_MAGAZINE_NOBULLET),
110 PluginDayzPlayerDebug_AbilityConfig("Sp Rifle - Reload NoMag NoBullet", WeaponActions.RELOAD, WeaponActionReloadTypes.RELOADSRIFLE_NOMAGAZINE_NOBULLET),
111
112 PluginDayzPlayerDebug_AbilityConfig("Mechanism Opened", WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_OPENED),
113 PluginDayzPlayerDebug_AbilityConfig("Mechanism Closed", WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED),
114 PluginDayzPlayerDebug_AbilityConfig("Mechanism Spec", WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_SPECIAL),
115 PluginDayzPlayerDebug_AbilityConfig("Mechanism Closed Uncocked", WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED_UNCOCKED),
116
117 PluginDayzPlayerDebug_AbilityConfig("Chamb 1 Bullet Opened", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_OPENED),
118 PluginDayzPlayerDebug_AbilityConfig("Chamb 1 Bullet Closed", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_CLOSED),
119 PluginDayzPlayerDebug_AbilityConfig("Chamb 1 Bullet Unique Opened", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_UNIQUE_OPENED),
120 PluginDayzPlayerDebug_AbilityConfig("Chamb 1 Bullet Unique Closed", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ONEBULLET_UNIQUE_CLOSED),
121
122 PluginDayzPlayerDebug_AbilityConfig("Chamb 2 Bullets Start", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_TWOBULLETS_START),
123 PluginDayzPlayerDebug_AbilityConfig("Chamb 2 Bullets End", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_TWOBULLETS_END),
124
125 PluginDayzPlayerDebug_AbilityConfig("Chamb Loopable Start Closed", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED),
126 PluginDayzPlayerDebug_AbilityConfig("Chamb Loopable Start Closed keep bullet", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_CLOSED_KEEP),
127 PluginDayzPlayerDebug_AbilityConfig("Chamb Loopable Start Opened", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_OPENED),
128 PluginDayzPlayerDebug_AbilityConfig("Chamb Loopable End", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_ENDLOOPABLE),
129
130 PluginDayzPlayerDebug_AbilityConfig("Chamb Loopable Shotgun Start Uncocked", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED),
131 PluginDayzPlayerDebug_AbilityConfig("Chamb Loopable Shotgun Start Cocked", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED),
132
133 PluginDayzPlayerDebug_AbilityConfig("Chamb 1", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_DOUBLE_1),
134 PluginDayzPlayerDebug_AbilityConfig("Chamb 2", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_DOUBLE_2),
135 PluginDayzPlayerDebug_AbilityConfig("Chamb 3", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_DOUBLE_3),
136 PluginDayzPlayerDebug_AbilityConfig("Chamb 4", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_DOUBLE_4),
137
138 PluginDayzPlayerDebug_AbilityConfig("Crossbow Opened", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_CROSSBOW_OPENED),
139 PluginDayzPlayerDebug_AbilityConfig("Crossbow Close", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_CROSSBOW_CLOSED),
140 PluginDayzPlayerDebug_AbilityConfig("Crossbow Full", WeaponActions.CHAMBERING, WeaponActionChamberingTypes.CHAMBERING_CROSSBOW_FULL),
141
142 PluginDayzPlayerDebug_AbilityConfig("INTERRUPT", WeaponActions.INTERRUPT, -1),
143
144
145 PluginDayzPlayerDebug_AbilityConfig("Chamb Loader 1 Bullet Opened", WeaponActions.CHAMBERING_LOADER, WeaponActionChamberingLoaderTypes.CHAMBERINGLOADER_OPENED),
146 PluginDayzPlayerDebug_AbilityConfig("Chamb Loader 1 Bullet Closed", WeaponActions.CHAMBERING_LOADER, WeaponActionChamberingLoaderTypes.CHAMBERINGLOADER_CLOSED),
147
148 PluginDayzPlayerDebug_AbilityConfig("Unjamming Start", WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_START),
149 PluginDayzPlayerDebug_AbilityConfig("Unjamming End", WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_END),
150 PluginDayzPlayerDebug_AbilityConfig("Unjamming Interrupt", WeaponActions.UNJAMMING, WeaponActionUnjammingTypes.UNJAMMING_INTERRUPT),
151
154 PluginDayzPlayerDebug_AbilityConfig("Fire Empty Cocked", WeaponActions.FIRE, WeaponActionFireTypes.FIRE_COCKED),
155 PluginDayzPlayerDebug_AbilityConfig("Fire Empty Uncocked", WeaponActions.FIRE, WeaponActionFireTypes.FIRE_UNCOCKED),
158
159 };
160
161
163 {
164 int l = m_AbilityConfig.Count();
165 for (int i = 0; i < l; i++)
166 {
168 return i;
169 }
170 return -1;
171 }
172
173
174 //---------------------------------------------------
175 // gui stuff
176
178 {
180
182
185 if (player)
186 {
187 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
188 hcw.DebugResetEvents();
189 }
190 }
191
192
197
198
200 {
201 m_Selector = TextListboxWidget.Cast(m_MainWnd.FindAnyWidget("WeapActionSelector"));
202 m_ButtonStart = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("WeapActionStart"));
203
204 m_WidgetActionRunning = TextWidget.Cast(m_MainWnd.FindAnyWidget("WeapActionRunning"));
205 m_WidgetActionEvents = TextWidget.Cast(m_MainWnd.FindAnyWidget("WeapActionEvents"));
206
207 m_SetInitStateI = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("WeapInitStateI"));
208 m_SetInitStateB = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("WeapInitStateB"));
209
210 m_WeaponChange = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("WeapChange"));
211 m_WeaponHide = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("WeapHide"));
212 m_WeaponSlotH = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("WeaponChangeSlotH"));
213 m_WeaponSlotS = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("WeaponChangeSlotS"));
214 m_WeaponActionProgressStart = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("WeapActionProgressStart"));
215 m_WeaponActionProgressEnd = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("WeapActionProgressEnd"));
216
217
218 m_WidgetActionEvents.SetText("Events:");
219
220 }
221
223 {
224 }
225
226
227 //---------------------------------------------------
228 // main update
229
230
231 void Tick()
232 {
234 if (!player)
235 return;
236
237 if (player)
238 {
239 EntityAI entityInHands = player.GetHumanInventory().GetEntityInHands();
242 {
243 if (m_CurrentWeapon != w)
244 WeaponsInit(w);
245 }
246 else
247 m_Selector.ClearItems();
248 }
249
251 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
252
253 string text = "Action: " + hcw.GetRunningAction().ToString() + " " + hcw.GetRunningActionType().ToString();
255
256
257 int aEvent = hcw.DebugIsEvent();
258 if (aEvent != -1)
259 {
260 string eventStr = "Event: ";
261 eventStr = eventStr + aEvent.ToString() + " ";
262 while (true)
263 {
264 aEvent = hcw.DebugIsEvent();
265 if (aEvent == -1)
266 break;
267
268 Print("Event: " + aEvent.ToString());
269
270 eventStr += aEvent.ToString();
271 eventStr += " ";
272 }
273
275 }
276 }
277
278
279 //---------------------------------------------------
280 // Actions
281
283 {
284
285 m_Selector.ClearItems();
286
288 int abilityCount = w.GetAbilityCount();
289
290 for (int i = 0; i < abilityCount; ++i)
291 {
292 AbilityRecord rec = w.GetAbility(i);
293 int abConfigIndex = FindAbilityConfig(rec.m_action, rec.m_actionType);
294 if (abConfigIndex != -1)
296 }
297
298 m_Selector.AddItem("=========== All - not safe =========", NULL, 0);
299
300
301 // if (abilityCount == 0)
302 {
303 int l = m_AbilityConfig.Count();
304 for (int a = 0; a < l; a++)
306 }
307
309 }
310
311
314 {
315 int row = m_Selector.GetSelectedRow();
316 if (row == -1)
317 return;
318
320 m_Selector.GetItemData(row, 0, userData);
321 if (userData)
322 {
323 m_CH_WeapAction = userData.GetAction();
324 m_CH_WeapActionType = userData.GetActionType();
327
328 Print("DayzPlayerImplement_Weapons::WeaponsStartAction");
329 }
330 }
331
332
333 //---------------------------------------------------
334 // window ui clicks
335
337 bool OnClick(Widget w, int x, int y, int button)
338 {
339 if (w == m_ButtonStart)
340 {
342 return true;
343 }
344 else if (w == m_SetInitStateB)
345 {
346 int frameI = m_SetInitStateI.GetText().ToInt();
347
349
350 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
351 hcw.SetInitState(frameI);
352 }
353 else if (w == m_WeaponChange)
354 {
355 Print("Weapon Change pressed");
356
358 if (d == null)
359 {
360 Print("No dispatcher - cannot get selected weapon");
361 return false;
362 }
363
365 if (p == null)
366 {
367 Print("No selected object");
368 return false;
369 }
370
372 Print(p1.param1);
373
374 m_CH_WeaponChangeI = p1.param1;
375 m_CH_WeaponChangeSlotH = m_WeaponSlotH.GetText().ToInt();
376 m_CH_WeaponChangeSlotS = m_WeaponSlotS.GetText().ToInt();
377 }
378 else if (w == m_WeaponHide)
379 {
381 m_CH_WeaponChangeSlotH = m_WeaponSlotH.GetText().ToInt();
382 m_CH_WeaponChangeSlotS = m_WeaponSlotS.GetText().ToInt();
383 }
384
385
386 return false;
387 }
388
389 //---------------------------------------------------
390 // Global handler to handle commands from player
391
393 {
394 if (m_CH_WeaponChangeSlotH == -1)
395 return false;
396
400
403
404 return true;
405 }
406
407
408 //---------------------------------------------------
409 // Global handler to handle commands from player
410
412 {
413
414 // last action again
415 if (KeyState(KeyCode.KC_MULTIPLY) == 1)
416 {
417 ClearKey(KeyCode.KC_MULTIPLY);
420
421 Print("DayzPlayerImplement_Weapons OnKC_MULTIPLY");
422 }
423
424
425 if (m_CH_WeapAction >= 0)
426 {
429
432 if (player != NULL)
433 {
434 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
437
438 Print("DayzPlayerImplement_Weapons::WeaponsStartAction2");
439
440 }
441
442 m_CH_WeapAction = -1;
443 }
444
445 }
446}
string m_Name
Dispatcher GetDispatcher()
Definition Dispatcher.c:20
const CallID CALL_ID_SCR_CNSL_GETSELECTEDITEM
Definition Dispatcher.c:11
Icon x
Icon y
PlayerBase GetPlayer()
void PluginDayzPlayerWeaponsDebugUserData(int pAction, int pActionType)
class PluginDayzPlayerWeaponsDebugUserData PluginDayzPlayerDebug_AbilityConfig(string pName, int pAction, int pActionT)
pair ( action, actionType )
Definition Weapon_Base.c:5
Super root of all classes in Enforce script.
Definition EnScript.c:11
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
int FindAbilityConfig(int pAction, int pActionT)
bool OnClick(Widget w, int x, int y, int button)
buttons clicks
ref array< ref PluginDayzPlayerDebug_AbilityConfig > m_AbilityConfig
bool IsWeaponChange(out string pNewWeapon, out int pHideSlot, out int pShowSlot)
void PluginDayzPlayerWeaponsDebugUserData(int pAction, int pActionType)
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native void ClearKey(KeyCode key)
KeyCode
Definition EnSystem.c:157
proto native int KeyState(KeyCode key)
WeaponActionReloadClipTypes
Definition human.c:841
WeaponActionChamberingTypes
Definition human.c:856
WeaponActions
actions
Definition human.c:796
WeaponActionChamberingLoaderTypes
Definition human.c:886
WeaponActionReloadTypes
Definition human.c:812
WeaponActionUnjammingTypes
Definition human.c:892
WeaponActionFireTypes
Definition human.c:900