//============================================================================
// control/client/misc/presetkeys.cs
// Copyright (c) 2003, 2006 by Kenneth C. Finney
//============================================================================
if ( IsObject(PlayerKeymap) )  // If we already have a player key map,
   PlayerKeymap.delete();        // delete it so that we can make a new one
new ActionMap(PlayerKeymap);

//function DoExitGame()
//{
//   MessageBoxYesNo( "Quit Mission", "Exit from this Mission?", "Quit();", "");
//}
function DoExitGame()///***KCF***25/09/2006 12:54AM
{
   if ( $Server::ServerType $= "SinglePlayer" )
      MessageBoxYesNo( "Exit Mission", "Exit?", "disconnect();", "");
   else
      MessageBoxYesNo( "Disconnect", "Disconnect?", "disconnect();", "");
}

//============================================================================
// Motion Functions
//============================================================================
function GoLeft(%val)
{
   $mvLeftAction = %val;
}
function GoRight(%val)
{
   $mvRightAction = %val;
}
//function GoAhead(%val)
//{
//   $mvForwardAction = %val;
//}


///***KCF***-ch20
function GoAhead(%val)
//----------------------------------------------------------------------------
// running forward
//----------------------------------------------------------------------------
{
   $mvForwardAction = %val;
   if (%val)
      commandToServer('startRustle');
   else
      commandToServer('stopRustle');
}

function BackUp(%val)
{
   $mvBackwardAction = %val;
}
function DoYaw(%val)
{
   $mvYaw += %val * ($cameraFov / 90) * 0.02;
}
function DoPitch(%val)
{
   $mvPitch += %val * ($cameraFov / 90) * 0.02;
}
function DoJump(%val)
{
   $mvTriggerCount2++;
}
//============================================================================
// View Functions
//============================================================================
function Toggle3rdPPOVLook( %val )
{
   if ( %val )      $mvFreeLook = true;
   else           $mvFreeLook = false;
}
function MouseAction(%val)
{
   $mvTriggerCount0++;
}
$firstPerson = true;
function Toggle1stPPOV(%val)
//----------------------------------------------------------------------------
// switch between 1st and 3rd person point-of-view.
//----------------------------------------------------------------------------
{
   if (%val)
   {
      $firstPerson = !$firstPerson;
      ServerConnection.setFirstPerson($firstPerson);
   }
}function dropCameraAtPlayer(%val)
{
   if (%val)
      commandToServer('dropCameraAtPlayer');
}
function dropPlayerAtCamera(%val)
{
   if (%val)
      commandToServer('DropPlayerAtCamera');
}
function toggleCamera(%val)
{
   if (%val)
      commandToServer('ToggleCamera');
}
//============================================================================
// keyboard control mappings
//============================================================================
// available when player is in game
PlayerKeymap.Bind( mouse, button0, MouseAction ); // left mouse button
PlayerKeymap.Bind(keyboard, w, GoAhead);
PlayerKeymap.Bind(keyboard, s, BackUp);
PlayerKeymap.Bind(keyboard, a, GoLeft);
PlayerKeymap.Bind(keyboard, d, GoRight);
PlayerKeymap.Bind(keyboard, space, DoJump );
PlayerKeymap.Bind(keyboard, z, Toggle3rdPPOVLook );
PlayerKeymap.Bind(keyboard, tab, Toggle1stPPOV );
PlayerKeymap.Bind(mouse, xaxis, DoYaw );
PlayerKeymap.Bind(mouse, yaxis, DoPitch );// always available
GlobalActionMap.Bind(keyboard, escape, DoExitGame);
GlobalActionMap.Bind(keyboard, tilde, ToggleConsole);

function Yell(%val)
{
	if (%val)
		commandToServer('HurlInsult');
}
PlayerKeymap.bind(keyboard, "y", Yell);

function suicide(%val)
{
   if(%val)
      commandToServer('suicide');
}
PlayerKeymap.bind(keyboard, "ctrl k", suicide);

function pageMessageBoxUp( %val )
{
   if ( %val )
      PageUpMessageBox();
}
function pageMessageBoxDown( %val )
{
   if ( %val )
      PageDownMessageBox ();
}
PlayerKeymap.bind(keyboard, "t", ToggleMessageBox );
PlayerKeymap.bind(keyboard, "PageUp", PageMessageBoxUp );
PlayerKeymap.bind(keyboard, "PageDown", PageMessageBoxDown );
