Team shirt colors
Posted: Wed Mar 14, 2012 4:10 pm
I want to improve the stock ctfbot TeamGetShirt() routine so that it can use bitflags on a teamshirt float to check if a certain color is used.
The stock code is:
...which seems to increment the floats, however once a player or bot leaves, that color is now freed, but this system wont consider that color is now available. What I have in mind is to make the team2shirt and team1shirt use bitflags, and I think that we could just check if (team2shirt && BLUE1) , for example, tells us if that shirtcolor 0 is available or not. I would make shirtcolor 0 the first float, and so fourth so that BLUE16 is 32768. Same for the RED team set. I would probably use scratch1 and scratch2 to keep these values known from level to level. I had also thought of merely cycling through the player and bot entities using ' find ' to check if a color is used, but the bitflag idea sounds more effective. Comments or ideas anyone?
EDIT: Other thing I forgot to mention is will need to check if the shirt color is the opposing teams pant color and disallow it. Whats a good explanation of what .colormap does?
The stock code is:
Code: Select all
float (float t, entity ent) TeamGetShirt =
{
if ((t == TEAM_COLOR1))
{
team1shirt = (team1shirt + FLAG_CARRIED);
if ((team1shirt == (TEAM_COLOR2 - FLAG_CARRIED)))
{
team1shirt = (team1shirt + FLAG_CARRIED);
}
if ((team1shirt == 2))
{
team1shirt = (team1shirt + FLAG_CARRIED);
}
if ((team1shirt > TEAM_COLOR2))
{
team1shirt = 0;
}
return (team1shirt);
}
else
{
team2shirt = (team2shirt + FLAG_CARRIED);
if ((team2shirt == (TEAM_COLOR1 - FLAG_CARRIED)))
{
team2shirt = (team2shirt + FLAG_CARRIED);
}
if ((team2shirt == 6))
{
team2shirt = (team2shirt + FLAG_CARRIED);
}
if ((team2shirt > TEAM_COLOR2))
{
team2shirt = 0;
}
return (team2shirt);
}
return ((t - FLAG_CARRIED));
...which seems to increment the floats, however once a player or bot leaves, that color is now freed, but this system wont consider that color is now available. What I have in mind is to make the team2shirt and team1shirt use bitflags, and I think that we could just check if (team2shirt && BLUE1) , for example, tells us if that shirtcolor 0 is available or not. I would make shirtcolor 0 the first float, and so fourth so that BLUE16 is 32768. Same for the RED team set. I would probably use scratch1 and scratch2 to keep these values known from level to level. I had also thought of merely cycling through the player and bot entities using ' find ' to check if a color is used, but the bitflag idea sounds more effective. Comments or ideas anyone?
EDIT: Other thing I forgot to mention is will need to check if the shirt color is the opposing teams pant color and disallow it. Whats a good explanation of what .colormap does?