const char * C_PlayerResource::GetTeamName(int index)
{
	C_Team *team = GetGlobalTeam( index );

	if ( !team )
		return "Unknown";

	return team->Get_Name();
}
int C_PlayerResource::GetTeamScore(int index)
{
	C_Team *team = GetGlobalTeam( index );

	if ( !team )
		return 0;

	return team->Get_Score();
}
Пример #3
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamplayRules::Precache( void )
{
	// Call the Team Manager's precaches
	for ( int i = 0; i < GetNumberOfTeams(); i++ )
	{
		CTeam *pTeam = GetGlobalTeam( i );
		pTeam->Precache();
	}
}
void CHL2MP_Player::Event_Killed( const CTakeDamageInfo &info )
{
    //update damage info with our accumulated physics force
    CTakeDamageInfo subinfo = info;
    subinfo.SetDamageForce( m_vecTotalBulletForce );

#ifdef GE_DLL
    // Since we fixed force application, give the ragdoll an extra oomph to emphasize his death
    m_vecTotalBulletForce.x *= 2.5f;
    m_vecTotalBulletForce.y *= 2.5f;
    m_vecTotalBulletForce.z *= 2.0f;
#endif

    // Note: since we're dead, it won't draw us on the client, but we don't set EF_NODRAW
    // because we still want to transmit to the clients in our PVS.
    CreateRagdollEntity();

#ifndef GE_DLL
    DetonateTripmines();
#endif

    BaseClass::Event_Killed( subinfo );

    if ( info.GetDamageType() & DMG_DISSOLVE )
    {
        if ( m_hRagdoll )
        {
            m_hRagdoll->GetBaseAnimating()->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
        }
    }

#ifndef GE_DLL
    CBaseEntity *pAttacker = info.GetAttacker();

    if ( pAttacker )
    {
        int iScoreToAdd = 1;

        if ( pAttacker == this )
        {
            iScoreToAdd = -1;
        }

        GetGlobalTeam( pAttacker->GetTeamNumber() )->AddMatchScore( iScoreToAdd );
    }
#endif

    FlashlightTurnOff();

    m_lifeState = LIFE_DEAD;

    RemoveEffects( EF_NODRAW );	// still draw player body
    StopZooming();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::BreakCapture( bool bNotEnoughPlayers )
{
	if( m_bCapturing )
	{
		// Remap team to get first game team = 1
		switch ( m_nCapturingTeam - FIRST_GAME_TEAM+1 )
		{
		case 1: 
			m_OnBreakTeam1.FireOutput( this, this );
			break;
		case 2: 
			m_OnBreakTeam2.FireOutput( this, this );
			break;
		default:
			Assert(0);
			break;
		}

		m_BreakOutput.FireOutput(this,this);

		m_bCapturing = false;
		m_nCapturingTeam = TEAM_UNASSIGNED;

		UpdateCappingTeam( TEAM_UNASSIGNED );

		if ( bNotEnoughPlayers )
		{
			IncrementCapAttemptNumber();
		}

		SetCapTimeRemaining( 0 );

		if( m_hPoint )
		{
			m_hPoint->CaptureEnd();
		}

		m_OnNumCappersChanged.Set( 0, this, this );

		// tell all touching players to stop racking up capture points
		CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam );
		if ( pTeam )
		{
			for ( int i=0;i<pTeam->GetNumPlayers();i++ )
			{
				CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) );
				if ( pPlayer && IsTouching( pPlayer ) )
				{
					pPlayer->StopScoringEscortPoints();					
				}
			}
		}
	}
}
Пример #6
0
void CTextureProxy::OnBind( void *pEntity )
{
	// Bail if no base variable
	if ( !m_pBaseTextureVar )
		return;

	char texture[128];

	if (Q_stricmp(m_szTextureType, "hometeamcrest") == 0 && GetGlobalTeam(TEAM_A)->HasCrest())
		Q_snprintf(texture, sizeof(texture), "%s/%s/teamcrest", TEAMKITS_PATH, GetGlobalTeam(TEAM_A)->GetFolderName());
	else if (Q_stricmp(m_szTextureType, "awayteamcrest") == 0 && GetGlobalTeam(TEAM_B)->HasCrest())
		Q_snprintf(texture, sizeof(texture), "%s/%s/teamcrest", TEAMKITS_PATH, GetGlobalTeam(TEAM_B)->GetFolderName());
	else
		Q_snprintf(texture, sizeof(texture), "%s", m_pDefaultTexture->GetName());

	m_pNewTexture = materials->FindTexture(texture, NULL, true);
		
	m_pBaseTextureVar->SetTextureValue(m_pNewTexture);

	GetMaterial()->RecomputeStateSnapshots();
}
Пример #7
0
void CSDKPlayer::ChangeTeam( int iTeamNum )
{
	if ( !GetGlobalTeam( iTeamNum ) )
	{
		Warning( "CSDKPlayer::ChangeTeam( %d ) - invalid team index.\n", iTeamNum );
		return;
	}

	int iOldTeam = GetTeamNumber();

	// if this is our current team, just abort
	if ( iTeamNum == iOldTeam )
		return;
	
	m_bTeamChanged = true;

	// do the team change:
	BaseClass::ChangeTeam( iTeamNum );

	// update client state 
	if ( iTeamNum == TEAM_UNASSIGNED )
	{
		State_Transition( STATE_OBSERVER_MODE );
	}
	else if ( iTeamNum == TEAM_SPECTATOR )
	{
		RemoveAllItems( true );
		
		State_Transition( STATE_OBSERVER_MODE );
	}
	else // active player
	{
		if ( !IsDead() )
		{
			// Kill player if switching teams while alive
			CommitSuicide();

			// add 1 to frags to balance out the 1 subtracted for killing yourself
			IncrementFragCount( 1 );
		}

		if( iOldTeam == TEAM_SPECTATOR )
			SetMoveType( MOVETYPE_NONE );
//Tony; pop up the class menu if we're using classes, otherwise just spawn.
#if defined ( SDK_USE_PLAYERCLASSES )
		// Put up the class selection menu.
		State_Transition( STATE_PICKINGCLASS );
#else
		State_Transition( STATE_ACTIVE );
#endif
	}
}
//-----------------------------------------------------------------------------
// Purpose: Attach this spawnpoint to it's team
//-----------------------------------------------------------------------------
void CTeamSpawnPoint::Activate( void )
{
	BaseClass::Activate();
	if ( GetTeamNumber() > 0 && GetTeamNumber() <= MAX_TEAMS )
	{
		GetGlobalTeam( GetTeamNumber() )->AddSpawnpoint( this );
	}
	else
	{
		Warning( "info_player_teamspawn with invalid team number: %d\n", GetTeamNumber() );
		UTIL_Remove( this );
	}
}
Пример #9
0
Color &C_Team::GetHudKitColor()
{
	Color *color;

	if (GetTeamNumber() == TEAM_HOME || GetTeamNumber() == TEAM_AWAY)
		color = &m_pKitInfo->m_HudPrimaryColor;
	else
		color = &g_ColorGray;

	if (GetTeamNumber() == TEAM_AWAY)
	{
		if (*color == GetGlobalTeam(TEAM_HOME)->GetHudKitColor())
		{
			color = &m_pKitInfo->m_HudSecondaryColor;

			if (*color == GetGlobalTeam(TEAM_HOME)->GetHudKitColor())
				color = &g_HudAlternativeColors[m_pKitInfo->m_HudPrimaryColorClass];
		}
	}

	return *color;
}
Пример #10
0
//=========================================================================
// Return the score/frags of a team, depending on whether TeamFrags is on
int TeamFortress_TeamGetScoreFrags(int tno)
{
	CTeam *pTeam = GetGlobalTeam( tno );
	if ( pTeam )
	{
		return pTeam->GetScore();
	}
	else
	{
		Assert( false );
		return -1;
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::HandleScoring( int iTeam )
{
	if ( TeamplayRoundBasedRules() && !TeamplayRoundBasedRules()->ShouldScorePerRound() )
	{
		GetGlobalTeam( iTeam )->AddScore( 1 );
		TeamplayRoundBasedRules()->HandleTeamScoreModify( iTeam, 1 );

		CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
		if ( pMaster && !pMaster->WouldNewCPOwnerWinGame( this, iTeam ) )
		{
			CTeamRecipientFilter filter( iTeam );
			EmitSound( filter, entindex(), "Hud.EndRoundScored" );
		}
	}
}
void CNPC_SO_BaseZombie::Event_Killed( const CTakeDamageInfo &info )
{
	CBaseEntity *pEnt = info.GetAttacker();
	if ( pEnt && pEnt->IsPlayer() )
	{
		CSO_Player *pPlayer = ToSOPlayer( pEnt );
		if ( pPlayer )
		{
			// Give players some credit for killing zombie NPCs
			pPlayer->IncrementFragCount( 1 );
			GetGlobalTeam( pPlayer->GetTeamNumber() )->AddScore( 1 );
		}
	}

	BaseClass::Event_Killed( info );
}
Пример #13
0
void CHL2MP_Player::Event_Killed( const CTakeDamageInfo &info )
{
	//update damage info with our accumulated physics force
	CTakeDamageInfo subinfo = info;
	subinfo.SetDamageForce( m_vecTotalBulletForce );

	// Note: since we're dead, it won't draw us on the client, but we don't set EF_NODRAW
	// because we still want to transmit to the clients in our PVS.
	CreateRagdollEntity();

	//DHL - Skillet - SLAMs are removed, plus the sound is cheesy at death
	//DetonateTripmines();

	BaseClass::Event_Killed( subinfo );

	if ( info.GetDamageType() & DMG_DISSOLVE )
	{
		if ( m_hRagdoll )
		{
			m_hRagdoll->GetBaseAnimating()->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
		}
	}

	CBaseEntity *pAttacker = info.GetAttacker();

	if ( pAttacker )
	{
		int iScoreToAdd = 1;

		if ( pAttacker == this )
		{
			iScoreToAdd = -1;
		}

		if ( !DHLRules()->IsGameWaiting() ) //DHL
		{
			GetGlobalTeam( pAttacker->GetTeamNumber() )->AddScore( iScoreToAdd );
		}
	}

	FlashlightTurnOff();

	m_lifeState = LIFE_DEAD;

	RemoveEffects( EF_NODRAW );	// still draw player body
	StopZooming();
}
bool CHL2MP_Player::HandleCommand_JoinTeam( int team )
{
#ifndef GE_DLL
    if ( !GetGlobalTeam( team ) || team == 0 )
    {
        Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team );
        return false;
    }

    if ( team == TEAM_SPECTATOR )
    {
        // Prevent this is the cvar is set
        if ( !mp_allowspectators.GetInt() )
        {
            ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" );
            return false;
        }

        if ( GetTeamNumber() != TEAM_UNASSIGNED && !IsDead() )
        {
            m_fNextSuicideTime = gpGlobals->curtime;	// allow the suicide to work

            CommitSuicide();

            // add 1 to frags to balance out the 1 subtracted for killing yourself
            IncrementFragCount( 1 );
        }

        ChangeTeam( TEAM_SPECTATOR );

        return true;
    }
    else
    {
        StopObserverMode();
        State_Transition(STATE_ACTIVE);
    }

    // Switch their actual team...
    ChangeTeam( team );

    return true;
#else
    return false;
#endif
}
Пример #15
0
void CReplayManager::AddMatchEvent(match_event_t type, int team, CSDKPlayer *pPlayer1, CSDKPlayer *pPlayer2/* = NULL*/, CSDKPlayer *pPlayer3/* = NULL*/)
{
	MatchEvent *pMatchEvent = new MatchEvent;

	if (type == MATCH_EVENT_GOAL || type == MATCH_EVENT_OWNGOAL || type == MATCH_EVENT_MISS || type == MATCH_EVENT_KEEPERSAVE || type == MATCH_EVENT_REDCARD)
	{
		float replayStartTime = GetReplayStartTime() + 1.0f;

		for (int i = 0; i < m_Snapshots.Count(); i++)
		{
			if (m_Snapshots[i]->snaptime >= replayStartTime)
			{
				pMatchEvent->snapshots.AddToTail(m_Snapshots[i]);
				m_Snapshots[i]->replayCount += 1;
			}
		}

		pMatchEvent->snapshotEndTime = gpGlobals->curtime + 1.0f;
	}
	else
		pMatchEvent->snapshotEndTime = 0;
	
	pMatchEvent->matchPeriod = SDKGameRules()->State_Get();
	pMatchEvent->matchEventType = type;
	pMatchEvent->second = SDKGameRules()->GetMatchDisplayTimeSeconds();
	pMatchEvent->team = team;
	pMatchEvent->atMinGoalPos = GetMatchBall()->GetPos().y < SDKGameRules()->m_vKickOff.GetY();
	pMatchEvent->pPlayer1Data = pPlayer1 ? pPlayer1->GetPlayerData() : NULL;
	pMatchEvent->pPlayer2Data = pPlayer2 ? pPlayer2->GetPlayerData() : NULL;
	pMatchEvent->pPlayer3Data = pPlayer3 ? pPlayer3->GetPlayerData() : NULL;

	m_MatchEvents.AddToTail(pMatchEvent);

	if (type == MATCH_EVENT_GOAL || type == MATCH_EVENT_OWNGOAL || type == MATCH_EVENT_YELLOWCARD || type == MATCH_EVENT_SECONDYELLOWCARD || type == MATCH_EVENT_REDCARD)
	{
		char matchEventPlayerNames[MAX_MATCH_EVENT_PLAYER_NAME_LENGTH] = {};
		if (pPlayer1 && !pPlayer2 && !pPlayer3)
			Q_strncpy(matchEventPlayerNames, UTIL_VarArgs("%s", pPlayer1->GetPlayerName()), MAX_MATCH_EVENT_PLAYER_NAME_LENGTH);
		else if (pPlayer1 && pPlayer2 && !pPlayer3)
			Q_strncpy(matchEventPlayerNames, UTIL_VarArgs("%.15s (%.15s)", pPlayer1->GetPlayerName(), pPlayer2->GetPlayerName()), MAX_MATCH_EVENT_PLAYER_NAME_LENGTH);
		else if (pPlayer1 && pPlayer2 && pPlayer3)
			Q_strncpy(matchEventPlayerNames, UTIL_VarArgs("%.10s (%.10s, %.10s)", pPlayer1->GetPlayerName(), pPlayer2->GetPlayerName(), pPlayer3->GetPlayerName()), MAX_MATCH_EVENT_PLAYER_NAME_LENGTH);

		GetGlobalTeam(pMatchEvent->team)->AddMatchEvent(pMatchEvent->matchPeriod, pMatchEvent->second, pMatchEvent->matchEventType, matchEventPlayerNames);
	}
}
Пример #16
0
void CHL2MP_Player::Event_Killed( const CTakeDamageInfo &info )
{
	//update damage info with our accumulated physics force
	CTakeDamageInfo subinfo = info;
	subinfo.SetDamageForce( m_vecTotalBulletForce );

	//BP empêche de créer un ragdoll si on change de team en mode spectateur
	if(GetTeamNumber() != TEAM_SPECTATOR)
		CreateRagdollEntity();

	BaseClass::Event_Killed( subinfo );

	if ( info.GetDamageType() & DMG_DISSOLVE )
		if ( m_hRagdoll )
			m_hRagdoll->GetBaseAnimating()->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );

	CBaseEntity *pAttacker = info.GetAttacker();
	if ( pAttacker )
	{
		int iScoreToAdd = 1;

		if ( pAttacker == this)
		{
			if(HL2MPRules()->GetGameType() == GAME_TDM)
				iScoreToAdd = 0;
			else
				iScoreToAdd = -1;
		}

		if((HL2MPRules()->GetGameType() == GAME_FORTS) || (HL2MPRules()->GetGameType() == GAME_PUSH))
			iScoreToAdd = 0;

		GetGlobalTeam( pAttacker->GetTeamNumber() )->AddScore( iScoreToAdd );
	}

	FlashlightTurnOff();

	m_lifeState = LIFE_DEAD;

	RemoveEffects( EF_NODRAW );	// still draw player body
	StopZooming();
	DetonateTripmines();
//BP enregistre le tueur
	SetKiller(info.GetAttacker());
}
Пример #17
0
void CSDKPlayer::State_Enter_OBSERVER_MODE()
{
	// Always start a spectator session in roaming mode
	m_iObserverLastMode = OBS_MODE_ROAMING;

	if( m_hObserverTarget == NULL )
	{
		// find a new observer target
		CheckObserverSettings();
	}

	// Change our observer target to the nearest teammate
	CTeam *pTeam = GetGlobalTeam( GetTeamNumber() );

	CBasePlayer *pPlayer;
	Vector localOrigin = GetAbsOrigin();
	Vector targetOrigin;
	float flMinDist = FLT_MAX;
	float flDist;

	for ( int i=0;i<pTeam->GetNumPlayers();i++ )
	{
		pPlayer = pTeam->GetPlayer(i);

		if ( !pPlayer )
			continue;

		if ( !IsValidObserverTarget(pPlayer) )
			continue;

		targetOrigin = pPlayer->GetAbsOrigin();

		flDist = ( targetOrigin - localOrigin ).Length();

		if ( flDist < flMinDist )
		{
			m_hObserverTarget.Set( pPlayer );
			flMinDist = flDist;
		}
	}

	StartObserverMode( m_iObserverLastMode );
	PhysObjectSleep();
}
Пример #18
0
bool CHL2MP_Player::HandleCommand_JoinTeam( int team )
{
	if ( !GetGlobalTeam( team ) || team == 0 )
	{
		Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team );
		return false;
	}

	if ( team == TEAM_SPECTATOR )
	{
		// Prevent this is the cvar is set
		if ( !mp_allowspectators.GetInt() )
		{
			ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" );
			return false;
		}

		if ( /*GetTeamNumber() != TEAM_UNASSIGNED &&*/ !IsDead() ) //DHL - Skillet - Players in deathmatch are unassigned
		{
			m_fNextSuicideTime = gpGlobals->curtime;	// allow the suicide to work

			CommitSuicide();

			// add 1 to frags to balance out the 1 subtracted for killing yourself
			IncrementFragCount( 1 );
			GetTeam()->AddScore( 1 ); //DHL - Skillet - Required to keep the scoreboard headers from getting out of sync
		}

		ChangeTeam( TEAM_SPECTATOR );

		return true;
	}
	else
	{
		StopObserverMode();
		State_Transition(STATE_ACTIVE);
	}

	// Switch their actual team...
	ChangeTeam( team );

	return true;
}
Пример #19
0
// Display all the Team Scores
void TeamFortress_TeamShowScores(BOOL bLong, CBasePlayer *pPlayer)
{
	for (int i = 1; i < g_Teams.Count(); i++)
	{
		if (!bLong)
		{
			// Dump short scores
			UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs("%s: %d\n", g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) );
		}
		else
		{
			// Dump long scores
			if (pPlayer == NULL)
				UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs("Team %d (%s): %d\n", i, g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) );
			else // Print to just one client
				ClientPrint( pPlayer, HUD_PRINTNOTIFY,  UTIL_VarArgs("Team %d (%s): %d\n", i, g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) );
		}
	}
}
Пример #20
0
//-----------------------------------------------------------------------------------------------------
int CFuncNavBlocker::DrawDebugTextOverlays( void )
{
	int offset = BaseClass::DrawDebugTextOverlays();

	if (m_debugOverlays & OVERLAY_TEXT_BIT) 
	{
		CFmtStr str;

		// FIRST_GAME_TEAM skips TEAM_SPECTATOR and TEAM_UNASSIGNED, so we can print
		// useful team names in a non-game-specific fashion.
		for ( int i=FIRST_GAME_TEAM; i<FIRST_GAME_TEAM + MAX_NAV_TEAMS; ++i )
		{
			if ( IsBlockingNav( i ) )
			{
				CTeam *team = GetGlobalTeam( i );
				if ( team )
				{
					EntityText( offset++, str.sprintf( "blocking team %s", team->GetName() ), 0 );
				}
				else
				{
					EntityText( offset++, str.sprintf( "blocking team %d", i ), 0 );
				}
			}
		}

		NavAreaCollector collector( true );
		Extent extent;
		extent.Init( this );
		TheNavMesh->ForAllAreasOverlappingExtent( collector, extent );

		for ( int i=0; i<collector.m_area.Count(); ++i )
		{
			CNavArea *area = collector.m_area[i];
			Extent areaExtent;
			area->GetExtent( &areaExtent );
			debugoverlay->AddBoxOverlay( vec3_origin, areaExtent.lo, areaExtent.hi, vec3_angle, 0, 255, 0, 10, NDEBUG_PERSIST_TILL_NEXT_SERVER );
		}
	}

	return offset;
}
Пример #21
0
void CSF132FlagBase::OnScore()
{
	CTeam *pTeam = GetGlobalTeam((GetTeamNumber() == SDK_TEAM_RED) ? SDK_TEAM_BLUE : SDK_TEAM_RED);
	if ( !pTeam )
	{
		Error( "Flag has no team" );
	}

	pTeam->AddCapturePoints( FLAG_CLASSIC_CAPTURE_POINTS );

	switch( GetTeamNumber() )
	{
		case SDK_TEAM_BLUE:
			PlaySound( FLAG_RED_SCORE );
			break;

		case SDK_TEAM_RED:
			PlaySound( FLAG_BLUE_SCORE );
			break;
	}
}
void CHL1MP_Player::SetPlayerTeamModel( void )
{
	int iTeamNum = GetTeamNumber();

	if ( iTeamNum <= TEAM_SPECTATOR )
		return;

	CTeam * pTeam = GetGlobalTeam( iTeamNum );

	char szModelName[256];
	Q_snprintf( szModelName, 256, "%s%s/%s.mdl", s_szModelPath, pTeam->GetName(), pTeam->GetName() );

    // Check to see if the model was properly precached, do not error out if not.
    int i = modelinfo->GetModelIndex( szModelName );
    if ( i == -1 )
    {
        Warning("Model %s does not exist.\n", szModelName );
        return;
    }
        
	SetModel( szModelName );
	m_flNextModelChangeTime = gpGlobals->curtime + 5;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDoDHudHealth::OnThink()
{
	BaseClass::OnThink();

	C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
	if ( pPlayer )
	{
		int nTeam = pPlayer->GetTeamNumber();

		if ( nTeam == TEAM_ALLIES || nTeam == TEAM_AXIS )
		{
			C_DODTeam *pTeam = dynamic_cast<C_DODTeam *>( GetGlobalTeam( nTeam ) );
			C_DOD_PlayerResource *dod_PR = dynamic_cast<C_DOD_PlayerResource *>( g_PR );
			int nClass = dod_PR->GetPlayerClass( GetLocalPlayerIndex() );

			if ( nClass != PLAYERCLASS_UNDEFINED )
			{
				if ( ( nClass != m_nPrevClass ) ||
					( nTeam != TEAM_INVALID && ( nTeam == TEAM_AXIS || nTeam == TEAM_ALLIES ) && nTeam != m_nPrevTeam ) )
				{
					m_nPrevClass = nClass;
					m_nPrevTeam = nTeam;

					if ( m_pClassImage )
					{
						m_pClassImage->SetImage( ( pTeam->GetPlayerClassInfo( nClass ) ).m_szClassHealthImage );
					}

					if ( m_pClassImageBG )
					{
						m_pClassImageBG->SetImage( ( pTeam->GetPlayerClassInfo( nClass ) ).m_szClassHealthImageBG );
					}
				}
			}
		}
	}
}
Пример #24
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pTeam - 
//-----------------------------------------------------------------------------
void CObjectResupply::ChangeTeam( int iTeamNum )
{
	CTFTeam *pExisting = (CTFTeam*)GetTeam();
	CTFTeam *pTeam = (CTFTeam*)GetGlobalTeam( iTeamNum );

	// Already on this team
	if ( GetTeamNumber() == iTeamNum )
		return;

	if ( pExisting )
	{
		// Remove it from current team ( if it's in one ) and give it to new team
		pExisting->RemoveResupply( this );
	}
		
	// Change to new team
	BaseClass::ChangeTeam( iTeamNum );
	
	// Add this object to the team's list
	if (pTeam)
	{
		pTeam->AddResupply( this );
	}
}
Пример #25
0
//-----------------------------------------------------------------------------
// Purpose: Get a pointer to the specified TF team manager
//-----------------------------------------------------------------------------
CBliinkTeam *GetGlobalSDKTeam( int iIndex )
{
	return (CBliinkTeam*)GetGlobalTeam( iIndex );
}
Пример #26
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayerResource::UpdatePlayerData( void )
{
	int pingSum[2] = { 0 };
	int pingPlayers[2] = { 0 };

	for (int i = 1; i <= gpGlobals->maxClients; i++)
	{
		CSDKPlayer *pPl = ToSDKPlayer(UTIL_PlayerByIndex(i));
		if (!pPl || !pPl->IsConnected())
		{
			m_bConnected.Set(i, 0);
			continue;
		}
		
		m_bConnected.Set( i, 1 );
		m_iTeam.Set( i, pPl->GetTeamNumber() );

		m_nSpecTeam.Set( i, pPl->GetSpecTeam() );
		m_TeamPosIndex.Set(i, pPl->GetTeamPosIndex() );
		m_ShirtNumber.Set(i, pPl->GetShirtNumber() );
		m_SkinIndex.Set(i, pPl->GetSkinIndex() );
		m_TeamToJoin.Set(i, pPl->GetTeamToJoin() );
		m_TeamPosIndexToJoin.Set(i, pPl->GetTeamPosIndexToJoin() );
		m_NextCardJoin.Set(i, pPl->GetNextCardJoin() );
		m_IsAway.Set(i, pPl->IsAway() );
		m_szPlayerNames.Set(i, MAKE_STRING(pPl->GetPlayerName()));
		m_CountryIndices.Set(i, pPl->GetCountryIndex());
		m_NationalityIndices.Set(i, pPl->GetNationalityIndex());
		m_szClubNames.Set(i, MAKE_STRING(pPl->GetClubName()));
		m_szNationalTeamNames.Set(i, MAKE_STRING(pPl->GetNationalTeamName()));
		m_szShirtNames.Set(i, MAKE_STRING(pPl->GetShirtName()));

		// We're dealing with arrays of char pointers which point to the char array of the player object variable.
		// Keep track of variable changes with a boolean variable so we know when to send an update to the clients.

		if (pPl->m_bPlayerNameChanged)
		{
			m_szPlayerNames.GetForModify(i);
			pPl->m_bPlayerNameChanged = false;
		}

		if (pPl->m_bClubNameChanged)
		{
			m_szClubNames.GetForModify(i);
			pPl->m_bClubNameChanged = false;
		}

		if (pPl->m_bNationalTeamNameChanged)
		{
			m_szNationalTeamNames.GetForModify(i);
			pPl->m_bNationalTeamNameChanged = false;
		}

		if (pPl->m_bShirtNameChanged)
		{
			m_szShirtNames.GetForModify(i);
			pPl->m_bShirtNameChanged = false;
		}

		// Don't update statistics every time

		if (m_nUpdateCounter % 20 == 0)
		{
			// update ping all 20 think ticks = (20*0.1=2seconds)
			int ping, packetloss;
			UTIL_GetPlayerConnectionInfo( i, ping, packetloss );

			// calc avg for scoreboard so it's not so jittery
			ping = 0.8f * m_iPing.Get(i) + 0.2f * ping;

			m_iPing.Set( i, ping );
			// m_iPacketloss.Set( i, packetloss );

			m_RedCards.Set(i, max( 0, pPl->GetRedCards() ) );
			m_YellowCards.Set(i, max( 0, pPl->GetYellowCards() ) );
			m_Fouls.Set(i, max( 0, pPl->GetFouls() ) );
			m_FoulsSuffered.Set(i, max( 0, pPl->GetFoulsSuffered() ) );
			m_SlidingTackles.Set(i, max( 0, pPl->GetSlidingTackles() ) );
			m_SlidingTacklesCompleted.Set(i, max( 0, pPl->GetSlidingTacklesCompleted() ) );
			m_GoalsConceded.Set(i, max( 0, pPl->GetGoalsConceded() ) );
			m_Shots.Set(i, max( 0, pPl->GetShots() ) );
			m_ShotsOnGoal.Set(i, max( 0, pPl->GetShotsOnGoal() ) );
			m_PassesCompleted.Set(i, max( 0, pPl->GetPassesCompleted() ) );
			m_Interceptions.Set(i, max( 0, pPl->GetInterceptions() ) );
			m_Offsides.Set(i, max( 0, pPl->GetOffsides() ) );
			m_Goals.Set(i, max( 0, pPl->GetGoals() ) );
			m_OwnGoals.Set(i, max( 0, pPl->GetOwnGoals() ) );
			m_Assists.Set(i, max( 0, pPl->GetAssists() ) );
			m_Possession.Set(i, max( 0, pPl->GetPossession() ) );
			m_DistanceCovered.Set(i, max( 0, pPl->GetDistanceCovered() ) );
			m_Passes.Set(i, max( 0, pPl->GetPasses() ) );
			m_FreeKicks.Set(i, max( 0, pPl->GetFreeKicks() ) );
			m_Penalties.Set(i, max( 0, pPl->GetPenalties() ) );
			m_Corners.Set(i, max( 0, pPl->GetCorners() ) );
			m_ThrowIns.Set(i, max( 0, pPl->GetThrowIns() ) );
			m_KeeperSaves.Set(i, max( 0, pPl->GetKeeperSaves() ) );
			m_KeeperSavesCaught.Set(i, max( 0, pPl->GetKeeperSavesCaught() ) );
			m_GoalKicks.Set(i, max( 0, pPl->GetGoalKicks() ) );
			//m_Ratings.Set(i, max( 0, pPl->GetRating() ) );
			m_Ratings.Set(i, 100 );

			if (pPl->GetTeamNumber() == TEAM_HOME || pPl->GetTeamNumber() == TEAM_AWAY)
			{
				int ti = pPl->GetTeamNumber() - TEAM_HOME;

				if (ping > 0)
				{
					pingSum[ti] += ping;
					pingPlayers[ti] += 1;
				}
			}
		}
	}

	for (int team = TEAM_HOME; team <= TEAM_AWAY; team++)
	{
		int ti = team - TEAM_HOME;
		CTeam *pTeam = GetGlobalTeam(team);

		if (m_nUpdateCounter % 20 == 0)
		{
			pTeam->m_Ping = pingSum[ti] / max(1, pingPlayers[ti]);
			pTeam->m_Rating = 100;
		}
	}
}
Пример #27
0
void CHL2MPRules::RestartGame()
{
    // bounds check
    if ( mp_timelimit.GetInt() < 0 )
    {
        mp_timelimit.SetValue( 0 );
    }
    m_flGameStartTime = gpGlobals->curtime;
    if ( !IsFinite( m_flGameStartTime.Get() ) )
    {
        Warning( "Trying to set a NaN game start time\n" );
        m_flGameStartTime.GetForModify() = 0.0f;
    }

    CleanUpMap();

    // now respawn all players
    for (int i = 1; i <= gpGlobals->maxClients; i++ )
    {
        CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

        if ( !pPlayer )
            continue;

        if ( pPlayer->GetActiveWeapon() )
        {
            pPlayer->GetActiveWeapon()->Holster();
        }
        pPlayer->RemoveAllItems( true );
        respawn( pPlayer, false );
        pPlayer->Reset();
    }

    // Respawn entities (glass, doors, etc..)

    CTeam *pRebels = GetGlobalTeam( TEAM_REBELS );
    CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE );

    if ( pRebels )
    {
        pRebels->SetScore( 0 );
    }

    if ( pCombine )
    {
        pCombine->SetScore( 0 );
    }

    m_flIntermissionEndTime = 0;
    m_flRestartGameTime = 0.0;
    m_bCompleteReset = false;

    IGameEvent * event = gameeventmanager->CreateEvent( "round_start" );
    if ( event )
    {
        event->SetInt("fraglimit", 0 );
        event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted

        event->SetString("objective","DEATHMATCH");

        gameeventmanager->FireEvent( event );
    }
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::BreakCapture( bool bNotEnoughPlayers )
{
	if( m_bCapturing )
	{
		// Remap team to get first game team = 1
		switch ( m_nCapturingTeam - FIRST_GAME_TEAM+1 )
		{
		case 1: 
			m_OnBreakTeam1.FireOutput( this, this );
			break;
		case 2: 
			m_OnBreakTeam2.FireOutput( this, this );
			break;
		default:
			Assert(0);
			break;
		}

		m_BreakOutput.FireOutput(this,this);

		m_bCapturing = false;
		m_nCapturingTeam = TEAM_UNASSIGNED;

		UpdateCappingTeam( TEAM_UNASSIGNED );

		if ( bNotEnoughPlayers )
		{
			IncrementCapAttemptNumber();
		}

		SetCapTimeRemaining( 0 );

		if( m_hPoint )
		{
			m_hPoint->CaptureEnd();

			// The point reverted to it's previous owner.
			IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_capture_broken" );
			if ( event )
			{
				event->SetInt( "cp", m_hPoint->GetPointIndex() );
				event->SetString( "cpname", m_hPoint->GetName() );
				event->SetFloat( "time_remaining", m_fTimeRemaining );
				gameeventmanager->FireEvent( event );
			}
		}

		SetNumCappers( 0 );

		// tell all touching players to stop racking up capture points
		CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam );
		if ( pTeam )
		{
			for ( int i=0;i<pTeam->GetNumPlayers();i++ )
			{
				CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) );
				if ( pPlayer && IsTouching( pPlayer ) )
				{
					pPlayer->StopScoringEscortPoints();					
				}
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::EndCapture( int team )
{
	IncrementCapAttemptNumber();

	// Remap team to get first game team = 1
	switch ( team - FIRST_GAME_TEAM+1 )
	{
	case 1: 
		m_OnCapTeam1.FireOutput( this, this );
		break;
	case 2: 
		m_OnCapTeam2.FireOutput( this, this );
		break;
	default:
		Assert(0);
		break;
	}

	m_CapOutput.FireOutput(this,this);

	int numcappers = 0;
	int cappingplayers[MAX_AREA_CAPPERS];

	GetNumCappingPlayers( team, numcappers, cappingplayers );

	// Handle this before we assign the new team as the owner of this area
	HandleRespawnTimeAdjustments( m_nOwningTeam, team );
		
	m_nOwningTeam = team;
	m_bCapturing = false;
	m_nCapturingTeam = TEAM_UNASSIGNED;
	SetCapTimeRemaining( 0 );

	//there may have been more than one capper, but only report this one.
	//he hasn't gotten points yet, and his name will go in the cap string if its needed
	//first capper gets name sent and points given by flag.
	//other cappers get points manually above, no name in message

	//send the player in the cap string
	if( m_hPoint )
	{
		OnEndCapture( m_nOwningTeam );

		UpdateOwningTeam();
		m_hPoint->SetOwner( m_nOwningTeam, true, numcappers, cappingplayers );
		m_hPoint->CaptureEnd();
	}

	SetNumCappers( 0 );

	// tell all touching players to stop racking up capture points
	CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam );
	if ( pTeam )
	{
		for ( int i=0;i<pTeam->GetNumPlayers();i++ )
		{
			CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) );
			if ( pPlayer && IsTouching( pPlayer ) )
			{	
				pPlayer->StopScoringEscortPoints();					
			}
		}
	}

	// play any special cap sounds
	if ( TeamplayRoundBasedRules() )
	{
		TeamplayRoundBasedRules()->PlaySpecialCapSounds( m_nOwningTeam );
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerAreaCapture::StartCapture( int team, int capmode )
{
	// Remap team to get first game team = 1
	switch ( team - FIRST_GAME_TEAM+1 )
	{
	case 1: 
		m_OnStartTeam1.FireOutput( this, this );
		break;
	case 2: 
		m_OnStartTeam2.FireOutput( this, this );
		break;
	default:
		Assert(0);
		break;
	}

	m_StartOutput.FireOutput(this,this);
	
	m_nCapturingTeam = team;

	UpdateNumPlayers();

	if ( CaptureModeScalesWithPlayers() )
	{
		SetCapTimeRemaining( ((m_flCapTime * 2) * m_TeamData[team].iNumRequiredToCap) );
	}
	else
	{
		SetCapTimeRemaining( m_flCapTime );
	}
	m_bCapturing = true;
	m_bBlocked = false;
	m_iCapMode = capmode;

	m_flLastReductionTime = gpGlobals->curtime;

	UpdateCappingTeam( m_nCapturingTeam );
	UpdateBlocked();

	if( m_hPoint )
	{
		int numcappers = 0;
		int cappingplayers[MAX_AREA_CAPPERS];

		GetNumCappingPlayers( m_nCapturingTeam, numcappers, cappingplayers );
		m_hPoint->CaptureStart( m_nCapturingTeam, numcappers, cappingplayers );
	}

	// tell all touching players to start racking up capture points
	CTeamControlPointMaster *pMaster = g_hControlPointMasters.Count() ? g_hControlPointMasters[0] : NULL;
	if ( pMaster )
	{
		float flRate = pMaster->GetPartialCapturePointRate();

		if ( flRate > 0.0f )
		{
			// for each player touch
			CTeam *pTeam = GetGlobalTeam( m_nCapturingTeam );
			if ( pTeam )
			{
				for ( int i=0;i<pTeam->GetNumPlayers();i++ )
				{
					CBaseMultiplayerPlayer *pPlayer = ToBaseMultiplayerPlayer( pTeam->GetPlayer(i) );
					if ( pPlayer && IsTouching( pPlayer ) )
					{
						pPlayer->StartScoringEscortPoints( flRate );
					}
				}
			}
		}		
	}
}