Beispiel #1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input :
//-----------------------------------------------------------------------------
void CViewModelInvisProxy::OnBind( C_BaseEntity *pEnt )
{
	if ( !m_pPercentInvisible )
		return;

	if ( !pEnt )
		return;

	C_BaseViewModel *pVM = dynamic_cast<C_BaseViewModel *>( pEnt );

	if ( !pVM )
	{
		m_pPercentInvisible->SetFloatValue( 0.0f );
		return;
	}

	C_TFPlayer *pPlayer = ToTFPlayer( pVM->GetOwner() );

	if ( !pPlayer )
	{
		m_pPercentInvisible->SetFloatValue( 0.0f );
		return;
	}

	float flPercentInvisible = pPlayer->GetPercentInvisible();

	// remap from 0.22 to 0.5
	// but drop to 0.0 if we're not invis at all
	float flWeaponInvis = ( flPercentInvisible < 0.01 ) ?
		0.0 :
		RemapVal( flPercentInvisible, 0.0, 1.0, tf_vm_min_invis.GetFloat(), tf_vm_max_invis.GetFloat() );

	m_pPercentInvisible->SetFloatValue( flWeaponInvis );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudDemomanChargeMeter::OnTick( void )
{
	C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( !pPlayer )
		return;

	CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
	ITFChargeUpWeapon *pChargeupWeapon = dynamic_cast< ITFChargeUpWeapon *>( pWpn );

	if ( !pWpn || !pChargeupWeapon )
		return;

	if ( m_pChargeMeter )
	{
		float flChargeMaxTime = pChargeupWeapon->GetChargeMaxTime();

		if ( flChargeMaxTime != 0 )
		{
			float flChargeBeginTime = pChargeupWeapon->GetChargeBeginTime();

			if ( flChargeBeginTime > 0 )
			{
				float flTimeCharged = max( 0, gpGlobals->curtime - flChargeBeginTime );
				float flPercentCharged = min( 1.0, flTimeCharged / flChargeMaxTime );

				m_pChargeMeter->SetProgress( flPercentCharged );
			}
			else
			{
				m_pChargeMeter->SetProgress( 0.0f );
			}
		}
	}
}
Beispiel #3
0
//-----------------------------------------------------------------------------
// Purpose: called to update the menu with new information
//-----------------------------------------------------------------------------
void CTFTeamMenu::Update( void )
{
	BaseClass::Update();

	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( pLocalPlayer && ( pLocalPlayer->GetTeamNumber() != TEAM_UNASSIGNED ) )
	{
#ifdef _X360
		if ( m_pFooter )
		{
			m_pFooter->ShowButtonLabel( "cancel", true );
		}
#else
		if ( m_pCancelButton )
		{
			m_pCancelButton->SetVisible( true );
		}
#endif
	}
	else
	{
#ifdef _X360
		if ( m_pFooter )
		{
			m_pFooter->ShowButtonLabel( "cancel", false );
		}
#else
		if ( m_pCancelButton && m_pCancelButton->IsVisible() )
		{
			m_pCancelButton->SetVisible( false );
		}
#endif
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CHudDemomanChargeMeter::ShouldDraw( void )
{
	C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( !pPlayer || !pPlayer->IsPlayerClass( TF_CLASS_DEMOMAN ) || !pPlayer->IsAlive() )
	{
		return false;
	}

	CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();

	if ( !pWpn )
	{
		return false;
	}

	int iWeaponID = pWpn->GetWeaponID();

	if ( iWeaponID != TF_WEAPON_PIPEBOMBLAUNCHER )
	{
		return false;
	}

	return CHudElement::ShouldDraw();
}
void CTFViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition, const QAngle& eyeAngles )
{
#if defined( CLIENT_DLL )

    Vector vecNewOrigin = eyePosition;
    QAngle vecNewAngles = eyeAngles;

    // Check for lowering the weapon
    C_TFPlayer *pPlayer = ToTFPlayer( owner );

    Assert( pPlayer );

    bool bLowered = pPlayer->IsWeaponLowered();

    QAngle vecLoweredAngles(0,0,0);

    m_vLoweredWeaponOffset.x = Approach( bLowered ? cl_gunlowerangle.GetFloat() : 0, m_vLoweredWeaponOffset.x, cl_gunlowerspeed.GetFloat() );
    vecLoweredAngles.x += m_vLoweredWeaponOffset.x;

    vecNewAngles += vecLoweredAngles;


    // Viewmodel offset
    Vector	forward, right, up;
    AngleVectors(eyeAngles, &forward, &right, &up);
    vecNewOrigin += forward*v_viewmodel_offset_x.GetFloat() + right*v_viewmodel_offset_y.GetFloat() + up*v_viewmodel_offset_z.GetFloat();

    if (owner->GetActiveWeapon())
        ToTFPlayer(owner)->GetActiveTFWeapon()->UpdateViewModel();

    BaseClass::CalcViewModelView( owner, vecNewOrigin, vecNewAngles );

#endif
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTFHudWeaponSwitch::ShouldDraw(void)
{
	if( IsTakingAFreezecamScreenshot() )
		return false;

	if (!TFGameRules() || !TFGameRules()->IsDeathmatch())
		return false;

	C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
	if (!pLocalTFPlayer)
		return false;

	int iWeaponTo = pLocalTFPlayer->m_Shared.GetDesiredWeaponIndex();
	if (iWeaponTo != TF_WEAPON_NONE)
	{
		pWeaponToInfo = GetTFWeaponInfo(iWeaponTo);

		C_TFWeaponBase *pWeaponFrom = (C_TFWeaponBase *)pLocalTFPlayer->Weapon_GetSlot( pWeaponToInfo->iSlot );
		if (!pWeaponFrom)
			return false;

		pWeaponFromInfo = GetTFWeaponInfo(pWeaponFrom->GetWeaponID());
		UpdateStatus();

		return true;
	}

	return false;
}
Beispiel #7
0
//-----------------------------------------------------------------------------
// Purpose: Player has waved his crosshair over this entity. Display appropriate hints.
//-----------------------------------------------------------------------------
void C_BaseObject::DisplayHintTo( C_BasePlayer *pPlayer )
{
	bool bHintPlayed = false;

	C_TFPlayer *pTFPlayer = ToTFPlayer(pPlayer);
	if ( InSameTeam( pPlayer ) )
	{
		// We're looking at a friendly object. 

		if ( HasSapper() )
		{
			bHintPlayed = pPlayer->HintMessage( HINT_OBJECT_HAS_SAPPER, true, true );
		}

		if ( pTFPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) )
		{
			// I'm an engineer.

			// If I'm looking at a constructing object, let me know I can help build it (but not 
			// if I built it myself, since I've already got that hint from the wrench).
			if ( !bHintPlayed && IsBuilding() && GetBuilder() != pTFPlayer )
			{
				bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_USE_WRENCH_ONOTHER, false, true );
			}

			// If it's damaged, I can repair it
			if ( !bHintPlayed && !IsBuilding() && GetHealth() < GetMaxHealth() )
			{
				bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_REPAIR_OBJECT, false, true );
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CSecondaryTargetID::CalculateTargetIndex( C_TFPlayer *pLocalTFPlayer )
{
	// If we're a medic & we're healing someone, target him.
	CBaseEntity *pHealTarget = pLocalTFPlayer->MedicGetHealTarget();
	if ( pHealTarget )
	{
		if ( pHealTarget->entindex() != m_iTargetEntIndex )
		{
			g_pVGuiLocalize->ConstructString( m_wszPrepend, sizeof(m_wszPrepend), g_pVGuiLocalize->Find("#TF_playerid_healtarget" ), 0 );
		}
		return pHealTarget->entindex();
	}

	// If we have a healer, target him.
	C_TFPlayer *pHealer;
	float flHealerChargeLevel;
	pLocalTFPlayer->GetHealer( &pHealer, &flHealerChargeLevel );
	if ( pHealer )
	{
		if ( pHealer->entindex() != m_iTargetEntIndex )
		{
			g_pVGuiLocalize->ConstructString( m_wszPrepend, sizeof(m_wszPrepend), g_pVGuiLocalize->Find("#TF_playerid_healer" ), 0 );
		}
		return pHealer->entindex();
	}

	if ( m_iTargetEntIndex )
	{
		m_wszPrepend[0] = '\0';
	}
	return 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientsideProjectileSyringeCallback( const CEffectData &data )
{
	// Get the syringe and add it to the client entity list, so we can attach a particle system to it.
	C_TFPlayer *pPlayer = dynamic_cast<C_TFPlayer*>( ClientEntityList().GetBaseEntityFromHandle( data.m_hEntity ) );
	if ( pPlayer )
	{
		C_LocalTempEntity *pSyringe = ClientsideProjectileCallback( data, SYRINGE_GRAVITY );
		if ( pSyringe )
		{
			switch (pPlayer->GetTeamNumber())
			{
			case TF_TEAM_RED:
				pSyringe->m_nSkin = 0;
				break;
			case TF_TEAM_BLUE:
				pSyringe->m_nSkin = 1;
				break;
			case TF_TEAM_GREEN:
				pSyringe->m_nSkin = 2;
				break;
			case TF_TEAM_YELLOW:
				pSyringe->m_nSkin = 3;
				break;
			}
			bool bCritical = ( ( data.m_nDamageType & DMG_CRITICAL ) != 0 );
			pPlayer->m_Shared.SetParticleToMercColor(
				pSyringe->AddParticleEffect(GetSyringeTrailParticleName(pPlayer->GetTeamNumber(), bCritical))
				);
			pSyringe->AddEffects( EF_NOSHADOW );
			pSyringe->flags |= FTENT_USEFASTCOLLISIONS;
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ClientsideProjectileNailCallback(const CEffectData &data)
{
	C_TFPlayer *pPlayer = dynamic_cast<C_TFPlayer*>(ClientEntityList().GetBaseEntityFromHandle(data.m_hEntity));
	if (pPlayer)
	{
		C_LocalTempEntity *pNail = ClientsideProjectileCallback(data, NAILGUN_NAIL_GRAVITY);
		if (pNail)
		{
			switch (pPlayer->GetTeamNumber())
			{
			case TF_TEAM_RED:
				pNail->m_nSkin = 0;
				break;
			case TF_TEAM_BLUE:
				pNail->m_nSkin = 1;
				break;
			case TF_TEAM_GREEN:
				pNail->m_nSkin = 2;
				break;
			case TF_TEAM_YELLOW:
				pNail->m_nSkin = 3;
				break;
			}
			bool bCritical = ((data.m_nDamageType & DMG_CRITICAL) != 0);
			pPlayer->m_Shared.SetParticleToMercColor(
				pNail->AddParticleEffect(GetNailTrailParticleName(pPlayer->GetTeamNumber(), bCritical))
				);
			pNail->AddEffects(EF_NOSHADOW);
			pNail->flags |= FTENT_USEFASTCOLLISIONS;
		}
	}
}
bool CHudMenuEngyBuild::SendDestroyMessage( int iSlot )
{
	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( !pLocalPlayer )
		return false;

	bool bSuccess = false;

	int iBuilding = GetBuildingIDFromSlot( iSlot );

	C_BaseObject *pObj = pLocalPlayer->GetObjectOfType( iBuilding );

	if ( pObj != NULL )
	{
		char szCmd[128];
		Q_snprintf( szCmd, sizeof(szCmd), "destroy %d", iBuilding );
		engine->ClientCmd( szCmd );
		bSuccess = true; 
	}
	else
	{
		pLocalPlayer->EmitSound( "Player.DenyWeaponSelection" );
	}

	return bSuccess;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
const char *CBuildingStatusItem_SentryGun::GetBackgroundImage( void )
{
	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	const char *pResult = "obj_status_background_tall_blue";

	if ( !pLocalPlayer )
	{
		return pResult;
	}

	switch( pLocalPlayer->GetTeamNumber() )
	{
	case TF_TEAM_BLUE:
		pResult = "obj_status_background_tall_blue";
		break;
	case TF_TEAM_RED:
		pResult = "obj_status_background_tall_red";
		break;
	default:
		break;
	}

	return pResult;
}
void CHudBuildingStatusContainer::OnTick( void )
{
	if ( m_AlertLevel >= BUILDING_HUD_ALERT_VERY_LOW_AMMO &&
		gpGlobals->curtime >= m_flNextBeep && 
		m_iNumBeepsToBeep > 0 )
	{
		C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

		if ( !pLocalPlayer )
			return;

		pLocalPlayer->EmitSound( "Hud.Warning" );
			
		switch( m_AlertLevel )
		{
			case BUILDING_HUD_ALERT_VERY_LOW_AMMO:
			case BUILDING_HUD_ALERT_VERY_LOW_HEALTH:
				m_flNextBeep = gpGlobals->curtime + 2.0f;
				m_iNumBeepsToBeep--;
				break;

			case BUILDING_HUD_ALERT_SAPPER:
				m_flNextBeep = gpGlobals->curtime + 1.0f;
				// don't decrement beeps, we want them to go on forever
				break;
		}
	}
}
void CHudBuildingStatusContainer::OnBuildingChanged( int iBuildingType, bool bBuildingIsDead )
{
	bool bFound = false;
	for ( int i = 0; i < m_BuildingPanels.Count() && !bFound; i++ )
	{
		CBuildingStatusItem *pItem = m_BuildingPanels.Element(i);

		if ( pItem && pItem->GetRepresentativeObjectType() == iBuildingType )
		{
			// find the item that represents this building type
			C_BaseObject *pObj = NULL;

			// find the object
			C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
			if ( pLocalPlayer )
			{
				pObj = pLocalPlayer->GetObjectOfType( iBuildingType );
				pItem->SetObject( pObj );
			}

			pItem->InvalidateLayout( true );
			bFound = true;

			RecalculateAlertState();
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudBuildingStatusContainer::UpdateAllBuildings( void )
{
	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
	if ( !pLocalPlayer )
		return;

	for ( int i = 0; i < m_BuildingPanels.Count(); i++ )
	{
		CBuildingStatusItem *pItem = m_BuildingPanels.Element(i);

		if ( pItem )
		{
			// find the item that represents this building type
			C_BaseObject *pObj = NULL;

			// find the object
			pObj = pLocalPlayer->GetObjectOfType( pItem->GetRepresentativeObjectType() );

			pItem->SetObject( pObj );

			pItem->InvalidateLayout( true );
			RecalculateAlertState();
		}
	}
}
void CHudMenuEngyBuild::SetVisible( bool state )
{
	if ( state == true )
	{
		// close the weapon selection menu
		engine->ClientCmd( "cancelselect" );

		bool bConsoleMode = ( IsConsole() || tf_build_menu_controller_mode.GetBool() );

		if ( bConsoleMode != m_bInConsoleMode )
		{
			InvalidateLayout( true, true );
			m_bInConsoleMode = bConsoleMode;
		}

		// set the %lastinv% dialog var to our binding
		const char *key = engine->Key_LookupBinding( "lastinv" );
		if ( !key )
		{
			key = "< not bound >";
		}

		SetDialogVariable( "lastinv", key );

		// Set selection to the first available building that we can build

		C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

		if ( !pLocalPlayer )
			return;

		int iDefaultSlot = 1;

		// Find the first slot that represents a building that we haven't built
		int iSlot;
		for ( iSlot = 1; iSlot <= 4; iSlot++ )
		{
			int iBuilding = GetBuildingIDFromSlot( iSlot );
			C_BaseObject *pObj = pLocalPlayer->GetObjectOfType( iBuilding );

			if ( pObj == NULL )
			{
				iDefaultSlot = iSlot;
				break;
			}
		}

		m_iSelectedItem = -1;	//force redo
		SetSelectedItem( iDefaultSlot );

		HideLowerPriorityHudElementsInGroup( "mid" );
	}
	else
	{
		UnhideLowerPriorityHudElementsInGroup( "mid" );
	}

	BaseClass::SetVisible( state );
}
Beispiel #17
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFImagePanel::FireGameEvent(IGameEvent * event)
{
	if ( FStrEq( "localplayer_changeteam", event->GetName() ) )
	{
		C_TFPlayer *pPlayer = ToTFPlayer( C_BasePlayer::GetLocalPlayer() );
		m_iBGTeam = pPlayer ? pPlayer->GetTeamNumber() : TEAM_UNASSIGNED;
		UpdateBGImage();
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CHudBuildingStatusContainer::ShouldDraw( void )
{
	// Don't draw in freezecam
	C_TFPlayer *pPlayer = CTFPlayer::GetLocalTFPlayer();
	if ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM )
		return false;

	return CHudElement::ShouldDraw();
}
bool CMainTargetID::ShouldDraw( void )
{
	C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
	if ( !pLocalTFPlayer )
		return false;

	if ( pLocalTFPlayer->GetObserverMode() > OBS_MODE_NONE )
		return false;

	return BaseClass::ShouldDraw();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFRocketLauncher::CreateMuzzleFlashEffects( C_BaseEntity *pAttachEnt, int nIndex )
{
	BaseClass::CreateMuzzleFlashEffects( pAttachEnt, nIndex );

	// Don't do backblast effects in first person
	C_TFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
	if ( pOwner->IsLocalPlayer() )
		return;

	ParticleProp()->Create( "rocketbackblast", PATTACH_POINT_FOLLOW, "backblast" );
}
Beispiel #21
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CTFImagePanel::CTFImagePanel(Panel *parent, const char *name) : ScalableImagePanel(parent, name)
{
	for ( int i = 0; i < TF_TEAM_COUNT; i++ )
	{
		m_szTeamBG[i][0] = '\0';
	}

	C_TFPlayer *pPlayer = ToTFPlayer( C_BasePlayer::GetLocalPlayer() );
	m_iBGTeam = pPlayer ? pPlayer->GetTeamNumber() : TEAM_UNASSIGNED;

	ListenForGameEvent( "localplayer_changeteam" );
}
bool CHudSmokeBomb::ShouldDraw()
{
	C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();

	// if we are spectating another player first person, check this player
	if ( pPlayer && ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) )
	{
		pPlayer = ToTFPlayer( pPlayer->GetObserverTarget() );
	}

	return ( pPlayer && pPlayer->IsAlive() && pPlayer->m_Shared.InCond( TF_COND_SMOKE_BOMB ) );
}
bool CSpectatorTargetID::ShouldDraw( void )
{
	C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
	if ( !pLocalTFPlayer )
		return false;

	if ( pLocalTFPlayer->GetObserverMode() <= OBS_MODE_NONE ||
		 pLocalTFPlayer->GetObserverMode() == OBS_MODE_FREEZECAM )
		return false;

	return BaseClass::ShouldDraw();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFStatPanel::TestStatPanel( TFStatType_t statType, RecordBreakType_t recordType )
{
	C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
	if ( !pPlayer )
		return;
	
	m_iCurStatClass = pPlayer->GetPlayerClass()->GetClassIndex();
	ClassStats_t &classStats = GetClassStats( m_iCurStatClass );;
	m_iCurStatValue = classStats.max.m_iStat[statType];
	m_iCurStatTeam = pPlayer->GetTeamNumber();

	ShowStatPanel( m_iCurStatClass, m_iCurStatTeam, m_iCurStatValue, statType, recordType, false );
}
Beispiel #25
0
//-----------------------------------------------------------------------------
// Purpose: Called when the user picks a team
//-----------------------------------------------------------------------------
void CTFTeamMenu::OnCommand( const char *command )
{
	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( Q_stricmp( command, "vguicancel" ) )
	{
		// we're selecting a team, so make sure it's not the team we're already on before sending to the server
		if ( pLocalPlayer && ( Q_strstr( command, "jointeam " ) ) )
		{
			const char *pTeam = command + Q_strlen( "jointeam " );
			int iTeam = TEAM_INVALID;

			if ( Q_stricmp( pTeam, "spectate" ) == 0 )
			{
				iTeam = TEAM_SPECTATOR;
			}
			else if ( Q_stricmp( pTeam, "red" ) == 0 )
			{
				iTeam = TF_TEAM_RED;
			}
			else if ( Q_stricmp( pTeam, "blue" ) == 0 )
			{
				iTeam = TF_TEAM_BLUE;
			}
	
			if ( iTeam == TF_TEAM_RED && m_bRedDisabled )
			{
				return;
			}

			if ( iTeam == TF_TEAM_BLUE && m_bBlueDisabled )
			{
				return;
			}

			// are we selecting the team we're already on?
			if ( pLocalPlayer->GetTeamNumber() != iTeam )
			{
				engine->ClientCmd( command );
			}
		}
		else if ( pLocalPlayer && ( Q_strstr( command, "jointeam_nomenus " ) ) )
		{
			engine->ClientCmd( command );
		}
	}

	BaseClass::OnCommand( command );
	ShowPanel( false );
	OnClose();
}
Beispiel #26
0
//-----------------------------------------------------------------------------
// Purpose: Don't render the weapon if its supposed to be lowered and we have
// finished the lowering animation
//-----------------------------------------------------------------------------
int CTFViewModel::DrawModel( int flags )
{
    // Check for lowering the weapon
    C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();

    Assert( pPlayer );

    bool bLowered = pPlayer->IsWeaponLowered();

    if ( bLowered && fabs( m_vLoweredWeaponOffset.x - cl_gunlowerangle.GetFloat() ) < 0.1 )
    {
        // fully lowered, stop drawing
        return 1;
    }

    C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
    if ( pLocalPlayer && pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE &&
            pLocalPlayer->GetObserverTarget() && pLocalPlayer->GetObserverTarget()->IsPlayer() )
    {
        pPlayer = ToTFPlayer( pLocalPlayer->GetObserverTarget() );

        if ( pPlayer != GetOwner() )
            return 0;
    }

    if ( pPlayer->IsAlive() == false )
    {
        return 0;
    }

    return BaseClass::DrawModel( flags );
}
void CProxySniperRifleCharge::OnBind( void *pC_BaseEntity )
{
	Assert( m_pResult );

	C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( GetSpectatorTarget() != 0 && GetSpectatorMode() == OBS_MODE_IN_EYE )
	{
		pPlayer = (C_TFPlayer *)UTIL_PlayerByIndex( GetSpectatorTarget() );
	}

	if ( pPlayer )
	{
		CTFSniperRifle *pWeapon = assert_cast<CTFSniperRifle*>(pPlayer->GetActiveTFWeapon());
		if ( pWeapon )
		{
			float flChargeValue = ( ( 1.0 - pWeapon->GetHUDDamagePerc() ) * 0.8 ) + 0.6;

			VMatrix mat, temp;

			Vector2D center( 0.5, 0.5 );
			MatrixBuildTranslation( mat, -center.x, -center.y, 0.0f );

			// scale
			{
				Vector2D scale( 1.0f, 0.25f );
				MatrixBuildScale( temp, scale.x, scale.y, 1.0f );
				MatrixMultiply( temp, mat, mat );
			}

			MatrixBuildTranslation( temp, center.x, center.y, 0.0f );
			MatrixMultiply( temp, mat, mat );

			// translation
			{
				Vector2D translation( 0.0f, flChargeValue );
				MatrixBuildTranslation( temp, translation.x, translation.y, 0.0f );
				MatrixMultiply( temp, mat, mat );
			}

			m_pResult->SetMatrixValue( mat );
		}
	}

	if ( ToolsEnabled() )
	{
		ToolFramework_RecordMaterialParams( GetMaterial() );
	}
}
Beispiel #28
0
//-----------------------------------------------------------------------------
// Purpose: Show mask to player's teammates.
//-----------------------------------------------------------------------------
bool C_TFSpyMask::ShouldDraw( void )
{
    C_TFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );

    if ( !pOwner )
        return false;

    if ( pOwner->IsEnemyPlayer() && pOwner->m_Shared.GetDisguiseClass() != TF_CLASS_SPY )
        return false;

    if ( !pOwner->ShouldDrawThisPlayer() )
        return false;

    return BaseClass::ShouldDraw();
}
Beispiel #29
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void DispatchParticleEffect( int iEffectIndex, Vector vecOrigin, Vector vecStart, QAngle vecAngles, CBaseEntity *pEntity )
{
	CEffectData	data;

	data.m_nHitBox = iEffectIndex;
	data.m_vOrigin = vecOrigin;
	data.m_vStart = vecStart;
	data.m_vAngles = vecAngles;

	if ( pEntity )
	{
#ifdef CLIENT_DLL
		data.m_hEntity = pEntity;
#else
		data.m_nEntIndex = pEntity->entindex();
#endif
		data.m_fFlags |= PARTICLE_DISPATCH_FROM_ENTITY;
		data.m_nDamageType = PATTACH_CUSTOMORIGIN;

#if defined(TF_CLASSIC_CLIENT)
		if (TFGameRules() && TFGameRules()->IsDeathmatch())
		{
			C_TFPlayer *pPlayer = ToTFPlayer(pEntity);
			if (pPlayer && pPlayer->m_Shared.InCond(TF_COND_POWERUP_CRITDAMAGE))
			{
				data.m_bCustomColors = true;
				C_TF_PlayerResource *pResource = dynamic_cast<C_TF_PlayerResource *>(g_PR);
				data.m_CustomColors.m_vecColor1 = Vector(
					pResource->GetPlayerColor(pPlayer->entindex()).r() / 255.0f,
					pResource->GetPlayerColor(pPlayer->entindex()).g() / 255.0f,
					pResource->GetPlayerColor(pPlayer->entindex()).b() / 255.0f
					);
			}
		}
#endif

	}
	else
	{
#ifdef CLIENT_DLL
		data.m_hEntity = NULL;
#else
		data.m_nEntIndex = 0;
#endif
	}

	DispatchEffect( "ParticleEffect", data );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CHudBuildingStatusContainer_Engineer::ShouldDraw( void )
{
	// Don't draw in freezecam
	C_TFPlayer *pPlayer = CTFPlayer::GetLocalTFPlayer();
	if ( !pPlayer || !pPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) || pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM )
	{
		return false;
	}

	if ( pPlayer->GetTeamNumber() <= TEAM_SPECTATOR )
	{
		return false;
	}

	return CHudElement::ShouldDraw();
}