void CHL2MP_Player::State_Enter_OBSERVER_MODE() { int observerMode = m_iObserverLastMode; if ( IsNetClient() ) { const char *pIdealMode = engine->GetClientConVarValue( engine->IndexOfEdict( edict() ), "cl_spec_mode" ); if ( pIdealMode ) { observerMode = atoi( pIdealMode ); if ( observerMode <= OBS_MODE_FIXED || observerMode > OBS_MODE_ROAMING ) { observerMode = m_iObserverLastMode; } } } m_bEnterObserver = true; StartObserverMode( observerMode ); }
void CSDKPlayer::State_Enter_DEATH_ANIM() { if ( HasWeapons() ) { // we drop the guns here because weapons that have an area effect and can kill their user // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the // player class sometimes is freed. It's safer to manipulate the weapons once we know // we aren't calling into any of their code anymore through the player pointer. PackDeadPlayerItems(); } // Used for a timer. m_flDeathTime = gpGlobals->curtime; StartObserverMode( OBS_MODE_DEATHCAM ); // go to observer mode RemoveEffects( EF_NODRAW ); // still draw player body }
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 ( 0 && !IsDead() ) // Don't want to be killed and repop { 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 ); StartObserverMode( OBS_MODE_ROAMING ); } ChangeTeam( TEAM_SPECTATOR ); return true; } else { StopObserverMode(); State_Transition(STATE_ACTIVE); } // Switch their actual team... ChangeTeam( team ); return true; }
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(); }