本文整理汇总了C++中CBaseTFPlayer::PlayerClass方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTFPlayer::PlayerClass方法的具体用法?C++ CBaseTFPlayer::PlayerClass怎么用?C++ CBaseTFPlayer::PlayerClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseTFPlayer
的用法示例。
在下文中一共展示了CBaseTFPlayer::PlayerClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetupMove
//-----------------------------------------------------------------------------
// Purpose: This is called pre player movement and copies all the data necessary
// from the player for movement. (Server-side, the client-side version
// of this code can be found in prediction.cpp.)
//-----------------------------------------------------------------------------
void CTFPlayerMove::SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move )
{
// Call the default SetupMove code.
BaseClass::SetupMove( player, ucmd, pHelper, move );
//
// Convert to TF2 data.
//
CBaseTFPlayer *pTFPlayer = static_cast<CBaseTFPlayer*>( player );
Assert( pTFPlayer );
CTFMoveData *pTFMove = static_cast<CTFMoveData*>( move );
Assert( pTFMove );
//
// Player movement data.
//
// Copy the position delta.
pTFMove->m_vecPosDelta = pTFPlayer->m_vecPosDelta;
// Copy the momentum data.
pTFMove->m_iMomentumHead = pTFPlayer->m_iMomentumHead;
for ( int iMomentum = 0; iMomentum < CTFMoveData::MOMENTUM_MAXSIZE; iMomentum++ )
{
pTFMove->m_aMomentum[iMomentum] = pTFPlayer->m_aMomentum[iMomentum];
}
pTFMove->m_nClassID = pTFPlayer->PlayerClass();
IVehicle *pVehicle = player->GetVehicle();
if (!pVehicle)
{
// Handle player class specific setup.
switch( pTFPlayer->PlayerClass() )
{
case TFCLASS_RECON:
{
SetupMoveRecon( pTFPlayer, ucmd, pHelper, pTFMove );
break;
}
case TFCLASS_COMMANDO:
{
SetupMoveCommando( pTFPlayer, ucmd, pHelper, pTFMove );
break;
}
default:
{
// pTFMove->m_nClassID = TFCLASS_UNDECIDED;
break;
}
}
}
else
{
pVehicle->SetupMove( player, ucmd, pHelper, move );
}
}
示例2: BoostPlayerThink
//-----------------------------------------------------------------------------
// Boost those attached to me as long as I'm not EMPed
//-----------------------------------------------------------------------------
void CObjectBuffStation::BoostPlayerThink( void )
{
// Are we emped?
bool bIsEmped = HasPowerup( POWERUP_EMP );
// Get range (squared = faster test).
float flMaxRangeSq = obj_buff_station_range.GetFloat();
flMaxRangeSq *= flMaxRangeSq;
// Boost all attached players and objects.
for ( int iPlayer = 0; iPlayer < BUFF_STATION_MAX_PLAYERS; iPlayer++ )
{
// Clean up dangling pointers + dead players, subversion, disconnection
CBaseTFPlayer *pPlayer = m_hPlayers[iPlayer].Get();
if ( !pPlayer || !pPlayer->IsAlive() || !InSameTeam( pPlayer ) || !pPlayer->PlayerClass() )
{
DetachPlayerByIndex( iPlayer );
continue;
}
// Check for out of range.
float flDistSq = GetAbsOrigin().DistToSqr( pPlayer->GetAbsOrigin() );
if ( flDistSq > flMaxRangeSq )
{
DetachPlayerByIndex( iPlayer );
continue;
}
bool bBoosted = false;
if ( !bIsEmped )
{
float flHealAmount = obj_buff_station_heal_rate.GetFloat() * BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL;
bBoosted = pPlayer->AttemptToPowerup( POWERUP_BOOST, 0, flHealAmount, this, &m_aPlayerAttachInfo[iPlayer].m_DamageModifier );
}
if ( !bBoosted )
{
m_aPlayerAttachInfo[iPlayer].m_DamageModifier.RemoveModifier();
}
}
// Set next think time.
if ( m_nPlayerCount > 0 )
{
SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL,
BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT );
}
else
{
SetNextThink( gpGlobals->curtime + 1.0f, BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT );
}
}
示例3: ShouldTransmit
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CEnvLaserDesignation::ShouldTransmit( const edict_t *recipient, const void *pvs, int clientArea )
{
// Only transmit to players who care about laser designation:
// - Player designating
// - Players in tanks
// - Commandos
CBaseEntity* pRecipientEntity = CBaseEntity::Instance( recipient );
if ( pRecipientEntity->IsPlayer() )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)pRecipientEntity;
// Designating player?
if ( pPlayer == GetOwnerEntity() )
return true;
if ( !InSameTeam( pPlayer ) )
return false;
// In a tank?
if ( pPlayer->IsInAVehicle() )
{
CBaseEntity *pVehicle = pPlayer->GetVehicle()->GetVehicleEnt();
if ( dynamic_cast<CVehicleTank*>(pVehicle) )
{
// Make sure it's within range of the tank's fire
static float flTankRange = 0;
if ( !flTankRange )
{
flTankRange = vehicle_tank_range.GetFloat() * weapon_grenade_rocket_track_range_mod.GetFloat();
flTankRange *= flTankRange;
}
float flDistanceSqr = ( GetAbsOrigin() - pPlayer->GetAbsOrigin() ).LengthSqr();
if ( flDistanceSqr < flTankRange )
return true;
}
else if ( dynamic_cast<CObjectMannedMissileLauncher*>(pVehicle) )
{
// Make sure it's within range of the manned missile launcher's fire
static float flGunRange = 0;
if ( !flGunRange )
{
flGunRange = obj_manned_missilelauncher_range_off.GetFloat() * weapon_grenade_rocket_track_range_mod.GetFloat();
flGunRange *= flGunRange;
}
float flDistanceSqr = ( GetAbsOrigin() - pPlayer->GetAbsOrigin() ).LengthSqr();
if ( flDistanceSqr < flGunRange )
return true;
}
}
// Is the player a commando?
if ( pPlayer->PlayerClass() == TFCLASS_COMMANDO )
{
// Make sure it's within range of the commando's rockets
static float flCommandoRange = 0;
if ( !flCommandoRange )
{
flCommandoRange = weapon_rocket_launcher_range.GetFloat() * weapon_grenade_rocket_track_range_mod.GetFloat();
flCommandoRange *= flCommandoRange;
}
float flDistanceSqr = ( GetAbsOrigin() - pPlayer->GetAbsOrigin() ).LengthSqr();
if ( flDistanceSqr < flCommandoRange )
return true;
}
}
return false;
}
示例4: FinishMove
//-----------------------------------------------------------------------------
// Purpose: This is called post player movement to copy back all data that
// movement could have modified and that is necessary for future
// movement. (Server-side, the client-side version of this code can
// be found in prediction.cpp.)
//-----------------------------------------------------------------------------
void CTFPlayerMove::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move )
{
// Call the default FinishMove code.
BaseClass::FinishMove( player, ucmd, move );
//
// Convert to TF2 data.
//
CBaseTFPlayer *pTFPlayer = static_cast<CBaseTFPlayer*>( player );
Assert( pTFPlayer );
CTFMoveData *pTFMove = static_cast<CTFMoveData*>( move );
Assert( pTFMove );
// The class had better not have changed during the move!!
Assert( pTFMove->m_nClassID == pTFPlayer->PlayerClass() );
IVehicle *pVehicle = player->GetVehicle();
if (!pVehicle)
{
// Handle player class specific setup.
switch( pTFPlayer->PlayerClass() )
{
case TFCLASS_RECON:
{
FinishMoveRecon( pTFPlayer, pTFMove, ucmd );
break;
}
case TFCLASS_COMMANDO:
{
FinishMoveCommando( pTFPlayer, pTFMove, ucmd );
break;
}
default:
{
break;
}
}
}
else
{
// Similarly, the vehicle had better not have changed during the move!
Assert( pTFPlayer->IsInAVehicle() );
pVehicle->FinishMove( pTFPlayer, ucmd, pTFMove );
}
//
// Player movement data.
//
// Copy the position delta.
pTFPlayer->m_vecPosDelta = pTFMove->m_vecPosDelta;
COMPILE_TIME_ASSERT( CBaseTFPlayer::MOMENTUM_MAXSIZE == CTFMoveData::MOMENTUM_MAXSIZE );
// Copy the momentum data back (the movement may have updated it!).
pTFPlayer->m_iMomentumHead = pTFMove->m_iMomentumHead;
for ( int iMomentum = 0; iMomentum < CTFMoveData::MOMENTUM_MAXSIZE; iMomentum++ )
{
pTFPlayer->m_aMomentum[iMomentum] = pTFMove->m_aMomentum[iMomentum];
}
}