//----------------------------------------------------------------------------- // Torque Game Engine // Copyright (C) GarageGames.com, Inc. //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Functions that implement game-play //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- package FpsGame { //----------------------------------------------------------------------------- function GameConnection::onClientEnterGame(%this) { commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime); commandToClient(%this, 'SetGameGUI',"FpsGUI"); // Create a new camera object. %this.camera = new Camera() { dataBlock = Observer; }; MissionCleanup.add( %this.camera ); %this.camera.scopeToClient(%this); // Spawn the player %this.score = 0; %this.spawnPlayer(); } //----------------------------------------------------------------------------- function GameConnection::createPlayer(%this, %spawnPoint) { if (%this.player > 0) { // The client should not have a player currently // assigned. Assigning a new one could result in // a player ghost. error( "Attempting to create an angus ghost!" ); } // Create the player object %player = new Player() { dataBlock = PlayerBody; client = %this; }; MissionCleanup.add(%player); // Player setup... %player.setTransform(%spawnPoint); %player.setEnergyLevel(60); %player.setShapeName(%this.name); // Starting equipment %player.mountImage(CrossbowImage,0); %player.setInventory(CrossbowAmmo,10); // Update the camera to start with the player %this.camera.setTransform(%player.getEyeTransform()); // Give the client control of the player %this.player = %player; %this.setControlObject(%player); } //----------------------------------------------------------------------------- function serverCmdSuicide(%client) { if (isObject(%client.player)) { %client.player.delete(); %client.player = 0; } %client.spawnPlayer(); } };