Game Development Community

Adding Bots to Teams

by Anthony Rosenbaum · in Torque Game Engine · 06/06/2002 (9:25 am) · 5 replies

If you all are following my post this week I have made advancements with team spawning, and triggers. So now I was ready to put in my first bot. I added the .h and .cc file Like Stefan's Tut said. It complied fine and I went into a game typed
$myBot =aiAddPlayer("Sneaky");
and the console says "I've been added." But I can't the bot.I look for him in the editor but nothing. If I try and move him it claims he is not there. I am thinking that the bot isn't being created as a player because of several reasons.
A)My players' shape is dependant on the team they choose
B)So I am guessing it is spawning as an observer
Where in the code do I start snooping around to find the aiAddPlayer() function? And will I be able to enhance it to give the spawning bot a team and hence mesh for his body? Can any one help?
edit
After altering the team code so it will always be 1 type and trying to do a
myBot.dump();
I still getting a message claiming that the bot(object) dose not exist. I think it might be in the team code, making a player an observer in the beginning. Still Need Help? Any clues? Is ther a function in the scripts that is something like
%this.isABot();
That can be used for this type of error?

#1
06/06/2002 (9:51 am)
Don't know what's goin on, but
myBot.dump();
should be
$myBot.dump();

and you could use %this.isAIControlled(); to check if its a bot or not...
#2
06/06/2002 (10:40 am)
TYPOS TYPOS TYPOS. . . .well now I can activate the dump. . . I was declaring him locally not globally.Now he exist and has functions but no body yet. Right now when a person enters the game they are put as an observer. . .then they have to push f5 to select the team. . . .how would I bypass that for bots. . .so they can have a team given to them?
EDIT
After reviewing the list of functions I was able to find the one I needed. I was right in that the bot joined the observers by default. . . I then simply typed
$myBot.joinTeam(1);

and was able to swtich min to each side. . . .now on the rest of the bot tutorials!!!!!
#3
03/16/2003 (7:53 am)
If a player spawned the bot, how do you get the bot to spawn on his team?

I tried:
%team = %client.team;
	echo("<++++++++++++++++ TEAM IS:");
	echo(%team);
	$myBot01 =aiAddPlayer("Botty");
	$myBot01.joinTeam(%team);

But it doesn't seem to add him to the team. Can someone point out what I am doing wrong? I am very new at this, so be gentle. :)

Thanks,
-Jeff
#4
03/16/2003 (7:57 am)
In my code, I just set the team ID like this:

%bot.setTeam(%team);

My spawn functions also select the spawn point according to the bot's team-ID.

All this of course only works for me. I don't know how you implemented teams.

EDIT: Assuming that your team implementation is somewhat similar to that of Xavier "Exodus", I suggest that you don't use the joinTeam function as this only works for clients, not players - and since bots are players...

set the team ID manually. Then select the spawn point manually, and set the bot's position accordingly. That should do the trick. You can also set different shapes for the player depending on the team.
#5
03/16/2003 (8:09 am)
Thanks for the reply! :)

Yes I was using that tutorial.

Hmmm, by manually do you mean in the console?

Basically I have a gui that spawns objects and AI bots. I want it to place the ai bot on the same team as the player creating it.

Do you have any suggestions on how I may automate that?

EDIT:
Sorry, also I am a little confused on what you meant by "It only works for clients, not players".

Thanks again,
-Jeff