mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-21 04:15:36 +00:00
Catches FPSGameplay module up to new gamemode and module paradigm
Adds additional args for callGamemodeFunction Adds default Observer camera datablock
This commit is contained in:
parent
49f4fddd77
commit
28c4bad74d
47 changed files with 309 additions and 274 deletions
|
|
@ -141,3 +141,8 @@ datablock MissionMarkerData(CameraBookmarkMarker)
|
|||
category = "Misc";
|
||||
shapeFile = "core/gameObjects/shapes/camera.dts";
|
||||
};
|
||||
|
||||
datablock CameraData(Observer)
|
||||
{
|
||||
mode = "Observer";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function callGamemodeFunction(%gameModeFuncName, %data)
|
||||
function callGamemodeFunction(%gameModeFuncName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6)
|
||||
{
|
||||
if(%data !$= "")
|
||||
%data = "\""@%data@"\"";
|
||||
|
|
@ -14,7 +14,7 @@ function callGamemodeFunction(%gameModeFuncName, %data)
|
|||
//if the scene defines a game mode, go ahead and envoke it here
|
||||
if(isObject(%gamemodeName) && %gamemodeName.isMethod(%gameModeFuncName))
|
||||
{
|
||||
eval(%gamemodeName @ "."@%gameModeFuncName@"("@%data@");" );
|
||||
eval(%gamemodeName @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
else
|
||||
|
|
@ -22,7 +22,7 @@ function callGamemodeFunction(%gameModeFuncName, %data)
|
|||
//if we don't have an object, attempt the static call
|
||||
if(isMethod(%gamemodeName, %gameModeFuncName))
|
||||
{
|
||||
eval(%gamemodeName @ "::"@%gameModeFuncName@"("@%data@");" );
|
||||
eval(%gamemodeName @ "::"@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -37,14 +37,14 @@ function callGamemodeFunction(%gameModeFuncName, %data)
|
|||
{
|
||||
if(isObject(%defaultModeName) && %defaultModeName.isMethod(%gameModeFuncName))
|
||||
{
|
||||
eval(%defaultModeName @ "."@%gameModeFuncName@"("@%data@");" );
|
||||
eval(%defaultModeName @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isMethod(%defaultModeName, %gameModeFuncName))
|
||||
{
|
||||
eval(%defaultModeName @ "::"@%gameModeFuncName@"("@%data@");" );
|
||||
eval(%defaultModeName @ "::"@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||
%hasGameMode = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ function ExampleGameMode::onClientLeaveGame(%this, %client)
|
|||
//This is called when the player has connected and finaly setup is done and control is handed
|
||||
//over to the client. It allows a point to special-case setting the client's canvas content
|
||||
//(Such as a gamemode-specific GUI) or setting up gamemode-specific keybinds/control schemes
|
||||
function ExampleGameMode::onInitialControlSet()
|
||||
function ExampleGameMode::onInitialControlSet(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
function FPSGameplay::onCreate( %this )
|
||||
{
|
||||
echo("Made it");
|
||||
|
||||
}
|
||||
|
||||
function FPSGameplay::onDestroy( %this )
|
||||
|
|
@ -51,31 +49,44 @@ function FPSGameplay::initServer(%this)
|
|||
exec("./scripts/server/physicsShape.cs");
|
||||
}
|
||||
|
||||
function FPSGameplay::onCreateServer(%this)
|
||||
function FPSGameplay::onCreateGameServer(%this)
|
||||
{
|
||||
if(isObject(DatablockFilesList))
|
||||
{
|
||||
for( %file = findFirstFile( "data/FPSGameplay/scripts/datablocks/*.cs.dso" );
|
||||
%file !$= "";
|
||||
%file = findNextFile( "data/FPSGameplay/scripts/datablocks/*.cs.dso" ))
|
||||
{
|
||||
// Only execute, if we don't have the source file.
|
||||
%csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
|
||||
if( !isFile( %csFileName ) )
|
||||
DatablockFilesList.add(%csFileName);
|
||||
}
|
||||
|
||||
// Load all source material files.
|
||||
for( %file = findFirstFile( "data/FPSGameplay/scripts/datablocks/*.cs" );
|
||||
%file !$= "";
|
||||
%file = findNextFile( "data/FPSGameplay/scripts/datablocks/*.cs" ))
|
||||
{
|
||||
DatablockFilesList.add(%file);
|
||||
}
|
||||
}
|
||||
%this.registerDatablock("./datablocks/audioProfiles.cs");
|
||||
%this.registerDatablock("./datablocks/audioData.cs");
|
||||
%this.registerDatablock("./datablocks/sounds.cs");
|
||||
%this.registerDatablock("./datablocks/aiPlayer.cs");
|
||||
%this.registerDatablock("./datablocks/brushes.cs");
|
||||
%this.registerDatablock("./datablocks/environment.cs");
|
||||
%this.registerDatablock("./datablocks/health.cs");
|
||||
%this.registerDatablock("./datablocks/lights.cs");
|
||||
|
||||
%this.registerDatablock("./datablocks/managedDatablocks.cs");
|
||||
%this.registerDatablock("./datablocks/managedDecalData.cs");
|
||||
%this.registerDatablock("./datablocks/managedForestItemData.cs");
|
||||
%this.registerDatablock("./datablocks/managedItemData.cs");
|
||||
%this.registerDatablock("./datablocks/managedParticleData.cs");
|
||||
%this.registerDatablock("./datablocks/managedParticleEmiterData.cs");
|
||||
|
||||
%this.registerDatablock("./datablocks/markers.cs");
|
||||
%this.registerDatablock("./datablocks/particles.cs");
|
||||
%this.registerDatablock("./datablocks/physics.cs");
|
||||
%this.registerDatablock("./datablocks/player.cs");
|
||||
%this.registerDatablock("./datablocks/ribbons.cs");
|
||||
%this.registerDatablock("./datablocks/rigidShape.cs");
|
||||
%this.registerDatablock("./datablocks/teleporter.cs");
|
||||
%this.registerDatablock("./datablocks/triggers.cs");
|
||||
%this.registerDatablock("./datablocks/weapon.cs");
|
||||
|
||||
%this.registerDatablock("./datablocks/vehicles/cheetahCar.cs");
|
||||
|
||||
%this.registerDatablock("./datablocks/weapons/grenadefx.cs");
|
||||
%this.registerDatablock("./datablocks/weapons/Lurker.cs");
|
||||
%this.registerDatablock("./datablocks/weapons/ProxMine.cs");
|
||||
%this.registerDatablock("./datablocks/weapons/Ryder.cs");
|
||||
%this.registerDatablock("./datablocks/weapons/Turret.cs");
|
||||
}
|
||||
|
||||
function FPSGameplay::onDestroyServer(%this)
|
||||
function FPSGameplay::onDestroyGameServer(%this)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -83,21 +94,13 @@ function FPSGameplay::initClient(%this)
|
|||
{
|
||||
exec("data/FPSGameplay/scripts/client/gameProfiles.cs");
|
||||
|
||||
//client scripts
|
||||
$KeybindPath = "data/FPSGameplay/scripts/client/default.keybinds.cs";
|
||||
exec($KeybindPath);
|
||||
|
||||
%prefPath = getPrefpath();
|
||||
if(isFile(%prefPath @ "/keybinds.cs"))
|
||||
exec(%prefPath @ "/keybinds.cs");
|
||||
|
||||
exec("data/FPSGameplay/scripts/client/inputCommands.cs");
|
||||
|
||||
//guis
|
||||
exec("./scripts/gui/chatHud.gui");
|
||||
exec("./scripts/gui/playerList.gui");
|
||||
exec("./scripts/gui/playGui.gui");
|
||||
exec("./scripts/gui/hudlessGui.gui");
|
||||
exec("./guis/chatHud.gui");
|
||||
exec("./guis/playerList.gui");
|
||||
exec("./guis/playGui.gui");
|
||||
exec("./guis/hudlessGui.gui");
|
||||
|
||||
exec("data/FPSGameplay/scripts/client/playGui.cs");
|
||||
exec("data/FPSGameplay/scripts/client/hudlessGui.cs");
|
||||
|
|
@ -113,10 +116,17 @@ function FPSGameplay::initClient(%this)
|
|||
exec("data/FPSGameplay/scripts/client/screenshot.cs");
|
||||
}
|
||||
|
||||
function FPSGameplay::onCreateClient(%this)
|
||||
function FPSGameplay::onCreateClientConnection(%this)
|
||||
{
|
||||
//client scripts
|
||||
$KeybindPath = "data/FPSGameplay/scripts/client/default.keybinds.cs";
|
||||
exec($KeybindPath);
|
||||
|
||||
%prefPath = getPrefpath();
|
||||
if(isFile(%prefPath @ "/keybinds.cs"))
|
||||
exec(%prefPath @ "/keybinds.cs");
|
||||
}
|
||||
|
||||
function FPSGameplay::onDestroyClient(%this)
|
||||
function FPSGameplay::onDestroyClientConnection(%this)
|
||||
{
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ new GuiControl(MessageHud)
|
|||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
bitmap = "data/UI/art/gui/hudfill.png";
|
||||
bitmap = "data/UI/images/hudfill.png";
|
||||
wrap = "0";
|
||||
};
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ new GuiControl(MainChatHud) {
|
|||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
bitmap = "data/UI/art/gui/hudfill.png";
|
||||
bitmap = "data/UI/images/hudfill.png";
|
||||
wrap = "0";
|
||||
};
|
||||
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
noCursor = "1";
|
||||
|
||||
new GuiBitmapCtrl(CenterPrintDlg) {
|
||||
bitmap = "data/UI/art/gui/hudfill.png";
|
||||
bitmap = "data/UI/images/hudfill.png";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "CenterPrintProfile";
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
};
|
||||
};
|
||||
new GuiBitmapCtrl(BottomPrintDlg) {
|
||||
bitmap = "data/UI/art/gui/hudfill.png";
|
||||
bitmap = "data/UI/images/hudfill.png";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "CenterPrintProfile";
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
};
|
||||
};
|
||||
new GuiBitmapCtrl(LagIcon) {
|
||||
bitmap = "data/UI/art/gui/lagIcon.png";
|
||||
bitmap = "data/UI/images/lagIcon.png";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiDefaultProfile";
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
bitmap = "data/FPSGameplay/art/gui/hudfill.png";
|
||||
bitmap = "data/UI/images/hudfill.png";
|
||||
wrap = "0";
|
||||
|
||||
new GuiScrollCtrl() {
|
||||
|
|
@ -1,41 +1,59 @@
|
|||
//--- OBJECT WRITE BEGIN ---
|
||||
new Scene(EmptyTerrainLevel) {
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
enabled = "1";
|
||||
isSubScene = "0";
|
||||
isEditing = "0";
|
||||
isDirty = "0";
|
||||
Enabled = "1";
|
||||
gameModeName="DeathMatchGame";
|
||||
|
||||
new LevelInfo(theLevelInfo) {
|
||||
nearClip = "0.1";
|
||||
visibleDistance = "2000";
|
||||
visibleGhostDistance = "0";
|
||||
decalBias = "0.0015";
|
||||
fogColor = "1 1 0.6 1";
|
||||
fogDensity = "0.001";
|
||||
fogDensityOffset = "10";
|
||||
fogAtmosphereHeight = "100";
|
||||
canvasClearColor = "233 220 143 255";
|
||||
advancedLightmapSupport = "0";
|
||||
class = "DeathMatchGame";
|
||||
ambientLightBlendPhase = "1";
|
||||
ambientLightBlendCurve = "0 0 -1 -1";
|
||||
soundAmbience = "AudioAmbienceDefault";
|
||||
soundDistanceModel = "Linear";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
advancedLightmapSupport = "0";
|
||||
desc0 = "An empty terrain ready to be populated with Torque objects.";
|
||||
LevelName = "Empty Terrain";
|
||||
preview = "data/FPSGameplay/levels/Empty Terrain_preview";
|
||||
};
|
||||
new ScatterSky() {
|
||||
skyBrightness = "30";
|
||||
mieScattering = "0.0015";
|
||||
sunSize = "1";
|
||||
colorizeAmount = "0";
|
||||
colorize = "0 0 0 1";
|
||||
rayleighScattering = "0.0035";
|
||||
sunScale = "1 1 0.8 1";
|
||||
ambientScale = "0.5 0.5 0.4 1";
|
||||
fogScale = "1 1 1 1";
|
||||
exposure = "0.85";
|
||||
zOffset = "0";
|
||||
azimuth = "84";
|
||||
elevation = "54";
|
||||
moonAzimuth = "0";
|
||||
moonElevation = "45";
|
||||
castShadows = "1";
|
||||
staticRefreshFreq = "8";
|
||||
dynamicRefreshFreq = "8";
|
||||
brightness = "1";
|
||||
flareType = "SunFlareExample1";
|
||||
flareScale = "1";
|
||||
nightColor = "0.0196078 0.0117647 0.109804 1";
|
||||
nightFogColor = "0.0196078 0.0117647 0.109804 1";
|
||||
moonEnabled = "1";
|
||||
moonTexture = "core/art/skies/night/moon_wglow";
|
||||
moonScale = "0.3";
|
||||
moonTint = "0.192157 0.192157 0.192157 1";
|
||||
moonLightColor = "0.192157 0.192157 0.192157 1";
|
||||
useNightCubemap = "0";
|
||||
attenuationRatio = "0 1 1";
|
||||
shadowType = "PSSM";
|
||||
|
|
@ -53,40 +71,62 @@ new Scene(EmptyTerrainLevel) {
|
|||
position = "0 0 0";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
mieScattering = "0.0015";
|
||||
moonTexture = "core/art/skies/night/moon_wglow";
|
||||
moonTint = "0.192157 0.192157 0.192157 1";
|
||||
sunBrightness = "50";
|
||||
};
|
||||
new TerrainBlock(theTerrain) {
|
||||
terrainFile = "data/FPSGameplay/art/terrains/Empty Terrain_0.ter";
|
||||
castShadows = "1";
|
||||
squareSize = "2";
|
||||
tile = "0";
|
||||
baseTexSize = "1024";
|
||||
baseTexFormat = "DDS";
|
||||
lightMapSize = "256";
|
||||
screenError = "16";
|
||||
ignoreZodiacs = "0";
|
||||
position = "-1024 -1024 179.978";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
scale = "1 1 1";
|
||||
tile = "0";
|
||||
};
|
||||
new SimGroup(PlayerDropPoints) {
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
enabled = "1";
|
||||
Enabled = "1";
|
||||
|
||||
new SpawnSphere() {
|
||||
autoSpawn = "0";
|
||||
spawnTransform = "0";
|
||||
radius = "1";
|
||||
sphereWeight = "1";
|
||||
indoorWeight = "1";
|
||||
outdoorWeight = "1";
|
||||
isAIControlled = "0";
|
||||
dataBlock = "SpawnSphereMarker";
|
||||
position = "0 0 241.772";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
enabled = "1";
|
||||
Enabled = "1";
|
||||
homingCount = "0";
|
||||
lockCount = "0";
|
||||
TypeBool locked = "False";
|
||||
};
|
||||
};
|
||||
new Skylight() {
|
||||
Enabled = "1";
|
||||
ReflectionMode = "Baked Cubemap";
|
||||
position = "181.562 73.8898 273.01";
|
||||
rotation = "1 0 0 0";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
persistentId = "806d86d9-e70e-11e9-b257-effec2306e84";
|
||||
reflectionPath = "data/FPSGameplay/levels/Empty Terrain/probes/";
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ new Scene(OutpostLevel) {
|
|||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
enabled = "1";
|
||||
gameModeName="DeathMatchGame";
|
||||
|
||||
new LevelInfo(theLevelInfo) {
|
||||
nearClip = "0.1";
|
||||
|
|
@ -20,7 +21,6 @@ new Scene(OutpostLevel) {
|
|||
soundDistanceModel = "Linear";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
class = "DeathMatchGame";
|
||||
desc = "A \'one of everything\' test level that demonstrates lots of stock classes.";
|
||||
levelName = "Outpost";
|
||||
preview = "data/FPSGameplay/levels/Outpost_preview";
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
datablock CameraData(Observer)
|
||||
{
|
||||
mode = "Observer";
|
||||
};
|
||||
|
|
@ -39,7 +39,7 @@ function Observer::onTrigger(%this,%obj,%trigger,%state)
|
|||
|
||||
case "Corpse":
|
||||
// Viewing dead corpse, so we probably want to respawn.
|
||||
$Game.preparePlayer(%client);
|
||||
callGamemodeFunction("preparePlayer", %client);
|
||||
|
||||
// Set the camera back into observer mode, since in
|
||||
// debug mode we like to switch to it.
|
||||
|
|
|
|||
|
|
@ -30,10 +30,88 @@
|
|||
// - gameType = "Deathmatch";
|
||||
// If this information is missing then the GameCore will default to Deathmatch.
|
||||
// ----------------------------------------------------------------------------
|
||||
function DeathMatchGame::initGameVars()
|
||||
function DeathMatchGame::onCreateGame()
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> DeathMatchGame::initGameVars");
|
||||
// Note: The Game object will be cleaned up by MissionCleanup. Therefore its lifetime is
|
||||
// limited to that of the mission.
|
||||
new ScriptObject(DeathMatchGame){};
|
||||
|
||||
return DeathMatchGame;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The server has started up so do some game start up
|
||||
//-----------------------------------------------------------------------------
|
||||
function DeathMatchGame::onMissionStart(%this)
|
||||
{
|
||||
//set up the game and game variables
|
||||
%this.initGameVars();
|
||||
|
||||
%this.Duration = 30 * 60;
|
||||
%this.EndGameScore = 20;
|
||||
%this.EndGamePause = 10;
|
||||
%this.AllowCycling = false; // Is mission cycling allowed?
|
||||
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onStartGame");
|
||||
if (%this.Running)
|
||||
{
|
||||
error("startGame: End the game first!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Inform the client we're starting up
|
||||
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
|
||||
{
|
||||
%cl = ClientGroup.getObject(%clientIndex);
|
||||
commandToClient(%cl, 'GameStart');
|
||||
|
||||
// Other client specific setup..
|
||||
%cl.score = 0;
|
||||
%cl.kills = 0;
|
||||
%cl.deaths = 0;
|
||||
}
|
||||
|
||||
// Start the game timer
|
||||
if (%this.Duration)
|
||||
%this.Schedule = schedule(%this.Duration * 1000, "onGameDurationEnd");
|
||||
|
||||
%this.Running = true;
|
||||
}
|
||||
|
||||
function DeathMatchGame::onMissionEnded(%this)
|
||||
{
|
||||
if (!%this.Running)
|
||||
{
|
||||
error("endGame: No game running!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop any game timers
|
||||
cancel(%this.Schedule);
|
||||
|
||||
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
|
||||
{
|
||||
%cl = ClientGroup.getObject(%clientIndex);
|
||||
commandToClient(%cl, 'GameEnd', %this.EndGamePause);
|
||||
}
|
||||
|
||||
%this.Running = false;
|
||||
%this.Cycling = false;
|
||||
}
|
||||
|
||||
function DeathMatchGame::onMissionReset(%this)
|
||||
{
|
||||
// Called by resetMission(), after all the temporary mission objects
|
||||
// have been deleted.
|
||||
%this.initGameVars();
|
||||
|
||||
%this.Duration = %this.duration;
|
||||
%this.EndGameScore = %this.endgameScore;
|
||||
%this.EndGamePause = %this.endgamePause;
|
||||
}
|
||||
|
||||
function DeathMatchGame::initGameVars(%this)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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
|
||||
|
|
@ -42,11 +120,11 @@ function DeathMatchGame::initGameVars()
|
|||
// 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 = "Player";
|
||||
$Game::defaultPlayerDataBlock = "DefaultPlayerData";
|
||||
$Game::defaultPlayerSpawnGroups = "PlayerSpawnPoints PlayerDropPoints";
|
||||
// Leave %this.defaultPlayerClass and %this.defaultPlayerDataBlock as empty strings ("")
|
||||
// to spawn a the %this.defaultCameraClass as the control object.
|
||||
%this.defaultPlayerClass = "Player";
|
||||
%this.defaultPlayerDataBlock = "DefaultPlayerData";
|
||||
%this.defaultPlayerSpawnGroups = "PlayerSpawnPoints PlayerDropPoints";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// What kind of "camera" is spawned is either controlled directly by the
|
||||
|
|
@ -55,28 +133,28 @@ function DeathMatchGame::initGameVars()
|
|||
// 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";
|
||||
%this.defaultCameraClass = "Camera";
|
||||
%this.defaultCameraDataBlock = "Observer";
|
||||
%this.defaultCameraSpawnGroups = "CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";
|
||||
|
||||
// Set the gameplay parameters
|
||||
$Game::Duration = 30 * 60;
|
||||
$Game::EndGameScore = 20;
|
||||
$Game::EndGamePause = 10;
|
||||
$Game::AllowCycling = false; // Is mission cycling allowed?
|
||||
%this.Duration = 30 * 60;
|
||||
%this.EndGameScore = 20;
|
||||
%this.EndGamePause = 10;
|
||||
%this.AllowCycling = false; // Is mission cycling allowed?
|
||||
}
|
||||
|
||||
function DeathMatchGame::onGameDurationEnd()
|
||||
function DeathMatchGame::onGameDurationEnd(%this)
|
||||
{
|
||||
// This "redirect" is here so that we can abort the game cycle if
|
||||
// the $Game::Duration variable has been cleared, without having
|
||||
// the %this.Duration variable has been cleared, without having
|
||||
// to have a function to cancel the schedule.
|
||||
|
||||
if ($Game::Duration && !(EditorIsActive() && GuiEditorIsActive()))
|
||||
DeathMatchGame::onGameDurationEnd();
|
||||
if (%this.Duration && !(EditorIsActive() && GuiEditorIsActive()))
|
||||
%this.onGameDurationEnd();
|
||||
}
|
||||
|
||||
function DeathMatchGame::onClientEnterGame(%client)
|
||||
function DeathMatchGame::onClientEnterGame(%this, %client)
|
||||
{
|
||||
// This function currently relies on some helper functions defined in
|
||||
// core/scripts/spawn.cs. For custom spawn behaviors one can either
|
||||
|
|
@ -86,7 +164,7 @@ function DeathMatchGame::onClientEnterGame(%client)
|
|||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onClientEntergame");
|
||||
|
||||
// Sync the client's clocks to the server's
|
||||
commandToClient(%client, 'SyncClock', $Sim::Time - $Game::StartTime);
|
||||
commandToClient(%client, 'SyncClock', $Sim::Time - %this.StartTime);
|
||||
|
||||
//Set the player name based on the client's connection data
|
||||
%client.setPlayerName(%client.connectData);
|
||||
|
|
@ -96,7 +174,7 @@ function DeathMatchGame::onClientEnterGame(%client)
|
|||
// core/scripts/server/spawn.cs. For custom spawn behaviors one can either
|
||||
// override the properties on the SpawnSphere's or directly override the
|
||||
// functions themselves.
|
||||
%cameraSpawnPoint = pickCameraSpawnPoint($Game::DefaultCameraSpawnGroups);
|
||||
%cameraSpawnPoint = pickCameraSpawnPoint(%this.DefaultCameraSpawnGroups);
|
||||
// Spawn a camera for this client using the found %spawnPoint
|
||||
%client.spawnCamera(%cameraSpawnPoint);
|
||||
|
||||
|
|
@ -110,7 +188,7 @@ function DeathMatchGame::onClientEnterGame(%client)
|
|||
%client.RefreshWeaponHud(0, "", "");
|
||||
|
||||
// Prepare the player object.
|
||||
DeathMatchGame::preparePlayer(%client);
|
||||
%this.preparePlayer(%client);
|
||||
|
||||
// Inform the client of all the other clients
|
||||
%count = ClientGroup.getCount();
|
||||
|
|
@ -162,7 +240,7 @@ function DeathMatchGame::onClientEnterGame(%client)
|
|||
%client.isSuperAdmin);
|
||||
}
|
||||
|
||||
function DeathMatchGame::onClientLeaveGame(%client)
|
||||
function DeathMatchGame::onClientLeaveGame(%this, %client)
|
||||
{
|
||||
// Cleanup the camera
|
||||
if (isObject(%client.camera))
|
||||
|
|
@ -170,80 +248,10 @@ function DeathMatchGame::onClientLeaveGame(%client)
|
|||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The server has started up so do some game start up
|
||||
//-----------------------------------------------------------------------------
|
||||
function DeathMatchGame::onMissionStart()
|
||||
function DeathMatchGame::onInitialControlSet(%this)
|
||||
{
|
||||
//set up the game and game variables
|
||||
DeathMatchGame::initGameVars();
|
||||
|
||||
$Game::Duration = 30 * 60;
|
||||
$Game::EndGameScore = 20;
|
||||
$Game::EndGamePause = 10;
|
||||
$Game::AllowCycling = false; // Is mission cycling allowed?
|
||||
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onStartGame");
|
||||
if ($Game::Running)
|
||||
{
|
||||
error("startGame: End the game first!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Inform the client we're starting up
|
||||
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
|
||||
{
|
||||
%cl = ClientGroup.getObject(%clientIndex);
|
||||
commandToClient(%cl, 'GameStart');
|
||||
|
||||
// Other client specific setup..
|
||||
%cl.score = 0;
|
||||
%cl.kills = 0;
|
||||
%cl.deaths = 0;
|
||||
}
|
||||
|
||||
// Start the game timer
|
||||
if ($Game::Duration)
|
||||
$Game::Schedule = schedule($Game::Duration * 1000, "onGameDurationEnd");
|
||||
|
||||
$Game::Running = true;
|
||||
|
||||
$Game = DeathMatchGame;
|
||||
}
|
||||
|
||||
function DeathMatchGame::onMissionEnded()
|
||||
{
|
||||
if (!$Game::Running)
|
||||
{
|
||||
error("endGame: No game running!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop any game timers
|
||||
cancel($Game::Schedule);
|
||||
|
||||
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
|
||||
{
|
||||
%cl = ClientGroup.getObject(%clientIndex);
|
||||
commandToClient(%cl, 'GameEnd', $Game::EndGamePause);
|
||||
}
|
||||
|
||||
$Game::Running = false;
|
||||
$Game::Cycling = false;
|
||||
$Game = "";
|
||||
}
|
||||
|
||||
function DeathMatchGame::onMissionReset()
|
||||
{
|
||||
// Called by resetMission(), after all the temporary mission objects
|
||||
// have been deleted.
|
||||
DeathMatchGame::initGameVars();
|
||||
|
||||
$Game::Duration = %this.duration;
|
||||
$Game::EndGameScore = %this.endgameScore;
|
||||
$Game::EndGamePause = %this.endgamePause;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions that implement game-play
|
||||
// These are here for backwards compatibilty only, games and/or mods should
|
||||
|
|
@ -252,7 +260,7 @@ function DeathMatchGame::onMissionReset()
|
|||
|
||||
// Added this stage to creating a player so game types can override it easily.
|
||||
// This is a good place to initiate team selection.
|
||||
function DeathMatchGame::preparePlayer(%client)
|
||||
function DeathMatchGame::preparePlayer(%this, %client)
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::preparePlayer");
|
||||
|
||||
|
|
@ -261,16 +269,16 @@ function DeathMatchGame::preparePlayer(%client)
|
|||
// core/scripts/spawn.cs. For custom spawn behaviors one can either
|
||||
// override the properties on the SpawnSphere's or directly override the
|
||||
// functions themselves.
|
||||
%playerSpawnPoint = pickPlayerSpawnPoint($Game::DefaultPlayerSpawnGroups);
|
||||
%playerSpawnPoint = pickPlayerSpawnPoint(%this.DefaultPlayerSpawnGroups);
|
||||
// Spawn a camera for this client using the found %spawnPoint
|
||||
//%client.spawnPlayer(%playerSpawnPoint);
|
||||
DeathMatchGame::spawnPlayer(%client, %playerSpawnPoint);
|
||||
%this.spawnPlayer(%client, %playerSpawnPoint);
|
||||
|
||||
// Starting equipment
|
||||
DeathMatchGame::loadOut(%client.player);
|
||||
%this.loadOut(%client.player);
|
||||
}
|
||||
|
||||
function DeathMatchGame::loadOut(%player)
|
||||
function DeathMatchGame::loadOut(%this, %player)
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::loadOut");
|
||||
|
||||
|
|
@ -306,30 +314,7 @@ function DeathMatchGame::loadOut(%player)
|
|||
}
|
||||
}
|
||||
|
||||
// Customized kill message for falling deaths
|
||||
function sendMsgClientKilled_Impact( %msgType, %client, %sourceClient, %damLoc )
|
||||
{
|
||||
messageAll( %msgType, '%1 fell to his death!', %client.playerName );
|
||||
}
|
||||
|
||||
// Customized kill message for suicides
|
||||
function sendMsgClientKilled_Suicide( %msgType, %client, %sourceClient, %damLoc )
|
||||
{
|
||||
messageAll( %msgType, '%1 takes his own life!', %client.playerName );
|
||||
}
|
||||
|
||||
// Default death message
|
||||
function sendMsgClientKilled_Default( %msgType, %client, %sourceClient, %damLoc )
|
||||
{
|
||||
if ( %sourceClient == %client )
|
||||
sendMsgClientKilled_Suicide(%client, %sourceClient, %damLoc);
|
||||
else if ( %sourceClient.team !$= "" && %sourceClient.team $= %client.team )
|
||||
messageAll( %msgType, '%1 killed by %2 - friendly fire!', %client.playerName, %sourceClient.playerName );
|
||||
else
|
||||
messageAll( %msgType, '%1 gets nailed by %2!', %client.playerName, %sourceClient.playerName );
|
||||
}
|
||||
|
||||
function DeathMatchGame::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc)
|
||||
function DeathMatchGame::onDeath(%this, %client, %sourceObject, %sourceClient, %damageType, %damLoc)
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onDeath");
|
||||
|
||||
|
|
@ -356,74 +341,26 @@ function DeathMatchGame::onDeath(%client, %sourceObject, %sourceClient, %damageT
|
|||
// Dole out points and check for win
|
||||
if (( %damageType $= "Suicide" || %sourceClient == %client ) && isObject(%sourceClient))
|
||||
{
|
||||
DeathMatchGame::incDeaths( %client, 1, true );
|
||||
DeathMatchGame::incScore( %client, -1, false );
|
||||
%this.incDeaths( %client, 1, true );
|
||||
%this.incScore( %client, -1, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
DeathMatchGame::incDeaths( %client, 1, false );
|
||||
DeathMatchGame::incScore( %sourceClient, 1, true );
|
||||
DeathMatchGame::incKills( %sourceClient, 1, false );
|
||||
%this.incDeaths( %client, 1, false );
|
||||
%this.incScore( %sourceClient, 1, true );
|
||||
%this.incKills( %sourceClient, 1, false );
|
||||
|
||||
// If the game may be ended by a client getting a particular score, check that now.
|
||||
if ( $Game::EndGameScore > 0 && %sourceClient.kills >= $Game::EndGameScore )
|
||||
DeathMatchGame::cycleGame();
|
||||
if ( %this.EndGameScore > 0 && %sourceClient.kills >= %this.EndGameScore )
|
||||
%this.cycleGame();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Scoring
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function DeathMatchGame::incKills(%client, %kill, %dontMessageAll)
|
||||
{
|
||||
%client.kills += %kill;
|
||||
|
||||
if( !%dontMessageAll )
|
||||
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
|
||||
}
|
||||
|
||||
function DeathMatchGame::incDeaths(%client, %death, %dontMessageAll)
|
||||
{
|
||||
%client.deaths += %death;
|
||||
|
||||
if( !%dontMessageAll )
|
||||
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
|
||||
}
|
||||
|
||||
function DeathMatchGame::incScore(%client, %score, %dontMessageAll)
|
||||
{
|
||||
%client.score += %score;
|
||||
|
||||
if( !%dontMessageAll )
|
||||
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
|
||||
}
|
||||
|
||||
function DeathMatchGame::getScore(%client) { return %client.score; }
|
||||
function DeathMatchGame::getKills(%client) { return %client.kills; }
|
||||
function DeathMatchGame::getDeaths(%client) { return %client.deaths; }
|
||||
|
||||
function DeathMatchGame::getTeamScore(%client)
|
||||
{
|
||||
%score = %client.score;
|
||||
if ( %client.team !$= "" )
|
||||
{
|
||||
// Compute team score
|
||||
for (%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||
{
|
||||
%other = ClientGroup.getObject(%i);
|
||||
if ((%other != %client) && (%other.team $= %client.team))
|
||||
%score += %other.score;
|
||||
}
|
||||
}
|
||||
return %score;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Spawning
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function DeathMatchGame::spawnPlayer(%client, %spawnPoint, %noControl)
|
||||
function DeathMatchGame::spawnPlayer(%this, %client, %spawnPoint, %noControl)
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::spawnPlayer");
|
||||
|
||||
|
|
@ -438,8 +375,8 @@ function DeathMatchGame::spawnPlayer(%client, %spawnPoint, %noControl)
|
|||
if (getWordCount(%spawnPoint) == 1 && isObject(%spawnPoint))
|
||||
{
|
||||
// Defaults
|
||||
%spawnClass = $Game::DefaultPlayerClass;
|
||||
%spawnDataBlock = $Game::DefaultPlayerDataBlock;
|
||||
%spawnClass = %this.DefaultPlayerClass;
|
||||
%spawnDataBlock = %this.DefaultPlayerDataBlock;
|
||||
|
||||
// Overrides by the %spawnPoint
|
||||
if (isDefined("%spawnPoint.spawnClass"))
|
||||
|
|
@ -466,7 +403,7 @@ function DeathMatchGame::spawnPlayer(%client, %spawnPoint, %noControl)
|
|||
if (isObject(%player))
|
||||
{
|
||||
// Pick a location within the spawn sphere.
|
||||
%spawnLocation = DeathMatchGame::pickPointInSpawnSphere(%player, %spawnPoint);
|
||||
%spawnLocation = %this.pickPointInSpawnSphere(%player, %spawnPoint);
|
||||
%player.setTransform(%spawnLocation);
|
||||
}
|
||||
else
|
||||
|
|
@ -494,7 +431,7 @@ function DeathMatchGame::spawnPlayer(%client, %spawnPoint, %noControl)
|
|||
{
|
||||
|
||||
// Create a default player
|
||||
%player = spawnObject($Game::DefaultPlayerClass, $Game::DefaultPlayerDataBlock);
|
||||
%player = spawnObject(%this.DefaultPlayerClass, %this.DefaultPlayerDataBlock);
|
||||
|
||||
if (!%player.isMemberOfClass("Player"))
|
||||
warn("Trying to spawn a class that does not derive from Player.");
|
||||
|
|
@ -589,7 +526,7 @@ function DeathMatchGame::spawnPlayer(%client, %spawnPoint, %noControl)
|
|||
%client.setControlObject(%control);
|
||||
}
|
||||
|
||||
function DeathMatchGame::pickPointInSpawnSphere(%objectToSpawn, %spawnSphere)
|
||||
function DeathMatchGame::pickPointInSpawnSphere(%this, %objectToSpawn, %spawnSphere)
|
||||
{
|
||||
%SpawnLocationFound = false;
|
||||
%attemptsToSpawn = 0;
|
||||
|
|
@ -648,18 +585,18 @@ function DeathMatchGame::pickPointInSpawnSphere(%objectToSpawn, %spawnSphere)
|
|||
// Observer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function DeathMatchGame::spawnObserver(%client)
|
||||
function DeathMatchGame::spawnObserver(%this, %client)
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::spawnObserver");
|
||||
|
||||
// Position the camera on one of our observer spawn points
|
||||
%client.camera.setTransform(DeathMatchGame::pickObserverSpawnPoint());
|
||||
%client.camera.setTransform(%this.pickObserverSpawnPoint());
|
||||
|
||||
// Set control to the camera
|
||||
%client.setControlObject(%client.camera);
|
||||
}
|
||||
|
||||
function DeathMatchGame::pickObserverSpawnPoint()
|
||||
function DeathMatchGame::pickObserverSpawnPoint(%this)
|
||||
{
|
||||
//echo (%game @"\c4 -> "@ %game.class @" -> GameCore::pickObserverSpawnPoint");
|
||||
|
||||
|
|
@ -687,29 +624,76 @@ function DeathMatchGame::pickObserverSpawnPoint()
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Server
|
||||
// Scoring
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Called by GameCore::cycleGame() when we need to destroy the server
|
||||
// because we're done playing. We don't want to call destroyServer()
|
||||
// directly so we can first check that we're about to destroy the
|
||||
// correct server session.
|
||||
function DeathMatchGame::DestroyServer(%serverSession)
|
||||
function DeathMatchGame::incKills(%this, %client, %kill, %dontMessageAll)
|
||||
{
|
||||
if (%serverSession == $Server::Session)
|
||||
%client.kills += %kill;
|
||||
|
||||
if( !%dontMessageAll )
|
||||
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
|
||||
}
|
||||
|
||||
function DeathMatchGame::incDeaths(%this, %client, %death, %dontMessageAll)
|
||||
{
|
||||
%client.deaths += %death;
|
||||
|
||||
if( !%dontMessageAll )
|
||||
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
|
||||
}
|
||||
|
||||
function DeathMatchGame::incScore(%this, %client, %score, %dontMessageAll)
|
||||
{
|
||||
%client.score += %score;
|
||||
|
||||
if( !%dontMessageAll )
|
||||
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
|
||||
}
|
||||
|
||||
function DeathMatchGame::getScore(%this, %client) { return %client.score; }
|
||||
function DeathMatchGame::getKills(%this, %client) { return %client.kills; }
|
||||
function DeathMatchGame::getDeaths(%this, %client) { return %client.deaths; }
|
||||
|
||||
function DeathMatchGame::getTeamScore(%this, %client)
|
||||
{
|
||||
%score = %client.score;
|
||||
if ( %client.team !$= "" )
|
||||
{
|
||||
if (isObject(LocalClientConnection))
|
||||
// Compute team score
|
||||
for (%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||
{
|
||||
// We're a local connection so issue a disconnect. The server will
|
||||
// be automatically destroyed for us.
|
||||
disconnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
// We're a stand alone server
|
||||
destroyServer();
|
||||
%other = ClientGroup.getObject(%i);
|
||||
if ((%other != %client) && (%other.team $= %client.team))
|
||||
%score += %other.score;
|
||||
}
|
||||
}
|
||||
return %score;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Messages
|
||||
// -----------------------------------------------------------------------------
|
||||
// Customized kill message for falling deaths
|
||||
function sendMsgClientKilled_Impact( %msgType, %client, %sourceClient, %damLoc )
|
||||
{
|
||||
messageAll( %msgType, '%1 fell to his death!', %client.playerName );
|
||||
}
|
||||
|
||||
// Customized kill message for suicides
|
||||
function sendMsgClientKilled_Suicide( %msgType, %client, %sourceClient, %damLoc )
|
||||
{
|
||||
messageAll( %msgType, '%1 takes his own life!', %client.playerName );
|
||||
}
|
||||
|
||||
// Default death message
|
||||
function sendMsgClientKilled_Default( %msgType, %client, %sourceClient, %damLoc )
|
||||
{
|
||||
if ( %sourceClient == %client )
|
||||
sendMsgClientKilled_Suicide(%client, %sourceClient, %damLoc);
|
||||
else if ( %sourceClient.team !$= "" && %sourceClient.team $= %client.team )
|
||||
messageAll( %msgType, '%1 killed by %2 - friendly fire!', %client.playerName, %sourceClient.playerName );
|
||||
else
|
||||
messageAll( %msgType, '%1 gets nailed by %2!', %client.playerName, %sourceClient.playerName );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function ItemData::onThrow(%this, %user, %amount)
|
|||
rotation = "0 0 1 "@ (getRandom() * 360);
|
||||
count = %amount;
|
||||
};
|
||||
MissionGroup.add(%obj);
|
||||
getRootScene().addDynamicObject(%obj);
|
||||
%obj.schedulePop();
|
||||
return %obj;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %dam
|
|||
|
||||
if (%obj.getState() $= "Dead")
|
||||
{
|
||||
$Game.onDeath(%client, %sourceObject, %sourceClient, %damageType, %location);
|
||||
callGamemodeFunction("onDeath", %client, %sourceObject, %sourceClient, %damageType, %location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue