Game Development Community

adding ai Player

by Injae Jeong · in Torque Game Engine · 05/07/2003 (8:41 am) · 4 replies

I am trying to add an ai Player through scripts. I used the function aiAddPlayer in game.cs in the onClientEnterGame method. If I use the same function at console while in a game it works fine.

I used the following in GameConnection::onClientEnterGame :

%aiplayer = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
client = %this;
};

$aBot = %aiplayer.aiAddPlayer("temp");

I get the following error in console:
unknown command aiAddPlayer.

I have added the aiPlayer.cc and aiPlayer.h files to my workspace and performed a claen rebuild. But it still doesnt work.

I think I am missing something...this is so plain straight. :(

#1
05/07/2003 (10:54 am)
Assuming you are using the HEAD version of Torque, add aiClient.cc and aiClient.h to your project workspace.

I would highly recommend looking at the tutorials that Stefan has here.

Rich
#2
05/07/2003 (11:02 am)
Rich,
The version I have doesnt have aiClient.cc and aiClient.h. The console method aiAddPlayer is in AiPlayer.cc. Do I need to download a newer version. I downloaded in about Feb 2003. Has it changed since? Help!
#3
05/07/2003 (11:11 am)
So you are using one of the Release_1_?_? versions, try using the below command:
%client = aiAddPlayer("Player Names goes here", "Optional player namespace goes here");

Rich
#4
05/07/2003 (11:31 am)
It worked finally. I used %aiplayer.spawnPlayer() instead of %aiplayer.aiAddPlayer("temp");


%aiplayer = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
client = %this;
};

$myBot01 = %aiplayer.spawnPlayer();

Thanks a lot Rich. The link proved useful too!

*Edit*
When I wrote the following in game.cs in the method onClientEnterGame:
$myBot01 = aiAddPlayer("Temp");

the application stopped and didnt go beyond "Loading Objects" when I selected a mission. I checked out the console.log and there was a long list of " CADD 13.. ai:local". So the application went into a infinite loop I guess. Does anybody know of any reasons as to why should this haapen? It will happen me understand Torque better. :)

*End Edit*