Inside3D!
     

Bot problem in teamplay.

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Sat Mar 24, 2007 8:19 pm    Post subject: Bot problem in teamplay. Reply with quote

Hello there.

On my mod I've implemented team play for my bots, when adding friendly bots it works correctly, but when adding enemies their colors aren't equal to the first enemy's color.

Here's the enemy's pants color code:

Code:

float() FindAnotherColor =
{
   local entity player;
   
   player = find(world, classname, "player");
   while (player != world)
   {
      if (player.team != self.team)
         return floor(random()*14);
      else
         return player.fPants;
      
      player = find(player, classname, "player");
   }
};


Can somebody give me a help?
Thanks!
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
scar3crow
Inside3D Staff


Joined: 18 Jan 2005
Posts: 837
Location: Las Vegas, NV

PostPosted: Thu Mar 29, 2007 1:41 am    Post subject: Reply with quote

Im no coder, but I figure the easiest way, assuming only 2 teams, would be to hardcode it in. If its a teamplay mode, allow the spawning of friendly bots, they automatically match your pants color. Then when you spawn an enemy bot, they have a fixed pants color and thus wont fire on each other as theyre forced into the team role.

Cheap and hacky, but... well, it was off the top of my head.
Back to top
View user's profile Send private message AIM Address
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Thu Mar 29, 2007 10:08 pm    Post subject: Reply with quote

I think you're missing key logic there. First off, it's rather pointless to have a while loop when either choice from the if will return a value and exit from the function. The function then boils down to:

1. Find first entity with classname player
2. If his team is not equal to my team, return some random integer value from 0 to 13 (note, it doesn't check if this is in conflict with anything, if there's already others on this team, etc). This will likely usually be the case because unless the bot is initialized, he'll have team 0 and the player will only have team 0 if he has white pants iirc.
3. Otherwise it returns .fPants on the player, which I don't know why. The .team field is the pants color, that's the whole point of the field.


I guess for a functioning example, check out my FindAnotherColor function in FrikBot. Curious it has the same name.
Back to top
View user's profile Send private message Send e-mail
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Thu Mar 29, 2007 10:14 pm    Post subject: Reply with quote

I've tried with your FindAnotherColor, but same problem happened. Enemy bots connect with orange shirt and rainbow pants.

And is because your function have some globals that I don't use...
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group