本文整理汇总了C++中CBaseTFPlayer::AttemptToPowerup方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTFPlayer::AttemptToPowerup方法的具体用法?C++ CBaseTFPlayer::AttemptToPowerup怎么用?C++ CBaseTFPlayer::AttemptToPowerup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseTFPlayer
的用法示例。
在下文中一共展示了CBaseTFPlayer::AttemptToPowerup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
示例2: StartAdrenalinRush
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassCommando::StartAdrenalinRush( void )
{
// Am I actually alive?
if ( !m_pPlayer->IsAlive() )
return;
// Do I have rush capability?
if ( !m_bCanRush )
return;
m_bPersonalRush = true;
// Start adrenalin rushing
m_pPlayer->AttemptToPowerup( POWERUP_RUSH, class_commando_rush_length.GetFloat() );
// If I have battlecry, adrenalin up all my nearby teammates
if ( m_bHasBattlecry )
{
// Find nearby teammates
for ( int i = 0; i < m_pPlayer->GetTFTeam()->GetNumPlayers(); i++ )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer *)m_pPlayer->GetTFTeam()->GetPlayer(i);
assert(pPlayer);
// Is it within range?
if ( pPlayer != m_pPlayer && (pPlayer->GetAbsOrigin() - m_pPlayer->GetAbsOrigin()).Length() < class_commando_battlecry_radius.GetFloat() )
{
// Can I see it?
trace_t tr;
UTIL_TraceLine( m_pPlayer->EyePosition(), pPlayer->EyePosition(), MASK_SOLID_BRUSHONLY, m_pPlayer, COLLISION_GROUP_NONE, &tr);
CBaseEntity *pEntity = tr.m_pEnt;
if ( (tr.fraction == 1.0) || ( pEntity == pPlayer ) )
{
pPlayer->AttemptToPowerup( POWERUP_RUSH, class_commando_battlecry_length.GetFloat() );
}
}
}
}
}