home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / control / client / misc / presetkeys.cs < prev    next >
Encoding:
Text File  |  2006-09-25  |  4.2 KB  |  149 lines

  1. //============================================================================
  2. // control/client/misc/presetkeys.cs
  3. // Copyright (c) 2003, 2006 by Kenneth C. Finney
  4. //============================================================================
  5. if ( IsObject(PlayerKeymap) )  // If we already have a player key map,
  6.    PlayerKeymap.delete();        // delete it so that we can make a new one
  7. new ActionMap(PlayerKeymap);
  8.  
  9. //function DoExitGame()
  10. //{
  11. //   MessageBoxYesNo( "Quit Mission", "Exit from this Mission?", "Quit();", "");
  12. //}
  13. function DoExitGame()///***KCF***25/09/2006 12:54AM
  14. {
  15.    if ( $Server::ServerType $= "SinglePlayer" )
  16.       MessageBoxYesNo( "Exit Mission", "Exit?", "disconnect();", "");
  17.    else
  18.       MessageBoxYesNo( "Disconnect", "Disconnect?", "disconnect();", "");
  19. }
  20.  
  21. //============================================================================
  22. // Motion Functions
  23. //============================================================================
  24. function GoLeft(%val)
  25. {
  26.    $mvLeftAction = %val;
  27. }
  28. function GoRight(%val)
  29. {
  30.    $mvRightAction = %val;
  31. }
  32. //function GoAhead(%val)
  33. //{
  34. //   $mvForwardAction = %val;
  35. //}
  36.  
  37.  
  38. ///***KCF***-ch20
  39. function GoAhead(%val)
  40. //----------------------------------------------------------------------------
  41. // running forward
  42. //----------------------------------------------------------------------------
  43. {
  44.    $mvForwardAction = %val;
  45.    if (%val)
  46.       commandToServer('startRustle');
  47.    else
  48.       commandToServer('stopRustle');
  49. }
  50.  
  51. function BackUp(%val)
  52. {
  53.    $mvBackwardAction = %val;
  54. }
  55. function DoYaw(%val)
  56. {
  57.    $mvYaw += %val * ($cameraFov / 90) * 0.02;
  58. }
  59. function DoPitch(%val)
  60. {
  61.    $mvPitch += %val * ($cameraFov / 90) * 0.02;
  62. }
  63. function DoJump(%val)
  64. {
  65.    $mvTriggerCount2++;
  66. }
  67. //============================================================================
  68. // View Functions
  69. //============================================================================
  70. function Toggle3rdPPOVLook( %val )
  71. {
  72.    if ( %val )      $mvFreeLook = true;
  73.    else           $mvFreeLook = false;
  74. }
  75. function MouseAction(%val)
  76. {
  77.    $mvTriggerCount0++;
  78. }
  79. $firstPerson = true;
  80. function Toggle1stPPOV(%val)
  81. //----------------------------------------------------------------------------
  82. // switch between 1st and 3rd person point-of-view.
  83. //----------------------------------------------------------------------------
  84. {
  85.    if (%val)
  86.    {
  87.       $firstPerson = !$firstPerson;
  88.       ServerConnection.setFirstPerson($firstPerson);
  89.    }
  90. }function dropCameraAtPlayer(%val)
  91. {
  92.    if (%val)
  93.       commandToServer('dropCameraAtPlayer');
  94. }
  95. function dropPlayerAtCamera(%val)
  96. {
  97.    if (%val)
  98.       commandToServer('DropPlayerAtCamera');
  99. }
  100. function toggleCamera(%val)
  101. {
  102.    if (%val)
  103.       commandToServer('ToggleCamera');
  104. }
  105. //============================================================================
  106. // keyboard control mappings
  107. //============================================================================
  108. // available when player is in game
  109. PlayerKeymap.Bind( mouse, button0, MouseAction ); // left mouse button
  110. PlayerKeymap.Bind(keyboard, w, GoAhead);
  111. PlayerKeymap.Bind(keyboard, s, BackUp);
  112. PlayerKeymap.Bind(keyboard, a, GoLeft);
  113. PlayerKeymap.Bind(keyboard, d, GoRight);
  114. PlayerKeymap.Bind(keyboard, space, DoJump );
  115. PlayerKeymap.Bind(keyboard, z, Toggle3rdPPOVLook );
  116. PlayerKeymap.Bind(keyboard, tab, Toggle1stPPOV );
  117. PlayerKeymap.Bind(mouse, xaxis, DoYaw );
  118. PlayerKeymap.Bind(mouse, yaxis, DoPitch );// always available
  119. GlobalActionMap.Bind(keyboard, escape, DoExitGame);
  120. GlobalActionMap.Bind(keyboard, tilde, ToggleConsole);
  121.  
  122. function Yell(%val)
  123. {
  124.     if (%val)
  125.         commandToServer('HurlInsult');
  126. }
  127. PlayerKeymap.bind(keyboard, "y", Yell);
  128.  
  129. function suicide(%val)
  130. {
  131.    if(%val)
  132.       commandToServer('suicide');
  133. }
  134. PlayerKeymap.bind(keyboard, "ctrl k", suicide);
  135.  
  136. function pageMessageBoxUp( %val )
  137. {
  138.    if ( %val )
  139.       PageUpMessageBox();
  140. }
  141. function pageMessageBoxDown( %val )
  142. {
  143.    if ( %val )
  144.       PageDownMessageBox ();
  145. }
  146. PlayerKeymap.bind(keyboard, "t", ToggleMessageBox );
  147. PlayerKeymap.bind(keyboard, "PageUp", PageMessageBoxUp );
  148. PlayerKeymap.bind(keyboard, "PageDown", PageMessageBoxDown );
  149.