Game Development Community

Adding two different bots in different paths and more

by Sventhors · in Technical Issues · 03/07/2006 (8:11 pm) · 13 replies

Cheers everyone.

I am trouble adding two different bots to two different path and run its path.

I just saw this forum to be similar
[url] http://www.garagegames.com/mg/forums/result.thread.php?qt=41008[/url] and I hope this is similar or different what I want. I got confused where they are adding this. Is it in the AIPLAYER or in player.cs.

This is what I have done:
- copy \tutorial.base\data\shapes\player folder to \starter.fps\data\shapes\greeny
- copy all dsq files from the player folder into the greeny folder
- copy all dsq files from the player folder into the blue folder. And changed its color in photoshop(uv texture).


- now
in server/scripts/player.cs copy the
datablock PlayerData(PlayerBody)
and turn the copy into
datablock PlayerData(GreenyBody)
and PlayerData(BlueBody)

in this copy change this line
shapeFile = "~/data/shapes/player/player.dts";
to
shapeFile = "~/data/shapes/greeny/player.dts";
to
shapeFile = "~/data/shapes/blue/player.dts";



- now copy player.cs from the player folder to the greeny folder

in greeny/player.cs change
datablock TSShapeConstructor(PlayerDts)
to
datablock TSShapeConstructor(GreenyDts)
to
datablock TSShapeConstructor(BlueDts)


- now in server/scripts/player.cs add
exec("~/data/shapes/greeny/player.cs");
exec("~/data/shapes/blue/player.cs");
under
exec("~/data/shapes/player/player.cs");





- now go to server/scripts/aiPlayer.cs
and change the line
datablock PlayerData(DemoPlayer : PlayerBody)
to
datablock PlayerData(DemoPlayer : GreenyBody)
to
datablock PlayerData(DemoPlayer : BlueBody)
-------
No luck

I have even made to two different cs files(where all shapeFile and exec are excuting its destination) . Like
player.cs
player2.cs
aiPlayer.cs
aiPlayer2.cs

and Im not getting two bots to show up the same time in its pathfinding.
When // one of those cs then one bot will show up it supposed spot.

and in aiPlayer I have also tried changing the
function AIPlayer::spawn(%name,%spawnPoint)
{
   // Create the demo player object
   %player = new AiPlayer() {
      dataBlock = BluePlayer;
      path = "";
   };
and

datablock PlayerData(BluePlayer : BlueBody)

and no luck.

Do I need to change it some where else or do I need to change some where else.


When I get one bot to work in Path I have tried to typing in the console

new AIPlayer(Bob) { datablock = "blue(or greeny)Body"; position = LocalClientConnection.camera.getPosition(); };

I have also tried to add
datablock PlayerData(BluePlayer : DemoPlayer)
{
   shapeFile = "~/data/shapes/blue/player.dts";
};

and engine crashed.


it drops it suppose bot with no pathfinding. I know its responing and not getting both bots to run its pat. Sniff :)

#1
03/08/2006 (7:54 am)
Let me try to explain how it works:

The Game.cs script creates a scriptObject called AIManager that is supposed to control the thinking of all the in game AI. Despite it's name, this object is just a simple object that will create the AIPlayers and be schedulled every half second to process what they are supposed to do.

The AIManager is the object that actually spawns the AIPlayers, but it spawns only one. What you are actually doing is spawning it with a different datablock.

Modify the AIManager to create two players instead of one and also try modifying the spawn function to accept the datablock as a parameter. Also modify the AIManager and SpawnOnPath to include include it on their subsequent calls.

HTH
#2
03/09/2006 (3:02 pm)
Thanks for explation that help me to understand what aiPlayer does and creates a AIManager. So the player.cs has do nothing for adding player. I will give it try:)

Curious. Do i need to create two PlayerData

like
datablock PlayerData(GreenPlayer : GreenyBody)
{
   shootingDelay = 2000;
};
datablock PlayerData(BluePlayer : BlueBody)
{
   shootingDelay = 2000;
};
...//a

function AIPlayer::spawn(%name,%spawnPoint)
{
   // Create the demo player object
   %player = new AiPlayer() {
      dataBlock = BluePlayer;
      path = "";
   };
function AIPlayer::spawn(%name,%spawnPoint)
{
   // Create the demo player object
   %player = new AiPlayer() {
      dataBlock = GreenPlayer;
      path = "";
   };
#3
03/09/2006 (3:35 pm)
If the bots are supposed to be different, yes.

In that case you'll need to have two different functions for spawning each aiplayer kind or pass the datablock as a parameter.

You could have both players inherithing from the same parent ( GreenyBody ) but I'll suggest a couple of things :
1) name the Datablocks GreenPlayerData and BluePlayerData to avoid further confusion
2) make sure you insert :
datablock PlayerData(GreenPlayer : GreenyBody)
{
  class = "armor";
   shootingDelay = 2000;
};
cause they will be able to use the original path following methods provided with TGE.
#4
08/26/2006 (4:12 pm)
Im trying to do the same thing. If anyone else can help us here I would be grateful.

Thanks!

Gordon
#5
08/27/2006 (6:29 am)
Function AIPlayer::spawn(%name,%spawnPoint, %datablock)
{
   // Create the demo player object
   %player = new AiPlayer() {
      dataBlock = %datablock;
      path = "";
   };

datablock PlayerData(BluePlayer : DemoPlayer)
{
   shapeFile = "~/data/shapes/blue/player.dts";
};
datablock PlayerData(GreenPlayer : DemoPlayer)
{
   shapeFile = "~/data/shapes/green/player.dts";
};

AIPlayer::Spawn("moo", spawnpointname, BluePlayer);
AIPlayer::Spawn("moo2", spawnpointname, GreenPlayer);



that should be a summation of what you need.
#6
08/27/2006 (12:36 pm)
Thanks for the reply Andrew. Ive spent a few hours on this and still cant get it to work. I either get a crash, or I get no ai players at all.

Thanks!

Gordon
#7
08/30/2006 (5:54 pm)
Did you get this solve Gordon?
#8
08/30/2006 (9:43 pm)
No, Ive tried almost everything I can think of. Ill work on it again this weekend. Too tired from work to think about this now.

Thanks!

Gordon
#9
08/31/2006 (5:29 pm)
If I understand you right you want two different bots on different path. Do a search For aiGuard, the zip has aiPatrol in it, which is bot follow a path. Once you get in the engine. Go this thread here I explain how to create the datablock for the aiPatrol.

http://www.garagegames.com/mg/forums/result.thread.php?qt=49597

When you get ready to work it if run in to any problems email me.
#10
09/20/2006 (3:21 pm)
Were you replacing spawnpointname?
feel free to send me your files.
#11
11/21/2006 (11:39 pm)
I posted an update to my super compressed solution.

www.garagegames.com/mg/forums/result.thread.php?qt=53717
#12
03/04/2007 (9:07 am)
Im also having some problems with this. Im trying to create 2 different types of bots, good ones and bad ones. I already am able to get them to show different shapes ( i made 2 different datablocks as stated earlier on the thread) and each one has its own ai functions. The problem im getting is that when i create a new bot, i add it to different SimSet depending if the bot is good or bad
- AIBGroup.add(%me);
- AIGroup.add(%me);
where %me is the bot

When im checking for new threats, i use a for to search the whole SimSet and compare which one is closer to the bot, but apparently, when i go through the SimSet, it returns empty strings

%count = AIBGroup.getCount();
for(%i = 0; %i < %count; %i++)
{
%client = AIBGroup.getObject(%i);
if (%client.player $= "" || %client.player == 0 )
return -1;
%playPos = %client.player.getPosition();
.
.
.

the getObject function returns some object, but when i use the &client.player it returns an empty string, however the getCount returns 10, which are the number of bots i added. So, i know the SimSet contains the bots, but when i try to get them, it returns empty. Any one knows if it returns empty cause they are bots?? is there a way to make this work??
Any help would be appreciated thx.
#13
03/06/2007 (5:23 am)
I have just posted a resource that does something like this.
Adding multiple AIs