当前位置: 首页>>代码示例>>C++>>正文


C++ TaskComplete函数代码示例

本文整理汇总了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);
        }
    }
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:56,代码来源:ai_basenpc_physicsflyer.cpp

示例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();
    }
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:53,代码来源:ai_basehumanoid.cpp

示例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;
    }
}
开发者ID:FaucetDC,项目名称:HLDC_SDK,代码行数:52,代码来源:bigmomma.cpp

示例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;
    }
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:53,代码来源:asw_ai_behavior_ranged_attack.cpp

示例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;
    }
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:52,代码来源:npc_ichthyosaur.cpp

示例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;
    }
}
开发者ID:oskarlh,项目名称:HLEnhanced,代码行数:48,代码来源:CController.cpp

示例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;
    }
}
开发者ID:Hammermaps-DEV,项目名称:Spirit-of-Half-Life-1.8--VC2010,代码行数:51,代码来源:npc_controller.cpp

示例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;
    }
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:38,代码来源:ai_behavior_alyx_injured.cpp

示例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;
        }
    }
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:29,代码来源:hl1_npc_bullsquid.cpp

示例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;
    }
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:35,代码来源:npc_rollerdozer.cpp

示例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;
    }
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:34,代码来源:ai_behavior_rappel.cpp

示例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;
    }
}
开发者ID:BenLubar,项目名称:riflemod,代码行数:25,代码来源:asw_alien_jumper.cpp

示例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();
    }
}
开发者ID:wrenchmods,项目名称:Sleepless,代码行数:35,代码来源:npc_infected.cpp

示例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;
    }
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:35,代码来源:asw_ai_behavior_prepare_to_engage.cpp

示例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;
    }
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:34,代码来源:hl1_npc_gargantua.cpp


注:本文中的TaskComplete函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。