team joining is kinda working now woo. use 'team' concommand

This commit is contained in:
Dexter 2013-11-04 06:59:21 +00:00 committed by squeek
parent 46658bdc5b
commit 1f115eb8c5
5 changed files with 57 additions and 9 deletions

View file

@ -1544,7 +1544,6 @@ bool CFF_SV_Player::CanHearAndReadChatFrom( CBasePlayer *pPlayer )
// do any eg class cleanup here etc
void CFF_SV_Player::PreChangeTeam( int iOldTeam, int iNewTeam )
{
// set team unassigned
// set class unassigned
// remove items
// special infection stuff,
@ -1552,6 +1551,14 @@ void CFF_SV_Player::PreChangeTeam( int iOldTeam, int iNewTeam )
// clear state (might do w/ player func)
// check kill
// lua player_killed
RemoveAllItems( true );
if ( IsAlive() && GetTeamNumber( ) >= TEAM_BLUE )
{
KillPlayer( );
// TODO: lua killed predicate
}
}
// called by team manager once a valid team is found, and after new team set
@ -1560,4 +1567,22 @@ void CFF_SV_Player::PostChangeTeam( int iOldTeam, int iNewTeam )
{
// reset state
// spawn called
if ( iOldTeam == TEAM_SPECTATOR )
{
StopObserverMode( );
}
// dont force spawn here right now, death think will spawn the player
//Spawn( );
}
void CFF_SV_Player::KillPlayer( void )
{
// TODO: FF stuff
m_iHealth = 0;
// slam it
SetThink(&CBasePlayer::PlayerDeathThink);
SetNextThink(gpGlobals->curtime);
}

View file

@ -141,6 +141,8 @@ public:
void PreChangeTeam( int iOldTeam, int iNewTeam );
// called by team manager once a valid team is found, and after new team set
void PostChangeTeam( int iOldTeam, int iNewTeam );
void KillPlayer( void );
private:
CNetworkQAngle( m_angEyeAngles );

View file

@ -2151,11 +2151,11 @@ void CBasePlayer::PlayerDeathThink(void)
// if the player has been dead for one second longer than allowed by forcerespawn,
// forcerespawn isn't on. Send the player off to an intermission camera until they
// choose to respawn.
if ( g_pGameRules->IsMultiplayer() && ( gpGlobals->curtime > (m_flDeathTime + DEATH_ANIMATION_TIME) ) && !IsObserver() )
{
// go to dead camera.
StartObserverMode( m_iObserverLastMode );
}
//if ( g_pGameRules->IsMultiplayer() && ( gpGlobals->curtime > (m_flDeathTime + DEATH_ANIMATION_TIME) ) && !IsObserver() )
//{
// // go to dead camera.
// StartObserverMode( m_iObserverLastMode );
//}
// wait for any button down, or mp_forcerespawn is set and the respawn time is up
if (!fAnyButtonDown

View file

@ -199,6 +199,9 @@ CFF_SH_Rules::CFF_SH_Rules()
{
#ifndef CLIENT_DLL
// Create the team managers
// TODO: right now this creates a team for every team name string,
// hook this into lua and have it create teams as needed per map
// or something cool like that
for ( int i = 0; i < ARRAYSIZE( sTeamNames ); i++ )
{
CFF_SH_TeamManager *pTeam = static_cast<CFF_SH_TeamManager*>(CreateEntityByName( "ff_team_manager" ));
@ -207,7 +210,9 @@ CFF_SH_Rules::CFF_SH_Rules()
g_Teams.AddToTail( pTeam );
}
m_bTeamPlayEnabled = teamplay.GetBool();
// Dexter: slammed this to always true instead of the cvar for now
//m_bTeamPlayEnabled = teamplay.GetBool();
m_bTeamPlayEnabled = true;
m_flIntermissionEndTime = 0.0f;
m_flGameStartTime = 0;

View file

@ -343,6 +343,9 @@ bool CFF_SH_TeamManager::HandlePlayerTeamCommand( CFF_SV_Player &pPlayer, const
int CFF_SH_TeamManager::PickAutoJoinTeam( )
{
// TODO:
// it is me, the auto picker thingy majig
return TEAM_BLUE;
}
@ -351,7 +354,7 @@ bool CFF_SH_TeamManager::IsTeamFull() const
if (m_iMaxPlayers == 0)
return false;
int numActive = 0;
int numActive = 0;
for( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CFF_SV_Player *pPlayer = (CFF_SV_Player *) UTIL_PlayerByIndex( i );
@ -359,7 +362,7 @@ bool CFF_SH_TeamManager::IsTeamFull() const
numActive++;
}
return numActive > m_iMaxPlayers;
return m_iMaxPlayers == 0 ||numActive > m_iMaxPlayers; // GetNumPlayers( ) > m_iMaxPlayers;
}
#endif
@ -386,6 +389,19 @@ void DebugSetTeamName_f( const CCommand &args )
DevMsg("Team name after set ='%s'\n", pTeam->GetName());
}
ConCommand cc_ffdbg_setteamname("ffdbg_set_team_name", DebugSetTeamName_f);
void DebugCurTeam_f( const CCommand &args )
{
CBasePlayer* pPlayer = UTIL_GetCommandClient();
if ( !pPlayer )
return;
CTeam *pPlayerTeam = pPlayer->GetTeam();
if ( !pPlayerTeam )
return;
pPlayerTeam->GetNumPlayers( );
DevMsg("Player team=%i name='%s' players on team=%d\n", pPlayerTeam->GetTeamNumber( ), pPlayerTeam->GetName( ), pPlayerTeam->GetNumPlayers( ) );
}
ConCommand cc_ffdbg_curteam("ffdbg_curteam", DebugCurTeam_f);
#endif