示例#1
0
bool C_PlayerResource::IsLocalPlayer(int index)
{
	C_BasePlayer *pPlayer =	C_BasePlayer::GetLocalPlayer();

	if ( !pPlayer )
		return false;

	return ( index == pPlayer->entindex() );
}
示例#2
0
int GetLocalPlayerIndex( void )
{
	C_BasePlayer * player = C_BasePlayer::GetLocalPlayer();

	if ( player )
		return player->entindex();
	else
		return  0;	// game not started yet
}
示例#3
0
//-----------------------------------------------------------------------------
// Main draw entry point
//-----------------------------------------------------------------------------
int	C_Shield::DrawModel( int flags )
{
	if ( !m_bReadyToDraw )
		return 0;

	if (m_FadeValue == 0.0f)
		return 1;

	// If I have no power, don't draw
	if ( m_flPowerLevel <= 0 )
		return 1;

	// Make it curvy or not!!
	m_SplinePatch.SetLinearBlend( m_CurveValue );

	// Set up the patch with all the data it's going to need
	int count = Width() * Height();
 	Vector const** pControlPoints = (Vector const**)stackalloc(count * sizeof(Vector*));
	float* pControlOpacity = (float*)stackalloc(count * sizeof(float));
	float* pControlBlend = (float*)stackalloc(count * sizeof(float));

	GetShieldData( pControlPoints, pControlOpacity, pControlBlend );
	m_SplinePatch.SetControlPositions( pControlPoints );
	m_SplinePatch.SetChannelData( 0, pControlOpacity );
	m_SplinePatch.SetChannelData( 1, pControlBlend );

//	DrawWireframeModel( pControlPoints );

	// Allocate space for temporary data
	int numSubdivisions = m_SubdivisionCount * m_SubdivisionCount;
	Vector* pt = (Vector*)stackalloc(numSubdivisions * sizeof(Vector));
	Vector* normal = (Vector*)stackalloc(numSubdivisions * sizeof(Vector));
	float* opacity = (float*)stackalloc(numSubdivisions * sizeof(float));

	// Do something a little special if this shield is owned by the local player
	C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
	m_ShieldOwnedByLocalPlayer = (player->entindex() == m_nOwningPlayerIndex);
	if (m_ShieldOwnedByLocalPlayer)
	{
		QAngle viewAngles;
		engine->GetViewAngles(viewAngles);
		AngleVectors( viewAngles, &m_ViewDir );
	}

	ComputeShieldPoints( pt, normal, opacity );
	RippleShieldPoints( pt, opacity );

	// Commented out because it causes things to not be drawn behind it
//	DrawShieldDecals( pt, false );

    DrawShieldPoints( pt, normal, opacity );
	DrawShieldDecals( pt, true );

	return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Adds a new row to the scoreboard, from the playerinfo structure
//-----------------------------------------------------------------------------
bool CHL2MPClientScoreBoardDialog::GetPlayerScoreInfo(int playerIndex, KeyValues *kv)
{
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	if ( !pPlayer )
		return false;

	kv->SetInt("playerIndex", playerIndex);
	kv->SetInt("team", g_PR->GetTeam( playerIndex ) );
	kv->SetString("name", g_PR->GetPlayerName(playerIndex) );
	//BG2 - Tjoppen - hide non-local player damage
	//kv->SetInt("deaths", g_PR->GetDeaths( playerIndex ));
	if ( sv_show_damages.GetBool() )
	{
		kv->SetInt("deaths", g_PR->GetDeaths( playerIndex ));
	}
	else
	{
		if( playerIndex == pPlayer->entindex() )
			kv->SetInt("deaths", g_PR->GetDeaths( playerIndex ) );
		else
			kv->SetString("deaths", "" );
	}
	//
	kv->SetInt("frags", g_PR->GetPlayerScore( playerIndex ));
	//BG2 - Tjoppen - dead column
	//kv->SetString("class", "");
	//display for dead participating players
	kv->SetWString("class", !g_PR->IsAlive(playerIndex) && g_PR->GetTeam(playerIndex) >= TEAM_AMERICANS ? g_pVGuiLocalize->Find("#DEAD") : g_pVGuiLocalize->Find("#ALIVE"));
	//
	
	if (g_PR->GetPing( playerIndex ) < 1)
	{
		if ( g_PR->IsFakePlayer( playerIndex ) )
		{
			kv->SetString("ping", "BOT");
		}
		else
		{
			kv->SetString("ping", "");
		}
	}
	else
	{
		kv->SetInt("ping", g_PR->GetPing( playerIndex ));
	}
	
	return true;
}
示例#5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseHudChat::FireGameEvent( IGameEvent *event )
{
#ifndef _XBOX
	const char *eventname = event->GetName();

	if ( Q_strcmp( "hltv_chat", eventname ) == 0 )
	{
		C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();

		if ( !player )
			return;
		
		ChatPrintf( player->entindex(), CHAT_FILTER_NONE, "(SourceTV) %s", event->GetString( "text" ) );
	}
#endif
}
示例#6
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudTeamSwitch::FireGameEvent( IGameEvent * event )
{
	const char *pEventName = event->GetName();

	if ( Q_strcmp( "teamplay_teambalanced_player", pEventName ) == 0 )
	{
		int iPlayer = event->GetInt( "player" );
		int iNewTeam = event->GetInt( "team" );
		C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			SetupSwitchPanel( iNewTeam );
			m_flHideAt = gpGlobals->curtime + 10.0;
			SetVisible( true );
		}
	}
}
示例#7
0
//-----------------------------------------------------------------------------
void CSDKMapOverview::Update( void )
{
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	if ( !pPlayer )
		return;

	int team = pPlayer->GetTeamNumber();

	// if dead with fadetoblack on, we can't show anything
	if ( mp_fadetoblack.GetBool() && team > TEAM_SPECTATOR && !pPlayer->IsAlive() )
	{
		SetMode( MAP_MODE_OFF );
		return;
	}

	BaseClass::Update();

	if ( GetSpectatorMode() == OBS_MODE_CHASE )
	{
		// Follow the local player in chase cam, so the map rotates using the local player's angles
		SetFollowEntity( pPlayer->entindex() );
	}
}
示例#8
0
文件: view.cpp 项目: EspyEspurr/game
//-----------------------------------------------------------------------------
// Sets up the view parameters
//-----------------------------------------------------------------------------
void CViewRender::SetUpViews()
{
	VPROF("CViewRender::SetUpViews");

	// Initialize view structure with default values
	float farZ = GetZFar();

    // Set up the mono/middle view.
    CViewSetup &view = m_View;

	view.zFar				= farZ;
	view.zFarViewmodel	    = farZ;
	// UNDONE: Make this farther out? 
	//  closest point of approach seems to be view center to top of crouched box
	view.zNear			    = GetZNear();
	view.zNearViewmodel	    = 1;
	view.fov				= default_fov.GetFloat();

	view.m_bOrtho			= false;
    view.m_bViewToProjectionOverride = false;
	view.m_eStereoEye		= STEREO_EYE_MONO;

	// Enable spatial partition access to edicts
	partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, false );

	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	// You in-view weapon aim.
	bool bCalcViewModelView = false;
	Vector ViewModelOrigin;
	QAngle ViewModelAngles;

	if ( engine->IsHLTV() )
	{
		HLTVCamera()->CalcView( view.origin, view.angles, view.fov );
	}
#if defined( REPLAY_ENABLED )
	else if ( g_pEngineClientReplay->IsPlayingReplayDemo() )
	{
		ReplayCamera()->CalcView( view.origin, view.angles, view.fov );
	}
#endif
	else
	{
		// FIXME: Are there multiple views? If so, then what?
		// FIXME: What happens when there's no player?
		if (pPlayer)
		{
			pPlayer->CalcView( view.origin, view.angles, view.zNear, view.zFar, view.fov );

			// If we are looking through another entities eyes, then override the angles/origin for view
			int viewentity = render->GetViewEntity();

			if ( !g_nKillCamMode && (pPlayer->entindex() != viewentity) )
			{
				C_BaseEntity *ve = cl_entitylist->GetEnt( viewentity );
				if ( ve )
				{
					VectorCopy( ve->GetAbsOrigin(), view.origin );
					VectorCopy( ve->GetAbsAngles(), view.angles );
				}
			}

			// There is a viewmodel.
			bCalcViewModelView = true;
			ViewModelOrigin = view.origin;
			ViewModelAngles = view.angles;
		}
		else
		{
			view.origin.Init();
			view.angles.Init();
		}

		// Even if the engine is paused need to override the view
		// for keeping the camera control during pause.
		g_pClientMode->OverrideView( &view );
	}

	// give the toolsystem a chance to override the view
	ToolFramework_SetupEngineView( view.origin, view.angles, view.fov );

	if ( engine->IsPlayingDemo() )
	{
		if ( cl_demoviewoverride.GetFloat() > 0.0f )
		{
			// Retreive view angles from engine ( could have been set in IN_AdjustAngles above )
			CalcDemoViewOverride( view.origin, view.angles );
		}
		else
		{
			s_DemoView = view.origin;
			s_DemoAngle = view.angles;
		}
	}

	//Find the offset our current FOV is from the default value
	float fDefaultFov = default_fov.GetFloat();
	float flFOVOffset = fDefaultFov - view.fov;

	//Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
	view.fovViewmodel = g_pClientMode->GetViewModelFOV() - flFOVOffset;

	if ( UseVR() )
	{
		// Let the headtracking read the status of the HMD, etc.
		// This call can go almost anywhere, but it needs to know the player FOV for sniper weapon zoom, etc
		if ( flFOVOffset == 0.0f )
		{
			g_ClientVirtualReality.ProcessCurrentTrackingState ( 0.0f );
		}
		else
		{
			g_ClientVirtualReality.ProcessCurrentTrackingState ( view.fov );
		}

		HeadtrackMovementMode_t hmmOverrideMode = g_pClientMode->ShouldOverrideHeadtrackControl();
		g_ClientVirtualReality.OverrideView( &m_View, &ViewModelOrigin, &ViewModelAngles, hmmOverrideMode );

		// left and right stereo views should default to being the same as the mono/middle view
		m_ViewLeft = m_View;
		m_ViewRight = m_View;
		m_ViewLeft.m_eStereoEye = STEREO_EYE_LEFT;
		m_ViewRight.m_eStereoEye = STEREO_EYE_RIGHT;

		g_ClientVirtualReality.OverrideStereoView( &m_View, &m_ViewLeft, &m_ViewRight );
	}
	else
	{
		// left and right stereo views should default to being the same as the mono/middle view
		m_ViewLeft = m_View;
		m_ViewRight = m_View;
		m_ViewLeft.m_eStereoEye = STEREO_EYE_LEFT;
		m_ViewRight.m_eStereoEye = STEREO_EYE_RIGHT;
	}

	if ( bCalcViewModelView )
	{
		Assert ( pPlayer != NULL );
		pPlayer->CalcViewModelView ( ViewModelOrigin, ViewModelAngles );
	}

	// Disable spatial partition access
	partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, true );

	// Enable access to all model bones
	C_BaseAnimating::PopBoneAccess( "OnRenderStart->CViewRender::SetUpView" ); // pops the (true, false) bone access set in OnRenderStart
	C_BaseAnimating::PushAllowBoneAccess( true, true, "CViewRender::SetUpView->OnRenderEnd" ); // pop is in OnRenderEnd()

	// Compute the world->main camera transform
    // This is only done for the main "middle-eye" view, not for the various other views.
	ComputeCameraVariables( view.origin, view.angles, 
		&g_vecVForward, &g_vecVRight, &g_vecVUp, &g_matCamInverse );

	// set up the hearing origin...
	AudioState_t audioState;
	audioState.m_Origin = view.origin;
	audioState.m_Angles = view.angles;
	audioState.m_bIsUnderwater = pPlayer && pPlayer->AudioStateIsUnderwater( view.origin );

	ToolFramework_SetupAudioState( audioState );

    // TomF: I wonder when the audio tools modify this, if ever...
    Assert ( view.origin == audioState.m_Origin );
    Assert ( view.angles == audioState.m_Angles );
	view.origin = audioState.m_Origin;
	view.angles = audioState.m_Angles;

	engine->SetAudioState( audioState );

	g_vecPrevRenderOrigin = g_vecRenderOrigin;
	g_vecPrevRenderAngles = g_vecRenderAngles;
	g_vecRenderOrigin = view.origin;
	g_vecRenderAngles = view.angles;

#ifdef DBGFLAG_ASSERT
	s_DbgSetupOrigin = view.origin;
	s_DbgSetupAngles = view.angles;
#endif
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudControlPointIcons::FireGameEvent( IGameEvent *event )
{
	const char *eventname = event->GetName();
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	if ( FStrEq( "controlpoint_initialized", eventname ) )
	{
		// Create our control points
		InitIcons();
		return;
	}

	if ( FStrEq( "controlpoint_updateimages", eventname ) )
	{
		// Update the images of our control point icons
		int iIndex = event->GetInt( "index" );
		if ( iIndex == -1 )
		{
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				m_Icons[i]->UpdateImage();
			}
		}
		else
		{
			// Only invalidate the specified cap point
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				if ( m_Icons[i]->GetCapIndex() == iIndex )
				{
					m_Icons[i]->UpdateImage();
				}
			}
		}
		UpdateProgressBarFor( iIndex );
		return;
	}

	if ( FStrEq( "controlpoint_updatelayout", eventname ) )
	{
		// Update the layout of our control point icons
		int iIndex = event->GetInt( "index" );
		if ( iIndex == -1 )
		{
			InvalidateLayout();
		}
		else
		{
			// Only invalidate the specified cap point
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				if ( m_Icons[i]->GetCapIndex() == iIndex )
				{
					m_Icons[i]->InvalidateLayout();
				}
			}
		}
		UpdateProgressBarFor( iIndex );
		return;
	}

	if ( FStrEq( "controlpoint_updatecapping", eventname ) )
	{
		// Update the capping status of our control point icons
		int iIndex = event->GetInt( "index" );
		if ( iIndex == -1 )
		{
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				m_Icons[i]->UpdateCapImage();
			}
		}
		else
		{
			// Only invalidate the specified cap point
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				if ( m_Icons[i]->GetCapIndex() == iIndex )
				{
					m_Icons[i]->UpdateCapImage();
				}
			}
		}

		UpdateProgressBarFor( iIndex );
		return;
	}

	if ( FStrEq( "controlpoint_starttouch", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			m_iCurrentCP = event->GetInt( "area" );
			UpdateProgressBarFor( m_iCurrentCP );
		}
	}
	else if ( FStrEq( "controlpoint_endtouch", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			m_iCurrentCP = -1;
			UpdateProgressBarFor( m_iCurrentCP );
		}
	}
	else if ( FStrEq( "controlpoint_pulse_element", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			for (int i = 0; i < m_Icons.Count(); i++)
			{
				m_Icons[i]->FakePulse( gpGlobals->curtime + (i * PULSE_TIME_PER_ICON) );
			}
		}
	}
	else if ( FStrEq( "controlpoint_fake_capture", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			m_iCurrentCP = event->GetInt( "int_data" );
			m_bFakingCapture = true;
			m_bFakingCaptureMult = false;
			m_flFakeCaptureTime = gpGlobals->curtime + FAKE_CAPTURE_TIME + FAKE_CAPTURE_POST_PAUSE;
			UpdateProgressBarFor( -1 );
		}
	}
	else if ( FStrEq( "controlpoint_fake_capture_mult", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			m_iCurrentCP = event->GetInt( "int_data" );
			m_bFakingCapture = true;
			m_bFakingCaptureMult = true;
			m_flFakeCaptureTime = gpGlobals->curtime + FAKE_CAPTURE_TIME + FAKE_CAPTURE_POST_PAUSE;
			UpdateProgressBarFor( -1 );
		}
	}
	else if ( FStrEq( "intro_nextcamera", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			m_iCurrentCP = -1;
			m_bFakingCapture = false;
			m_bFakingCaptureMult = false;
			UpdateProgressBarFor( -1 );
		}
	}
	else if ( FStrEq( "intro_finish", eventname ) )
	{
		int iPlayer = event->GetInt( "player" );
		if ( pPlayer && iPlayer == pPlayer->entindex() )
		{
			m_iCurrentCP = -1;
			m_flPulseTime = 0;
			m_bFakingCapture = false;
			m_bFakingCaptureMult = false;

			InitIcons();
		}
	}
}
示例#10
0
文件: view.cpp 项目: torbensko/HAL
//-----------------------------------------------------------------------------
// Sets up the view parameters
//-----------------------------------------------------------------------------
void CViewRender::SetUpView()
{
    VPROF("CViewRender::SetUpView");
    // Initialize view structure with default values
    float farZ = GetZFar();

    m_View.zFar				= farZ;
    m_View.zFarViewmodel	= farZ;
    // UNDONE: Make this farther out?
    //  closest point of approach seems to be view center to top of crouched box
    m_View.zNear			= GetZNear();
    m_View.zNearViewmodel	= 1;
    m_View.fov				= default_fov.GetFloat();

    m_View.m_bOrtho			= false;

    // Enable spatial partition access to edicts
    partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, false );

    C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

    if ( engine->IsHLTV() )
    {
        HLTVCamera()->CalcView( m_View.origin, m_View.angles, m_View.fov );
    }
    else
    {
        // FIXME: Are there multiple views? If so, then what?
        // FIXME: What happens when there's no player?
        if (pPlayer)
        {
            pPlayer->CalcView( m_View.origin, m_View.angles, m_View.zNear, m_View.zFar, m_View.fov );

            // If we are looking through another entities eyes, then override the angles/origin for m_View
            int viewentity = render->GetViewEntity();

            if ( !g_nKillCamMode && (pPlayer->entindex() != viewentity) )
            {
                C_BaseEntity *ve = cl_entitylist->GetEnt( viewentity );
                if ( ve )
                {
                    VectorCopy( ve->GetAbsOrigin(), m_View.origin );
                    VectorCopy( ve->GetAbsAngles(), m_View.angles );
                }
            }

            pPlayer->CalcViewModelView( m_View.origin, m_View.angles );
        }

        // Even if the engine is paused need to override the view
        // for keeping the camera control during pause.
        g_pClientMode->OverrideView( &m_View );
    }

    // give the toolsystem a chance to override the view
    ToolFramework_SetupEngineView( m_View.origin, m_View.angles, m_View.fov );

    if ( engine->IsPlayingDemo() )
    {
        if ( cl_demoviewoverride.GetFloat() > 0.0f )
        {
            // Retreive view angles from engine ( could have been set in IN_AdjustAngles above )
            CalcDemoViewOverride( m_View.origin, m_View.angles );
        }
        else
        {
            s_DemoView = m_View.origin;
            s_DemoAngle = m_View.angles;
        }
    }

    //Find the offset our current FOV is from the default value
    float flFOVOffset = default_fov.GetFloat() - m_View.fov;

    //Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
    m_View.fovViewmodel = g_pClientMode->GetViewModelFOV() - flFOVOffset;

    // Disable spatical partition access
    partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, true );

    // Enable access to all model bones
    C_BaseAnimating::PopBoneAccess( "OnRenderStart->CViewRender::SetUpView" ); // pops the (true, false) bone access set in OnRenderStart
    C_BaseAnimating::PushAllowBoneAccess( true, true, "CViewRender::SetUpView->OnRenderEnd" ); // pop is in OnRenderEnd()

    // Compute the world->main camera transform
    ComputeCameraVariables( m_View.origin, m_View.angles,
                            &g_vecVForward, &g_vecVRight, &g_vecVUp, &g_matCamInverse );

    // set up the hearing origin...
    AudioState_t audioState;
    audioState.m_Origin = m_View.origin;
    audioState.m_Angles = m_View.angles;
    audioState.m_bIsUnderwater = pPlayer && pPlayer->AudioStateIsUnderwater( m_View.origin );

    ToolFramework_SetupAudioState( audioState );

    m_View.origin = audioState.m_Origin;
    m_View.angles = audioState.m_Angles;

    engine->SetAudioState( audioState );

    g_vecPrevRenderOrigin = g_vecRenderOrigin;
    g_vecPrevRenderAngles = g_vecRenderAngles;
    g_vecRenderOrigin = m_View.origin;
    g_vecRenderAngles = m_View.angles;

#ifdef _DEBUG
    s_DbgSetupOrigin = m_View.origin;
    s_DbgSetupAngles = m_View.angles;
#endif
}
示例#11
0
文件: view.cpp 项目: Randdalf/bliink
//-----------------------------------------------------------------------------
// Sets up the view parameters
//-----------------------------------------------------------------------------
void CViewRender::SetUpView()
{
	ASSERT_LOCAL_PLAYER_RESOLVABLE();
	int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();

	m_bAllowViewAccess = true;
	VPROF("CViewRender::SetUpView");
	// Initialize view structure with default values
	float farZ = GetZFar();

	CViewSetup &view = GetView();

	view.zFar				= farZ;
	view.zFarViewmodel	= farZ;
	// UNDONE: Make this farther out? 
	//  closest point of approach seems to be view center to top of crouched box
	view.zNear			= GetZNear();
	view.zNearViewmodel	= 1;
	view.fov				= default_fov.GetFloat();

	view.m_bOrtho			= false;

	// Enable spatial partition access to edicts
	partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, false );

	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	bool bNoViewEnt = false;
	if( pPlayer == NULL )
	{
		pPlayer = GetSplitScreenViewPlayer( nSlot );
		bNoViewEnt = true;
	}

	if ( g_bEngineIsHLTV )
	{
		HLTVCamera()->CalcView( view.origin, view.angles, view.fov );
	}
#if defined( REPLAY_ENABLED )
	else if ( engine->IsReplay() )
	{
		ReplayCamera()->CalcView( view.origin, view.angles, view.fov );
	}
#endif
	else
	{
		// FIXME: Are there multiple views? If so, then what?
		// FIXME: What happens when there's no player?
		if (pPlayer)
		{
			pPlayer->CalcView( view.origin, view.angles, view.zNear, view.zFar, view.fov );

			// If we are looking through another entities eyes, then override the angles/origin for GetView()
			int viewentity = render->GetViewEntity();

			if ( !bNoViewEnt && !g_nKillCamMode && (pPlayer->entindex() != viewentity) )
			{
				C_BaseEntity *ve = cl_entitylist->GetEnt( viewentity );
				if ( ve )
				{
					VectorCopy( ve->GetAbsOrigin(), view.origin );
					VectorCopy( ve->GetAbsAngles(), view.angles );
				}
			}

			pPlayer->CalcViewModelView( view.origin, view.angles );

			// Is this the proper place for this code?
			if ( cl_camera_follow_bone_index.GetInt() >= -1 && input->CAM_IsThirdPerson() )
			{
				VectorCopy( g_cameraFollowPos, view.origin );
			}
		}

		// Even if the engine is paused need to override the view
		// for keeping the camera control during pause.
		GetClientMode()->OverrideView( &GetView() );
	}

	// give the toolsystem a chance to override the view
	ToolFramework_SetupEngineView( view.origin, view.angles, view.fov );

	if ( engine->IsPlayingDemo() )
	{
		if ( cl_demoviewoverride.GetFloat() > 0.0f )
		{
			// Retreive view angles from engine ( could have been set in IN_AdjustAngles above )
			CalcDemoViewOverride( view.origin, view.angles );
		}
		else
		{
			s_DemoView = view.origin;
			s_DemoAngle = view.angles;
		}
	}

	// Disable spatial partition access
	partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, true );

	//Find the offset our current FOV is from the default value
	float flFOVOffset = default_fov.GetFloat() - view.fov;

	//Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
	view.fovViewmodel = GetClientMode()->GetViewModelFOV() - flFOVOffset;

	// Compute the world->main camera transform
	ComputeCameraVariables( view.origin, view.angles, 
		&g_vecVForward[ nSlot ], &g_vecVRight[ nSlot ], &g_vecVUp[ nSlot ], &g_matCamInverse[ nSlot ] );

	// set up the hearing origin...
	AudioState_t audioState;
	audioState.m_Origin = view.origin;
	audioState.m_Angles = view.angles;
	audioState.m_bIsUnderwater = pPlayer && pPlayer->AudioStateIsUnderwater( view.origin );

	ToolFramework_SetupAudioState( audioState );

	view.origin = audioState.m_Origin;
	view.angles = audioState.m_Angles;

	GetClientMode()->OverrideAudioState( &audioState );
	engine->SetAudioState( audioState );

	g_vecPrevRenderOrigin[ nSlot ] = g_vecRenderOrigin[ nSlot ];
	g_vecPrevRenderAngles[ nSlot ] = g_vecRenderAngles[ nSlot ];
	g_vecRenderOrigin[ nSlot ] = view.origin;
	g_vecRenderAngles[ nSlot ] = view.angles;

#ifdef DBGFLAG_ASSERT
	s_DbgSetupOrigin[ nSlot ] = view.origin;
	s_DbgSetupAngles[ nSlot ] = view.angles;
#endif

	m_bAllowViewAccess = false;
}
//-----------------------------------------------------------------------------
// Purpose: Handle player_death message
//-----------------------------------------------------------------------------
void CDODDeathStatsPanel::FireGameEvent( IGameEvent * event)
{
	if ( Q_strcmp( "player_death", event->GetName() ) == 0 )
	{	
		C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();

		if ( !pLocalPlayer )
			return;

		if ( !g_PR )
			return;

		int victim = engine->GetPlayerForUserID( event->GetInt("userid") );

		// only deal with deathnotices where we die
		if ( victim != pLocalPlayer->entindex() )
		{
			return;
		}

		int killer = engine->GetPlayerForUserID( event->GetInt("attacker") );
		
		const char *killedwith = event->GetString( "weapon" );

		char fullkilledwith[128];
		if ( killedwith && *killedwith )
		{
			Q_snprintf( fullkilledwith, sizeof(fullkilledwith), "d_%s", killedwith );
		}
		else
		{
			fullkilledwith[0] = 0;
		}

		// Get the names of the players
		const char *killer_name = g_PR->GetPlayerName( killer );
		const char *victim_name = g_PR->GetPlayerName( victim );

		if ( !killer_name )
			killer_name = "";
		if ( !victim_name )
			victim_name = "";

		m_DeathRecord.Killer.iEntIndex = killer;
		m_DeathRecord.Victim.iEntIndex = victim;
		Q_strncpy( m_DeathRecord.Killer.szName, killer_name, MAX_PLAYER_NAME_LENGTH );
		Q_strncpy( m_DeathRecord.Victim.szName, victim_name, MAX_PLAYER_NAME_LENGTH );
		m_DeathRecord.bSuicide = ( !killer || killer == victim );

		// Try and find the death identifier in the icon list
		m_DeathRecord.iconDeath = gHUD.GetIcon( fullkilledwith );

		if ( !m_DeathRecord.iconDeath )
		{
			// Can't find it, so use the default skull & crossbones icon
			m_DeathRecord.iconDeath = m_iconD_skull;
		}

		// Info we get from this message:
		// - who killed us with what

		// Info that is networked to the local player
		// - the hitgroups we hit the guy who killed us with
		// - life kills
		// - life woundings
		// - life caps
		// - life defenses

		Show();
	}	
}
示例#13
0
//-----------------------------------------------------------------------------
// Purpose: Save CPU cycles by letting the HUD system early cull
// costly traversal.  Called per frame, return true if thinking and 
// painting need to occur.
//-----------------------------------------------------------------------------
bool CHudCrosshair::ShouldDraw( void )
{
	bool bNeedsDraw;

	if ( m_bHideCrosshair )
		return false;

	C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return false;

	C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
	if ( pWeapon && !pWeapon->ShouldDrawCrosshair() )
		return false;

#ifdef PORTAL
	C_Portal_Player *portalPlayer = ToPortalPlayer(pPlayer);
	if ( portalPlayer && portalPlayer->IsSuppressingCrosshair() )
		return false;
#endif // PORTAL

	/* disabled to avoid assuming it's an HL2 player.
	// suppress crosshair in zoom.
	if ( pPlayer->m_HL2Local.m_bZooming )
	return false;
	*/

	// draw a crosshair only if alive or spectating in eye
	if ( IsX360() )
	{
		bNeedsDraw = m_pCrosshair && 
			!engine->IsDrawingLoadingImage() &&
			!engine->IsPaused() && 
			( !pPlayer->IsSuitEquipped() || g_pGameRules->IsMultiplayer() ) &&
			g_pClientMode->ShouldDrawCrosshair() &&
			!( pPlayer->GetFlags() & FL_FROZEN ) &&
			( pPlayer->entindex() == render->GetViewEntity() ) &&
			( pPlayer->IsAlive() ||	( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );
	}
	else
	{


		bNeedsDraw = m_pCrosshair && 
			crosshair.GetInt() &&
			// FAKEFACTORY Crosshair
			( pPlayer->IsSuitEquipped() ) &&
			// FAKEFACTORY Crosshair
			!engine->IsDrawingLoadingImage() &&
			!engine->IsPaused() && 
			g_pClientMode->ShouldDrawCrosshair() &&
			!( pPlayer->GetFlags() & FL_FROZEN ) &&
			( pPlayer->entindex() == render->GetViewEntity() ) &&
			!pPlayer->IsInVGuiInputMode() &&
			( pPlayer->IsAlive() ||	( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );


	}

	return ( bNeedsDraw && CHudElement::ShouldDraw() );
}