本文整理汇总了C++中TaskComplete函数的典型用法代码示例。如果您正苦于以下问题:C++ TaskComplete函数的具体用法?C++ TaskComplete怎么用?C++ TaskComplete使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TaskComplete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CAI_BasePhysicsFlyingBot::StartTask( const Task_t *pTask )
{
switch (pTask->iTask)
{
// Skip as done via bone controller
case TASK_FACE_ENEMY:
{
TaskComplete();
break;
}
// Activity is just idle (have no run)
case TASK_RUN_PATH:
{
GetNavigator()->SetMovementActivity(ACT_IDLE);
TaskComplete();
break;
}
// Don't check for run/walk activity
case TASK_RUN_TO_TARGET:
case TASK_WALK_TO_TARGET:
{
if (GetTarget() == NULL)
{
TaskFail(FAIL_NO_TARGET);
}
else
{
if (!GetNavigator()->SetGoal( GOALTYPE_TARGETENT ) )
{
TaskFail(FAIL_NO_ROUTE);
GetNavigator()->ClearGoal();
}
}
TaskComplete();
break;
}
// Override to get more to get a directional path
case TASK_GET_PATH_TO_RANDOM_NODE:
{
if ( GetNavigator()->SetRandomGoal( pTask->flTaskData, m_vLastPatrolDir ) )
TaskComplete();
else
TaskFail(FAIL_NO_REACHABLE_NODE);
break;
}
default:
{
BaseClass::StartTask(pTask);
}
}
}
示例2: AutoMovement
//-----------------------------------------------------------------------------
// TASK_RANGE_ATTACK1 / TASK_RANGE_ATTACK2 / etc.
//-----------------------------------------------------------------------------
void CAI_BaseHumanoid::RunTaskRangeAttack1( const Task_t *pTask )
{
if ( ( CapabilitiesGet() & bits_CAP_USE_SHOT_REGULATOR ) == 0 )
{
BaseClass::RunTask( pTask );
return;
}
AutoMovement( );
Vector vecEnemyLKP = GetEnemyLKP();
// If our enemy was killed, but I'm not done animating, the last known position comes
// back as the origin and makes the me face the world origin if my attack schedule
// doesn't break when my enemy dies. (sjb)
if( vecEnemyLKP != vec3_origin )
{
if ( ( pTask->iTask == TASK_RANGE_ATTACK1 || pTask->iTask == TASK_RELOAD ) &&
( CapabilitiesGet() & bits_CAP_AIM_GUN ) &&
FInAimCone( vecEnemyLKP ) )
{
// Arms will aim, so leave body yaw as is
GetMotor()->SetIdealYawAndUpdate( GetMotor()->GetIdealYaw(), AI_KEEP_YAW_SPEED );
}
else
{
GetMotor()->SetIdealYawToTargetAndUpdate( vecEnemyLKP, AI_KEEP_YAW_SPEED );
}
}
if ( IsActivityFinished() )
{
if ( !GetEnemy() || !GetEnemy()->IsAlive() )
{
TaskComplete();
return;
}
if ( !GetShotRegulator()->IsInRestInterval() )
{
if ( GetShotRegulator()->ShouldShoot() )
{
OnRangeAttack1();
ResetIdealActivity( ACT_RANGE_ATTACK1 );
}
return;
}
TaskComplete();
}
}
示例3: switch
//=========================================================
// RunTask
//=========================================================
void CBigMomma::RunTask( Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_MOVE_TO_NODE_RANGE:
{
float distance;
if ( m_hTargetEnt == NULL )
TaskFail();
else
{
distance = ( m_vecMoveGoal - pev->origin ).Length2D();
// Set the appropriate activity based on an overlapping range
// overlap the range to prevent oscillation
if ( (distance < GetNodeRange()) || MovementIsComplete() )
{
ALERT( at_aiconsole, "BM: Reached node!\n" );
TaskComplete();
RouteClear(); // Stop moving
}
}
}
break;
case TASK_WAIT_NODE:
if ( m_hTargetEnt != NULL && (m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT) )
return;
if ( gpGlobals->time > m_flWaitFinished )
TaskComplete();
ALERT( at_aiconsole, "BM: The WAIT is over!\n" );
break;
case TASK_PLAY_NODE_PRESEQUENCE:
case TASK_PLAY_NODE_SEQUENCE:
if ( m_fSequenceFinished )
{
m_Activity = ACT_RESET;
TaskComplete();
}
break;
default:
CBaseMonster::RunTask( pTask );
break;
}
}
示例4: switch
//------------------------------------------------------------------------------
// Purpose: routine called every frame when a task is running
// Input : pTask - the task structure
//------------------------------------------------------------------------------
void CAI_ASW_RangedAttackBehavior::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_RANGED_FIND_MISSILE_LOCATION:
{
TaskComplete();
m_flDeferUntil = gpGlobals->curtime + m_flFireRate;
break;
}
case TASK_RANGED_PREPARE_TO_FIRE:
{
if ( !GetOuter()->FInAimCone( m_vMissileLocation ) )
{
GetMotor()->SetIdealYawToTargetAndUpdate( m_vMissileLocation, AI_KEEP_YAW_SPEED );
}
if ( GetOuter()->IsActivityFinished() )
{
TaskComplete();
}
break;
}
case TASK_RANGED_FIRE:
{
if ( GetOuter()->IsActivityFinished() )
{
TaskComplete();
GetOuter()->OnRangeAttack1();
}
break;
}
case TASK_RANGED_FIRE_RECOVER:
{
if ( GetOuter()->IsActivityFinished() )
{
TaskComplete();
}
break;
}
default:
BaseClass::RunTask( pTask );
break;
}
}
示例5: switch
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pTask -
//-----------------------------------------------------------------------------
void CNPC_Ichthyosaur::StartTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_ICH_THRASH_PATH:
GetNavigator()->SetMovementActivity( (Activity) ACT_ICH_THRASH );
TaskComplete();
break;
case TASK_ICH_GET_PATH_TO_RANDOM_NODE:
{
if ( GetEnemy() == NULL || !GetNavigator()->SetRandomGoal( GetEnemy()->GetLocalOrigin(), pTask->flTaskData ) )
{
if (!GetNavigator()->SetRandomGoal( pTask->flTaskData ) )
{
TaskFail(FAIL_NO_REACHABLE_NODE);
return;
}
}
TaskComplete();
}
break;
case TASK_ICH_GET_PATH_TO_DROWN_NODE:
{
Vector drownPos = GetLocalOrigin() - Vector( 0, 0, pTask->flTaskData );
if ( GetNavigator()->SetGoal( drownPos, AIN_CLEAR_TARGET ) == false )
{
TaskFail( FAIL_NO_ROUTE );
return;
}
TaskComplete();
}
break;
case TASK_MELEE_ATTACK1:
m_flPlaybackRate = 1.0f;
BaseClass::StartTask(pTask);
break;
default:
BaseClass::StartTask(pTask);
break;
}
}
示例6: StartTask
void CController :: StartTask ( const Task_t& task )
{
switch ( task.iTask )
{
case TASK_RANGE_ATTACK1:
CSquadMonster :: StartTask ( task );
break;
case TASK_GET_PATH_TO_ENEMY_LKP:
{
if (BuildNearestRoute( m_vecEnemyLKP, GetViewOffset(), task.flData, (m_vecEnemyLKP - GetAbsOrigin()).Length() + 1024 ))
{
TaskComplete();
}
else
{
// no way to get there =(
ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" );
TaskFail();
}
break;
}
case TASK_GET_PATH_TO_ENEMY:
{
CBaseEntity *pEnemy = m_hEnemy;
if ( pEnemy == NULL )
{
TaskFail();
return;
}
if (BuildNearestRoute( pEnemy->GetAbsOrigin(), pEnemy->GetViewOffset(), task.flData, (pEnemy->GetAbsOrigin() - GetAbsOrigin()).Length() + 1024 ))
{
TaskComplete();
}
else
{
// no way to get there =(
ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" );
TaskFail();
}
break;
}
default:
CSquadMonster :: StartTask ( task );
break;
}
}
示例7: StartTask
//=========================================================
// StartTask
//=========================================================
void CController :: StartTask ( Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_RANGE_ATTACK1:
CSquadMonster :: StartTask ( pTask );
break;
case TASK_GET_PATH_TO_ENEMY_LKP:
{
if (BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, pTask->flData, (m_vecEnemyLKP - pev->origin).Length() + 1024 ))
{
TaskComplete();
}
else
{
// no way to get there =(
ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" );
TaskFail();
}
break;
}
case TASK_GET_PATH_TO_ENEMY:
{
CBaseEntity *pEnemy = m_hEnemy;
if ( pEnemy == NULL )
{
TaskFail();
return;
}
if (BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, pTask->flData, (pEnemy->pev->origin - pev->origin).Length() + 1024 ))
{
TaskComplete();
}
else
{
// no way to get there =(
ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" );
TaskFail();
}
break;
}
default:
CSquadMonster :: StartTask ( pTask );
break;
}
}
示例8: switch
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pTask -
//-----------------------------------------------------------------------------
void CAI_BehaviorAlyxInjured::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_FIND_COVER_FROM_ENEMY:
{
CBaseEntity *pLeader = GetFollowTarget();
if ( !pLeader )
{
BaseClass::StartTask( pTask );
break;
}
// Find a position behind our follow target
Vector coverPos = vec3_invalid;
if ( FindCoverFromEnemyBehindTarget( pLeader, COVER_DISTANCE, &coverPos ) )
{
AI_NavGoal_t goal( GOALTYPE_LOCATION, coverPos, ACT_RUN, AIN_HULL_TOLERANCE, AIN_DEF_FLAGS );
GetOuter()->GetNavigator()->SetGoal( goal );
GetOuter()->m_flMoveWaitFinished = gpGlobals->curtime + pTask->flTaskData;
TaskComplete();
return;
}
// Couldn't find anything
TaskFail( FAIL_NO_COVER );
break;
}
default:
BaseClass::StartTask( pTask );
break;
}
}
示例9: switch
//=========================================================
// RunTask
//=========================================================
void CNPC_Bullsquid::RunTask ( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_SQUID_HOPTURN:
{
if ( GetEnemy() )
{
Vector vecFacing = ( GetEnemy()->GetAbsOrigin() - GetAbsOrigin() );
VectorNormalize( vecFacing );
GetMotor()->SetIdealYaw( vecFacing );
}
if ( IsSequenceFinished() )
{
TaskComplete();
}
break;
}
default:
{
BaseClass::RunTask( pTask );
break;
}
}
}
示例10: switch
//-----------------------------------------------------------------------------
// Purpose:
//
//
// Output :
//-----------------------------------------------------------------------------
void CNPC_RollerDozer::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_ROLLERDOZER_GET_PATH_TO_CLEANUP_POINT:
if ( GetNavigator()->SetGoal( m_vecCleanupPoint, AIN_CLEAR_TARGET ) )
{
TaskComplete();
}
else
{
// no way to get there
TaskFail(FAIL_NO_ROUTE);
}
break;
case TASK_ROLLERDOZER_CLEAR_DEBRIS:
GetNavigator()->ClearGoal();
m_flWaitFinished = gpGlobals->curtime + 5;
break;
case TASK_ROLLERDOZER_FIND_CLEANUP_NODE:
break;
default:
BaseClass::StartTask( pTask );
break;
}
}
示例11: switch
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pTask -
//-----------------------------------------------------------------------------
void CAI_RappelBehavior::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_MOVE_AWAY_PATH:
GetOuter()->GetMotor()->SetIdealYaw( UTIL_AngleMod( GetOuter()->GetLocalAngles().y - 180.0f ) );
BaseClass::StartTask( pTask );
break;
case TASK_RANGE_ATTACK1:
BaseClass::StartTask( pTask );
break;
case TASK_RAPPEL:
{
CreateZipline();
SetDescentSpeed();
}
break;
case TASK_HIT_GROUND:
m_bOnGround = true;
TaskComplete();
break;
default:
BaseClass::StartTask( pTask );
break;
}
}
示例12: switch
void CASW_Alien_Jumper::StartTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_ASW_ALIEN_FACE_JUMP:
break;
case TASK_ASW_ALIEN_JUMP:
if ( CheckLanding() )
{
TaskComplete();
}
break;
case TASK_ASW_ALIEN_RETRY_JUMP:
{
if (!DoJumpTo(m_vecLastJumpAttempt))
WaitAndRetryJump(m_vecLastJumpAttempt);
}
break;
default:
BaseClass::StartTask( pTask );
break;
}
}
示例13: AutoMovement
void CNPC_Infected::RunAttackTask( int task )
{
AutoMovement( );
Vector vecEnemyLKP = GetEnemyLKP();
// If our enemy was killed, but I'm not done animating, the last known position comes
// back as the origin and makes the me face the world origin if my attack schedule
// doesn't break when my enemy dies. (sjb)
if( vecEnemyLKP != vec3_origin )
{
if ( ( task == TASK_RANGE_ATTACK1 || task == TASK_RELOAD ) &&
( CapabilitiesGet() & bits_CAP_AIM_GUN ) &&
FInAimCone( vecEnemyLKP ) )
{
// Arms will aim, so leave body yaw as is
GetMotor()->SetIdealYawAndUpdate( GetMotor()->GetIdealYaw(), AI_KEEP_YAW_SPEED );
}
else
{
GetMotor()->SetIdealYawToTargetAndUpdate( vecEnemyLKP, AI_KEEP_YAW_SPEED );
}
}
CAnimationLayer *pPlayer = GetAnimOverlay( m_iAttackLayer );
if ( pPlayer->m_bSequenceFinished )
{
if ( task == TASK_RELOAD && GetShotRegulator() )
{
GetShotRegulator()->Reset( false );
}
TaskComplete();
}
}
示例14: switch
//------------------------------------------------------------------------------
// Purpose: routine called to start when a task initially starts
// Input : pTask - the task structure
//------------------------------------------------------------------------------
void CAI_ASW_PrepareToEngageBehavior::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_PREPARE_TO_ENGAGE:
{
CBaseEntity *pEnemy = GetEnemy();
if ( pEnemy == NULL )
{
TaskFail( FAIL_NO_ENEMY );
return;
}
if ( GetPrepareToAttackPath( GetEnemy()->GetAbsOrigin() ) )
{
TaskComplete();
}
else
{
// TODO: wander to a random nearby spot
TaskFail( FAIL_NO_ROUTE );
}
return;
}
default:
BaseClass::StartTask( pTask );
break;
}
}
示例15: switch
void CNPC_Gargantua::StartTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_FLAME_SWEEP:
//TEMP TEMP
FlameCreate();
m_flWaitFinished = gpGlobals->curtime + pTask->flTaskData;
m_flameTime = gpGlobals->curtime + 6;
m_flameX = 0;
m_flameY = 0;
break;
case TASK_SOUND_ATTACK:
if ( random->RandomInt(0,100) < 30 )
{
CPASAttenuationFilter filter( this );
enginesound->EmitSound( filter, entindex(), CHAN_VOICE, pAttackSounds[ random->RandomInt(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM );
}
TaskComplete();
break;
case TASK_DIE:
m_flWaitFinished = gpGlobals->curtime + 1.6;
DeathEffect();
// FALL THROUGH
default:
BaseClass::StartTask( pTask );
break;
}
}