plugindayzplayerdebug_othercmds.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // *************************************************************************************
  2. // ! PluginDayzPlayerDebug_OtherCmds
  3. // *************************************************************************************
  4. class PluginDayzPlayerDebug_OtherCmds
  5. {
  6. // widgets
  7. Widget m_MainWnd;
  8. XComboBoxWidget m_DeathTypeCB;
  9. EditBoxWidget m_DeathDirectionEdit;
  10. ButtonWidget m_DeathStartButton;
  11. XComboBoxWidget m_HitTypeCB;
  12. ButtonWidget m_HitStartButton;
  13. XComboBoxWidget m_UnconTypeCB;
  14. ButtonWidget m_UnconStartButton;
  15. ButtonWidget m_UnconEndButton;
  16. // command handler properties
  17. bool m_CH_DeathStart = false;
  18. bool m_CH_HitStart = false;
  19. bool m_CH_UnconStart = false;
  20. bool m_CH_UnconEnd = false;
  21. //---------------------------------------------------
  22. // gui stuff
  23. void PluginDayzPlayerDebug_OtherCmds(Widget pMainWnd)
  24. {
  25. m_MainWnd = pMainWnd;
  26. CreateModuleWidgets();
  27. }
  28. void ~PluginDayzPlayerDebug_OtherCmds()
  29. {
  30. DestroyModuleWidgets();
  31. }
  32. void CreateModuleWidgets()
  33. {
  34. m_DeathTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("DeathTypeCB") );
  35. m_DeathDirectionEdit = EditBoxWidget.Cast( m_MainWnd.FindAnyWidget("DeathDirectionEdit") );
  36. m_DeathStartButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("DeathStartButton") );
  37. m_HitTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("HitTypeCB") );
  38. m_HitStartButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("HitStartButton") );
  39. m_UnconTypeCB = XComboBoxWidget.Cast( m_MainWnd.FindAnyWidget("UnconTypeCB") );
  40. m_UnconStartButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("UnconStartButton") );
  41. m_UnconEndButton = ButtonWidget.Cast( m_MainWnd.FindAnyWidget("UnconEndButton") );
  42. }
  43. void DestroyModuleWidgets()
  44. {
  45. }
  46. //---------------------------------------------------
  47. // window ui clicks
  48. //! buttons clicks
  49. bool OnClick(Widget w, int x, int y, int button)
  50. {
  51. if( w == m_DeathStartButton )
  52. {
  53. Print("PluginPlayerDebug: Death Start");
  54. m_CH_DeathStart = true;
  55. return true;
  56. }
  57. else if( w == m_HitStartButton )
  58. {
  59. Print("PluginPlayerDebug: Uncon Start");
  60. m_CH_HitStart = true;
  61. return true;
  62. }
  63. else if( w == m_UnconStartButton )
  64. {
  65. Print("PluginPlayerDebug: Uncon Start");
  66. m_CH_UnconStart = true;
  67. return true;
  68. }
  69. else if( w == m_UnconEndButton )
  70. {
  71. Print("PluginPlayerDebug: Uncon End");
  72. m_CH_UnconEnd = true;
  73. return true;
  74. }
  75. return false;
  76. }
  77. //---------------------------------------------------
  78. // Global handler to handle commands from player
  79. void CommandHandler()
  80. {
  81. if( m_CH_DeathStart )
  82. {
  83. Death_Start();
  84. m_CH_DeathStart = false;
  85. }
  86. if( m_CH_HitStart )
  87. {
  88. Hit_Start();
  89. m_CH_HitStart = false;
  90. }
  91. if( m_CH_UnconStart )
  92. {
  93. Uncon_Start();
  94. m_CH_UnconStart = false;
  95. }
  96. if( m_CH_UnconEnd )
  97. {
  98. Uncon_End();
  99. m_CH_UnconEnd = false;
  100. }
  101. }
  102. //---------------------------------------------------
  103. // Commands start functions
  104. void Death_Start()
  105. {
  106. DayZPlayer player = DayZPlayer.Cast( GetGame().GetPlayer() );
  107. if( !player )
  108. return;
  109. int deathType = m_DeathTypeCB.GetCurrentItem();
  110. if( deathType > 0 )
  111. deathType += 9;
  112. float deathDirection = m_DeathDirectionEdit.GetText().ToInt();
  113. player.StartCommand_Death(deathType, deathDirection, HumanCommandDeathCallback);
  114. }
  115. void Hit_Start()
  116. {
  117. DayZPlayer player = DayZPlayer.Cast( GetGame().GetPlayer() );
  118. if( !player )
  119. return;
  120. float hitDirection = m_DeathDirectionEdit.GetText().ToInt();
  121. int hitType = m_HitTypeCB.GetCurrentItem();
  122. if( hitType == 0 )
  123. {
  124. player.AddCommandModifier_Damage(0, hitDirection);
  125. }
  126. else
  127. {
  128. player.StartCommand_Damage(0, hitDirection);
  129. }
  130. }
  131. void Uncon_Start()
  132. {
  133. DayZPlayerImplement player = DayZPlayerImplement.Cast( GetGame().GetPlayer() );
  134. if( !player )
  135. return;
  136. int type = m_UnconTypeCB.GetCurrentItem();
  137. player.m_UnconsciousDebug = true;
  138. player.StartCommand_Unconscious(type);
  139. }
  140. void Uncon_End()
  141. {
  142. DayZPlayerImplement player = DayZPlayerImplement.Cast( GetGame().GetPlayer() );
  143. if( !player )
  144. return;
  145. player.m_UnconsciousDebug = false;
  146. HumanCommandUnconscious hcu = player.GetCommand_Unconscious();
  147. if( hcu )
  148. hcu.WakeUp();
  149. }
  150. }