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


C++ PrimaryAttack函数代码示例

本文整理汇总了C++中PrimaryAttack函数的典型用法代码示例。如果您正苦于以下问题:C++ PrimaryAttack函数的具体用法?C++ PrimaryAttack怎么用?C++ PrimaryAttack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PrimaryAttack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ToBasePlayer

//-----------------------------------------------------------------------------
// Purpose: Override so SLAM to so secondary attack when no secondary ammo
//			but satchel is in the world
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::ItemPostFrame( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	if (!pOwner)
	{
		return;
	}

	if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime))
	{
		SecondaryAttack();
	}
	else if (!m_bNeedReload && (pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
	{
		PrimaryAttack();
	}

	// -----------------------
	//  No buttons down
	// -----------------------
	else 
	{
		WeaponIdle( );
		return;
	}
}
开发者ID:DreikVal,项目名称:nicksproject,代码行数:32,代码来源:weapon_slam.cpp

示例2: PrimaryAttack

//Fire both barrels
void CWeaponSawedOff::SecondaryAttack( void )
{
	if ( m_iClip1 < 2 )
	{
		if ( m_iClip1 == 1 )
			PrimaryAttack();
		return;
	}

	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

	WeaponSound(WPN_DOUBLE);
	pOwner->DoMuzzleFlash();
	SendWeaponAnim( ACT_VM_SECONDARYATTACK );
	m_iClip1 -= 2;
	pOwner->SetAnimation( PLAYER_ATTACK1 );

	Vector	vecSrc		= pOwner->Weapon_ShootPosition( );
	Vector	vecAiming	= pOwner->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT );	

	FireBulletsInfo_t info( 14, vecSrc, vecAiming, CDHLBaseWeapon::GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
	info.m_pAttacker = pOwner;

	pOwner->FireBullets( info );

	AddDHLViewKick( BaseClass::GetRecoilX(), BaseClass::GetRecoilY() );
}
开发者ID:dreckard,项目名称:dhl2,代码行数:28,代码来源:weapon_sawedoff.cpp

示例3: ToBasePlayer

void CWeaponGravityGun::ItemPostFrame( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	if (!pOwner)
		return;

	if ( pOwner->m_afButtonPressed & IN_ATTACK2 )
	{
		SecondaryAttack();
	}
	else if ( pOwner->m_nButtons & IN_ATTACK )
	{
		PrimaryAttack();
	}
	else if ( pOwner->m_afButtonPressed & IN_RELOAD )
	{
		Reload();
	}
	// -----------------------
	//  No buttons down
	// -----------------------
	else 
	{
		WeaponIdle( );
		return;
	}
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:27,代码来源:physgun.cpp

示例4: ToBasePlayer

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponCombatBaseGrenade::ItemPostFrame( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	if (!pOwner)
		return;

	AllowShieldPostFrame( !m_flStartedThrowAt );

	// Look for button downs
	if ( (pOwner->m_nButtons & IN_ATTACK) && GetShieldState() == SS_DOWN && !m_flStartedThrowAt && (m_flNextPrimaryAttack <= gpGlobals->curtime) )
	{
		m_flStartedThrowAt = gpGlobals->curtime;

		SendWeaponAnim( ACT_VM_DRAW );
	}

	// Look for button ups
	if ( (pOwner->m_afButtonReleased & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime) && m_flStartedThrowAt )
	{
		m_flNextPrimaryAttack = gpGlobals->curtime;
		PrimaryAttack();
		m_flStartedThrowAt = 0;
	}

	//  No buttons down?
	if ( !((pOwner->m_nButtons & IN_ATTACK) || (pOwner->m_nButtons & IN_ATTACK2) || (pOwner->m_nButtons & IN_RELOAD)) )
	{
		WeaponIdle( );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:33,代码来源:weapon_combat_basegrenade.cpp

示例5: ToGEPlayer

void CWeaponAR33::ItemPostFrame( void )
{
	CGEPlayer *pOwner = ToGEPlayer ( GetOwner() );
	if ( !pOwner )
		return;

	if ( !m_bInBurst && m_nNumShotsFired > 0 )
		m_iBurst = (m_nNumShotsFired < 3) ? (3 - m_nNumShotsFired) : (m_nNumShotsFired % 3);

	if ( m_iBurst > 0 && ( pOwner->m_nButtons & IN_ATTACK ) == false && !pOwner->IsInAimMode() )
	{
		m_bInBurst = true;
		if ( gpGlobals->curtime > m_flNextPrimaryAttack )
		{
			PrimaryAttack();
			m_iBurst--;
		}
	}
	else
	{
		m_bInBurst = false;
		m_iBurst = 0;
	}

	BaseClass::ItemPostFrame();
}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:26,代码来源:weapon_ar33.cpp

示例6: ToBasePlayer

//-----------------------------------------------------------------------------
// Purpose: Override so shotgun can do mulitple reloads in a row
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeaponMolotov::ItemPostFrame( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	if (!pOwner)
	{
		return;
	}


	if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime))
	{
		SecondaryAttack();
	}
	else if ((pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
	{
		// Uses secondary ammo only
		if (pOwner->GetAmmoCount(m_iSecondaryAmmoType))
		{
			PrimaryAttack();
		}
	}
	else if (m_bNeedDraw)
	{
		DrawAmmo();
	}
	else
	{
		WeaponIdle( );
	}
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:35,代码来源:weapon_molotov.cpp

示例7: GetPlayerOwner

//=====================================================================================//
// Purpose: Controls the attacks and the call of WeaponIdle() method
//=====================================================================================//
void CTDPBludgeonWeaponBase::ItemPostFrame()
{
	// Do we have a valid owner holding the weapon?
	CTDPPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return;

	static int lastButton = 0;

	//TDP_TODO
	if ( pPlayer->m_nButtons & IN_ATTACK3 && m_flNextSecondaryAttack <= gpGlobals->curtime && (lastButton != pPlayer->m_afButtonPressed) )
	{	
		ThirdAttack();
	}
	lastButton = pPlayer->m_afButtonPressed;

	// Is the player pressing the secondary attack button and is it time for the next
	// secondary attack?
	if ( pPlayer->m_nButtons & IN_ATTACK2 && m_flNextSecondaryAttack <= gpGlobals->curtime )
		SecondaryAttack();

	// Is the player pressing the primary attack button and is it time for the next
	// primary attack?
	if ( pPlayer->m_nButtons & IN_ATTACK && m_flNextPrimaryAttack <= gpGlobals->curtime )
		PrimaryAttack();

	// If the player is not pressing any of the attack buttons let's try to idle
	if ( !( pPlayer->m_nButtons & IN_ATTACK3 || pPlayer->m_nButtons & IN_ATTACK2 || pPlayer->m_nButtons & IN_ATTACK ) )
		WeaponIdle();

	//BaseClass::ItemPostFrame(); // Make this conditionnal

	return;
}
开发者ID:jrbedard,项目名称:troy-divine-playground,代码行数:37,代码来源:tdp_weapon_basebludgeon.cpp

示例8: ToBasePlayer

//------------------------------------------------------------------------------
// Purpose : Update weapon
//------------------------------------------------------------------------------
void CBaseHLBludgeonWeapon::ItemPostFrame( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	
	if ( pOwner == NULL )
		return;

	if ( CheckSwingMotion() )
	{
		// Handles it's own animation....
	} 
	else if ( (pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime) )
	{
		PrimaryAttack();
	} 
	else if ( (pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime) )
	{
		SecondaryAttack();
	}
	else 
	{
		WeaponIdle();
		return;
	}
}
开发者ID:Mixpicles,项目名称:halflife-vr,代码行数:28,代码来源:basebludgeonweapon.cpp

示例9: PrimaryAttack

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponMortar::Fire( float flPower, float flAccuracy )
{
	m_flFiringPower = flPower;
	m_flFiringAccuracy = flAccuracy;

	PrimaryAttack();
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:10,代码来源:weapon_mortar.cpp

示例10: ToBaseTFPlayer

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponBuilder::ItemPostFrame( void )
{
	CBaseTFPlayer *pOwner = ToBaseTFPlayer( GetOwner() );
	if ( !pOwner )
		return;

	// Ignore input while the player's building anything
	if ( pOwner->IsBuilding() )
		return;

	// Switch away if I'm not in placement mode
	if ( m_iBuildState != BS_PLACING && m_iBuildState != BS_PLACING_INVALID )
	{
		pOwner->SwitchToNextBestWeapon( NULL );
		return;
	}

	if (( pOwner->m_nButtons & IN_ATTACK ) && (m_flNextPrimaryAttack <= gpGlobals->curtime) )
	{
		PrimaryAttack();
	}

	// Allow shield post frame 
	AllowShieldPostFrame( true );

	WeaponIdle();
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:30,代码来源:weapon_builder.cpp

示例11: PrimaryAttack

bool CASW_Weapon_Buff_Grenade::OffhandActivate()
{
	if (!GetMarine() || GetMarine()->GetFlags() & FL_FROZEN)	// don't allow this if the marine is frozen
		return false;
	PrimaryAttack();

	return true;
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:8,代码来源:asw_weapon_buff_grenade.cpp

示例12: PrimaryAttack

//-----------------------------------------------------------------------------
// Purpose: Allow activation even if this is our last piece of ammo
//-----------------------------------------------------------------------------
void CWeaponHopwire::HandleFireOnEmpty( void )
{
	if ( m_hActiveHopWire!= NULL )
	{
		// FIXME: This toggle is hokey
		m_bRedraw = false;
		PrimaryAttack();
		m_bRedraw = true;
	}
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source-2013,代码行数:13,代码来源:weapon_hopwire.cpp

示例13: PrimaryAttack

bool CASW_Weapon_Stim::OffhandActivate()
{	
	if (!GetMarine() || GetMarine()->GetFlags() & FL_FROZEN)	// don't allow this if the marine is frozen
		return false;

	if (m_flNextPrimaryAttack < gpGlobals->curtime)
		PrimaryAttack();

	return true;
}
开发者ID:BenLubar,项目名称:riflemod,代码行数:10,代码来源:asw_weapon_stim_shared.cpp

示例14: ToBasePlayer

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponGrapple::ItemPostFrame( void )
{
	//Enforces being able to use PrimaryAttack and Secondary Attack
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
 
	if ( ( pOwner->m_nButtons & IN_ATTACK ) )
	{
		if ( m_flNextPrimaryAttack < gpGlobals->curtime )
		{
			PrimaryAttack();
		}
	}
	else if ( m_bMustReload ) //&& HasWeaponIdleTimeElapsed() )
	{
		Reload();
	}

	if ( ( pOwner->m_afButtonPressed & IN_ATTACK2 ) )
	{
		if ( m_flNextPrimaryAttack < gpGlobals->curtime )
		{
			SecondaryAttack();
		}
	}
	else if ( m_bMustReload ) //&& HasWeaponIdleTimeElapsed() )
	{
		Reload();
	}

	//Allow a refire as fast as the player can click
	if ( ( ( pOwner->m_nButtons & IN_ATTACK ) == false ) )
	{
		m_flNextPrimaryAttack = gpGlobals->curtime - 0.1f;
	}
 
#ifndef CLIENT_DLL
	if ( m_hHook )
	{
		if ( !(pOwner->m_nButtons & IN_ATTACK) && !(pOwner->m_nButtons & IN_ATTACK2))
		{
			m_hHook->SetTouch( NULL );
			m_hHook->SetThink( NULL );
 
			UTIL_Remove( m_hHook );
			m_hHook = NULL;
 
			NotifyHookDied();
 
			m_bMustReload = true;
		}
	}
#endif
 
//	BaseClass::ItemPostFrame();
}
开发者ID:MaestroFenix,项目名称:NewGrappleHook,代码行数:58,代码来源:c_weapon_grapple.cpp

示例15: ToBaseTFPlayer

//-----------------------------------------------------------------------------
// Purpose: Handle deploying, undeploying, firing, etc.
// TODO: Add a deploy to the firing!  Currently no reloading!
//-----------------------------------------------------------------------------
void CWeaponRocketLauncher::ItemPostFrame( void )
{
	// Get the player.
	CBaseTFPlayer *pPlayer = ToBaseTFPlayer( GetOwner() );
	if ( !pPlayer )
		return;

	if ( UsesClipsForAmmo1() )
	{
		CheckReload();
	}

#if !defined( CLIENT_DLL )
	if ( !HasPrimaryAmmo() && ( m_flNextPrimaryAttack <= gpGlobals->curtime ) )
	{
		pPlayer->SwitchToNextBestWeapon( NULL );
	}
#endif

	// Handle Firing
	if ( GetShieldState() == SS_DOWN && !m_bInReload )
	{
		// Attempting to fire.
		if ( ( pPlayer->m_nButtons & IN_ATTACK ) && ( m_flNextPrimaryAttack <= gpGlobals->curtime ) )
		{
			if ( m_iClip1 > 0 )
			{
				PrimaryAttack();
			}
			else
			{
				Reload();
			}
		}

		// Reload button (or fire button when we're out of ammo)
		if ( m_flNextPrimaryAttack <= gpGlobals->curtime ) 
		{
			if ( pPlayer->m_nButtons & IN_RELOAD ) 
			{
				Reload();
			}
			else if ( !((pPlayer->m_nButtons & IN_ATTACK) || (pPlayer->m_nButtons & IN_ATTACK2) || (pPlayer->m_nButtons & IN_RELOAD)) )
			{
				if ( !m_iClip1 && HasPrimaryAmmo() )
				{
					Reload();
				}
			}
		}
	}

	// Prevent shield post frame if we're not ready to attack, or we're charging
	AllowShieldPostFrame( m_flNextPrimaryAttack <= gpGlobals->curtime || m_bInReload );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:59,代码来源:weapon_rocketlauncher.cpp


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