Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
plugindayzinfecteddebug.c
Go to the documentation of this file.
1// *************************************************************************************
2// ! PluginDayZInfectedDebugUIHandler
3// *************************************************************************************
4class PluginDayZInfectedDebugUIHandler extends ScriptedWidgetEventHandler
5{
6 override bool OnClick(Widget w, int x, int y, int button)
7 {
8 super.OnClick(w, x, y, button);
9 return m_pPluginInfectedDebug.OnClick(w, x, y, button);
10 }
11
12 override bool OnChange(Widget w, int x, int y, bool finished)
13 {
14 super.OnChange(w, x, y, finished);
15 return m_pPluginInfectedDebug.OnChange(w, x, y, finished);
16 }
17
18 PluginDayZInfectedDebug m_pPluginInfectedDebug;
19}
20
21// *************************************************************************************
22// ! PluginDayZInfectedDebugAttackDesc
23// *************************************************************************************
25{
26 void PluginDayZInfectedDebugAttackDesc(string pName, int pValue)
27 {
28 name = pName;
29 animValue = pValue;
30 }
31
32 string name;
34}
35
36// *************************************************************************************
37// ! PluginDayZInfectedDebug
38// *************************************************************************************
39class PluginDayZInfectedDebug extends PluginBase
40{
41 int m_CurrentMode = 0;
42 bool m_HasFocus = false;
43 bool m_IsActive = false;
44
46 Widget m_MainWnd;
47 ButtonWidget m_SpawnEntityButton;
48 ButtonWidget m_CardMovementButton;
49 ButtonWidget m_CardFightButton;
50 Widget m_CardMovementFrame;
51 Widget m_CardFightFrame;
52 TextWidget m_StatusText;
53
55 XComboBoxWidget m_StanceCB;
56 XComboBoxWidget m_MindStateCB;
57 EditBoxWidget m_MovementSpeedEB;
58
59 ButtonWidget m_StartTurnButton;
60 XComboBoxWidget m_TurnTypeCB;
61 EditBoxWidget m_TurnDirectionEB;
62
63 XComboBoxWidget m_VaultingCB;
64 ButtonWidget m_StartVaultButton;
65 ButtonWidget m_KnucleOutButton;
66
67 XComboBoxWidget m_CrawlingTypeCB;
68 ButtonWidget m_StartCrawlingButton;
69
71 EditBoxWidget m_HitDirEB;
72 XComboBoxWidget m_HitTypeCB;
73 XComboBoxWidget m_HitBodyPartCB;
74 ButtonWidget m_StartHitButton;
75
76 XComboBoxWidget m_DeathTypeCB;
77 ButtonWidget m_StartDeathButton;
78
79 XComboBoxWidget m_AttackTypeCB;
80 XComboBoxWidget m_AttackDirCB;
81 ButtonWidget m_StartAttackButton;
82
84 DayZInfected m_ControlledInfected;
85
87 bool m_CH_DoTurn = false;
88 bool m_CH_DoVault = false;
89 bool m_CH_DoKnucleOut = false;
90 bool m_CH_GoToCrawl = false;
91 bool m_CH_DoHit = false;
92 bool m_CH_StartDeath = false;
93 bool m_CH_DoAttack = false;
94
95 ref PluginDayZInfectedDebugUIHandler m_pUIHandler;
97
98 private ref array<Shape> m_DebugShapes = new array<Shape>();
99
101 ref Timer m_TickTimer;
102
103 void PluginDayZInfectedDebug()
104 {
105 #ifndef NO_GUI
107 #endif
108 }
109
110 void ~PluginDayZInfectedDebug()
111 {
112 #ifndef NO_GUI
114 #endif
115 }
116
119 {
121 if (m_CurrentMode > 2)
122 {
123 m_CurrentMode = 0;
124 }
125
127 }
128
130 void ToggleDebugWindowSetMode(int pMode)
131 {
132 switch (pMode)
133 {
134 case 0: Hide(); ReleaseFocus(); CleanupDebugShapes(m_DebugShapes); break;
135 case 1: Show(); ReleaseFocus(); break;
136 case 2: Show(); CaptureFocus(); break;
137 }
138 }
139
141 void CaptureFocus()
142 {
143 if (!m_HasFocus)
144 {
145 GetGame().GetInput().ChangeGameFocus(1);
146 GetGame().GetUIManager().ShowUICursor(true);
147 m_HasFocus = true;
148 }
149 }
150
152 void ReleaseFocus()
153 {
154 if (m_HasFocus)
155 {
156 GetGame().GetInput().ChangeGameFocus(-1);
157 GetGame().GetUIManager().ShowUICursor(false);
158 m_HasFocus = false;
159 }
160 }
161
163 void Show()
164 {
165 ShowWidgets(true);
166 m_IsActive = true;
167
168 GetUApi().ActivateExclude("menu");
169 GetUApi().UpdateControls();
170
171 if (!m_TickTimer)
172 {
173 m_TickTimer = new Timer();
174 m_TickTimer.Run(0.1, this, "Tick", NULL, true);
175 }
176 }
177
179 void Hide()
180 {
181 ShowWidgets(false);
182 m_IsActive = false;
183
184 GetUApi().UpdateControls();
185
186 m_TickTimer = NULL;
187 }
188
190 void ShowWidgets(bool show)
191 {
192 if(m_MainWnd)
193 {
194 m_MainWnd.Show(show);
195 }
196 }
197
198 override void OnUpdate(float delta_time)
199 {
200 super.OnUpdate(delta_time);
201
202 CleanupDebugShapes(m_DebugShapes);
203
204 if (m_IsActive)
205 {
206 if (!m_ControlledInfected)
207 return;
208
209 m_DebugShapes.Insert(Debug.DrawSphere(m_ControlledInfected.GetPosition() + "0 2 0", 0.25, FadeColors.RED));
210 }
211 }
212
215 {
216 if (!m_pUIHandler)
217 {
218 m_pUIHandler = new PluginDayZInfectedDebugUIHandler();
219 m_pUIHandler.m_pPluginInfectedDebug = this;
220 }
221
222 if (!m_MainWnd)
223 {
224 m_MainWnd = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_infecteddebug.layout");
225 m_MainWnd.SetHandler(m_pUIHandler);
226 m_MainWnd.Show(false);
227 }
228
230 m_SpawnEntityButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("SpawnEntityButton") );
231 m_CardMovementButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("CardMovementButton") );
232 m_CardFightButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("CardFightButton") );
233 m_CardMovementFrame = m_MainWnd.FindAnyWidget("CardMovementFrame");
234 m_CardFightFrame = m_MainWnd.FindAnyWidget("CardFightFrame");
235 m_StatusText = TextWidget.Cast( m_MainWnd.FindAnyWidget("StatusText") );
236
238 m_StanceCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("StanceCB") );
239 m_MindStateCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("MindStateCB") );
240 m_MovementSpeedEB = EditBoxWidget.Cast( m_MainWnd.FindAnyWidget("MovementSpeedEB") );
241
242 m_StartTurnButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("StartTurnButton") );
243 m_TurnTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("TurnTypeCB") );
244 m_TurnDirectionEB = EditBoxWidget.Cast( m_MainWnd.FindAnyWidget("TurnDirectionEB") );
245
246 m_VaultingCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("TurnTypeCB") );
247 m_StartVaultButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("StartVaultButton") );
248 m_KnucleOutButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("KnucleOutButton") );
249
250 m_CrawlingTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("TurnTypeCB") );
251 m_StartCrawlingButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("StartCrawlingButton") );
252
254 m_HitDirEB = EditBoxWidget.Cast( m_MainWnd.FindAnyWidget("HitDirEB") );
255 m_HitTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("HitTypeCB") );
256 m_HitBodyPartCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("HitBodyPartCB") );
257 m_StartHitButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("StartHitButton") );
258
259 m_DeathTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("DeathTypeCB") );
260 m_StartDeathButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("StartDeathButton") );
261
262 m_AttackTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("AttackTypeCB") );
263 m_AttackDirCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("AttackDirCB") );
264 m_StartAttackButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("StartAttackButton") );
265
267 InitAttacks();
268
269 ShowCard(0);
270 }
271
274 {
275 delete m_MainWnd;
276 }
277
279 void ShowCard(int pCard)
280 {
281 m_CardMovementFrame.Show(pCard == 0);
282 m_CardFightFrame.Show(pCard == 1);
283 }
284
286 bool OnClick(Widget w, int x, int y, int button)
287 {
288 if (w == m_SpawnEntityButton)
289 {
290 ResetValues();
291 SpawnNewInfectedEntity();
292 return true;
293 }
294
295 if (w == m_CardMovementButton)
296 {
297 ShowCard(0);
298 return true;
299 }
300 else if (w == m_CardFightButton)
301 {
302 ShowCard(1);
303 return true;
304 }
305 else if (w == m_StartTurnButton)
306 {
307 m_CH_DoTurn = true;
308 return true;
309 }
310 else if (w == m_StartVaultButton)
311 {
312 m_CH_DoVault = true;
313 return true;
314 }
315 else if (w == m_KnucleOutButton)
316 {
317 m_CH_DoKnucleOut = true;
318 return true;
319 }
320 else if (w == m_StartCrawlingButton)
321 {
322 m_CH_GoToCrawl = true;
323 return true;
324 }
325 else if (w == m_StartHitButton)
326 {
327 m_CH_DoHit = true;
328 return true;
329 }
330 else if (w == m_StartDeathButton)
331 {
332 m_CH_StartDeath = true;
333 return true;
334 }
335 else if (w == m_StartAttackButton)
336 {
337 m_CH_DoAttack = true;
338 return true;
339 }
340
341 return false;
342 }
343
345 bool OnChange(Widget w, int x, int y, bool finished)
346 {
347 return false;
348 }
349
351 void ResetValues()
352 {
353 m_CH_DoTurn = false;
354 m_CH_DoVault = false;
355 m_CH_DoKnucleOut = false;
356 m_CH_GoToCrawl = false;
357 m_CH_DoHit = false;
358 m_CH_StartDeath = false;
359 m_CH_DoAttack = false;
360 m_MovementSpeedEB.SetText("0");
361 m_MainWnd.Update();
362 }
363
365 void SpawnNewInfectedEntity()
366 {
367 m_ControlledInfected = DayZInfected.Cast(GetGame().CreateObjectEx("ZmbF_JournalistNormal_Blue", GetGame().GetPlayer().GetPosition(), ECE_PLACE_ON_SURFACE|ECE_INITAI|ECE_EQUIP_ATTACHMENTS));
368 m_ControlledInfected.GetAIAgent().SetKeepInIdle(true);
369 }
370
371 protected void PossesInfected()
372 {
373 ResetValues();
374 FreeDebugCamera.GetInstance().SetActive(true);
375 m_ControlledInfected = DayZInfected.Cast(FreeDebugCamera.GetInstance().GetCrosshairObject());
376 FreeDebugCamera.GetInstance().SetActive(false);
377 }
378
381 {
382 if( infected != m_ControlledInfected )
383 return;
384
385 infected.GetInputController().OverrideMovementSpeed(true, m_MovementSpeedEB.GetText().ToFloat());
386
387 DayZInfectedCommandMove moveCommand = infected.GetCommand_Move();
388 if( moveCommand )
389 {
390 moveCommand.SetStanceVariation(m_StanceCB.GetCurrentItem());
391 moveCommand.SetIdleState(m_MindStateCB.GetCurrentItem());
392 }
393
394 if( m_CH_DoTurn )
395 {
396 moveCommand.StartTurn(m_TurnDirectionEB.GetText().ToFloat(), m_TurnTypeCB.GetCurrentItem());
397 m_CH_DoTurn = false;
398 }
399 if( m_CH_DoVault )
400 {
401 infected.StartCommand_Vault(m_VaultingCB.GetCurrentItem());
402 m_CH_DoVault = false;
403 }
404 if( m_CH_DoKnucleOut )
405 {
406 infected.StartCommand_Vault(-1);
407 m_CH_DoKnucleOut = false;
408 }
409 if( m_CH_GoToCrawl )
410 {
411 infected.StartCommand_Crawl(m_CrawlingTypeCB.GetCurrentItem());
412 m_CH_GoToCrawl = false;
413 }
414 if( m_CH_DoHit )
415 {
416 float hitDir = m_HitDirEB.GetText().ToFloat();
417 int bodyPart = m_HitBodyPartCB.GetCurrentItem();
418 bool heavyHit = m_HitTypeCB.GetCurrentItem() == 1;
419
420 infected.StartCommand_Hit(heavyHit, bodyPart, hitDir);
421
422 m_CH_DoHit = false;
423 }
424 if( m_CH_StartDeath )
425 {
426 int deathType = m_DeathTypeCB.GetCurrentItem();
427 float deathDir = m_HitDirEB.GetText().ToFloat();
428
429 infected.StartCommand_Death(deathType, deathDir);
430
431 m_CH_StartDeath = false;
432 }
433 if( m_CH_DoAttack )
434 {
435 float attackDir = m_AttackDirCB.GetCurrentItem();
436 int attackType = m_AttackDescriptors.Get(m_AttackTypeCB.GetCurrentItem()).animValue;
437
438 infected.StartCommand_Attack(null, attackType, attackDir);
439
440 m_CH_DoAttack = false;
441 }
442 }
443
445 void Tick()
446 {
447 if( !m_ControlledInfected )
448 return;
449
450 }
451
454 {
455 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Left Light", 0));
456 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Right Light", 1));
457 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Left Heavy", 2));
458 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Right Heavy", 3));
459
460 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Crawl Attack", 7));
461 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Crawl Attack Combo", 8));
462
463 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Push Attack", 9));
464 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Head Attack", 10));
465 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Shoulder Attack", 11));
466 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door LR Attack", 12));
467 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Kick Attack", 13));
468 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Charge R", 14));
469 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Charge L", 15));
470
471 for( int i = 0; i < m_AttackDescriptors.Count(); ++i )
472 {
473 m_AttackTypeCB.AddItem(m_AttackDescriptors.Get(i).name);
474 }
475 }
476
477 private void CleanupDebugShapes(array<Shape> shapesArr)
478 {
479 for ( int it = 0; it < shapesArr.Count(); ++it )
480 {
481 Debug.RemoveShape( shapesArr[it] );
482 }
483
484 shapesArr.Clear();
485 }
486}
487
const int ECE_EQUIP_ATTACHMENTS
const int ECE_PLACE_ON_SURFACE
const int ECE_INITAI
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Definition debug.c:2
Plugin interface for controlling of agent pool system.
Definition pluginbase.c:2
void CommandHandler(DayZInfected infected)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Hide()
Definition dayzgame.c:170
void Show()
Definition dayzgame.c:162
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition dayzgame.c:151
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition
Icon x
Icon y
bool m_IsActive
PlayerBase GetPlayer()
ref Timer m_TickTimer
class PluginDayZInfectedDebugUIHandler extends ScriptedWidgetEventHandler PluginDayZInfectedDebugAttackDesc(string pName, int pValue)
override bool OnChange(Widget w, int x, int y, bool finished)
PluginDayZInfectedDebug m_pPluginInfectedDebug
void ShowWidgets(bool show)
void ShowCard(int pCard)
void ToggleDebugWindowSetMode(int pMode)
Widget m_MainWnd
int m_CurrentMode
ref PluginDayzPlayerDebugUIHandler m_pUIHandler
void ToggleDebugWindowEvent()
bool m_HasFocus
void ReleaseFocus()
void DestroyModuleWidgets()
void CreateModuleWidgets()
void CaptureFocus()
void ResetValues()
proto native UAInputAPI GetUApi()