Game Development Community

team spawn points and base capture

by Katrell Logan · in Torque Game Engine · 12/10/2009 (5:12 pm) · 6 replies

my team and I are having problems implementing team spawn points and base capture for our game we want to use the on enter function for base capture triggers but are not quite sure what to do as the instructions we got were very vague
this is the code we are using for team spawn points but it doesn't work

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 @ "RedTeamDropPoints";
%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";
}



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";
}

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 = %classDatablock;
client = %this;
};

MissionCleanup.add(%player);

// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);

// 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.

we would appreciate any help that anyone could give us

About the author

Recent Threads


#1
12/10/2009 (6:13 pm)
Quote:it doesn't work
Can you give us any more details? What happens? Any console errors?

From a cursory look at the script, you've defined pickSpawnPoint and pickObserverPoint to return the transforms of a spawn point or an observer spawn point... but you're never using them.
%player.setTransform(%spawnPoint);
%spawnPoint does not exist - you haven't given it any value yet, so your players will probably be set with some weird transform.
#2
12/10/2009 (7:19 pm)
Well we tried to implementing a code from a team resource that involved setting spawn points for teams and we don't have much of a clue what to do with them after the code in order to use them. When a player dies to join a team from the suicide function, the player becomes locked in camera mode and cannot move or respawn afterwards instead of respawning to a given teamspawn.
#3
12/10/2009 (7:28 pm)
debug your code, i think that the problem is in ::onDeath function, you need to push the select team gui, or respawn as an observer (cam)
#4
12/11/2009 (12:11 pm)
My deepest apologies. I left out part of the code accidently, this was on top:

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
}
#5
12/11/2009 (6:27 pm)
Whoops, I failed to notice that %spawnPoint was a parameter of that function.

I'd agree with Javier, it's probably something in the death code that isn't allowing you to respawn. All the stuff you've posted looks all right.

I'd put echos in createPlayer and spawnPlayer, just to see if those functions are actually being called at all. If not, you can clear this code of any blame.
#6
12/12/2009 (4:17 pm)
Do what Daniel says. I was messing around with the same teams/classes resource and while debugging through all the code they had put together I found at-least 2-3 functions that weren't even being called.