本文整理汇总了C++中CAI_BaseNPC::SetAbsVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC::SetAbsVelocity方法的具体用法?C++ CAI_BaseNPC::SetAbsVelocity怎么用?C++ CAI_BaseNPC::SetAbsVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_BaseNPC
的用法示例。
在下文中一共展示了CAI_BaseNPC::SetAbsVelocity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunTask
//=========================================================
// RunTask
//=========================================================
void CNPC_Controller::RunTask ( const Task_t *pTask )
{
if (m_flShootEnd > gpGlobals->curtime)
{
Vector vecHand;
QAngle vecAngle;
GetAttachment( 2, vecHand, vecAngle );
while (m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->curtime)
{
Vector vecSrc = vecHand + GetAbsVelocity() * (m_flShootTime - gpGlobals->curtime);
Vector vecDir;
if (GetEnemy() != NULL)
{
if (HasCondition( COND_SEE_ENEMY ))
{
m_vecEstVelocity = m_vecEstVelocity * 0.5 + GetEnemy()->GetAbsVelocity() * 0.5;
}
else
{
m_vecEstVelocity = m_vecEstVelocity * 0.8;
}
vecDir = Intersect( vecSrc, GetEnemy()->BodyTarget( GetAbsOrigin() ), m_vecEstVelocity, sk_controller_speedball.GetFloat() );
float delta = 0.03490; // +-2 degree
vecDir = vecDir + Vector( random->RandomFloat( -delta, delta ), random->RandomFloat( -delta, delta ), random->RandomFloat( -delta, delta ) ) * sk_controller_speedball.GetFloat();
vecSrc = vecSrc + vecDir * (gpGlobals->curtime - m_flShootTime);
CAI_BaseNPC *pBall = (CAI_BaseNPC*)Create( "controller_energy_ball", vecSrc, GetAbsAngles(), this );
pBall->SetAbsVelocity( vecDir );
// DevMsg( 2, "controller shooting energy ball\n" );
}
m_flShootTime += 0.2;
}
if (m_flShootTime > m_flShootEnd)
{
m_iBall[0] = 64;
m_iBallTime[0] = m_flShootEnd;
m_iBall[1] = 64;
m_iBallTime[1] = m_flShootEnd;
m_fInCombat = FALSE;
}
}
switch ( pTask->iTask )
{
case TASK_WAIT_FOR_MOVEMENT:
case TASK_WAIT:
case TASK_WAIT_FACE_ENEMY:
case TASK_WAIT_PVS:
{
if( GetEnemy() )
{
float idealYaw = UTIL_VecToYaw( GetEnemy()->GetAbsOrigin() - GetAbsOrigin() );
GetMotor()->SetIdealYawAndUpdate( idealYaw );
}
if ( IsSequenceFinished() || GetActivity() == ACT_IDLE)
{
m_fInCombat = false;
}
BaseClass::RunTask ( pTask );
if (!m_fInCombat)
{
if( HasCondition( COND_CAN_RANGE_ATTACK1 ))
{
SetActivity( ACT_RANGE_ATTACK1 );
SetCycle( 0 );
ResetSequenceInfo( );
m_fInCombat = true;
}
else if( HasCondition( COND_CAN_RANGE_ATTACK2 ) )
{
SetActivity( ACT_RANGE_ATTACK2 );
SetCycle( 0 );
ResetSequenceInfo( );
m_fInCombat = true;
}
else
{
int iFloatActivity = LookupFloat();
if( IsSequenceFinished() || iFloatActivity != GetActivity() )
{
SetActivity( (Activity)iFloatActivity );
}
}
}
}
break;
default:
//.........这里部分代码省略.........
示例2: HandleAnimEvent
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CNPC_Controller::HandleAnimEvent( animevent_t *pEvent )
{
switch( pEvent->event )
{
case CONTROLLER_AE_HEAD_OPEN:
{
Vector vecStart;
QAngle angleGun;
GetAttachment( 0, vecStart, angleGun );
// BUGBUG - attach to attachment point!
CBroadcastRecipientFilter filter;
te->DynamicLight( filter, 0.0, &vecStart, 255, 192, 64, 0, 1 /*radius*/, 0.2, -32 );
m_iBall[0] = 192;
m_iBallTime[0] = gpGlobals->curtime + atoi( pEvent->options ) / 15.0;
m_iBall[1] = 255;
m_iBallTime[1] = gpGlobals->curtime + atoi( pEvent->options ) / 15.0;
}
break;
case CONTROLLER_AE_BALL_SHOOT:
{
Vector vecStart;
QAngle angleGun;
GetAttachment( 1, vecStart, angleGun );
CBroadcastRecipientFilter filter;
te->DynamicLight( filter, 0.0, &vecStart, 255, 192, 64, 0, 1 /*radius*/, 0.1, 32 );
CAI_BaseNPC *pBall = (CAI_BaseNPC*)Create( "controller_head_ball", vecStart, angleGun );
pBall->SetAbsVelocity( Vector(0,0,32) );
pBall->SetEnemy( GetEnemy() );
// DevMsg( 1, "controller shooting head ball\n" );
m_iBall[0] = 0;
m_iBall[1] = 0;
}
break;
case CONTROLLER_AE_SMALL_SHOOT:
{
AttackSound( );
m_flShootTime = gpGlobals->curtime;
m_flShootEnd = m_flShootTime + atoi( pEvent->options ) / 15.0;
}
break;
case CONTROLLER_AE_POWERUP_FULL:
{
m_iBall[0] = 255;
m_iBallTime[0] = gpGlobals->curtime + atoi( pEvent->options ) / 15.0;
m_iBall[1] = 255;
m_iBallTime[1] = gpGlobals->curtime + atoi( pEvent->options ) / 15.0;
}
break;
case CONTROLLER_AE_POWERUP_HALF:
{
m_iBall[0] = 192;
m_iBallTime[0] = gpGlobals->curtime + atoi( pEvent->options ) / 15.0;
m_iBall[1] = 192;
m_iBallTime[1] = gpGlobals->curtime + atoi( pEvent->options ) / 15.0;
}
break;
default:
BaseClass::HandleAnimEvent( pEvent );
break;
}
}