mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Empty Template for ticket #1
This commit is contained in:
parent
8337cad7ee
commit
40220512d3
1573 changed files with 141028 additions and 0 deletions
31
Templates/Empty/game/scripts/client/commands.cs
Normal file
31
Templates/Empty/game/scripts/client/commands.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Game start / end events sent from the server
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function clientCmdGameEnd(%seq)
|
||||
{
|
||||
// Stop local activity... the game will be destroyed on the server
|
||||
sfxStopAll();
|
||||
}
|
||||
542
Templates/Empty/game/scripts/client/default.bind.cs
Normal file
542
Templates/Empty/game/scripts/client/default.bind.cs
Normal file
|
|
@ -0,0 +1,542 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if ( isObject( moveMap ) )
|
||||
moveMap.delete();
|
||||
new ActionMap(moveMap);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Non-remapable binds
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function escapeFromGame()
|
||||
{
|
||||
if ( $Server::ServerType $= "SinglePlayer" )
|
||||
MessageBoxYesNo( "Exit", "Exit from this Mission?", "disconnect();", "");
|
||||
else
|
||||
MessageBoxYesNo( "Disconnect", "Disconnect from the server?", "disconnect();", "");
|
||||
}
|
||||
|
||||
moveMap.bindCmd(keyboard, "escape", "", "handleEscape();");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Movement Keys
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
$movementSpeed = 1; // m/s
|
||||
|
||||
function setSpeed(%speed)
|
||||
{
|
||||
if(%speed)
|
||||
$movementSpeed = %speed;
|
||||
}
|
||||
|
||||
function moveleft(%val)
|
||||
{
|
||||
$mvLeftAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function moveright(%val)
|
||||
{
|
||||
$mvRightAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function moveforward(%val)
|
||||
{
|
||||
$mvForwardAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function movebackward(%val)
|
||||
{
|
||||
$mvBackwardAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function moveup(%val)
|
||||
{
|
||||
%object = ServerConnection.getControlObject();
|
||||
|
||||
if(%object.isInNamespaceHierarchy("Camera"))
|
||||
$mvUpAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function movedown(%val)
|
||||
{
|
||||
%object = ServerConnection.getControlObject();
|
||||
|
||||
if(%object.isInNamespaceHierarchy("Camera"))
|
||||
$mvDownAction = %val * $movementSpeed;
|
||||
}
|
||||
|
||||
function turnLeft( %val )
|
||||
{
|
||||
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function turnRight( %val )
|
||||
{
|
||||
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function panUp( %val )
|
||||
{
|
||||
$mvPitchDownSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function panDown( %val )
|
||||
{
|
||||
$mvPitchUpSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
|
||||
}
|
||||
|
||||
function getMouseAdjustAmount(%val)
|
||||
{
|
||||
// based on a default camera FOV of 90'
|
||||
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
|
||||
}
|
||||
|
||||
function getGamepadAdjustAmount(%val)
|
||||
{
|
||||
// based on a default camera FOV of 90'
|
||||
return(%val * ($cameraFov / 90) * 0.01) * 10.0;
|
||||
}
|
||||
|
||||
function yaw(%val)
|
||||
{
|
||||
%yawAdj = getMouseAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%yawAdj *= 0.5;
|
||||
}
|
||||
|
||||
$mvYaw += %yawAdj;
|
||||
}
|
||||
|
||||
function pitch(%val)
|
||||
{
|
||||
%pitchAdj = getMouseAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%pitchAdj *= 0.5;
|
||||
}
|
||||
|
||||
$mvPitch += %pitchAdj;
|
||||
}
|
||||
|
||||
function jump(%val)
|
||||
{
|
||||
$mvTriggerCount2++;
|
||||
}
|
||||
|
||||
function gamePadMoveX( %val )
|
||||
{
|
||||
$mvXAxis_L = %val;
|
||||
}
|
||||
|
||||
function gamePadMoveY( %val )
|
||||
{
|
||||
$mvYAxis_L = %val;
|
||||
}
|
||||
|
||||
function gamepadYaw(%val)
|
||||
{
|
||||
%yawAdj = getGamepadAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%yawAdj *= 0.5;
|
||||
}
|
||||
|
||||
if(%yawAdj > 0)
|
||||
{
|
||||
$mvYawLeftSpeed = %yawAdj;
|
||||
$mvYawRightSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mvYawLeftSpeed = 0;
|
||||
$mvYawRightSpeed = -%yawAdj;
|
||||
}
|
||||
}
|
||||
|
||||
function gamepadPitch(%val)
|
||||
{
|
||||
%pitchAdj = getGamepadAdjustAmount(%val);
|
||||
if(ServerConnection.isControlObjectRotDampedCamera())
|
||||
{
|
||||
// Clamp and scale
|
||||
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
|
||||
%pitchAdj *= 0.5;
|
||||
}
|
||||
|
||||
if(%pitchAdj > 0)
|
||||
{
|
||||
$mvPitchDownSpeed = %pitchAdj;
|
||||
$mvPitchUpSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mvPitchDownSpeed = 0;
|
||||
$mvPitchUpSpeed = -%pitchAdj;
|
||||
}
|
||||
}
|
||||
|
||||
moveMap.bind( keyboard, a, moveleft );
|
||||
moveMap.bind( keyboard, d, moveright );
|
||||
moveMap.bind( keyboard, left, moveleft );
|
||||
moveMap.bind( keyboard, right, moveright );
|
||||
|
||||
moveMap.bind( keyboard, w, moveforward );
|
||||
moveMap.bind( keyboard, s, movebackward );
|
||||
moveMap.bind( keyboard, up, moveforward );
|
||||
moveMap.bind( keyboard, down, movebackward );
|
||||
|
||||
moveMap.bind( keyboard, e, moveup );
|
||||
moveMap.bind( keyboard, c, movedown );
|
||||
|
||||
moveMap.bind( keyboard, space, jump );
|
||||
moveMap.bind( mouse, xaxis, yaw );
|
||||
moveMap.bind( mouse, yaxis, pitch );
|
||||
|
||||
moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
|
||||
moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
|
||||
moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
|
||||
moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
|
||||
|
||||
moveMap.bind( gamepad, btn_a, jump );
|
||||
moveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
|
||||
|
||||
moveMap.bindCmd(gamepad, dpadl, "toggleLightColorViz();", "");
|
||||
moveMap.bindCmd(gamepad, dpadu, "toggleDepthViz();", "");
|
||||
moveMap.bindCmd(gamepad, dpadd, "toggleNormalsViz();", "");
|
||||
moveMap.bindCmd(gamepad, dpadr, "toggleLightSpecularViz();", "");
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Mouse Trigger
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function mouseFire(%val)
|
||||
{
|
||||
$mvTriggerCount0++;
|
||||
}
|
||||
|
||||
function altTrigger(%val)
|
||||
{
|
||||
$mvTriggerCount1++;
|
||||
}
|
||||
|
||||
moveMap.bind( mouse, button0, mouseFire );
|
||||
moveMap.bind( mouse, button1, altTrigger );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Gamepad Trigger
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function gamepadFire(%val)
|
||||
{
|
||||
if(%val > 0.1 && !$gamepadFireTriggered)
|
||||
{
|
||||
$gamepadFireTriggered = true;
|
||||
$mvTriggerCount0++;
|
||||
}
|
||||
else if(%val <= 0.1 && $gamepadFireTriggered)
|
||||
{
|
||||
$gamepadFireTriggered = false;
|
||||
$mvTriggerCount0++;
|
||||
}
|
||||
}
|
||||
|
||||
function gamepadAltTrigger(%val)
|
||||
{
|
||||
if(%val > 0.1 && !$gamepadAltTriggerTriggered)
|
||||
{
|
||||
$gamepadAltTriggerTriggered = true;
|
||||
$mvTriggerCount1++;
|
||||
}
|
||||
else if(%val <= 0.1 && $gamepadAltTriggerTriggered)
|
||||
{
|
||||
$gamepadAltTriggerTriggered = false;
|
||||
$mvTriggerCount1++;
|
||||
}
|
||||
}
|
||||
|
||||
moveMap.bind(gamepad, triggerr, gamepadFire);
|
||||
moveMap.bind(gamepad, triggerl, gamepadAltTrigger);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Zoom and FOV functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if($Player::CurrentFOV $= "")
|
||||
$Player::CurrentFOV = $pref::Player::DefaultFOV / 2;
|
||||
|
||||
// toggleZoomFOV() works by dividing the CurrentFOV by 2. Each time that this
|
||||
// toggle is hit it simply divides the CurrentFOV by 2 once again. If the
|
||||
// FOV is reduced below a certain threshold then it resets to equal half of the
|
||||
// DefaultFOV value. This gives us 4 zoom levels to cycle through.
|
||||
|
||||
function toggleZoomFOV()
|
||||
{
|
||||
$Player::CurrentFOV = $Player::CurrentFOV / 2;
|
||||
|
||||
if($Player::CurrentFOV < 5)
|
||||
resetCurrentFOV();
|
||||
|
||||
if(ServerConnection.zoomed)
|
||||
setFOV($Player::CurrentFOV);
|
||||
else
|
||||
{
|
||||
setFov(ServerConnection.getControlCameraDefaultFov());
|
||||
}
|
||||
}
|
||||
|
||||
function resetCurrentFOV()
|
||||
{
|
||||
$Player::CurrentFOV = ServerConnection.getControlCameraDefaultFov() / 2;
|
||||
}
|
||||
|
||||
function turnOffZoom()
|
||||
{
|
||||
ServerConnection.zoomed = false;
|
||||
setFov(ServerConnection.getControlCameraDefaultFov());
|
||||
|
||||
// Rather than just disable the DOF effect, we want to set it to the level's
|
||||
// preset values.
|
||||
//DOFPostEffect.disable();
|
||||
ppOptionsUpdateDOFSettings();
|
||||
}
|
||||
|
||||
function setZoomFOV(%val)
|
||||
{
|
||||
if(%val)
|
||||
toggleZoomFOV();
|
||||
}
|
||||
|
||||
function toggleZoom(%val)
|
||||
{
|
||||
if (%val)
|
||||
{
|
||||
ServerConnection.zoomed = true;
|
||||
setFov($Player::CurrentFOV);
|
||||
|
||||
DOFPostEffect.setAutoFocus( true );
|
||||
DOFPostEffect.setFocusParams( 0.5, 0.5, 50, 500, -5, 5 );
|
||||
DOFPostEffect.enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
turnOffZoom();
|
||||
}
|
||||
}
|
||||
|
||||
moveMap.bind(keyboard, f, setZoomFOV);
|
||||
moveMap.bind(keyboard, r, toggleZoom);
|
||||
moveMap.bind( gamepad, btn_b, toggleZoom );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Camera & View functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function toggleFreeLook( %val )
|
||||
{
|
||||
if ( %val )
|
||||
$mvFreeLook = true;
|
||||
else
|
||||
$mvFreeLook = false;
|
||||
}
|
||||
|
||||
function toggleFirstPerson(%val)
|
||||
{
|
||||
if (%val)
|
||||
{
|
||||
ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCamera(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('ToggleCamera');
|
||||
}
|
||||
|
||||
moveMap.bind( keyboard, z, toggleFreeLook );
|
||||
moveMap.bind(keyboard, tab, toggleFirstPerson );
|
||||
moveMap.bind(keyboard, "alt c", toggleCamera);
|
||||
|
||||
moveMap.bind( gamepad, btn_back, toggleCamera );
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Demo recording functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function startRecordingDemo( %val )
|
||||
{
|
||||
if ( %val )
|
||||
startDemoRecord();
|
||||
}
|
||||
|
||||
function stopRecordingDemo( %val )
|
||||
{
|
||||
if ( %val )
|
||||
stopDemoRecord();
|
||||
}
|
||||
|
||||
moveMap.bind( keyboard, F3, startRecordingDemo );
|
||||
moveMap.bind( keyboard, F4, stopRecordingDemo );
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helper Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function dropCameraAtPlayer(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('dropCameraAtPlayer');
|
||||
}
|
||||
|
||||
function dropPlayerAtCamera(%val)
|
||||
{
|
||||
if (%val)
|
||||
commandToServer('DropPlayerAtCamera');
|
||||
}
|
||||
|
||||
moveMap.bind(keyboard, "F8", dropCameraAtPlayer);
|
||||
moveMap.bind(keyboard, "F7", dropPlayerAtCamera);
|
||||
|
||||
function bringUpOptions(%val)
|
||||
{
|
||||
if (%val)
|
||||
Canvas.pushDialog(OptionsDlg);
|
||||
}
|
||||
|
||||
GlobalActionMap.bind(keyboard, "ctrl o", bringUpOptions);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Debugging Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
$MFDebugRenderMode = 0;
|
||||
function cycleDebugRenderMode(%val)
|
||||
{
|
||||
if (!%val)
|
||||
return;
|
||||
|
||||
$MFDebugRenderMode++;
|
||||
|
||||
if ($MFDebugRenderMode > 16)
|
||||
$MFDebugRenderMode = 0;
|
||||
if ($MFDebugRenderMode == 15)
|
||||
$MFDebugRenderMode = 16;
|
||||
|
||||
setInteriorRenderMode($MFDebugRenderMode);
|
||||
|
||||
if (isObject(ChatHud))
|
||||
{
|
||||
%message = "Setting Interior debug render mode to ";
|
||||
%debugMode = "Unknown";
|
||||
|
||||
switch($MFDebugRenderMode)
|
||||
{
|
||||
case 0:
|
||||
%debugMode = "NormalRender";
|
||||
case 1:
|
||||
%debugMode = "NormalRenderLines";
|
||||
case 2:
|
||||
%debugMode = "ShowDetail";
|
||||
case 3:
|
||||
%debugMode = "ShowAmbiguous";
|
||||
case 4:
|
||||
%debugMode = "ShowOrphan";
|
||||
case 5:
|
||||
%debugMode = "ShowLightmaps";
|
||||
case 6:
|
||||
%debugMode = "ShowTexturesOnly";
|
||||
case 7:
|
||||
%debugMode = "ShowPortalZones";
|
||||
case 8:
|
||||
%debugMode = "ShowOutsideVisible";
|
||||
case 9:
|
||||
%debugMode = "ShowCollisionFans";
|
||||
case 10:
|
||||
%debugMode = "ShowStrips";
|
||||
case 11:
|
||||
%debugMode = "ShowNullSurfaces";
|
||||
case 12:
|
||||
%debugMode = "ShowLargeTextures";
|
||||
case 13:
|
||||
%debugMode = "ShowHullSurfaces";
|
||||
case 14:
|
||||
%debugMode = "ShowVehicleHullSurfaces";
|
||||
// Depreciated
|
||||
//case 15:
|
||||
// %debugMode = "ShowVertexColors";
|
||||
case 16:
|
||||
%debugMode = "ShowDetailLevel";
|
||||
}
|
||||
|
||||
ChatHud.addLine(%message @ %debugMode);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalActionMap.bind(keyboard, "F9", cycleDebugRenderMode);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Start profiler by pressing ctrl f3
|
||||
// ctrl f3 - starts profile that will dump to console and file
|
||||
//
|
||||
function doProfile(%val)
|
||||
{
|
||||
if (%val)
|
||||
{
|
||||
// key down -- start profile
|
||||
echo("Starting profile session...");
|
||||
profilerReset();
|
||||
profilerEnable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// key up -- finish off profile
|
||||
echo("Ending profile session...");
|
||||
|
||||
profilerDumpToFile("profilerDumpToFile" @ getSimTime() @ ".txt");
|
||||
profilerEnable(false);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalActionMap.bind(keyboard, "ctrl F3", doProfile);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Misc.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
GlobalActionMap.bind(keyboard, "tilde", toggleConsole);
|
||||
GlobalActionMap.bindCmd(keyboard, "alt k", "cls();","");
|
||||
GlobalActionMap.bindCmd(keyboard, "alt enter", "", "Canvas.attemptFullscreenToggle();");
|
||||
43
Templates/Empty/game/scripts/client/defaults.cs
Normal file
43
Templates/Empty/game/scripts/client/defaults.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// First we execute the core default preferences.
|
||||
exec( "core/scripts/client/defaults.cs" );
|
||||
|
||||
|
||||
// Now add your own game specific client preferences as
|
||||
// well as any overloaded core defaults here.
|
||||
|
||||
|
||||
|
||||
|
||||
// Finally load the preferences saved from the last
|
||||
// game execution if they exist.
|
||||
if ( $platform !$= "xenon" )
|
||||
{
|
||||
if ( isFile( "./prefs.cs" ) )
|
||||
exec( "./prefs.cs" );
|
||||
}
|
||||
else
|
||||
{
|
||||
echo( "Not loading client prefs.cs on Xbox360" );
|
||||
}
|
||||
170
Templates/Empty/game/scripts/client/init.cs
Normal file
170
Templates/Empty/game/scripts/client/init.cs
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Variables used by client scripts & code. The ones marked with (c)
|
||||
// are accessed from code. Variables preceeded by Pref:: are client
|
||||
// preferences and stored automatically in the ~/client/prefs.cs file
|
||||
// in between sessions.
|
||||
//
|
||||
// (c) Client::MissionFile Mission file name
|
||||
// ( ) Client::Password Password for server join
|
||||
|
||||
// (?) Pref::Player::CurrentFOV
|
||||
// (?) Pref::Player::DefaultFov
|
||||
// ( ) Pref::Input::KeyboardTurnSpeed
|
||||
|
||||
// (c) pref::Master[n] List of master servers
|
||||
// (c) pref::Net::RegionMask
|
||||
// (c) pref::Client::ServerFavoriteCount
|
||||
// (c) pref::Client::ServerFavorite[FavoriteCount]
|
||||
// .. Many more prefs... need to finish this off
|
||||
|
||||
// Moves, not finished with this either...
|
||||
// (c) firstPerson
|
||||
// $mv*Action...
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// These are variables used to control the shell scripts and
|
||||
// can be overriden by mods:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function initClient()
|
||||
{
|
||||
echo("\n--------- Initializing " @ $appName @ ": Client Scripts ---------");
|
||||
|
||||
// Make sure this variable reflects the correct state.
|
||||
$Server::Dedicated = false;
|
||||
|
||||
// Game information used to query the master server
|
||||
$Client::GameTypeQuery = $appName;
|
||||
$Client::MissionTypeQuery = "Any";
|
||||
|
||||
// The common module provides basic client functionality
|
||||
initBaseClient();
|
||||
|
||||
// Use our prefs to configure our Canvas/Window
|
||||
configureCanvas();
|
||||
|
||||
// Load up the Game GUI
|
||||
exec("art/gui/playGui.gui");
|
||||
|
||||
// Load up the shell GUIs
|
||||
if($platform !$= "xenon") // Use the unified shell instead
|
||||
exec("art/gui/mainMenuGui.gui");
|
||||
exec("art/gui/StartupGui.gui");
|
||||
|
||||
// Gui scripts
|
||||
exec("scripts/gui/playGui.cs");
|
||||
exec("scripts/gui/startupGui.cs");
|
||||
|
||||
// Client scripts
|
||||
exec("./missionDownload.cs");
|
||||
exec("./serverConnection.cs");
|
||||
|
||||
// Default player key bindings
|
||||
exec("./default.bind.cs");
|
||||
|
||||
if (isFile("./config.cs"))
|
||||
exec("./config.cs");
|
||||
|
||||
loadMaterials();
|
||||
|
||||
// Really shouldn't be starting the networking unless we are
|
||||
// going to connect to a remote server, or host a multi-player
|
||||
// game.
|
||||
setNetPort(0);
|
||||
|
||||
// Copy saved script prefs into C++ code.
|
||||
setDefaultFov( $pref::Player::defaultFov );
|
||||
setZoomSpeed( $pref::Player::zoomSpeed );
|
||||
|
||||
if( isFile( "./audioData.cs" ) )
|
||||
exec( "./audioData.cs" );
|
||||
|
||||
// Start up the main menu... this is separated out into a
|
||||
// method for easier mod override.
|
||||
|
||||
if ($startWorldEditor || $startGUIEditor) {
|
||||
// Editor GUI's will start up in the primary main.cs once
|
||||
// engine is initialized.
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect to server if requested.
|
||||
if ($JoinGameAddress !$= "") {
|
||||
// If we are instantly connecting to an address, load the
|
||||
// loading GUI then attempt the connect.
|
||||
loadLoadingGui();
|
||||
connect($JoinGameAddress, "", $Pref::Player::Name);
|
||||
}
|
||||
else {
|
||||
// Otherwise go to the splash screen.
|
||||
Canvas.setCursor("DefaultCursor");
|
||||
loadStartup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function loadMainMenu()
|
||||
{
|
||||
// Startup the client with the Main menu...
|
||||
if (isObject( MainMenuGui ))
|
||||
Canvas.setContent( MainMenuGui );
|
||||
else if (isObject( UnifiedMainMenuGui ))
|
||||
Canvas.setContent( UnifiedMainMenuGui );
|
||||
Canvas.setCursor("DefaultCursor");
|
||||
|
||||
// first check if we have a level file to load
|
||||
if ($levelToLoad !$= "")
|
||||
{
|
||||
%levelFile = "levels/";
|
||||
%ext = getSubStr($levelToLoad, strlen($levelToLoad) - 3, 3);
|
||||
if(%ext !$= "mis")
|
||||
%levelFile = %levelFile @ $levelToLoad @ ".mis";
|
||||
else
|
||||
%levelFile = %levelFile @ $levelToLoad;
|
||||
|
||||
// Clear out the $levelToLoad so we don't attempt to load the level again
|
||||
// later on.
|
||||
$levelToLoad = "";
|
||||
|
||||
// let's make sure the file exists
|
||||
%file = findFirstFile(%levelFile);
|
||||
|
||||
if(%file !$= "")
|
||||
createAndConnectToLocalServer( "SinglePlayer", %file );
|
||||
}
|
||||
}
|
||||
|
||||
function loadLoadingGui()
|
||||
{
|
||||
Canvas.setContent("LoadingGui");
|
||||
LoadingProgress.setValue(1);
|
||||
|
||||
LoadingProgressTxt.setValue("WAITING FOR SERVER");
|
||||
|
||||
Canvas.repaint();
|
||||
}
|
||||
215
Templates/Empty/game/scripts/client/missionDownload.cs
Normal file
215
Templates/Empty/game/scripts/client/missionDownload.cs
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Mission Loading & Mission Info
|
||||
// The mission loading server handshaking is handled by the
|
||||
// core/scripts/client/missingLoading.cs. This portion handles the interface
|
||||
// with the game GUI.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Loading Phases:
|
||||
// Phase 1: Download Datablocks
|
||||
// Phase 2: Download Ghost Objects
|
||||
// Phase 3: Scene Lighting
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 1
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function onMissionDownloadPhase1(%missionName, %musicTrack)
|
||||
{
|
||||
// Load the post effect presets for this mission.
|
||||
%path = "levels/" @ fileBase( %missionName ) @ $PostFXManager::fileExtension;
|
||||
if ( isScriptFile( %path ) )
|
||||
postFXManager::loadPresetHandler( %path );
|
||||
else
|
||||
PostFXManager::settingsApplyDefaultPreset();
|
||||
|
||||
// Close and clear the message hud (in case it's open)
|
||||
if ( isObject( MessageHud ) )
|
||||
MessageHud.close();
|
||||
|
||||
// Reset the loading progress controls:
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(0);
|
||||
LoadingProgressTxt.setValue("LOADING DATABLOCKS");
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function onPhase1Progress(%progress)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(%progress);
|
||||
Canvas.repaint(33);
|
||||
}
|
||||
|
||||
function onPhase1Complete()
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue( 1 );
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 2
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function onMissionDownloadPhase2()
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(0);
|
||||
LoadingProgressTxt.setValue("LOADING OBJECTS");
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function onPhase2Progress(%progress)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(%progress);
|
||||
Canvas.repaint(33);
|
||||
}
|
||||
|
||||
function onPhase2Complete()
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue( 1 );
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function onFileChunkReceived(%fileName, %ofs, %size)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(%ofs / %size);
|
||||
LoadingProgressTxt.setValue("Downloading " @ %fileName @ "...");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 3
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function onMissionDownloadPhase3()
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(0);
|
||||
LoadingProgressTxt.setValue("LIGHTING MISSION");
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function onPhase3Progress(%progress)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(%progress);
|
||||
Canvas.repaint(33);
|
||||
}
|
||||
|
||||
function onPhase3Complete()
|
||||
{
|
||||
$lightingMission = false;
|
||||
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgressTxt.setValue("STARTING MISSION");
|
||||
LoadingProgress.setValue( 1 );
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Mission loading done!
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function onMissionDownloadComplete()
|
||||
{
|
||||
// Client will shortly be dropped into the game, so this is
|
||||
// good place for any last minute gui cleanup.
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Before downloading a mission, the server transmits the mission
|
||||
// information through these messages.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
addMessageCallback( 'MsgLoadInfo', handleLoadInfoMessage );
|
||||
addMessageCallback( 'MsgLoadDescripition', handleLoadDescriptionMessage );
|
||||
addMessageCallback( 'MsgLoadInfoDone', handleLoadInfoDoneMessage );
|
||||
addMessageCallback( 'MsgLoadFailed', handleLoadFailedMessage );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function handleLoadInfoMessage( %msgType, %msgString, %mapName )
|
||||
{
|
||||
// Clear all of the loading info lines:
|
||||
for( %line = 0; %line < LoadingGui.qLineCount; %line++ )
|
||||
LoadingGui.qLine[%line] = "";
|
||||
LoadingGui.qLineCount = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function handleLoadDescriptionMessage( %msgType, %msgString, %line )
|
||||
{
|
||||
LoadingGui.qLine[LoadingGui.qLineCount] = %line;
|
||||
LoadingGui.qLineCount++;
|
||||
|
||||
// Gather up all the previous lines, append the current one
|
||||
// and stuff it into the control
|
||||
%text = "<spush><font:Arial:16>";
|
||||
|
||||
for( %line = 0; %line < LoadingGui.qLineCount - 1; %line++ )
|
||||
%text = %text @ LoadingGui.qLine[%line] @ " ";
|
||||
%text = %text @ LoadingGui.qLine[%line] @ "<spop>";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function handleLoadInfoDoneMessage( %msgType, %msgString )
|
||||
{
|
||||
// This will get called after the last description line is sent.
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function handleLoadFailedMessage( %msgType, %msgString )
|
||||
{
|
||||
MessageBoxOK( "Mission Load Failed", %msgString NL "Press OK to return to the Main Menu", "disconnect();" );
|
||||
}
|
||||
127
Templates/Empty/game/scripts/client/serverConnection.cs
Normal file
127
Templates/Empty/game/scripts/client/serverConnection.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Functions dealing with connecting to a server
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server connection error
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
addMessageCallback( 'MsgConnectionError', handleConnectionErrorMessage );
|
||||
|
||||
function handleConnectionErrorMessage(%msgType, %msgString, %msgError)
|
||||
{
|
||||
// On connect the server transmits a message to display if there
|
||||
// are any problems with the connection. Most connection errors
|
||||
// are game version differences, so hopefully the server message
|
||||
// will tell us where to get the latest version of the game.
|
||||
$ServerConnectionErrorMessage = %msgError;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// GameConnection client callbacks
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function GameConnection::initialControlSet(%this)
|
||||
{
|
||||
echo ("*** Initial Control Object");
|
||||
|
||||
// The first control object has been set by the server
|
||||
// and we are now ready to go.
|
||||
|
||||
// first check if the editor is active
|
||||
if (!isToolBuild() || !Editor::checkActiveLoadDone())
|
||||
{
|
||||
if (Canvas.getContent() != PlayGui.getId())
|
||||
Canvas.setContent(PlayGui);
|
||||
}
|
||||
}
|
||||
|
||||
function GameConnection::onControlObjectChange(%this)
|
||||
{
|
||||
echo ("*** Control Object Changed");
|
||||
|
||||
// Reset the current FOV to match the new object
|
||||
// and turn off any current zoom.
|
||||
resetCurrentFOV();
|
||||
turnOffZoom();
|
||||
}
|
||||
|
||||
// Called on the new connection object after connect() succeeds.
|
||||
function GameConnection::onConnectionAccepted(%this)
|
||||
{
|
||||
// Startup the physX world on the client before any
|
||||
// datablocks and objects are ghosted over.
|
||||
physicsInitWorld( "client" );
|
||||
}
|
||||
|
||||
function GameConnection::onConnectionError(%this, %msg)
|
||||
{
|
||||
// General connection error, usually raised by ghosted objects
|
||||
// initialization problems, such as missing files. We'll display
|
||||
// the server's connection error message.
|
||||
disconnectedCleanup();
|
||||
MessageBoxOK( "DISCONNECT", $ServerConnectionErrorMessage @ " (" @ %msg @ ")" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Disconnect
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function disconnect()
|
||||
{
|
||||
// We need to stop the client side simulation
|
||||
// else physics resources will not cleanup properly.
|
||||
physicsStopSimulation( "client" );
|
||||
|
||||
// Delete the connection if it's still there.
|
||||
if (isObject(ServerConnection))
|
||||
ServerConnection.delete();
|
||||
|
||||
disconnectedCleanup();
|
||||
|
||||
// Call destroyServer in case we're hosting
|
||||
destroyServer();
|
||||
}
|
||||
|
||||
function disconnectedCleanup()
|
||||
{
|
||||
// End mission, if it's running.
|
||||
|
||||
if( $Client::missionRunning )
|
||||
clientEndMission();
|
||||
|
||||
// Disable mission lighting if it's going, this is here
|
||||
// in case we're disconnected while the mission is loading.
|
||||
|
||||
$lightingMission = false;
|
||||
$sceneLighting::terminateLighting = true;
|
||||
|
||||
// Back to the launch screen
|
||||
if (isObject( MainMenuGui ))
|
||||
Canvas.setContent( MainMenuGui );
|
||||
|
||||
// We can now delete the client physics simulation.
|
||||
physicsDestroyWorld( "client" );
|
||||
}
|
||||
80
Templates/Empty/game/scripts/gui/playGui.cs
Normal file
80
Templates/Empty/game/scripts/gui/playGui.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PlayGui is the main TSControl through which the game is viewed.
|
||||
// The PlayGui also contains the hud controls.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function PlayGui::onWake(%this)
|
||||
{
|
||||
// Turn off any shell sounds...
|
||||
// sfxStop( ... );
|
||||
|
||||
$enableDirectInput = "1";
|
||||
activateDirectInput();
|
||||
|
||||
// Message hud dialog
|
||||
if ( isObject( MainChatHud ) )
|
||||
{
|
||||
Canvas.pushDialog( MainChatHud );
|
||||
chatHud.attach(HudMessageVector);
|
||||
}
|
||||
|
||||
// just update the action map here
|
||||
moveMap.push();
|
||||
|
||||
// hack city - these controls are floating around and need to be clamped
|
||||
if ( isFunction( "refreshCenterTextCtrl" ) )
|
||||
schedule(0, 0, "refreshCenterTextCtrl");
|
||||
if ( isFunction( "refreshBottomTextCtrl" ) )
|
||||
schedule(0, 0, "refreshBottomTextCtrl");
|
||||
}
|
||||
|
||||
function PlayGui::onSleep(%this)
|
||||
{
|
||||
if ( isObject( MainChatHud ) )
|
||||
Canvas.popDialog( MainChatHud );
|
||||
|
||||
// pop the keymaps
|
||||
moveMap.pop();
|
||||
}
|
||||
|
||||
function PlayGui::clearHud( %this )
|
||||
{
|
||||
Canvas.popDialog( MainChatHud );
|
||||
|
||||
while ( %this.getCount() > 0 )
|
||||
%this.getObject( 0 ).delete();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function refreshBottomTextCtrl()
|
||||
{
|
||||
BottomPrintText.position = "0 0";
|
||||
}
|
||||
|
||||
function refreshCenterTextCtrl()
|
||||
{
|
||||
CenterPrintText.position = "0 0";
|
||||
}
|
||||
149
Templates/Empty/game/scripts/gui/startupGui.cs
Normal file
149
Templates/Empty/game/scripts/gui/startupGui.cs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// StartupGui is the splash screen that initially shows when the game is loaded
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function loadStartup()
|
||||
{
|
||||
// The index of the current splash screen
|
||||
$StartupIdx = 0;
|
||||
|
||||
// A list of the splash screens and logos
|
||||
// to cycle through. Note that they have to
|
||||
// be in consecutive numerical order
|
||||
StartupGui.bitmap0 = "art/gui/background";
|
||||
StartupGui.logo0 = "art/gui/Torque-3D-logo";
|
||||
StartupGui.logoPos0 = "178 251";
|
||||
StartupGui.logoExtent0 = "443 139";
|
||||
|
||||
// Call the next() function to set our firt
|
||||
// splash screen
|
||||
StartupGui.next();
|
||||
|
||||
// Play our startup sound
|
||||
//SFXPlayOnce(AudioGui, "art/sound/gui/startup");//SFXPlay(startsnd);
|
||||
}
|
||||
|
||||
function StartupGui::click(%this)
|
||||
{
|
||||
%this.done = true;
|
||||
%this.onDone();
|
||||
}
|
||||
|
||||
function StartupGui::next(%this)
|
||||
{
|
||||
// Set us to a blank screen while we load the next one
|
||||
Canvas.setContent(BlankGui);
|
||||
|
||||
// Set our bitmap and reset the done variable
|
||||
%this.setBitmap(getVariable(%this @ ".bitmap" @ $StartupIdx));
|
||||
%this.done = false;
|
||||
|
||||
// If we have a logo then set it
|
||||
if (isObject(%this->StartupLogo))
|
||||
{
|
||||
if (getVariable(%this @ ".logo" @ $StartupIdx) !$= "")
|
||||
{
|
||||
%this->StartupLogo.setBitmap(getVariable(%this @ ".logo" @ $StartupIdx));
|
||||
|
||||
if (getVariable(%this @ ".logoPos" @ $StartupIdx) !$= "")
|
||||
{
|
||||
%logoPosX = getWord(getVariable(%this @ ".logoPos" @ $StartupIdx), 0);
|
||||
%logoPosY = getWord(getVariable(%this @ ".logoPos" @ $StartupIdx), 1);
|
||||
|
||||
%this->StartupLogo.setPosition(%logoPosX, %logoPosY);
|
||||
}
|
||||
|
||||
if (getVariable(%this @ ".logoExtent" @ $StartupIdx) !$= "")
|
||||
%this->StartupLogo.setExtent(getVariable(%this @ ".logoExtent" @ $StartupIdx));
|
||||
|
||||
%this->StartupLogo.setVisible(true);
|
||||
}
|
||||
else
|
||||
%this->StartupLogo.setVisible(false);
|
||||
}
|
||||
|
||||
// If we have a secondary logo then set it
|
||||
if (isObject(%this->StartupLogoSecondary))
|
||||
{
|
||||
if (getVariable(%this @ ".seclogo" @ $StartupIdx) !$= "")
|
||||
{
|
||||
%this->StartupLogoSecondary.setBitmap(getVariable(%this @ ".seclogo" @ $StartupIdx));
|
||||
|
||||
if (getVariable(%this @ ".seclogoPos" @ $StartupIdx) !$= "")
|
||||
{
|
||||
%logoPosX = getWord(getVariable(%this @ ".seclogoPos" @ $StartupIdx), 0);
|
||||
%logoPosY = getWord(getVariable(%this @ ".seclogoPos" @ $StartupIdx), 1);
|
||||
|
||||
%this->StartupLogoSecondary.setPosition(%logoPosX, %logoPosY);
|
||||
}
|
||||
|
||||
if (getVariable(%this @ ".seclogoExtent" @ $StartupIdx) !$= "")
|
||||
%this->StartupLogoSecondary.setExtent(getVariable(%this @ ".seclogoExtent" @ $StartupIdx));
|
||||
|
||||
%this->StartupLogoSecondary.setVisible(true);
|
||||
}
|
||||
else
|
||||
%this->StartupLogoSecondary.setVisible(false);
|
||||
}
|
||||
|
||||
// Increment our screen index for the next screen
|
||||
$StartupIdx++;
|
||||
|
||||
// Set the Canvas to our newly updated GuiFadeinBitmapCtrl
|
||||
Canvas.setContent(%this);
|
||||
}
|
||||
|
||||
function StartupGui::onDone(%this)
|
||||
{
|
||||
// If we have been tagged as done decide if we need
|
||||
// to end or cycle to the next one
|
||||
if (%this.done)
|
||||
{
|
||||
// See if we have a valid bitmap for the next screen
|
||||
if (getVariable(%this @ ".bitmap" @ $StartupIdx) $= "")
|
||||
{
|
||||
// Clear our data and load the main menu
|
||||
%this.done = true;
|
||||
|
||||
// NOTE: Don't ever ever delete yourself during a callback from C++.
|
||||
//
|
||||
// Deleting the whole gui itself seems a bit excessive, what if we want
|
||||
// to return to the startup gui at a later time? Any bitmaps set on
|
||||
// the controls should be unloaded automatically if the control is not
|
||||
// awake, if this is not the case then that's what needs to be fixed.
|
||||
|
||||
//%this.delete();
|
||||
//BlankGui.delete();
|
||||
//flushTextureCache();
|
||||
|
||||
loadMainMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
// We do have a bitmap so cycle to it
|
||||
%this.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
142
Templates/Empty/game/scripts/main.cs
Normal file
142
Templates/Empty/game/scripts/main.cs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Load up core script base
|
||||
loadDir("core"); // Should be loaded at a higher level, but for now leave -- SRZ 11/29/07
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Package overrides to initialize the mod.
|
||||
package fps {
|
||||
|
||||
function displayHelp() {
|
||||
Parent::displayHelp();
|
||||
error(
|
||||
"Fps Mod options:\n"@
|
||||
" -dedicated Start as dedicated server\n"@
|
||||
" -connect <address> For non-dedicated: Connect to a game at <address>\n" @
|
||||
" -mission <filename> For dedicated: Load the mission\n"
|
||||
);
|
||||
}
|
||||
|
||||
function parseArgs()
|
||||
{
|
||||
// Call the parent
|
||||
Parent::parseArgs();
|
||||
|
||||
// Arguments, which override everything else.
|
||||
for (%i = 1; %i < $Game::argc ; %i++)
|
||||
{
|
||||
%arg = $Game::argv[%i];
|
||||
%nextArg = $Game::argv[%i+1];
|
||||
%hasNextArg = $Game::argc - %i > 1;
|
||||
|
||||
switch$ (%arg)
|
||||
{
|
||||
//--------------------
|
||||
case "-dedicated":
|
||||
$Server::Dedicated = true;
|
||||
enableWinConsole(true);
|
||||
$argUsed[%i]++;
|
||||
|
||||
//--------------------
|
||||
case "-mission":
|
||||
$argUsed[%i]++;
|
||||
if (%hasNextArg) {
|
||||
$missionArg = %nextArg;
|
||||
$argUsed[%i+1]++;
|
||||
%i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -mission <filename>");
|
||||
|
||||
//--------------------
|
||||
case "-connect":
|
||||
$argUsed[%i]++;
|
||||
if (%hasNextArg) {
|
||||
$JoinGameAddress = %nextArg;
|
||||
$argUsed[%i+1]++;
|
||||
%i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -connect <ip_address>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onStart()
|
||||
{
|
||||
// The core does initialization which requires some of
|
||||
// the preferences to loaded... so do that first.
|
||||
exec( "./client/defaults.cs" );
|
||||
exec( "./server/defaults.cs" );
|
||||
|
||||
Parent::onStart();
|
||||
echo("\n--------- Initializing Directory: scripts ---------");
|
||||
|
||||
// Load the scripts that start it all...
|
||||
exec("./client/init.cs");
|
||||
exec("./server/init.cs");
|
||||
|
||||
// Init the physics plugin.
|
||||
physicsInit();
|
||||
|
||||
// Start up the audio system.
|
||||
sfxStartup();
|
||||
|
||||
// Server gets loaded for all sessions, since clients
|
||||
// can host in-game servers.
|
||||
initServer();
|
||||
|
||||
// Start up in either client, or dedicated server mode
|
||||
if ($Server::Dedicated)
|
||||
initDedicated();
|
||||
else
|
||||
initClient();
|
||||
}
|
||||
|
||||
function onExit()
|
||||
{
|
||||
// Ensure that we are disconnected and/or the server is destroyed.
|
||||
// This prevents crashes due to the SceneGraph being deleted before
|
||||
// the objects it contains.
|
||||
if ($Server::Dedicated)
|
||||
destroyServer();
|
||||
else
|
||||
disconnect();
|
||||
|
||||
// Destroy the physics plugin.
|
||||
physicsDestroy();
|
||||
|
||||
echo("Exporting client prefs");
|
||||
export("$pref::*", "./client/prefs.cs", False);
|
||||
|
||||
echo("Exporting server prefs");
|
||||
export("$Pref::Server::*", "./server/prefs.cs", False);
|
||||
BanList::Export("./server/banlist.cs");
|
||||
|
||||
Parent::onExit();
|
||||
}
|
||||
|
||||
}; // package fps
|
||||
|
||||
// Activate the game package.
|
||||
activatePackage(fps);
|
||||
25
Templates/Empty/game/scripts/server/commands.cs
Normal file
25
Templates/Empty/game/scripts/server/commands.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Misc. server commands avialable to clients
|
||||
//-----------------------------------------------------------------------------
|
||||
43
Templates/Empty/game/scripts/server/defaults.cs
Normal file
43
Templates/Empty/game/scripts/server/defaults.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// First we execute the core default preferences.
|
||||
exec( "core/scripts/server/defaults.cs" );
|
||||
|
||||
|
||||
// Now add your own game specific server preferences as
|
||||
// well as any overloaded core defaults here.
|
||||
|
||||
|
||||
|
||||
|
||||
// Finally load the preferences saved from the last
|
||||
// game execution if they exist.
|
||||
if ( $platform !$= "xenon" )
|
||||
{
|
||||
if ( isFile( "./prefs.cs" ) )
|
||||
exec( "./prefs.cs" );
|
||||
}
|
||||
else
|
||||
{
|
||||
echo( "Not loading server prefs.cs on Xbox360" );
|
||||
}
|
||||
233
Templates/Empty/game/scripts/server/game.cs
Normal file
233
Templates/Empty/game/scripts/server/game.cs
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// What kind of "player" is spawned is either controlled directly by the
|
||||
// SpawnSphere or it defaults back to the values set here. This also controls
|
||||
// which SimGroups to attempt to select the spawn sphere's from by walking down
|
||||
// the list of SpawnGroups till it finds a valid spawn object.
|
||||
// These override the values set in core/scripts/server/spawn.cs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Leave $Game::defaultPlayerClass and $Game::defaultPlayerDataBlock as empty strings ("")
|
||||
// to spawn a the $Game::defaultCameraClass as the control object.
|
||||
$Game::DefaultPlayerClass = "";
|
||||
$Game::DefaultPlayerDataBlock = "";
|
||||
$Game::DefaultPlayerSpawnGroups = "CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// What kind of "camera" is spawned is either controlled directly by the
|
||||
// SpawnSphere or it defaults back to the values set here. This also controls
|
||||
// which SimGroups to attempt to select the spawn sphere's from by walking down
|
||||
// the list of SpawnGroups till it finds a valid spawn object.
|
||||
// These override the values set in core/scripts/server/spawn.cs
|
||||
//-----------------------------------------------------------------------------
|
||||
$Game::DefaultCameraClass = "Camera";
|
||||
$Game::DefaultCameraDataBlock = "Observer";
|
||||
$Game::DefaultCameraSpawnGroups = "CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";
|
||||
|
||||
// Global movement speed that affects all Cameras
|
||||
$Camera::MovementSpeed = 30;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GameConnection manages the communication between the server's world and the
|
||||
// client's simulation. These functions are responsible for maintaining the
|
||||
// client's camera and player objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This is the main entry point for spawning a control object for the client.
|
||||
// The control object is the actual game object that the client is responsible
|
||||
// for controlling in the client and server simulations. We also spawn a
|
||||
// convenient camera object for use as an alternate control object. We do not
|
||||
// have to spawn this camera object in order to function in the simulation.
|
||||
//
|
||||
// Called for each client after it's finished downloading the mission and is
|
||||
// ready to start playing.
|
||||
//-----------------------------------------------------------------------------
|
||||
function GameConnection::onClientEnterGame(%this)
|
||||
{
|
||||
// This function currently relies on some helper functions defined in
|
||||
// core/scripts/spawn.cs. For custom spawn behaviors one can either
|
||||
// override the properties on the SpawnSphere's or directly override the
|
||||
// functions themselves.
|
||||
|
||||
// Find a spawn point for the camera
|
||||
%cameraSpawnPoint = pickCameraSpawnPoint($Game::DefaultCameraSpawnGroups);
|
||||
// Spawn a camera for this client using the found %spawnPoint
|
||||
%this.spawnCamera(%cameraSpawnPoint);
|
||||
|
||||
// Find a spawn point for the player
|
||||
%playerSpawnPoint = pickPlayerSpawnPoint($Game::DefaultPlayerSpawnGroups);
|
||||
// Spawn a camera for this client using the found %spawnPoint
|
||||
%this.spawnPlayer(%playerSpawnPoint);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Clean up the client's control objects
|
||||
//-----------------------------------------------------------------------------
|
||||
function GameConnection::onClientLeaveGame(%this)
|
||||
{
|
||||
// Cleanup the camera
|
||||
if (isObject(%this.camera))
|
||||
%this.camera.delete();
|
||||
// Cleanup the player
|
||||
if (isObject(%this.player))
|
||||
%this.player.delete();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handle a player's death
|
||||
//-----------------------------------------------------------------------------
|
||||
function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
|
||||
{
|
||||
// Clear out the name on the corpse
|
||||
if (isObject(%this.player))
|
||||
{
|
||||
if (%this.player.isMethod("setShapeName"))
|
||||
%this.player.setShapeName("");
|
||||
}
|
||||
|
||||
// Switch the client over to the death cam
|
||||
if (isObject(%this.camera) && isObject(%this.player))
|
||||
{
|
||||
%this.camera.setMode("Corpse", %this.player);
|
||||
%this.setControlObject(%this.camera);
|
||||
}
|
||||
|
||||
// Unhook the player object
|
||||
%this.player = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server, mission, and game management
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The server has started up so do some game start up
|
||||
//-----------------------------------------------------------------------------
|
||||
function onServerCreated()
|
||||
{
|
||||
// Server::GameType is sent to the master server.
|
||||
// This variable should uniquely identify your game and/or mod.
|
||||
$Server::GameType = "Torque 3D";
|
||||
|
||||
// Server::MissionType sent to the master server. Clients can
|
||||
// filter servers based on mission type.
|
||||
$Server::MissionType = "pureLIGHT";
|
||||
|
||||
// GameStartTime is the sim time the game started. Used to calculated
|
||||
// game elapsed time.
|
||||
$Game::StartTime = 0;
|
||||
|
||||
// Create the server physics world.
|
||||
physicsInitWorld( "server" );
|
||||
|
||||
// Load up any objects or datablocks saved to the editor managed scripts
|
||||
%datablockFiles = new ArrayObject();
|
||||
%datablockFiles.add( "art/shapes/particles/managedParticleData.cs" );
|
||||
%datablockFiles.add( "art/shapes/particles/managedParticleEmitterData.cs" );
|
||||
%datablockFiles.add( "art/decals/managedDecalData.cs" );
|
||||
%datablockFiles.add( "art/datablocks/managedDatablocks.cs" );
|
||||
%datablockFiles.add( "art/forest/managedItemData.cs" );
|
||||
%datablockFiles.add( "art/datablocks/datablockExec.cs" );
|
||||
loadDatablockFiles( %datablockFiles, true );
|
||||
|
||||
// Run the other gameplay scripts in this folder
|
||||
exec("./scriptExec.cs");
|
||||
|
||||
// Keep track of when the game started
|
||||
$Game::StartTime = $Sim::Time;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This function is called as part of a server shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
function onServerDestroyed()
|
||||
{
|
||||
// Destroy the server physcis world
|
||||
physicsDestroyWorld( "server" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called by loadMission() once the mission is finished loading
|
||||
//-----------------------------------------------------------------------------
|
||||
function onMissionLoaded()
|
||||
{
|
||||
// Start the server side physics simulation
|
||||
physicsStartSimulation( "server" );
|
||||
|
||||
// Nothing special for now, just start up the game play
|
||||
startGame();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called by endMission(), right before the mission is destroyed
|
||||
//-----------------------------------------------------------------------------
|
||||
function onMissionEnded()
|
||||
{
|
||||
// Stop the server physics simulation
|
||||
physicsStopSimulation( "server" );
|
||||
|
||||
// Normally the game should be ended first before the next
|
||||
// mission is loaded, this is here in case loadMission has been
|
||||
// called directly. The mission will be ended if the server
|
||||
// is destroyed, so we only need to cleanup here.
|
||||
$Game::Running = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called once the game has started
|
||||
//-----------------------------------------------------------------------------
|
||||
function startGame()
|
||||
{
|
||||
if ($Game::Running)
|
||||
{
|
||||
error("startGame(): End the game first!");
|
||||
return;
|
||||
}
|
||||
|
||||
$Game::Running = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called once the game has ended
|
||||
//-----------------------------------------------------------------------------
|
||||
function endGame()
|
||||
{
|
||||
if (!$Game::Running)
|
||||
{
|
||||
error("endGame(): No game running!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Inform the client the game is over
|
||||
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ )
|
||||
{
|
||||
%cl = ClientGroup.getObject( %clientIndex );
|
||||
commandToClient(%cl, 'GameEnd');
|
||||
}
|
||||
|
||||
// Delete all the temporary mission objects
|
||||
resetMission();
|
||||
$Game::Running = false;
|
||||
}
|
||||
96
Templates/Empty/game/scripts/server/init.cs
Normal file
96
Templates/Empty/game/scripts/server/init.cs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Variables used by server scripts & code. The ones marked with (c)
|
||||
// are accessed from code. Variables preceeded by Pref:: are server
|
||||
// preferences and stored automatically in the ServerPrefs.cs file
|
||||
// in between server sessions.
|
||||
//
|
||||
// (c) Server::ServerType {SinglePlayer, MultiPlayer}
|
||||
// (c) Server::GameType Unique game name
|
||||
// (c) Server::Dedicated Bool
|
||||
// ( ) Server::MissionFile Mission .mis file name
|
||||
// (c) Server::MissionName DisplayName from .mis file
|
||||
// (c) Server::MissionType Not used
|
||||
// (c) Server::PlayerCount Current player count
|
||||
// (c) Server::GuidList Player GUID (record list?)
|
||||
// (c) Server::Status Current server status
|
||||
//
|
||||
// (c) Pref::Server::Name Server Name
|
||||
// (c) Pref::Server::Password Password for client connections
|
||||
// ( ) Pref::Server::AdminPassword Password for client admins
|
||||
// (c) Pref::Server::Info Server description
|
||||
// (c) Pref::Server::MaxPlayers Max allowed players
|
||||
// (c) Pref::Server::RegionMask Registers this mask with master server
|
||||
// ( ) Pref::Server::BanTime Duration of a player ban
|
||||
// ( ) Pref::Server::KickBanTime Duration of a player kick & ban
|
||||
// ( ) Pref::Server::MaxChatLen Max chat message len
|
||||
// ( ) Pref::Server::FloodProtectionEnabled Bool
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function initServer()
|
||||
{
|
||||
echo("\n--------- Initializing " @ $appName @ ": Server Scripts ---------");
|
||||
|
||||
// Server::Status is returned in the Game Info Query and represents the
|
||||
// current status of the server. This string sould be very short.
|
||||
$Server::Status = "Unknown";
|
||||
|
||||
// Turn on testing/debug script functions
|
||||
$Server::TestCheats = false;
|
||||
|
||||
// Specify where the mission files are.
|
||||
$Server::MissionFileSpec = "levels/*.mis";
|
||||
|
||||
// The common module provides the basic server functionality
|
||||
initBaseServer();
|
||||
|
||||
// Load up game server support scripts
|
||||
exec("./commands.cs");
|
||||
exec("./game.cs");
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function initDedicated()
|
||||
{
|
||||
enableWinConsole(true);
|
||||
echo("\n--------- Starting Dedicated Server ---------");
|
||||
|
||||
// Make sure this variable reflects the correct state.
|
||||
$Server::Dedicated = true;
|
||||
|
||||
// The server isn't started unless a mission has been specified.
|
||||
if ($missionArg !$= "") {
|
||||
createServer("MultiPlayer", $missionArg);
|
||||
}
|
||||
else
|
||||
echo("No mission specified (use -mission filename)");
|
||||
}
|
||||
|
||||
24
Templates/Empty/game/scripts/server/scriptExec.cs
Normal file
24
Templates/Empty/game/scripts/server/scriptExec.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Load up all scripts. This function is called when
|
||||
// a server is constructed.
|
||||
Loading…
Add table
Add a link
Reference in a new issue