I will work on writing the actual code for this later if I get around to it, but so far for TF2 it seems everyone has just written their own team balancers to be able to block certain players from being switched by the built in balancer. Thanks to an idea from pRED, I searched it a bit more tonight and this should be enough to do it with an extention.
Will need to hook this function
Code:
404 CTFPlayer::CalculateTeamBalanceScore(void)
Here is the original code from the SDK
Code:
int CBaseMultiplayerPlayer::CalculateTeamBalanceScore( void )
{
// base score is 0 - ( seconds on server )
float flTimeConnected = gpGlobals->curtime - m_flConnectionTime;
int iScore = 0 - (int)flTimeConnected;
// if we were switched recently, score us way down
float flLastSwitchedTime = GetLastForcedChangeTeamTime();
if ( flLastSwitchedTime > 0 && ( gpGlobals->curtime - flLastSwitchedTime ) < 300 )
{
iScore -= 10000;
}
return iScore;
}
You will want to return a "low score" for players that you do not want to be switched, and a higher score for players that are susceptible to team balancer. Some other functions that could possibly be used are...
void SetTeamBalanceScore( int iScore ) { m_iBalanceScore = iScore; }
int GetTeamBalanceScore( void ) { return m_iBalanceScore; }
void SetLastForcedChangeTeamTimeToNow( void ) { m_flLastForcedChangeTeamTime = gpGlobals->curtime; }
I will experiment with this more later, but its just to give an idea. Theres nothing wrong with writing a new balancer, but it would be nice to have an option of keeping the built in balancer as well