Change the script or C++?
by Mike Stoddart · in Torque Game Engine · 05/15/2002 (1:11 pm) · 1 replies
I added in the basic team implementation code from the resources on this site, and I made some minor mods to suit my wishes. I also added a new test weapon (a Walther pistol), and some code in the Walther script that prints out the client (%obj.client) that fired the shot that hit me. So in essence, if I look down and shoot myself, I should see my own client ID as being the originator or the shot.
Got that? Right onwards....
But one thing struck me; when a client joins a game, they are automatically assigned a team of $Game::Team0 (which is the observer). So:
function gameConnection::joinTeam(%this, %teamId)
{
...
%this.team = $Game::Team0;
...
}
where:
$Game::Team0 = new ScriptObject()
{
teamId = 0;
name = Observer;
score = 0;
numPlayers = 0;
};
But when I checked the team of the client that fired a shot at me (i.e. should be my own team), the team variable isn't defined/is empty.
Does that still make sense?
So my question is, should I add a variable for the client's team into the player class in the C++ source files for completeness, or is it enough just to store the variable in the script?
I really hope that makes sense to someone.
Got that? Right onwards....
But one thing struck me; when a client joins a game, they are automatically assigned a team of $Game::Team0 (which is the observer). So:
function gameConnection::joinTeam(%this, %teamId)
{
...
%this.team = $Game::Team0;
...
}
where:
$Game::Team0 = new ScriptObject()
{
teamId = 0;
name = Observer;
score = 0;
numPlayers = 0;
};
But when I checked the team of the client that fired a shot at me (i.e. should be my own team), the team variable isn't defined/is empty.
Does that still make sense?
So my question is, should I add a variable for the client's team into the player class in the C++ source files for completeness, or is it enough just to store the variable in the script?
I really hope that makes sense to someone.
Torque Owner Badguy
teamId = 0; ?
is it ever set anything other than 0 ?
there should be no problem having a variable owned completely by the script as long as you dont need it in the code.