cl_dll/hltvcamera.cpp
330331332333334335
eyeAngles = m_aCamAngle;
fov = m_flFOV;
pPlayer->CalcViewModelView( eyeOrigin, eyeAngles);
C_BaseViewModel *pViewModel = pPlayer->GetViewModel( 0 );
330331332333334335336337338
eyeAngles = m_aCamAngle;
fov = m_flFOV;
float zNear,zFar;
pPlayer->CalcView(eyeOrigin, eyeAngles, zNear, zFar, fov);
pPlayer->CalcViewModelView( eyeOrigin, eyeAngles);
C_BaseViewModel *pViewModel = pPlayer->GetViewModel( 0 );
439440441442443444445446447448
Assert( iMode > OBS_MODE_NONE && iMode <= OBS_MODE_ROAMING );
m_nCameraMode = iMode;
}
void C_HLTVCamera::SetPrimaryTarget( int nEntity )
{
if ( m_iTraget1 == nEntity )
return;
442443444445446447448449450451452453454455456457458459460461
Assert( iMode > OBS_MODE_NONE && iMode <= OBS_MODE_ROAMING );
m_nCameraMode = iMode;
// update spectator name when you change mode
IViewPortPanel *spectator = gViewPortInterface->FindPanelByName( PANEL_SPECGUI );
if ( spectator && spectator->IsVisible() )
{
spectator->Update();
}
}
void C_HLTVCamera::SetPrimaryTarget( int nEntity )
{
if (!IsValidObserverTarget( nEntity ))
return;
if ( m_iTraget1 == nEntity )
return;
471472473474475476477478
m_flLastDistance = m_flDistance;
m_flLastAngleUpdateTime = -1;
}
void C_HLTVCamera::SpecNextPlayer( bool bInverse )
{
int start = 1;
484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
m_flLastDistance = m_flDistance;
m_flLastAngleUpdateTime = -1;
// update spectator name when you change target
IViewPortPanel *spectator = gViewPortInterface->FindPanelByName( PANEL_SPECGUI );
if ( spectator && spectator->IsVisible() )
{
spectator->Update();
}
}
bool C_HLTVCamera::IsValidObserverTarget( int nEntity )
{
if ( nEntity <= 0 || nEntity > gpGlobals->maxClients )
return false;
C_BasePlayer *pPlayer = UTIL_PlayerByIndex( nEntity );
if ( !pPlayer )
return false;
// only follow living players
if ( pPlayer->IsObserver() )
return false;
/* Don't spec observers or players who haven't picked a class yet
if ( player->IsObserver() )
return false; */
if( pPlayer == C_BasePlayer::GetLocalPlayer() )
return false; // We can't observe ourselves.
// gibbed players have EF_NODRAW effect active, so make an exception for LIFE_DEAD players
if ( pPlayer->m_lifeState != LIFE_DEAD && pPlayer->m_lifeState != LIFE_RESPAWNABLE && pPlayer->IsEffectActive( EF_NODRAW ) ) // don't watch invisible players
return false;
// 0001670: Player you are spectating changes when they die
// Commenting out the death check as dead players are actually valid targets (since they respawn almost instantly anyway...)
// Might want to alter this to be controllable by lua in future as certain game types may not allow respawning -> Defrag
//if ( player->m_lifeState == LIFE_RESPAWNABLE ) // target is dead, waiting for respawn
// return false;
return true; // passed all test
}
void C_HLTVCamera::SpecNextPlayer( bool bInverse )
{
int start = 1;
499500501502503504505506507508509510511512513
if ( index == start )
break; // couldn't find a new valid player
C_BasePlayer *pPlayer = UTIL_PlayerByIndex( index );
if ( !pPlayer )
continue;
// only follow living players
if ( pPlayer->IsObserver() )
continue;
break; // found a new player
}
554555556557558559560561562
if ( index == start )
break; // couldn't find a new valid player
if (!IsValidObserverTarget( index ))
continue;
break; // found a new player
}