本文整理汇总了C++中C_TFPlayer类的典型用法代码示例。如果您正苦于以下问题:C++ C_TFPlayer类的具体用法?C++ C_TFPlayer怎么用?C++ C_TFPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C_TFPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToTFPlayer
//-----------------------------------------------------------------------------
// 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 );
}
示例2: OnTick
//-----------------------------------------------------------------------------
// 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 );
}
}
}
}
示例3: Update
//-----------------------------------------------------------------------------
// 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
}
}
示例4: ShouldDraw
//-----------------------------------------------------------------------------
// 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();
}
示例5: defined
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
}
示例6: ShouldDraw
//-----------------------------------------------------------------------------
// 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;
}
示例7: ToTFPlayer
//-----------------------------------------------------------------------------
// 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 );
}
}
}
}
示例8: sizeof
//-----------------------------------------------------------------------------
// 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;
}
示例9: ClientsideProjectileSyringeCallback
//-----------------------------------------------------------------------------
// 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;
}
}
}
示例10: ClientsideProjectileNailCallback
//-----------------------------------------------------------------------------
// 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;
}
}
}
示例11: SendDestroyMessage
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;
}
示例12:
//-----------------------------------------------------------------------------
// 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;
}
示例13: OnTick
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;
}
}
}
示例14: OnBuildingChanged
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();
}
}
}
示例15: UpdateAllBuildings
//-----------------------------------------------------------------------------
// 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();
}
}
}