Mission Cycling and selected vehicle problems
by Ronald J Nelson · in Torque Game Engine · 09/13/2005 (5:09 am) · 13 replies
Hey all I have a problem I hope you can help me with.
I have managed to successfully get players to spawn mounted in vehicles, and that each player can chose what vehicle they want to spawn in before the game. Here is my problem though, while the player's vehicle shows up just fine initially, upon mission end and cycle into a new mission of the exact same type, the player's vehicle does not show up, just the player character. I have checked the log and it is trying to recreate the vehicle in the new mission as it should but can't find the information for the variable I assigned to the datablock. For some reason the client information is not all being passed from one mission to the next.
Here is what I have done:
$playerVehicle is a global variable I have set up for temporary use until I finish the Vehilce selection gui to assing it different values.
In ..common\server\clientConnection.cs I have:
and in the same function:
Then in my hosting args I have the function:
which contains this:
Then in my joining args I have the function:
which contains this:
Finally I have this in my game script:
Can someone tell me what I have done wrong or need to do to fix this?
I have managed to successfully get players to spawn mounted in vehicles, and that each player can chose what vehicle they want to spawn in before the game. Here is my problem though, while the player's vehicle shows up just fine initially, upon mission end and cycle into a new mission of the exact same type, the player's vehicle does not show up, just the player character. I have checked the log and it is trying to recreate the vehicle in the new mission as it should but can't find the information for the variable I assigned to the datablock. For some reason the client information is not all being passed from one mission to the next.
Here is what I have done:
$playerVehicle is a global variable I have set up for temporary use until I finish the Vehilce selection gui to assing it different values.
In ..common\server\clientConnection.cs I have:
function GameConnection::onConnect( %client, %name, %vehicle )
and in the same function:
%client.vehicle = %vehicle;
Then in my hosting args I have the function:
function SM_StartMission()
which contains this:
%conn.setConnectArgs($pref::Player::Name, $playerVehicle);
Then in my joining args I have the function:
function joinLanGui::join(%this)
which contains this:
%conn.setConnectArgs($pref::Player::Name, $playerVehicle);
Finally I have this in my game script:
function GameConnection::createvehicle(%this, %spawnPoint)
{
error("inside onNewDataBlock");
if (%this.vehicle > 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!" );
}
%player = new Player()
{
dataBlock = PlayerBody;
client = %this;
};
error("created player");
MissionCleanup.add(%player);
error("added driver to missionCleanup");
// player setup
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
%this.camera.setTransform(%player.getEyeTransform());
%this.player = %player;
//%this.setControlObject(%player);
// Create the vehicle object
%vehicle = new WheeledVehicle()
{
dataBlock = %this.vehicle;
mountable = true;
client = %this;
};
error("created vehicle");
MissionCleanup.add(%vehicle);
error("added vehicle to missionCleanup");
//attempt to mount player
error("Attempting to mount player to vehicle");
%node = "mount0";
//%this.player.onMount(%this,%player,%vehicle,%node);
%vehicle.mountObject(%player, 0);
//%player.Armor.onMount(%this,%player,%vehicle,%node);
// Player setup...
%vehicle.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%vehicle.getEyeTransform());
// Give the client control of the player
%this.vehicle = %vehicle;
//%this.setControlObject(%vehicle);
error("leaving racing.game.cs");
}Can someone tell me what I have done wrong or need to do to fix this?
#2
09/13/2005 (2:26 pm)
Well there should not be a need for that since the player's name follows into the next game. Also I see there is an additional problem, when my player dies, the car does not appear when he respawns. This seems to be more of a on death issue since that also intiates the cycle of the game when there is a winner.
#3
09/13/2005 (2:45 pm)
OK I tried to add the vehicle args to the onDeath function and now the game will not start.
#4
09/13/2005 (4:27 pm)
Well apparently none of the onDeath args are being passed because I set up a deathmatch, killed another player, and it left a blank where it should have said it was me that killed him.
#5
09/13/2005 (6:13 pm)
I neglected to add that I ran him over in my car.
#6
09/13/2005 (7:26 pm)
Maybe it's trying to get a field from the car that's not getting set?
#7
Now the one thing I still have a problem with is that when I kill someone with the car like running them over it doesn't register it as me killing them.
09/14/2005 (5:30 am)
Well I managed to get everything but one working with a very simple change. In the clientConnection.cc function I mentioned before I referenced %vehicle and set it as an arg. that I used to name the datablock in creating the car. If you look a few lines below that I also had // Give the client control of the player %this.vehicle = %vehicle;. That was the mistake. I was creating a new object named the same thing as my arg. So I renamed my arg and it works.Now the one thing I still have a problem with is that when I kill someone with the car like running them over it doesn't register it as me killing them.
#8
09/14/2005 (6:07 am)
Probably because the game is looking at the vehicle object that caused the collision instead of the player object. I guess you'll have check who was mounted in the vehicle when the other player was killed and credit the player with the kill.
#9
09/14/2005 (7:30 am)
How would I do something like that?
#10
Or you could just store a reference to the player/connection on a dynamic field on the car and use that.
09/14/2005 (10:49 am)
I don't know off hand, but I'd try calling dump() on the car and looking at the functions that deal with mounted objects.Or you could just store a reference to the player/connection on a dynamic field on the car and use that.
#11
For example, in you createvehicle routine use this,
Edit: forgot the rest of the example.
09/14/2005 (11:38 am)
You're reassigning the %vehicle argument already assigned as a datablock. In the client connection routine, the %vehcile is a datablock, then you reassigne it again in spawning routine. The value for %vehicle when created is a simobject value. Don't reuse the %vehicle argument to correct the error.For example, in you createvehicle routine use this,
function GameConnection::createvehicle(%this, %spawnPoint)
{
...
[b]%car[/b]= new WheeledVehicle()
{
dataBlock = %this.vehicle;
mountable = true;
client = %this;
};
// Give the client control of the player
[b]%this.car= %car;[/b]
...
}Edit: forgot the rest of the example.
#12
09/14/2005 (1:27 pm)
Thanks Akio, but I beat you to that one 4 posts earlier, you just demonstrated what I said.
#13
09/14/2005 (1:43 pm)
Ah, OK. I didn't read all the posts except for what was at the bottom. Good going.
Associate Kyle Carter