本文整理汇总了C++中CAI_BaseNPC::GetAlternateMoveShootTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_BaseNPC::GetAlternateMoveShootTarget方法的具体用法?C++ CAI_BaseNPC::GetAlternateMoveShootTarget怎么用?C++ CAI_BaseNPC::GetAlternateMoveShootTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_BaseNPC
的用法示例。
在下文中一共展示了CAI_BaseNPC::GetAlternateMoveShootTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunShootWhileMove
void CAI_MoveAndShootOverlay::RunShootWhileMove()
{
if ( m_bNoShootWhileMove )
return;
if ( gpGlobals->curtime < m_flSuspendUntilTime )
return;
m_flSuspendUntilTime = MOVESHOOT_DO_NOT_SUSPEND;
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->SetEnemy( pNewEnemy );
pOuter->SetState( NPC_STATE_COMBAT );
}
else
{
pOuter->ClearAttackConditions();
}
// SetEnemy( NULL );
}
/*if( !pOuter->GetNavigator()->IsGoalActive() )
return;*/
if ( GetEnemy() == NULL )
{
if ( pOuter->GetAlternateMoveShootTarget() )
{
// Aim at this other thing if I can't aim at my enemy.
pOuter->AddFacingTarget( pOuter->GetAlternateMoveShootTarget(), pOuter->GetAlternateMoveShootTarget()->GetAbsOrigin(), 1.0, 0.2 );
}
return;
}
bool bMoveAimAtEnemy = CanAimAtEnemy();
UpdateMoveShootActivity( bMoveAimAtEnemy );
if ( !bMoveAimAtEnemy )
{
EndShootWhileMove();
return;
}
Assert( HasAvailableRangeAttack() ); // This should have been caught at task start
Activity activity;
bool bIsReloading = false;
if ( ( activity = pOuter->TranslateActivity( ACT_GESTURE_RELOAD ) ) != ACT_INVALID )
{
bIsReloading = pOuter->IsPlayingGesture( activity );
}
if ( !bIsReloading && HasAvailableRangeAttack() )
{
// time to fire?
if ( pOuter->HasCondition( COND_CAN_RANGE_ATTACK1, false ) )
{
if ( pOuter->GetShotRegulator()->IsInRestInterval() )
{
EndShootWhileMove();
}
else if ( pOuter->GetShotRegulator()->ShouldShoot() )
{
if ( m_bMovingAndShooting || pOuter->OnBeginMoveAndShoot() )
{
m_bMovingAndShooting = true;
pOuter->OnRangeAttack1();
activity = pOuter->TranslateActivity( ACT_GESTURE_RANGE_ATTACK1 );
Assert( activity != ACT_INVALID );
pOuter->RestartGesture( activity );
// FIXME: this seems a bit wacked
pOuter->Weapon_SetActivity( pOuter->Weapon_TranslateActivity( ACT_RANGE_ATTACK1 ), 0 );
}
}
}
}
// 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 );
}