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


C++ CBasePlayer::ApplyAbsVelocityImpulse方法代码示例

本文整理汇总了C++中CBasePlayer::ApplyAbsVelocityImpulse方法的典型用法代码示例。如果您正苦于以下问题:C++ CBasePlayer::ApplyAbsVelocityImpulse方法的具体用法?C++ CBasePlayer::ApplyAbsVelocityImpulse怎么用?C++ CBasePlayer::ApplyAbsVelocityImpulse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBasePlayer的用法示例。


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

示例1: ChargedFire


//.........这里部分代码省略.........

	SendWeaponAnim( ACT_VM_SECONDARYATTACK );
	StopChargeSound();

	m_bCharging = false;
	m_bChargeIndicated = false;

	m_flNextPrimaryAttack	= gpGlobals->curtime + 0.2f;
	m_flNextSecondaryAttack = gpGlobals->curtime + 0.5f;

	//Shoot a shot straight out
	Vector	startPos= pOwner->Weapon_ShootPosition();
	Vector	aimDir	= pOwner->GetAutoaimVector( AUTOAIM_5DEGREES );
	Vector	endPos	= startPos + ( aimDir * MAX_TRACE_LENGTH );
	
	trace_t	tr;
	UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );
	
#ifndef CLIENT_DLL

	ClearMultiDamage();

	//Find how much damage to do
	float flChargeAmount = ( gpGlobals->curtime - m_flChargeStartTime ) / MAX_GAUSS_CHARGE_TIME;

	//Clamp this
	if ( flChargeAmount > 1.0f )
		flChargeAmount = 1.0f;

	//Determine the damage amount
	float flDamage = sk_plr_dmg_gauss.GetFloat() + ( ( sk_plr_max_dmg_gauss.GetFloat() - sk_plr_dmg_gauss.GetFloat() ) * flChargeAmount );

#endif

	CBaseEntity *pHit = tr.m_pEnt;

	if ( tr.DidHitWorld() )
	{
		//Try wall penetration
		UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );
		UTIL_DecalTrace( &tr, "RedGlowFade" );

		CPVSFilter filter( tr.endpos );
		te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 );
		
		Vector	testPos = tr.endpos + ( aimDir * 48.0f );

		UTIL_TraceLine( testPos, tr.endpos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );
			
		if ( tr.allsolid == false )
		{
			UTIL_DecalTrace( &tr, "RedGlowFade" );

			penetrated = true;
		}
	}

#ifndef CLIENT_DLL
	else if ( pHit != NULL )
	{
		CTakeDamageInfo dmgInfo( this, pOwner, flDamage, DMG_SHOCK | DMG_DISSOLVE );
		CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos );

		//Do direct damage to anything in our path
		pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr );
	}

	ApplyMultiDamage();
#endif

	UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );

	QAngle	viewPunch;

	viewPunch.x = random->RandomFloat( -4.0f, -8.0f );
	viewPunch.y = random->RandomFloat( -0.25f,  0.25f );
	viewPunch.z = 0;

	pOwner->ViewPunch( viewPunch );

	DrawBeam( startPos, tr.endpos, 25, true );

#ifndef CLIENT_DLL
	Vector	recoilForce = pOwner->BodyDirection2D() * -( flDamage * 10.0f );
	recoilForce[2] += 300.0f;//128

	pOwner->ApplyAbsVelocityImpulse( recoilForce );
#endif

	CPVSFilter filter( tr.endpos );
	te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 );

#ifndef CLIENT_DLL
	if ( penetrated == true )
		RadiusDamage( CTakeDamageInfo( this, this, flDamage, DMG_SHOCK ), tr.endpos, 200.0f, CLASS_NONE, NULL );

	// Register a muzzleflash for the AI
	pOwner->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 );
#endif
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:101,代码来源:weapon_gauss.cpp

示例2: ChargedFire


//.........这里部分代码省略.........

		  UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );
		  UTIL_DecalTrace( &tr, "RedGlowFade" );
#ifndef CLIENT_DLL
		  //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner );
          RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner );
#endif

		  }

	  } else if(pHit != NULL){
#ifndef CLIENT_DLL
		 // CTakeDamageInfo dmgInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK );
//		  CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos );
          UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );
          UTIL_DecalTrace( &tr, "RedGlowFade" );
		  //Do Direct damage to anything in our path
//		  pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr );
#endif
	  }
#ifndef CLIENT_DLL
	  ApplyMultiDamage();
#endif


#ifndef CLIENT_DLL
		  //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner );
          RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner );
#endif

	 Vector  newPos = tr.endpos + ( aimDir * MAX_TRACE_LENGTH);
	  QAngle  viewPunch;
	  viewPunch.x = random->RandomFloat( -4.0f, -8.0f );
	  viewPunch.y = random->RandomFloat( -0.25f,  0.25f );
	  viewPunch.z = 0;
	  pOwner->ViewPunch( viewPunch );

	 // DrawBeam( startPos, tr.endpos, 9.6, true ); //Draw beam from gun through first wall.
#ifndef CLIENT_DLL
	Vector	recoilForce = pOwner->BodyDirection3D() * -( flDamage * 15.0f );
      recoilForce[2] += 128.0f;

      pOwner->ApplyAbsVelocityImpulse( recoilForce );
#endif
	  CPVSFilter filter( tr.endpos );
	  te->GaussExplosion(filter, 0.0f, tr.endpos, tr.plane.normal, 0 );

#ifndef CLIENT_DLL
		  //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner );
          RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner );
#endif


	  if ( penetrated == true ){

		  trace_t beam_tr;
		  Vector vecDest = tr.endpos + aimDir * MAX_TRACE_LENGTH;
		  UTIL_TraceLine( tr.endpos, vecDest, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &beam_tr ); //Traces from back of first wall to second wall


#ifndef CLIENT_DLL
	 // float flDamage = sk_plr_max_dmg_gauss.GetFloat() + ( ( sk_plr_max_dmg_gauss.GetFloat() - sk_plr_max_dmg_gauss.GetFloat() ) * flChargeAmount );


	float flDamage = 37 + ( ( 115 - 15 ) * flChargeAmount );
#endif



		  for(int i = 0; i < 0; i++){

			  UTIL_TraceLine(beam_tr.endpos + aimDir * 128.0f, beam_tr.endpos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &beam_tr ); //Traces To back of second wall


UTIL_ImpactTrace( &beam_tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );
UTIL_DecalTrace( &beam_tr, "RedGlowFade" );

#ifndef CLIENT_DLL
			  //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ), beam_tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner );
              RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner );
#endif



		  }
		  DrawBeam( tr.endpos, beam_tr.endpos, 9.6, false );
		  DoWallBreak(tr.endpos,newPos,aimDir,&tr,pOwner,true);

UTIL_ImpactTrace( &beam_tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );
UTIL_DecalTrace( &beam_tr, "RedGlowFade" );

#ifndef CLIENT_DLL
			  //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ), beam_tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner );
          RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner );
#endif

	return;	  
	  }

}
开发者ID:Sub-Zero1324,项目名称:HL2-DM-Gauss-Gun-Code,代码行数:101,代码来源:weapon_gauss.cpp


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