本文整理汇总了C++中CAI_BaseNPC::SetLastAttackTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC::SetLastAttackTime方法的具体用法?C++ CAI_BaseNPC::SetLastAttackTime怎么用?C++ CAI_BaseNPC::SetLastAttackTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_BaseNPC
的用法示例。
在下文中一共展示了CAI_BaseNPC::SetLastAttackTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunShootWhileMove
void CAI_MoveAndShootOverlay::RunShootWhileMove()
{
if ( m_flNextMoveShootTime == FLT_MAX )
return;
CAI_BaseNPC *pOuter = GetOuter();
// keep enemy if dead but try to look for a new one
if (!pOuter->GetEnemy() || !pOuter->GetEnemy()->IsAlive())
{
CBaseEntity *pNewEnemy = pOuter->BestEnemy();
if( pNewEnemy != NULL )
{
//New enemy! Clear the timers and set conditions.
pOuter->SetCondition( COND_NEW_ENEMY );
pOuter->SetEnemy( pNewEnemy );
pOuter->SetState( NPC_STATE_COMBAT );
}
else
{
pOuter->ClearAttackConditions();
}
// SetEnemy( NULL );
}
if ( GetEnemy() == NULL || !pOuter->GetNavigator()->IsGoalActive() )
return;
bool bMoveAimAtEnemy = CanAimAtEnemy();
UpdateMoveShootActivity( bMoveAimAtEnemy );
if (bMoveAimAtEnemy)
{
Assert( pOuter->GetActiveWeapon() ); // This should have been caught at task start
// time to fire?
if ( pOuter->HasCondition( COND_CAN_RANGE_ATTACK1 ) && gpGlobals->curtime >= m_flNextMoveShootTime )
{
if ( m_bMovingAndShooting || GetOuter()->OnBeginMoveAndShoot() )
{
m_bMovingAndShooting = true;
Activity activity = pOuter->TranslateActivity( ACT_GESTURE_RANGE_ATTACK1 );
Assert( activity != ACT_INVALID );
if (--m_nMoveShots > 0)
{
pOuter->SetLastAttackTime( gpGlobals->curtime );
pOuter->AddGesture( activity );
// FIXME: this seems a bit wacked
pOuter->Weapon_SetActivity( pOuter->Weapon_TranslateActivity( ACT_RANGE_ATTACK1 ), 0 );
m_flNextMoveShootTime = gpGlobals->curtime + pOuter->GetActiveWeapon()->GetFireRate() - 0.1;
}
else
{
m_nMoveShots = random->RandomInt( m_minBurst, m_maxBurst );
m_flNextMoveShootTime = gpGlobals->curtime + random->RandomFloat( m_minPause, m_maxPause );
m_bMovingAndShooting = false;
GetOuter()->OnEndMoveAndShoot();
}
}
}
// try to keep facing towards the last known position of the enemy
Vector vecEnemyLKP = pOuter->GetEnemyLKP();
pOuter->AddFacingTarget( pOuter->GetEnemy(), vecEnemyLKP, 1.0, 0.8 );
}
else
{
if ( m_bMovingAndShooting )
{
m_bMovingAndShooting = false;
GetOuter()->OnEndMoveAndShoot();
}
}
}