Bot problem in teamplay.
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
Bot problem in teamplay.
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:
Can somebody give me a help?
Thanks!
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!
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
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.
Cheap and hacky, but... well, it was off the top of my head.
-

scar3crow - InsideQC Staff
- Posts: 1054
- Joined: Tue Jan 18, 2005 8:54 pm
- Location: Alabama
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.
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
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest