当前位置: 首页>>代码示例>>C++>>正文


C++ CBaseTFPlayer::AttemptToPowerup方法代码示例

本文整理汇总了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 );
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:55,代码来源:tf_obj_buff_station.cpp

示例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() );
				}
			}
		}
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:42,代码来源:tf_class_commando.cpp


注:本文中的CBaseTFPlayer::AttemptToPowerup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。