Raised This Month: $51 Target: $400
 12% 

TF2 Snippet: Blocking Players from Team Balance


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 11-12-2008 , 02:24   TF2 Snippet: Blocking Players from Team Balance
Reply With Quote #1

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
CrimsonGT is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-12-2008 , 12:44   Re: TF2 Snippet: Blocking Players from Team Balance
Reply With Quote #2

Let me tell you now, that's not really enough to do it (I already have a successful team balancer immunity extension for admins). In TF2 it really depends on who is dead when the team switch happens. The team balance score stuff only does anything at the beginning of the round when teams are balanced.

Last edited by bl4nk; 11-12-2008 at 12:47.
bl4nk is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode