DayZ 1.24
Loading...
Searching...
No Matches
PluginDayZInfectedDebug.c File Reference

Go to the source code of this file.

Classes

class  ScriptedWidgetEventHandler
 map: item x vector(index, width, height) More...
 
class  PluginBase
 

Functions

class PluginDayZInfectedDebugUIHandler extends ScriptedWidgetEventHandler PluginDayZInfectedDebugAttackDesc (string pName, int pValue)
 
override bool OnClick (Widget w, int x, int y, int button)
 
override bool OnChange (Widget w, int x, int y, bool finished)
 

Variables

PluginDayZInfectedDebug m_pPluginInfectedDebug
 
string name
 
int animValue
 

Function Documentation

◆ OnChange()

bool OnChange ( Widget w,
int x,
int y,
bool finished )

Definition at line 33 of file PluginDayZInfectedDebug.c.

40{
41 int m_CurrentMode = 0;
42 bool m_HasFocus = false;
43 bool m_IsActive = false;
44
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
97
98 private ref array<Shape> m_DebugShapes = new array<Shape>();
99
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 m_CurrentMode = 0;
123
125 }
126
129 {
130 switch (pMode)
131 {
132 case 0: Hide(); ReleaseFocus(); CleanupDebugShapes(m_DebugShapes); break;
133 case 1: Show(); ReleaseFocus(); break;
134 case 2: Show(); CaptureFocus(); break;
135 }
136 }
137
139 void CaptureFocus()
140 {
141 if (!m_HasFocus)
142 {
143 GetGame().GetInput().ChangeGameFocus(1);
144 GetGame().GetUIManager().ShowUICursor(true);
145 m_HasFocus = true;
146 }
147 }
148
150 void ReleaseFocus()
151 {
152 if (m_HasFocus)
153 {
154 GetGame().GetInput().ChangeGameFocus(-1);
155 GetGame().GetUIManager().ShowUICursor(false);
156 m_HasFocus = false;
157 }
158 }
159
161 void Show()
162 {
163 ShowWidgets(true);
164 m_IsActive = true;
165
166 GetUApi().ActivateExclude("menu");
167 GetUApi().UpdateControls();
168
169 if (!m_TickTimer)
170 {
171 m_TickTimer = new Timer();
172 m_TickTimer.Run(0.1, this, "Tick", NULL, true);
173 }
174 }
175
177 void Hide()
178 {
179 ShowWidgets(false);
180 m_IsActive = false;
181
182 GetUApi().UpdateControls();
183
185 }
186
188 void ShowWidgets(bool show)
189 {
190 if (m_MainWnd)
191 m_MainWnd.Show(show);
192 }
193
194 override void OnUpdate(float delta_time)
195 {
196 super.OnUpdate(delta_time);
197
198 CleanupDebugShapes(m_DebugShapes);
199
200 if (m_IsActive)
201 {
202 if (!m_ControlledInfected)
203 return;
204
205 m_DebugShapes.Insert(Debug.DrawSphere(m_ControlledInfected.GetPosition() + "0 2 0", 0.25, FadeColors.RED));
206 }
207 }
208
211 {
212 if (!m_pUIHandler)
213 {
215 m_pUIHandler.m_pPluginInfectedDebug = this;
216 }
217
218 if (!m_MainWnd)
219 {
220 m_MainWnd = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_infecteddebug.layout");
221 m_MainWnd.SetHandler(m_pUIHandler);
222 m_MainWnd.Show(false);
223 }
224
226 m_SpawnEntityButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("SpawnEntityButton"));
227 m_CardMovementButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("CardMovementButton"));
228 m_CardFightButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("CardFightButton"));
229 m_CardMovementFrame = m_MainWnd.FindAnyWidget("CardMovementFrame");
230 m_CardFightFrame = m_MainWnd.FindAnyWidget("CardFightFrame");
231 m_StatusText = TextWidget.Cast(m_MainWnd.FindAnyWidget("StatusText"));
232
234 m_StanceCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("StanceCB"));
235 m_MindStateCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("MindStateCB"));
236 m_MovementSpeedEB = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("MovementSpeedEB"));
237
238 m_StartTurnButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("StartTurnButton"));
239 m_TurnTypeCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("TurnTypeCB"));
240 m_TurnDirectionEB = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("TurnDirectionEB"));
241
242 m_VaultingCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("TurnTypeCB"));
243 m_StartVaultButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("StartVaultButton"));
244 m_KnucleOutButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("KnucleOutButton"));
245
246 m_CrawlingTypeCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("TurnTypeCB"));
247 m_StartCrawlingButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("StartCrawlingButton"));
248
250 m_HitDirEB = EditBoxWidget.Cast(m_MainWnd.FindAnyWidget("HitDirEB"));
251 m_HitTypeCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("HitTypeCB"));
252 m_HitBodyPartCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("HitBodyPartCB"));
253 m_StartHitButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("StartHitButton"));
254
255 m_DeathTypeCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("DeathTypeCB"));
256 m_StartDeathButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("StartDeathButton"));
257
258 m_AttackTypeCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("AttackTypeCB"));
259 m_AttackDirCB = XComboBoxWidget.Cast(m_MainWnd.FindAnyWidget("AttackDirCB"));
260 m_StartAttackButton = ButtonWidget.Cast(m_MainWnd.FindAnyWidget("StartAttackButton"));
261
263 InitAttacks();
264
265 ShowCard(0);
266 }
267
270 {
271 delete m_MainWnd;
272 }
273
275 void ShowCard(int pCard)
276 {
277 m_CardMovementFrame.Show(pCard == 0);
278 m_CardFightFrame.Show(pCard == 1);
279 }
280
282 bool OnClick(Widget w, int x, int y, int button)
283 {
284 if (w == m_SpawnEntityButton)
285 {
286 ResetValues();
287 SpawnNewInfectedEntity();
288 return true;
289 }
290
291 if (w == m_CardMovementButton)
292 {
293 ShowCard(0);
294 return true;
295 }
296 else if (w == m_CardFightButton)
297 {
298 ShowCard(1);
299 return true;
300 }
301 else if (w == m_StartTurnButton)
302 {
303 m_CH_DoTurn = true;
304 return true;
305 }
306 else if (w == m_StartVaultButton)
307 {
308 m_CH_DoVault = true;
309 return true;
310 }
311 else if (w == m_KnucleOutButton)
312 {
313 m_CH_DoKnucleOut = true;
314 return true;
315 }
316 else if (w == m_StartCrawlingButton)
317 {
318 m_CH_GoToCrawl = true;
319 return true;
320 }
321 else if (w == m_StartHitButton)
322 {
323 m_CH_DoHit = true;
324 return true;
325 }
326 else if (w == m_StartDeathButton)
327 {
328 m_CH_StartDeath = true;
329 return true;
330 }
331 else if (w == m_StartAttackButton)
332 {
333 m_CH_DoAttack = true;
334 return true;
335 }
336
337 return false;
338 }
339
341 bool OnChange(Widget w, int x, int y, bool finished)
342 {
343 return false;
344 }
345
347 void ResetValues()
348 {
349 m_CH_DoTurn = false;
350 m_CH_DoVault = false;
351 m_CH_DoKnucleOut = false;
352 m_CH_GoToCrawl = false;
353 m_CH_DoHit = false;
354 m_CH_StartDeath = false;
355 m_CH_DoAttack = false;
356 m_MovementSpeedEB.SetText("0");
357 m_MainWnd.Update();
358 }
359
361 void SpawnNewInfectedEntity()
362 {
363 m_ControlledInfected = DayZInfected.Cast(GetGame().CreateObjectEx("ZmbF_JournalistNormal_Blue", GetGame().GetPlayer().GetPosition(), ECE_PLACE_ON_SURFACE | ECE_INITAI | ECE_EQUIP_ATTACHMENTS));
364 m_ControlledInfected.GetAIAgent().SetKeepInIdle(true);
365 }
366
367 protected void PossesInfected()
368 {
369 ResetValues();
370 FreeDebugCamera.GetInstance().SetActive(true);
371 m_ControlledInfected = DayZInfected.Cast(FreeDebugCamera.GetInstance().GetCrosshairObject());
372 FreeDebugCamera.GetInstance().SetActive(false);
373 }
374
377 {
378 if (infected != m_ControlledInfected)
379 return;
380
381 infected.GetInputController().OverrideMovementSpeed(true, m_MovementSpeedEB.GetText().ToFloat());
382
383 DayZInfectedCommandMove moveCommand = infected.GetCommand_Move();
384 if (moveCommand)
385 {
386 moveCommand.SetStanceVariation(m_StanceCB.GetCurrentItem());
387 moveCommand.SetIdleState(m_MindStateCB.GetCurrentItem());
388 }
389
390 if (m_CH_DoTurn)
391 {
392 moveCommand.StartTurn(m_TurnDirectionEB.GetText().ToFloat(), m_TurnTypeCB.GetCurrentItem());
393 m_CH_DoTurn = false;
394 }
395 if (m_CH_DoVault)
396 {
397 infected.StartCommand_Vault(m_VaultingCB.GetCurrentItem());
398 m_CH_DoVault = false;
399 }
400 if (m_CH_DoKnucleOut)
401 {
402 infected.StartCommand_Vault(-1);
403 m_CH_DoKnucleOut = false;
404 }
405 if (m_CH_GoToCrawl)
406 {
407 infected.StartCommand_Crawl(m_CrawlingTypeCB.GetCurrentItem());
408 m_CH_GoToCrawl = false;
409 }
410 if (m_CH_DoHit)
411 {
412 float hitDir = m_HitDirEB.GetText().ToFloat();
413 int bodyPart = m_HitBodyPartCB.GetCurrentItem();
414 bool heavyHit = m_HitTypeCB.GetCurrentItem() == 1;
415
416 infected.StartCommand_Hit(heavyHit, bodyPart, hitDir);
417
418 m_CH_DoHit = false;
419 }
420 if (m_CH_StartDeath)
421 {
422 int deathType = m_DeathTypeCB.GetCurrentItem();
423 float deathDir = m_HitDirEB.GetText().ToFloat();
424
425 infected.StartCommand_Death(deathType, deathDir);
426
427 m_CH_StartDeath = false;
428 }
429 if (m_CH_DoAttack)
430 {
431 float attackDir = m_AttackDirCB.GetCurrentItem();
432 int attackType = m_AttackDescriptors.Get(m_AttackTypeCB.GetCurrentItem()).animValue;
433
434 infected.StartCommand_Attack(null, attackType, attackDir);
435
436 m_CH_DoAttack = false;
437 }
438 }
439
441 void Tick()
442 {
443 if (!m_ControlledInfected)
444 return;
445
446 }
447
449 void InitAttacks()
450 {
451 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Left Light", 0));
452 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Right Light", 1));
453 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Left Heavy", 2));
454 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Attack Right Heavy", 3));
455
456 m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Crawl Attack", 7));
457 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Crawl Attack Combo", 8));
458
459 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Push Attack", 9));
460 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Head Attack", 10));
461 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Shoulder Attack", 11));
462 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door LR Attack", 12));
463 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Kick Attack", 13));
464 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Charge R", 14));
465 //m_AttackDescriptors.Insert(new PluginDayZInfectedDebugAttackDesc("Door Charge L", 15));
466
467 for (int i = 0; i < m_AttackDescriptors.Count(); ++i)
468 m_AttackTypeCB.AddItem(m_AttackDescriptors.Get(i).name);
469 }
470
471 private void CleanupDebugShapes(array<Shape> shapesArr)
472 {
473 for (int it = 0; it < shapesArr.Count(); ++it)
475
476 shapesArr.Clear();
477 }
478}
479
const int ECE_EQUIP_ATTACHMENTS
const int ECE_PLACE_ON_SURFACE
const int ECE_INITAI
void Hide()
Definition DayZGame.c:161
void Show()
Definition DayZGame.c:155
Icon x
Icon y
bool m_IsActive
PlayerBase GetPlayer()
ref Timer m_TickTimer
override bool OnClick(Widget w, int x, int y, int button)
class PluginDayZInfectedDebugUIHandler extends ScriptedWidgetEventHandler PluginDayZInfectedDebugAttackDesc(string pName, int pValue)
override bool OnChange(Widget w, int x, int y, bool finished)
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 CommandHandler()
void DestroyModuleWidgets()
void CreateModuleWidgets()
void CaptureFocus()
void Tick()
proto native UAInputAPI GetUApi()
class JsonUndergroundAreaTriggerData GetPosition
Definition Debug.c:14
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
Definition Debug.c:434
static void RemoveShape(out Shape shape)
Definition Debug.c:107
proto native CGame GetGame()
proto native void OnUpdate()
Definition tools.c:333

◆ OnClick()

override bool PluginDayZInfectedDebugAttackDesc::OnClick ( Widget w,
int x,
int y,
int button )

Definition at line 27 of file PluginDayZInfectedDebug.c.

27 {
28 name = pName;
30 }
31
string name

References animValue, and name.

◆ PluginDayZInfectedDebugAttackDesc()

class PluginDayZInfectedDebugUIHandler extends ScriptedWidgetEventHandler PluginDayZInfectedDebugAttackDesc ( string pName,
int pValue )

Definition at line 4 of file PluginDayZInfectedDebug.c.

27 {
28 name = pName;
30 }

Referenced by PluginBase::InitAttacks().

Variable Documentation

◆ animValue

int animValue

Definition at line 33 of file PluginDayZInfectedDebug.c.

Referenced by OnClick().

◆ m_pPluginInfectedDebug

PluginDayZInfectedDebug m_pPluginInfectedDebug

◆ name

string name

Definition at line 32 of file PluginDayZInfectedDebug.c.