本文整理汇总了C++中CBaseCombatCharacter::GetSmoothedVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatCharacter::GetSmoothedVelocity方法的具体用法?C++ CBaseCombatCharacter::GetSmoothedVelocity怎么用?C++ CBaseCombatCharacter::GetSmoothedVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatCharacter
的用法示例。
在下文中一共展示了CBaseCombatCharacter::GetSmoothedVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartTask
//=========================================================
// start task
//=========================================================
void CNPC_Stalker::StartTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_STALKER_SCREAM:
{
if( gpGlobals->curtime > m_flNextScreamTime )
{
EmitSound( "NPC_Stalker.Scream" );
m_flNextScreamTime = gpGlobals->curtime + random->RandomFloat( 10.0, 15.0 );
}
TaskComplete();
}
case TASK_ANNOUNCE_ATTACK:
{
// If enemy isn't facing me and I haven't attacked in a while
// annouce my attack before I start wailing away
CBaseCombatCharacter *pBCC = GetEnemyCombatCharacterPointer();
if (pBCC && (!pBCC->FInViewCone ( this )) &&
(gpGlobals->curtime - m_flLastAttackTime > 1.0) )
{
m_flLastAttackTime = gpGlobals->curtime;
// Always play this sound
EmitSound( "NPC_Stalker.Scream" );
m_flNextScrambleSoundTime = gpGlobals->curtime + 2;
m_flNextBreatheSoundTime = gpGlobals->curtime + 2;
// Wait two seconds
SetWait( 2.0 );
SetActivity(ACT_IDLE);
}
break;
}
case TASK_STALKER_ZIGZAG:
break;
case TASK_RANGE_ATTACK1:
{
CBaseEntity *pEnemy = GetEnemy();
if (pEnemy)
{
m_vLaserTargetPos = GetEnemyLKP() + pEnemy->GetViewOffset();
// Never hit target on first try
Vector missPos = m_vLaserTargetPos;
if( pEnemy->Classify() == CLASS_BULLSEYE && hl2_episodic.GetBool() )
{
missPos.x += 60 + 120*random->RandomInt(-1,1);
missPos.y += 60 + 120*random->RandomInt(-1,1);
}
else
{
missPos.x += 80*random->RandomInt(-1,1);
missPos.y += 80*random->RandomInt(-1,1);
}
// ----------------------------------------------------------------------
// If target is facing me and not running towards me shoot below his feet
// so he can see the laser coming
// ----------------------------------------------------------------------
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter(pEnemy);
if (pBCC)
{
Vector targetToMe = (pBCC->GetAbsOrigin() - GetAbsOrigin());
Vector vBCCFacing = pBCC->BodyDirection2D( );
if ((DotProduct(vBCCFacing,targetToMe) < 0) &&
(pBCC->GetSmoothedVelocity().Length() < 50))
{
missPos.z -= 150;
}
// --------------------------------------------------------
// If facing away or running towards laser,
// shoot above target's head
// --------------------------------------------------------
else
{
missPos.z += 60;
}
}
m_vLaserDir = missPos - LaserStartPosition(GetAbsOrigin());
VectorNormalize(m_vLaserDir);
}
else
{
TaskFail(FAIL_NO_ENEMY);
return;
}
StartAttackBeam();
SetActivity(ACT_RANGE_ATTACK1);
break;
}
case TASK_GET_PATH_TO_ENEMY_LOS:
//.........这里部分代码省略.........