本文整理汇总了C++中CBasePlayer::BodyDirection3D方法的典型用法代码示例。如果您正苦于以下问题:C++ CBasePlayer::BodyDirection3D方法的具体用法?C++ CBasePlayer::BodyDirection3D怎么用?C++ CBasePlayer::BodyDirection3D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBasePlayer
的用法示例。
在下文中一共展示了CBasePlayer::BodyDirection3D方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GatherEnemyConditions
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNPC_Assassin::GatherEnemyConditions( CBaseEntity *pEnemy )
{
ClearCondition( COND_ASSASSIN_ENEMY_TARGETTING_ME );
BaseClass::GatherEnemyConditions( pEnemy );
// See if we're being targetted specifically
if ( HasCondition( COND_ENEMY_FACING_ME ) )
{
Vector enemyDir = GetAbsOrigin() - pEnemy->GetAbsOrigin();
VectorNormalize( enemyDir );
Vector enemyBodyDir;
CBasePlayer *pPlayer = ToBasePlayer( pEnemy );
if ( pPlayer != NULL )
{
enemyBodyDir = pPlayer->BodyDirection3D();
}
else
{
AngleVectors( pEnemy->GetAbsAngles(), &enemyBodyDir );
}
float enemyDot = DotProduct( enemyBodyDir, enemyDir );
//FIXME: Need to refine this a bit
if ( enemyDot > 0.97f )
{
SetCondition( COND_ASSASSIN_ENEMY_TARGETTING_ME );
}
}
}
示例2: SatchelThrow
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::SatchelThrow( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
#ifndef CLIENT_DLL
m_bThrowSatchel = false;
Vector vecSrc = pPlayer->WorldSpaceCenter();
Vector vecFacing = pPlayer->BodyDirection3D( );
vecSrc = vecSrc + vecFacing * 18.0;
// BUGBUG: is this because vecSrc is not from Weapon_ShootPosition()???
vecSrc.z += 24.0f;
Vector vecThrow;
GetOwner()->GetVelocity( &vecThrow, NULL );
vecThrow += vecFacing * 500;
// Player may have turned to face a wall during the throw anim in which case
// we don't want to throw the SLAM into the wall
if (CanAttachSLAM())
{
vecThrow = vecFacing;
vecSrc = pPlayer->WorldSpaceCenter() + vecFacing * 5.0;
}
CSatchelCharge *pSatchel = (CSatchelCharge*)Create( "npc_satchel", vecSrc, vec3_angle, GetOwner() );
if ( pSatchel )
{
pSatchel->SetThrower( GetOwner() );
pSatchel->ApplyAbsVelocityImpulse( vecThrow );
pSatchel->SetLocalAngularVelocity( QAngle( 0, 400, 0 ) );
pSatchel->m_bIsLive = true;
pSatchel->m_pMyWeaponSLAM = this;
}
pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType );
pPlayer->SetAnimation( PLAYER_ATTACK1 );
#endif
//Tony; is there a different anim in the player? must check..
ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
// Play throw sound
EmitSound( "Weapon_SLAM.SatchelThrow" );
}
示例3: StartTripmineAttach
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::StartTripmineAttach( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
Vector vecSrc = pPlayer->Weapon_ShootPosition();
Vector vecAiming = pPlayer->BodyDirection3D( );
trace_t tr;
UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 128), MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &tr );
if (tr.fraction < 1.0)
{
// ALERT( at_console, "hit %f\n", tr.flFraction );
CBaseEntity *pEntity = tr.m_pEnt;
if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
{
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
// -----------------------------------------
// Play attach animation
// -----------------------------------------
SendWeaponAnim(ACT_SLAM_TRIPMINE_ATTACH);
m_bNeedReload = true;
m_bAttachTripmine = true;
}
else
{
// ALERT( at_console, "no deploy\n" );
}
}
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration();
// SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration() );
}
示例4: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponMolotov::PrimaryAttack( void )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
Vector vecSrc = pPlayer->WorldSpaceCenter();
Vector vecFacing = pPlayer->BodyDirection3D( );
vecSrc = vecSrc + vecFacing * 18.0;
// BUGBUG: is this some hack because it's not at the eye position????
vecSrc.z += 24.0f;
// Player may have turned to face a wall during the throw anim in which case
// we don't want to throw the SLAM into the wall
if (ObjectInWay())
{
vecSrc = pPlayer->WorldSpaceCenter() + vecFacing * 5.0;
}
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
vecAiming.z += 0.20; // Raise up so passes through reticle
ThrowMolotov(vecSrc, vecAiming*800);
pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType );
// Don't fire again until fire animation has completed
//m_flNextPrimaryAttack = gpGlobals->curtime + CurSequenceDuration();
//<<TEMP>> - till real animation is avaible
m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
m_flNextSecondaryAttack = gpGlobals->curtime + 1.0;
m_bNeedDraw = true;
}
示例5: Throw
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponBrickbat::Throw( void )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
Vector vecSrc = pPlayer->WorldSpaceCenter();
Vector vecFacing = pPlayer->BodyDirection3D( );
vecSrc = vecSrc + vecFacing * 18.0;
vecSrc.z += 24.0f;
// Player may have turned to face a wall during the throw anim in which case
// we don't want to throw the SLAM into the wall
if (ObjectInWay())
{
vecSrc = pPlayer->WorldSpaceCenter() + vecFacing * 5.0;
}
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
vecAiming.z += 0.20; // Raise up so passes through reticle
ThrowBrickbat(vecSrc, vecAiming*800, sk_plr_dmg_brickbat.GetFloat());
pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
SendWeaponAnim(ACT_VM_THROW);
// Don't fire again until fire animation has completed
float flSequenceEndTime = gpGlobals->curtime + SequenceDuration();
pPlayer->m_flNextAttack = m_flNextPrimaryAttack = m_flNextSecondaryAttack = flSequenceEndTime;
m_bNeedThrow = false;
m_bNeedDraw = true;
}
示例6: 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;
}
}