Forum

Bot problem in teamplay.

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Bot problem in teamplay.

Postby Orion » Sat Mar 24, 2007 8:19 pm

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: Select all
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!
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby scar3crow » Thu Mar 29, 2007 1:41 am

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.
User avatar
scar3crow
InsideQC Staff
 
Posts: 1054
Joined: Tue Jan 18, 2005 8:54 pm
Location: Alabama

Postby FrikaC » Thu Mar 29, 2007 10:08 pm

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.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby Orion » Thu Mar 29, 2007 10:14 pm

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...
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest