client.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. //-----------------------------------------------------------------------------
  23. // Server Admin Commands
  24. //-----------------------------------------------------------------------------
  25. function SAD(%password)
  26. {
  27. if (%password !$= "")
  28. commandToServer('SAD', %password);
  29. }
  30. function SADSetPassword(%password)
  31. {
  32. commandToServer('SADSetPassword', %password);
  33. }
  34. //----------------------------------------------------------------------------
  35. // Misc server commands
  36. //----------------------------------------------------------------------------
  37. function clientCmdSyncClock(%time)
  38. {
  39. // Time update from the server, this is only sent at the start of a mission
  40. // or when a client joins a game in progress.
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Damage Direction Indicator
  44. //-----------------------------------------------------------------------------
  45. function clientCmdSetDamageDirection(%direction)
  46. {
  47. eval("%ctrl = DamageHUD-->damage_" @ %direction @ ";");
  48. if (isObject(%ctrl))
  49. {
  50. // Show the indicator, and schedule an event to hide it again
  51. cancelAll(%ctrl);
  52. %ctrl.setVisible(true);
  53. %ctrl.schedule(500, setVisible, false);
  54. }
  55. }
  56. //-----------------------------------------------------------------------------
  57. // Teleporter visual effect
  58. //-----------------------------------------------------------------------------
  59. function clientCmdPlayTeleportEffect(%position, %effectDataBlock)
  60. {
  61. if (isObject(%effectDataBlock))
  62. {
  63. new Explosion()
  64. {
  65. position = %position;
  66. dataBlock = %effectDataBlock;
  67. };
  68. }
  69. }
  70. // ----------------------------------------------------------------------------
  71. // WeaponHUD
  72. // ----------------------------------------------------------------------------
  73. // Update the Ammo Counter with current ammo, if not any then hide the counter.
  74. function clientCmdSetAmmoAmountHud(%amount, %amountInClips)
  75. {
  76. if (!%amount)
  77. AmmoAmount.setVisible(false);
  78. else
  79. {
  80. AmmoAmount.setVisible(true);
  81. AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips);
  82. }
  83. }
  84. // Here we update the Weapon Preview image & reticle for each weapon. We also
  85. // update the Ammo Counter (just so we don't have to call it separately).
  86. // Passing an empty parameter ("") hides the HUD component.
  87. function clientCmdRefreshWeaponHUD(%amount, %preview, %ret, %zoomRet, %amountInClips)
  88. {
  89. if (!%amount)
  90. AmmoAmount.setVisible(false);
  91. else
  92. {
  93. AmmoAmount.setVisible(true);
  94. AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips);
  95. }
  96. if (%preview $= "")
  97. WeaponHUD.setVisible(false);//PreviewImage.setVisible(false);
  98. else
  99. {
  100. WeaponHUD.setVisible(true);//PreviewImage.setVisible(true);
  101. PreviewImage.setbitmap("art/gui/weaponHud/"@ detag(%preview));
  102. }
  103. if (%ret $= "")
  104. Reticle.setVisible(false);
  105. else
  106. {
  107. Reticle.setVisible(true);
  108. Reticle.setbitmap("art/gui/weaponHud/"@ detag(%ret));
  109. }
  110. if (isObject(ZoomReticle))
  111. {
  112. if (%zoomRet $= "")
  113. {
  114. ZoomReticle.setBitmap("");
  115. }
  116. else
  117. {
  118. ZoomReticle.setBitmap("art/gui/weaponHud/"@ detag(%zoomRet));
  119. }
  120. }
  121. }
  122. // ----------------------------------------------------------------------------
  123. // Vehicle Support
  124. // ----------------------------------------------------------------------------
  125. function clientCmdtoggleVehicleMap(%toggle)
  126. {
  127. if(%toggle)
  128. {
  129. moveMap.pop();
  130. // clear movement
  131. $mvForwardAction = 0;
  132. $mvBackwardAction = 0;
  133. vehicleMap.push();
  134. }
  135. else
  136. {
  137. vehicleMap.pop();
  138. moveMap.push();
  139. }
  140. }
  141. // ----------------------------------------------------------------------------
  142. // Turret Support
  143. // ----------------------------------------------------------------------------
  144. // Call by the Turret class when a player mounts or unmounts it.
  145. // %turret = The turret that was mounted
  146. // %player = The player doing the mounting
  147. // %mounted = True if the turret was mounted, false if it was unmounted
  148. function turretMountCallback(%turret, %player, %mounted)
  149. {
  150. //echo ( "\c4turretMountCallback -> " @ %mounted );
  151. if (%mounted)
  152. {
  153. // Push the action map
  154. turretMap.push();
  155. }
  156. else
  157. {
  158. // Pop the action map
  159. turretMap.pop();
  160. }
  161. }