Game Development Community

Teams & Classes for T3D

by mb · 09/27/2009 (7:59 pm) · 15 comments

Description: Updated Teams Implementation & Multiple Player Class Selection Resource for T3D

Note: This is both resources combined into one for T3D. I originally based my code for player classes off of Xavier's Team Implementation resource.

Note 2: I used the "New Project" button in Torque Toolbox to start the project.

Note 3: The weapons are not set up. Set them up here -> function GameConnection::createPlayer(%this, %spawnPoint)


TI = Teams Implementation, and MPCS = Multiple Player Class Selection

Original Resources:

Teams Implementation by: Xavier "eXoDuS" Amado: www.garagegames.com/community/resources/view/2312
Multiple Player Class Selection by MB: www.garagegames.com/community/resources/view/11733


art/datablocks/players/player.cs(613):

// MB MPCS
datablock PlayerData(Player1Class1 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/Spacesuit/Spacesuit.dts";
};

datablock PlayerData(Player1Class2 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/Spacesuit/Spacesuit.dts";
};
datablock PlayerData(Player1Class3 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/Spacesuit/Spacesuit.dts";
};
datablock PlayerData(Player1Class4 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/Spacesuit/Spacesuit.dts";
};
datablock PlayerData(Player1Class5 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/Spacesuit/Spacesuit.dts";
};

datablock PlayerData(Player2Class1 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/ForgeSoldier/ForgeSoldier.dts";
};
datablock PlayerData(Player2Class2 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/ForgeSoldier/ForgeSoldier.dts";
};
datablock PlayerData(Player2Class3 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/ForgeSoldier/ForgeSoldier.dts";
};
datablock PlayerData(Player2Class4 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/ForgeSoldier/ForgeSoldier.dts";
};
datablock PlayerData(Player2Class5 : DefaultPlayerData)
{
    shapeFile = "art/shapes/players/ForgeSoldier/ForgeSoldier.dts";
};
/// MB MPCS

scripts/client/config.cs(58):

// MB TI & MPCS - modified by MPCS
moveMap.bindCmd(keyboard, "m", "Canvas.pushDialog(TeamSelectDlg2);", "");
/// MB TI & MPCS

scripts/client/default.bind.cs(592):

// MB TI & MPCS - modified TI code - MPCS 
moveMap.bindCmd(keyboard, "m", "Canvas.pushDialog(TeamSelectDlg2);", "");
/// MB TI & MPCS

scripts/client/init.cs(131): Add to the function like so:

// Load Example objectView
   exec("art/gui/objectViewExample.gui");
   exec("./objectViewExample.cs");
   
   // MB TI
   exec("art/gui/TeamSelectDlg.gui");
   /// MB TI
   
   // MB MPCS
   exec("art/gui/ClassSelectDlg.gui");
   exec("art/gui/TeamSelectDlg2.gui");
   /// MB MPCS
   
   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);

scripts/client/serverConnection.cs(42):

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 (!Editor::checkActiveLoadDone())
   {
      if (Canvas.getContent() != PlayGui.getId())
         Canvas.setContent(PlayGui);
         
         // MB MPCS
         // Teamplay - popup team select gui   
         Canvas.pushDialog(TeamSelectDlg);
         /// MB MPCS
   }
}

scripts/servercommands.cs(222):

// MB TI & MPCS

// These are all named the same so it's a little confusing.  
//
// jointeam: called by the GUI button
// serverCmdJoinTeam: called by the jointeam function
// joinTeam: called by the serverCmdJoinTeam function



// This gets called by the GUI button
function jointeam(%this, %teamid)
{
	commandtoserver('JoinTeam', %this, %teamid);
	Canvas.popDialog(TeamSelectDlg); 	//Hide team select menu
   Canvas.pushDialog(ClassSelectDlg); 	// Show class select menu    
}


// Teamplay - called by the function jointeam
function serverCmdJoinTeam(%client, %teamid)
{  
   %client.joinTeam(%teamid);
}

// Called by the GUI button
function joinclass(%classid)
{
   commandtoserver('JoinPlayerClass', %classid);
   Canvas.popDialog(ClassSelectDlg); //Hide the dialog once selection was made
}

// Teamplay - pick a class
// Called by the function joinclass
function serverCmdJoinPlayerClass(%client, %classid)
{  
    %client.joinPlayerClass(%classid); // game.cs  GameConnection::joinPlayerClass
}


function suicideJoinTeam(%this, %teamid)
{
	commandtoserver('Suicide');
	commandtoserver('JoinTeam', %this, %teamid);
	Canvas.popDialog(TeamSelectDlg2); 	//Hide team select menu
   Canvas.pushDialog(ClassSelectDlg); 	// Show class select menu	
}
/// MB TI & MPCS


scripts/servergame.cs(6):

// MB TI
$Team1 = new ScriptObject()   
{   
   teamId = 1;   
   teamname = Red;   
   score = 0;   
   numPlayers = 0;   
};   
  
$Team2 = new ScriptObject()   
{   
   teamId = 2;   
   teamname = Blue;   
   score = 0;   
   numPlayers = 0;   
};  
/// MB TI

// MB MPCS
$PlayerClass1 = new ScriptObject()
{   
    playerClassId = 1;
    myclassname = Engineer;
};

$PlayerClass2 = new ScriptObject()
{   
    playerClassId = 2;
    myclassname = Assault;
};

$PlayerClass3 = new ScriptObject()
{   
    playerClassId = 3;
    myclassname = Medic;
};

$PlayerClass4 = new ScriptObject()
{   
    playerClassId = 4;
    myclassname = Demolition;
};

$PlayerClass5 = new ScriptObject()
{   
    playerClassId = 5;
    myclassname = Noob;
};
/// MB MPCS

scripts/servergame.cs(96):

// MB TI
function GameConnection::onClientEnterGame(%this)   
{   
   commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);   
  
   // Create a new camera object.   
   %this.camera = new Camera() {   
      dataBlock = Observer;   
   };   
   MissionCleanup.add( %this.camera );   
   %this.camera.scopeToClient(%this);   
  
   // Setup game parameters, the onConnect method currently starts   
   // everyone with a 0 score.   
   %this.score = 0;
   %this.team = 0;  //default team is 0 (observer) // MB TI
   
   // MB MPCS
   %this.respawn = 0; // tracks whether a player is spawning or not
   %this.playerClass = 0; // default class is 0
   /// MB MPCS     
  
   //Spawn a camera by default on a observer point   
   %this.camera.setTransform(pickObserverPoint(%this));   
   %this.camera.setVelocity("0 0 0");   
   %this.setControlObject(%this.camera);   
} 
/// MB TI

// MB : I don't think the function GameConnection::preparePlayer below will be called since I replaced the function above GameConnection::onClientEnterGame with the Teams Implementation function


scripts/servergame.cs(395):

//----------------------------------------------------------------------------------------------------------------------
// MB - Teams Implementation Resource by Xavier "eXoDuS" Amado - I will refer to it as TI from now on  (search MB TI 
// I end the functions with /// MB TI  
//
// http://www.garagegames.com/community/resources/view/2312
//----------------------------------------------------------------------------------------------------------------------

function GameConnection::joinTeam(%this, %teamid)   
{   
   echo("--------------------------------------------------------------------------");
   echo("%this= " @ %this);
   echo("teamId= " @ %teamid);
   echo("--------------------------------------------------------------------------");
   
   //We only have 2 teams so if team is greater than 2 or less than 0 its invalid.   
   if (%teamid > 2 || %teamid < 0)    
      return false;   
   //If we already are on that team return.    
   if (%teamid == %this.team.teamId)   
      return false;   
  
   %this.leaveTeam();   
  
   if (%teamid == 1)   
      %this.team = $Team1;    
   if (%teamid == 2)   
      %this.team = $Team2;   
  
   MessageAll('MsgClientJoinTeam', 'c2%1 joined the %2 side',   
      %this.name,   
      %this.team.teamname,   
      %this.team.teamId,   
      %this,   
      %this.sendGuid,   
      %this.score,   
      %this.isAiControlled(),   
      %this.isAdmin,   
      %this.isSuperAdmin);   
  
   //%this.spawnPlayer();  // MB MPCS - comment this out
}
/// MB TI

// MB TI
function GameConnection::leaveTeam(%client, %teamnumber)   
{   
   %this.score = 0;   
      
   messageAll('MsgClientLeaveTeam', 'c2%1 left the %2 team.',   
      %client.name,   
      %client.team.name,   
      %client);   
      
   if (%client.player)   
      %client.player.delete();   
}
/// MB TI - modified in MPCS  //MB MPCS

function GameConnection::spawnPlayer(%this)
{
	
   if (%this.respawn == 1)	// If player is spawning then dont spawn again!
     return;
   	
    %this.respawn = 1;
	
   // Combination create player and drop him somewhere
   %spawnPoint = pickSpawnPoint(%this);
   
   %this.schedule(10000,createPlayer,%spawnPoint); // delay spawn	
}
/// MB TI
///MB MPCS this was a modified function of Teams Implementation

// MB TI
function pickSpawnPoint(%client)
{
   echo("CLIENT= " @ %client);
   echo("CLIENT.team= " @ %client.team);
   echo("CLIENT.team.teamname= " @ %client.team.teamname);
   echo(%client.dump());
   
   
   %groupName = "MissionGroup/" @ %client.team.teamname @ "TeamDropPoints";
   %group = nameToID(%groupName);

   if (%group != -1) {
      %count = %group.getCount();
      if (%count != 0) {
         %index = getRandom(%count-1);
         %spawn = %group.getObject(%index);
         return %spawn.getTransform();
      }
      else
         error("No " @ %client.team.teamname @ " team spawn points found in " @ %groupName);
   }
   else
      error("Missing " @ %client.team.teamname @ " team spawn points group " @ %groupName);

   // Could be no spawn points, in which case we'll stick the
   // player at the center of the world.
   return "0 0 300 1 0 0 0";
}
/// MB TI

// MB TI
function pickObserverPoint(%client)
{
   %groupName = "MissionGroup/ObserverDropPoints";
   %group = nameToID(%groupName);
   
   if (%group != -1) {
      %count = %group.getCount();
      if (%count != 0) {
         %index = getRandom(%count-1);
         %spawn = %group.getObject(%index);
         return %spawn.getTransform();
      }
      else
         error("No observer spawn points found in " @ %groupName);
   }
   else
      error("Missing observer spawn points group " @ %groupName);

   // Could be no spawn points, in which case we'll stick the
   // player at the center of the world.
   return "0 0 300 1 0 0 0";
}
/// MB TI


// MB MPCS - Multiple Player Class Selection by ME! - Will be referred to as MPCS
function GameConnection::joinPlayerClass(%this, %classid)
{
   //We only have 5 player classes so if class is greater than 5 or less than 0 its invalid.
   if (%classid > 5 || %classid < 0)
       return false;  

   if (%this.respawn == 1)	// If player is spawning then dont spawn again!
     return false;
   
   if (%classid == 1)
       %this.playerClass = $PlayerClass1;

   if (%classid == 2) 
       %this.playerClass = $PlayerClass2; 
   
   if (%classid == 3) 
       %this.playerClass = $PlayerClass3;
   
   if (%classid == 4) 
       %this.playerClass = $PlayerClass4;
   
   if (%classid == 5) 
       %this.playerClass = $PlayerClass5;

  // MessageAll('MsgClientJoinTeam', 'c2%1 joined the %2 side', %this.name, %this.team.name, %this.team.teamId, %this, 

//%this.sendGuid, %this.score,  %this.isAiControlled(), %this.isAdmin, %this.isSuperAdmin);
   
   %this.spawnPlayer(%this);        
}
/// MB MPCS

// MB MPCS
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!" );
   }

   // get the correct datablock for the player. This is the players class.
   
    // TEAM 1 DATABLOCKS
    if (%this.team.teamId == 1)
    {
        switch ( %this.playerClass.playerClassId )
        {
            // Class 1
            case 1:
                %classDatablock = Player1Class1;  // change to another datablock when we make new models for each class           
				

            // Class 2
            case 2:
                %classDatablock = Player1Class2;
                

            // Class 3
            case 3:
                %classDatablock = Player1Class3;
                

            // Class 4
            case 4:
                %classDatablock = Player1Class4;
                

            // Class 5
            case 5:
                %classDatablock = Player1Class5;
                
        }
    }
   
    // TEAM 2 DATABLOCKS
   if (%this.team.teamId == 2)
   {
      switch ( %this.playerClass.playerClassId )
      {
         // Class 1
         case 1:
            %classDatablock = Player2Class1;  // change to another datablock when we make new models for each class
            

         // Class 2
         case 2:
            %classDatablock = Player2Class2;
            

         // Class 3
         case 3:
            %classDatablock = Player2Class3;
            

         // Class 4
         case 4:
            %classDatablock = Player2Class4;
            

         // Class 5
         case 5:
            %classDatablock = Player2Class5;
            
        }
   }
   // Create the player object
   %player = new Player() {
      dataBlock = %classDatablock;
      client = %this;
   };
	
	
   MissionCleanup.add(%player);

   // Player setup...
   %player.setTransform(%spawnPoint);
   %player.setShapeName(%this.name);
   
   // Starting equipment
   
    // TEAM 1 WEAPONS
    if (%this.team.teamId == 1)
    {
        switch ( %this.playerClass.playerClassId )
        {
            // Class 1
            case 1:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0);       


            // Class 2
            case 2:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0);  

            // Class 3
            case 3:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0);  
                

            // Class 4
            case 4:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0);  
                

            // Class 5
            case 5:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0);  
                
        }
    }
   
    // TEAM 2 WEAPONS
   if (%this.team.teamId == 2)
    {
        switch ( %this.playerClass.playerClassId )
        {
            // Class 1
            case 1:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0); 
                

            // Class 2
            case 2:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0); 
                

            // Class 3
            case 3:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0); 
                

            // Class 4
            case 4:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0); 
                

            // Class 5
            case 5:
                  %player.setInventory(RocketLauncher, 1);
                  %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
                  %player.mountImage(RocketLauncherImage, 0); 
        }
    }
  

   // 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); 
   %this.respawn = 0; // allow player to respawn after dying.	

   echo ("CLASS NAME: " @ %this.playerClass.myclassname );

}
/// MB MPCS

Create this file and paste the code below into it:

art/gui/TeamSelectDlg.gui:


//--- OBJECT WRITE BEGIN ---
new GameTSCtrl(TeamSelectDlg) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 8";
   visible = "1";
   helpTag = "0";

   new GuiWindowCtrl() {
      profile = "GuiWindowProfile";
      horizSizing = "center";
      vertSizing = "center";
      position = "159 155";
      extent = "321 170";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      maxLength = "255";
      resizeWidth = "1";
      resizeHeight = "1";
      canMove = "1";
      canClose = "1";
      canMinimize = "1";
      canMaximize = "1";
      minSize = "50 50";
      closeCommand = "Canvas.popDialog(TeamSelectDlg);";

      new GuiTextCtrl() {
         profile = "GuiBigTextProfile";
         horizSizing = "center";
         vertSizing = "relative";
         position = "32 30";
         extent = "257 40";
         minExtent = "8 8";
         visible = "1";
         helpTag = "0";
         text = "Choose your team";
         maxLength = "255";
      };
      new GuiButtonCtrl(RedTeam) {
         profile = "GuiButtonProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "10 130";
         extent = "140 30";
         minExtent = "8 8";
         visible = "1";
         command = "jointeam(1);";
         helpTag = "0";
         text = "Red Team";
         groupNum = "-1";
         buttonType = "PushButton";
      };
      new GuiButtonCtrl(BlueTeam) {
         profile = "GuiButtonProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "170 130";
         extent = "140 30";
         minExtent = "8 8";
         visible = "1";
         command = "jointeam(2);";
         helpTag = "0";
         text = "Blue Team";
         groupNum = "-1";
         buttonType = "PushButton";
      };
   };
};
//--- OBJECT WRITE END ---


Create this file and paste the code below into it:

art/gui/TeamSelectDlg2.gui:


//--- OBJECT WRITE BEGIN ---
%guiContent = new GameTSCtrl(TeamSelectDlg2) {
   cameraZRot = "0";
   forceFOV = "0";
   reflectPriority = "1";
   Margin = "0 0 0 0";
   Padding = "0 0 0 0";
   AnchorTop = "1";
   AnchorBottom = "0";
   AnchorLeft = "1";
   AnchorRight = "0";
   isContainer = "1";
   Profile = "GuiDefaultProfile";
   HorizSizing = "right";
   VertSizing = "bottom";
   position = "0 0";
   Extent = "1024 768";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   tooltipprofile = "GuiToolTipProfile";
   hovertime = "1000";
   canSaveDynamicFields = "1";
      helpTag = "0";

   new GuiWindowCtrl() {
      resizeWidth = "1";
      resizeHeight = "1";
      canMove = "1";
      canClose = "1";
      canMinimize = "1";
      canMaximize = "1";
      minSize = "50 50";
      closeCommand = "Canvas.popDialog(TeamSelectDlg2);";
      EdgeSnap = "1";
      text = "New Window";
      Margin = "0 0 0 0";
      Padding = "0 0 0 0";
      AnchorTop = "1";
      AnchorBottom = "0";
      AnchorLeft = "1";
      AnchorRight = "0";
      isContainer = "1";
      Profile = "GuiWindowProfile";
      HorizSizing = "center";
      VertSizing = "center";
      position = "351 299";
      Extent = "321 170";
      MinExtent = "8 8";
      canSave = "1";
      Visible = "1";
      tooltipprofile = "GuiToolTipProfile";
      hovertime = "1000";
      canSaveDynamicFields = "0";

      new GuiTextCtrl() {
         text = "Choose your team";
         maxLength = "255";
         Margin = "0 0 0 0";
         Padding = "0 0 0 0";
         AnchorTop = "1";
         AnchorBottom = "0";
         AnchorLeft = "1";
         AnchorRight = "0";
         isContainer = "0";
         Profile = "GuiBigTextProfile";
         HorizSizing = "center";
         VertSizing = "relative";
         position = "31 30";
         Extent = "257 40";
         MinExtent = "8 8";
         canSave = "1";
         Visible = "1";
         tooltipprofile = "GuiToolTipProfile";
         hovertime = "1000";
         canSaveDynamicFields = "0";
      };
      new GuiButtonCtrl() {
         text = "Join Blue";
         groupNum = "-1";
         buttonType = "PushButton";
         useMouseEvents = "0";
         isContainer = "0";
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "165 122";
         Extent = "140 30";
         MinExtent = "8 2";
         canSave = "1";
         Visible = "1";
         Command = "suicideJoinTeam(2);";
         tooltipprofile = "GuiToolTipProfile";
         hovertime = "1000";
         canSaveDynamicFields = "0";
      };
      new GuiButtonCtrl() {
         text = "Join Red";
         groupNum = "-1";
         buttonType = "PushButton";
         useMouseEvents = "0";
         isContainer = "0";
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "14 122";
         Extent = "140 30";
         MinExtent = "8 2";
         canSave = "1";
         Visible = "1";
         Command = "suicideJoinTeam(1);";
         tooltipprofile = "GuiToolTipProfile";
         hovertime = "1000";
         canSaveDynamicFields = "1";
      };
   };
};
//--- OBJECT WRITE END ---

Create this file and paste the code below into it:

art/gui/ClassSelectDlg.gui


//--- OBJECT WRITE BEGIN ---
new GameTSCtrl(ClassSelectDlg) {
   Profile = "GuiDefaultProfile";
   HorizSizing = "right";
   VertSizing = "bottom";
   position = "0 0";
   Extent = "640 480";
   MinExtent = "8 8";
   Visible = "1";
   applyFilterToChildren = "1";
   cameraZRot = "0";
   forceFOV = "0";
      helpTag = "0";

   new GuiWindowCtrl() {
      Profile = "GuiWindowProfile";
      HorizSizing = "center";
      VertSizing = "center";
      position = "159 155";
      Extent = "321 170";
      MinExtent = "8 8";
      Visible = "1";
      maxLength = "255";
      resizeWidth = "1";
      resizeHeight = "1";
      canMove = "1";
      canClose = "1";
      canMinimize = "1";
      canMaximize = "1";
      MinSize = "50 50";
      closeCommand = "Canvas.popDialog(ClassSelectDlg);";
         helpTag = "0";

      new GuiTextCtrl() {
         Profile = "GuiBigTextProfile";
         HorizSizing = "center";
         VertSizing = "relative";
         position = "31 22";
         Extent = "259 40";
         MinExtent = "8 8";
         Visible = "1";
         text = "Choose your class";
         maxLength = "255";
            helpTag = "0";
      };
      new GuiButtonCtrl(Class1) {
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "11 63";
         Extent = "140 30";
         MinExtent = "8 8";
         Visible = "1";
         Command = "joinclass(1);";
         tooltipprofile = "GuiDefaultProfile";
         text = "Class 1";
         groupNum = "-1";
         buttonType = "PushButton";
            helpTag = "0";
      };
      new GuiButtonCtrl(Class2) {
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "11 97";
         Extent = "140 30";
         MinExtent = "8 8";
         Visible = "1";
         Command = "joinclass(2);";
         text = "Class 2";
         groupNum = "-1";
         buttonType = "PushButton";
            helpTag = "0";
      };
      new GuiButtonCtrl(Class3) {
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "11 132";
         Extent = "140 30";
         MinExtent = "8 8";
         Visible = "1";
         Command = "joinclass(3);";
         text = "Class 3";
         groupNum = "-1";
         buttonType = "PushButton";
            helpTag = "0";
      };
      new GuiButtonCtrl(Class4) {
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "157 64";
         Extent = "140 30";
         MinExtent = "8 8";
         Visible = "1";
         Command = "joinclass(4);";
         text = "Class 4";
         groupNum = "-1";
         buttonType = "PushButton";
            helpTag = "0";
      };
      new GuiButtonCtrl(Class5) {
         Profile = "GuiButtonProfile";
         HorizSizing = "right";
         VertSizing = "bottom";
         position = "157 97";
         Extent = "140 30";
         MinExtent = "8 8";
         Visible = "1";
         Command = "joinclass(5);";
         text = "Class 5";
         groupNum = "-1";
         buttonType = "PushButton";
            helpTag = "0";
      };
   };
};
//--- OBJECT WRITE END ---

The final thing to do:

Go into your mission and add 3 SimSets named: ObserverDropPoints, RedTeamDropPoints and BlueTeamDropPoints. Then add spawn spheres in each of them, placing them where you want.

I hope I'm not missing anything. Enjoy. :D

#1
09/27/2009 (8:14 pm)
Heh heh, might have should have waited a little longer ;)

Torque3D already had a teams implementation in the FPS Genre Kit, but it was essentially unused. The Template and the FPS kit have also been superseded with something "new" for the next release -- so a little minor work will be necessary to make this work past Beta5. Mostly just namespace differences between the GameConnection/GameTypeObject. I did strip the Team selection and gameplay out of the "new" code but this resource will work just the same, though you'll have to do your own "Team XXXGameMode", of which anyone who has any of the betas can find an example of (which does work with the new Torque3D spawn methods).

EDIT: You missed one thing. The code tags ;D
#2
09/27/2009 (8:29 pm)
I saw the teams in the FPS Kit but I wasn't sure what changes they had made. I needed to get my code ported over from TGEA into T3D so I started from scratch.


I left out the code tags because when you save the file locally and try to copy/paste via 'view plain' it won't keep the cursor in the same place. And if you try to copy/paste without 'view plain' it will add line numbers to every line and you have to manually delete each one. This way everything works perfect.. just not as pretty :)
#3
09/28/2009 (9:02 am)
but hell difficult to follow....
#4
09/30/2009 (5:55 pm)
I don't see teams & classes implemented in T3D 1.0 so this should work fine. I might code it to work with different game types but for now my game is only teams/classes.
#5
09/30/2009 (6:52 pm)
Small Update: I changed the weapons to be T3D weapons. Everyone gets a rocket launcher. Change them to your own weapons of course in GameConnection::createPlayer. Also, if anyone finds this usefull I've added a countdown delay timer for spawning. If you want I'll update the code. It's an easy thing to add in.
#6
10/08/2009 (9:22 am)
@Michael - care to elaborate on what the "new" team implementation is since 1.0 is now out?

mb - there is some code for implementing a TDM game type in the physX demo but it looks like the same thing that was carried forward from the beta's and not something "new".
#7
10/08/2009 (12:39 pm)
@Bone:
The FPS Genre Kit had the team code, but it was unused -- the PhysxDemo was based on an old version of the FPSKit. It's the Template (FPSExample) itself that I was referring to as being "new". Re-read my statement:
Quote:I did strip the Team selection and gameplay out of the "new" code but this resource will work just the same, though you'll have to do your own "Team XXXGameMode", of which anyone who has any of the betas can find an example of

This resource is still usable and the class selection as indicated here is one way of doing such a thing. At the time of posting my comment was more that mb maybe should have waited since I knew the release date was imminent (just couldn't say anything about it) and that there would possibly need to be a few minor minor changes in the instructions.
#8
10/08/2009 (1:15 pm)
I see. It sounded like you had plans to replace the old team-code with something else and it just wasn't released yet. It's clearer now, Thanks.
#9
11/27/2009 (9:42 am)
not get a Spawn point, please tutorial, on the T3D alpha 1.1 version is a possible?
#10
11/27/2009 (1:35 pm)
Please Tutorial Spawn point
#11
12/07/2009 (11:16 am)
@Alex Wild.
Maybe you should BUY the engine first?
#12
12/10/2009 (9:25 am)
I have the 101 demo and this is unfortunately confusing. I see you used line numbers, but if I use line numbers there is times that I will end up putting code into the middle of code. Also the folder structure is not the same but i can figure that out. These scripts are not suppose to bhe in the core folder correct?
#13
12/29/2009 (4:55 am)
This needs to be updated for T3D 1.1a as most of the structure has changed. Good resource though.
#14
12/29/2009 (12:42 pm)
@Jason

The line numbers are put there by this website. You can click on 'view plain' above the code sections to get a good copy/paste.

I haven't tried it for T3D 1.1a yet.. My computer is dead at the moment so it may be a while before I look at it.
#15
12/30/2009 (9:16 pm)
I attempted to implement the resource myself (with the very little knowledge of Torque Script I know) into T3D 1.0.1 and this is what I got: http://www.youtube.com/watch?v=DMPG2cYmb-k
I didn't have any errors within the console so I'm hoping I just didn't place the code into some of the correct places.

Note: I set all the classes to use the same player model because there aren't any more within T3D by default (at least I didn't thoroughly check), also the fact I'm the default player with the standard weapon when I spawn.

mb when you update this resource could you add a bit of a description to what each part does, just so users can understand what each piece of code contributes.