diff --git a/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs b/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs index b04a2c795..5d9f245aa 100644 --- a/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs +++ b/Templates/BaseGame/game/core/gameObjects/datablocks/defaultDatablocks.cs @@ -141,3 +141,8 @@ datablock MissionMarkerData(CameraBookmarkMarker) category = "Misc"; shapeFile = "core/gameObjects/shapes/camera.dts"; }; + +datablock CameraData(Observer) +{ + mode = "Observer"; +}; diff --git a/Templates/BaseGame/game/core/utility/scripts/scene.cs b/Templates/BaseGame/game/core/utility/scripts/scene.cs index 67fc35ad0..795d541f3 100644 --- a/Templates/BaseGame/game/core/utility/scripts/scene.cs +++ b/Templates/BaseGame/game/core/utility/scripts/scene.cs @@ -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; } } diff --git a/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs b/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs index fc046e020..d24a5b715 100644 --- a/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs +++ b/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs @@ -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) { } \ No newline at end of file diff --git a/Templates/Modules/FPSGameplay/FPSGameplay.cs b/Templates/Modules/FPSGameplay/FPSGameplay.cs index 51e40f887..1ce7cecc7 100644 --- a/Templates/Modules/FPSGameplay/FPSGameplay.cs +++ b/Templates/Modules/FPSGameplay/FPSGameplay.cs @@ -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) { } \ No newline at end of file diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/aiPlayer.cs b/Templates/Modules/FPSGameplay/datablocks/aiPlayer.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/aiPlayer.cs rename to Templates/Modules/FPSGameplay/datablocks/aiPlayer.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/audioData.cs b/Templates/Modules/FPSGameplay/datablocks/audioData.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/audioData.cs rename to Templates/Modules/FPSGameplay/datablocks/audioData.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/audioProfiles.cs b/Templates/Modules/FPSGameplay/datablocks/audioProfiles.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/audioProfiles.cs rename to Templates/Modules/FPSGameplay/datablocks/audioProfiles.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/brushes.cs b/Templates/Modules/FPSGameplay/datablocks/brushes.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/brushes.cs rename to Templates/Modules/FPSGameplay/datablocks/brushes.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/defaultParticle.cs b/Templates/Modules/FPSGameplay/datablocks/defaultParticle.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/defaultParticle.cs rename to Templates/Modules/FPSGameplay/datablocks/defaultParticle.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/environment.cs b/Templates/Modules/FPSGameplay/datablocks/environment.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/environment.cs rename to Templates/Modules/FPSGameplay/datablocks/environment.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/health.cs b/Templates/Modules/FPSGameplay/datablocks/health.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/health.cs rename to Templates/Modules/FPSGameplay/datablocks/health.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/lights.cs b/Templates/Modules/FPSGameplay/datablocks/lights.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/lights.cs rename to Templates/Modules/FPSGameplay/datablocks/lights.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/managedDatablocks.cs b/Templates/Modules/FPSGameplay/datablocks/managedDatablocks.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/managedDatablocks.cs rename to Templates/Modules/FPSGameplay/datablocks/managedDatablocks.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/managedDecalData.cs b/Templates/Modules/FPSGameplay/datablocks/managedDecalData.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/managedDecalData.cs rename to Templates/Modules/FPSGameplay/datablocks/managedDecalData.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/managedForestItemData.cs b/Templates/Modules/FPSGameplay/datablocks/managedForestItemData.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/managedForestItemData.cs rename to Templates/Modules/FPSGameplay/datablocks/managedForestItemData.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/managedItemData.cs b/Templates/Modules/FPSGameplay/datablocks/managedItemData.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/managedItemData.cs rename to Templates/Modules/FPSGameplay/datablocks/managedItemData.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/managedParticleData.cs b/Templates/Modules/FPSGameplay/datablocks/managedParticleData.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/managedParticleData.cs rename to Templates/Modules/FPSGameplay/datablocks/managedParticleData.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/managedParticleEmitterData.cs b/Templates/Modules/FPSGameplay/datablocks/managedParticleEmitterData.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/managedParticleEmitterData.cs rename to Templates/Modules/FPSGameplay/datablocks/managedParticleEmitterData.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/markers.cs b/Templates/Modules/FPSGameplay/datablocks/markers.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/markers.cs rename to Templates/Modules/FPSGameplay/datablocks/markers.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/particles.cs b/Templates/Modules/FPSGameplay/datablocks/particles.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/particles.cs rename to Templates/Modules/FPSGameplay/datablocks/particles.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/physics.cs b/Templates/Modules/FPSGameplay/datablocks/physics.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/physics.cs rename to Templates/Modules/FPSGameplay/datablocks/physics.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/player.cs b/Templates/Modules/FPSGameplay/datablocks/player.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/player.cs rename to Templates/Modules/FPSGameplay/datablocks/player.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/ribbons.cs b/Templates/Modules/FPSGameplay/datablocks/ribbons.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/ribbons.cs rename to Templates/Modules/FPSGameplay/datablocks/ribbons.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/rigidShape.cs b/Templates/Modules/FPSGameplay/datablocks/rigidShape.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/rigidShape.cs rename to Templates/Modules/FPSGameplay/datablocks/rigidShape.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/sounds.cs b/Templates/Modules/FPSGameplay/datablocks/sounds.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/sounds.cs rename to Templates/Modules/FPSGameplay/datablocks/sounds.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/teleporter.cs b/Templates/Modules/FPSGameplay/datablocks/teleporter.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/teleporter.cs rename to Templates/Modules/FPSGameplay/datablocks/teleporter.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/triggers.cs b/Templates/Modules/FPSGameplay/datablocks/triggers.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/triggers.cs rename to Templates/Modules/FPSGameplay/datablocks/triggers.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/vehicles/cheetahCar.cs b/Templates/Modules/FPSGameplay/datablocks/vehicles/cheetahCar.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/vehicles/cheetahCar.cs rename to Templates/Modules/FPSGameplay/datablocks/vehicles/cheetahCar.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapon.cs b/Templates/Modules/FPSGameplay/datablocks/weapon.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapon.cs rename to Templates/Modules/FPSGameplay/datablocks/weapon.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/Lurker.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/Lurker.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/Lurker.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/Lurker.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/NewWeaponTemplate.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/NewWeaponTemplate.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/NewWeaponTemplate.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/NewWeaponTemplate.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/ProxMine.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/ProxMine.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/ProxMine.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/ProxMine.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/Ryder.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/Ryder.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/Ryder.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/Ryder.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/Turret.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/Turret.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/Turret.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/Turret.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/grenadefx.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/grenadefx.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/grenadefx.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/grenadefx.cs diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/weapons/rocketfx.cs b/Templates/Modules/FPSGameplay/datablocks/weapons/rocketfx.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/datablocks/weapons/rocketfx.cs rename to Templates/Modules/FPSGameplay/datablocks/weapons/rocketfx.cs diff --git a/Templates/Modules/FPSGameplay/scripts/gui/chatHud.gui b/Templates/Modules/FPSGameplay/guis/chatHud.gui similarity index 97% rename from Templates/Modules/FPSGameplay/scripts/gui/chatHud.gui rename to Templates/Modules/FPSGameplay/guis/chatHud.gui index e1d1b2af8..8890fc5fc 100644 --- a/Templates/Modules/FPSGameplay/scripts/gui/chatHud.gui +++ b/Templates/Modules/FPSGameplay/guis/chatHud.gui @@ -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"; }; diff --git a/Templates/Modules/FPSGameplay/scripts/gui/hudlessGui.gui b/Templates/Modules/FPSGameplay/guis/hudlessGui.gui similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/gui/hudlessGui.gui rename to Templates/Modules/FPSGameplay/guis/hudlessGui.gui diff --git a/Templates/Modules/FPSGameplay/scripts/gui/playGui.gui b/Templates/Modules/FPSGameplay/guis/playGui.gui similarity index 98% rename from Templates/Modules/FPSGameplay/scripts/gui/playGui.gui rename to Templates/Modules/FPSGameplay/guis/playGui.gui index 8574199d4..20f1c5269 100644 --- a/Templates/Modules/FPSGameplay/scripts/gui/playGui.gui +++ b/Templates/Modules/FPSGameplay/guis/playGui.gui @@ -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"; diff --git a/Templates/Modules/FPSGameplay/scripts/gui/playerList.gui b/Templates/Modules/FPSGameplay/guis/playerList.gui similarity index 98% rename from Templates/Modules/FPSGameplay/scripts/gui/playerList.gui rename to Templates/Modules/FPSGameplay/guis/playerList.gui index 3741aa0f5..7f3c356d8 100644 --- a/Templates/Modules/FPSGameplay/scripts/gui/playerList.gui +++ b/Templates/Modules/FPSGameplay/guis/playerList.gui @@ -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() { diff --git a/Templates/Modules/FPSGameplay/levels/Empty Terrain.mis b/Templates/Modules/FPSGameplay/levels/Empty Terrain.mis index 72a136c3c..4961a2fe0 100644 --- a/Templates/Modules/FPSGameplay/levels/Empty Terrain.mis +++ b/Templates/Modules/FPSGameplay/levels/Empty Terrain.mis @@ -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 --- diff --git a/Templates/Modules/FPSGameplay/levels/Outpost.mis b/Templates/Modules/FPSGameplay/levels/Outpost.mis index c9d28b2c9..88401a742 100644 --- a/Templates/Modules/FPSGameplay/levels/Outpost.mis +++ b/Templates/Modules/FPSGameplay/levels/Outpost.mis @@ -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"; diff --git a/Templates/Modules/FPSGameplay/scripts/datablocks/camera.cs b/Templates/Modules/FPSGameplay/scripts/datablocks/camera.cs deleted file mode 100644 index c7a87d0b2..000000000 --- a/Templates/Modules/FPSGameplay/scripts/datablocks/camera.cs +++ /dev/null @@ -1,4 +0,0 @@ -datablock CameraData(Observer) -{ - mode = "Observer"; -}; \ No newline at end of file diff --git a/Templates/Modules/FPSGameplay/scripts/server/camera.cs b/Templates/Modules/FPSGameplay/scripts/server/camera.cs index 42655d403..4b19a8c4a 100644 --- a/Templates/Modules/FPSGameplay/scripts/server/camera.cs +++ b/Templates/Modules/FPSGameplay/scripts/server/camera.cs @@ -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. diff --git a/Templates/Modules/FPSGameplay/scripts/server/deathMatchGame.cs b/Templates/Modules/FPSGameplay/scripts/server/deathMatchGame.cs index 345e7f3fd..db1a23563 100644 --- a/Templates/Modules/FPSGameplay/scripts/server/deathMatchGame.cs +++ b/Templates/Modules/FPSGameplay/scripts/server/deathMatchGame.cs @@ -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 ); } // ---------------------------------------------------------------------------- diff --git a/Templates/Modules/FPSGameplay/scripts/server/item.cs b/Templates/Modules/FPSGameplay/scripts/server/item.cs index f4f355386..adcf5841f 100644 --- a/Templates/Modules/FPSGameplay/scripts/server/item.cs +++ b/Templates/Modules/FPSGameplay/scripts/server/item.cs @@ -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; } diff --git a/Templates/Modules/FPSGameplay/scripts/server/player.cs b/Templates/Modules/FPSGameplay/scripts/server/player.cs index d3396b139..c2b25ad1e 100644 --- a/Templates/Modules/FPSGameplay/scripts/server/player.cs +++ b/Templates/Modules/FPSGameplay/scripts/server/player.cs @@ -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); } } }