DayZ 1.24
Loading...
Searching...
No Matches
PluginDayZInfectedDebug.c
Go to the documentation of this file.
1// *************************************************************************************
2// ! PluginDayZInfectedDebugUIHandler
3// *************************************************************************************
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{
27 {
28 name = pName;
30 }
31
32 string name;
34}
35
36// *************************************************************************************
37// ! PluginDayZInfectedDebug
38// *************************************************************************************
39class PluginDayZInfectedDebug extends PluginBase
40{
42 bool m_HasFocus = false;
43 bool m_IsActive = false;
44
53
58
62
66
69
75
78
82
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
104 {
105#ifndef NO_GUI
107#endif
108 }
109
111 {
112#ifndef NO_GUI
114#endif
115 }
116
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
140 {
141 if (!m_HasFocus)
142 {
143 GetGame().GetInput().ChangeGameFocus(1);
144 GetGame().GetUIManager().ShowUICursor(true);
145 m_HasFocus = true;
146 }
147 }
148
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();
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
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
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
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
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
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
bool m_IsActive
PlayerBase GetPlayer()
ref Timer m_TickTimer
class PluginDayZInfectedDebugUIHandler extends ScriptedWidgetEventHandler PluginDayZInfectedDebugAttackDesc(string pName, int pValue)
PluginDayZInfectedDebug m_pPluginInfectedDebug
Widget m_MainWnd
int m_CurrentMode
ref PluginDayzPlayerDebugUIHandler m_pUIHandler
bool m_HasFocus
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
void CommandHandler(DayZInfected infected)
ButtonWidget m_StartHitButton
EditBoxWidget m_TurnDirectionEB
bool OnClick(Widget w, int x, int y, int button)
buttons clicks
XComboBoxWidget m_HitTypeCB
XComboBoxWidget m_DeathTypeCB
ButtonWidget m_CardMovementButton
ButtonWidget m_CardFightButton
ref PluginDayZInfectedDebugUIHandler m_pUIHandler
void ShowWidgets(bool show)
ButtonWidget m_SpawnEntityButton
bool OnChange(Widget w, int x, int y, bool finished)
XComboBoxWidget m_VaultingCB
ButtonWidget m_KnucleOutButton
XComboBoxWidget m_HitBodyPartCB
XComboBoxWidget m_AttackDirCB
Widget m_MainWnd
main controls
XComboBoxWidget m_TurnTypeCB
ButtonWidget m_StartTurnButton
ButtonWidget m_StartCrawlingButton
void ToggleDebugWindowSetMode(int pMode)
EditBoxWidget m_HitDirEB
fight card
ButtonWidget m_StartDeathButton
XComboBoxWidget m_StanceCB
movement card
ButtonWidget m_StartVaultButton
XComboBoxWidget m_AttackTypeCB
ButtonWidget m_StartAttackButton
EditBoxWidget m_MovementSpeedEB
DayZInfected m_ControlledInfected
controlled instance
void ShowCard(int pCard)
ref Timer m_TickTimer
status refresh timer
override void OnUpdate(float delta_time)
XComboBoxWidget m_CrawlingTypeCB
XComboBoxWidget m_MindStateCB
void CleanupDebugShapes(array< Shape > shapesArr)
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override bool OnChange(Widget w, int x, int y, bool finished)
override bool OnClick(Widget w, int x, int y, int button)
PluginDayZInfectedDebug m_pPluginInfectedDebug
proto native CGame GetGame()