Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
plugindayzplayerdebug_othercmds.c
Go to the documentation of this file.
1 // *************************************************************************************
2 // ! PluginDayzPlayerDebug_OtherCmds
3 // *************************************************************************************
4 
6 {
7  // widgets
8  Widget m_MainWnd;
9 
10  XComboBoxWidget m_DeathTypeCB;
11  EditBoxWidget m_DeathDirectionEdit;
12  ButtonWidget m_DeathStartButton;
13 
14  XComboBoxWidget m_HitTypeCB;
15  ButtonWidget m_HitStartButton;
16 
17  XComboBoxWidget m_UnconTypeCB;
18  ButtonWidget m_UnconStartButton;
19  ButtonWidget m_UnconEndButton;
20 
21  // command handler properties
22  bool m_CH_DeathStart = false;
23  bool m_CH_HitStart = false;
24  bool m_CH_UnconStart = false;
25  bool m_CH_UnconEnd = false;
26 
27 
28  //---------------------------------------------------
29  // gui stuff
30 
32  {
33  m_MainWnd = pMainWnd;
34  CreateModuleWidgets();
35  }
36 
37 
39  {
40  DestroyModuleWidgets();
41  }
42 
43 
44  void CreateModuleWidgets()
45  {
46  m_DeathTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("DeathTypeCB") );
47  m_DeathDirectionEdit = EditBoxWidget.Cast( m_MainWnd.FindAnyWidget("DeathDirectionEdit") );
48  m_DeathStartButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("DeathStartButton") );
49 
50  m_HitTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("HitTypeCB") );
51  m_HitStartButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("HitStartButton") );
52 
53  m_UnconTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("UnconTypeCB") );
54  m_UnconStartButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("UnconStartButton") );
55  m_UnconEndButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("UnconEndButton") );
56  }
57 
58  void DestroyModuleWidgets()
59  {
60  }
61 
62  //---------------------------------------------------
63  // window ui clicks
64 
66  bool OnClick(Widget w, int x, int y, int button)
67  {
68  if( w == m_DeathStartButton )
69  {
70  Print("PluginPlayerDebug: Death Start");
71  m_CH_DeathStart = true;
72  return true;
73  }
74  else if( w == m_HitStartButton )
75  {
76  Print("PluginPlayerDebug: Uncon Start");
77  m_CH_HitStart = true;
78  return true;
79  }
80  else if( w == m_UnconStartButton )
81  {
82  Print("PluginPlayerDebug: Uncon Start");
83  m_CH_UnconStart = true;
84  return true;
85  }
86  else if( w == m_UnconEndButton )
87  {
88  Print("PluginPlayerDebug: Uncon End");
89  m_CH_UnconEnd = true;
90  return true;
91  }
92 
93  return false;
94  }
95 
96 
97  //---------------------------------------------------
98  // Global handler to handle commands from player
99 
100  void CommandHandler()
101  {
102  if( m_CH_DeathStart )
103  {
104  Death_Start();
105  m_CH_DeathStart = false;
106  }
107  if( m_CH_HitStart )
108  {
109  Hit_Start();
110  m_CH_HitStart = false;
111  }
112  if( m_CH_UnconStart )
113  {
114  Uncon_Start();
115  m_CH_UnconStart = false;
116  }
117  if( m_CH_UnconEnd )
118  {
119  Uncon_End();
120  m_CH_UnconEnd = false;
121  }
122  }
123 
124  //---------------------------------------------------
125  // Commands start functions
126 
127  void Death_Start()
128  {
129  DayZPlayer player = DayZPlayer.Cast( GetGame().GetPlayer() );
130  if( !player )
131  return;
132 
133  int deathType = m_DeathTypeCB.GetCurrentItem();
134  if( deathType > 0 )
135  deathType += 9;
136 
137  float deathDirection = m_DeathDirectionEdit.GetText().ToInt();
138 
139 
140  player.StartCommand_Death(deathType, deathDirection, HumanCommandDeathCallback);
141  }
142 
143  void Hit_Start()
144  {
145  DayZPlayer player = DayZPlayer.Cast( GetGame().GetPlayer() );
146  if( !player )
147  return;
148 
149  float hitDirection = m_DeathDirectionEdit.GetText().ToInt();
150  int hitType = m_HitTypeCB.GetCurrentItem();
151  if( hitType == 0 )
152  {
153  player.AddCommandModifier_Damage(0, hitDirection);
154  }
155  else
156  {
157  player.StartCommand_Damage(0, hitDirection);
158  }
159  }
160 
161  void Uncon_Start()
162  {
164  if( !player )
165  return;
166 
167  int type = m_UnconTypeCB.GetCurrentItem();
168 
169  player.m_UnconsciousDebug = true;
170  player.StartCommand_Unconscious(type);
171  }
172 
173  void Uncon_End()
174  {
176  if( !player )
177  return;
178 
179  player.m_UnconsciousDebug = false;
180  HumanCommandUnconscious hcu = player.GetCommand_Unconscious();
181  if( hcu )
182  hcu.WakeUp();
183  }
184 }
GetGame
proto native CGame GetGame()
HumanCommandDeathCallback
Definition: human.c:595
EditBoxWidget
Definition: enwidgets.c:353
y
Icon y
PluginDayzPlayerDebug_OtherCmds
Definition: plugindayzplayerdebug_othercmds.c:5
Print
proto void Print(void var)
Prints content of variable to console/log.
DayZPlayer
Definition: dayzplayerimplement.c:72
HumanCommandUnconscious
Definition: human.c:619
DayZPlayerImplement
Definition: manbase.c:1
x
Icon x
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
Widget
Definition: enwidgets.c:189
m_MainWnd
Widget m_MainWnd
Definition: plugindayzplayerdebug.c:206