本文整理汇总了C++中TaskFail函数的典型用法代码示例。如果您正苦于以下问题:C++ TaskFail函数的具体用法?C++ TaskFail怎么用?C++ TaskFail使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TaskFail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: switch
void CAI_PlayerAlly::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_TALKER_CLIENT_STARE:
case TASK_TALKER_LOOK_AT_CLIENT:
if ( pTask->iTask == TASK_TALKER_CLIENT_STARE )
{
// Get edict for one player
CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( engine->PEntityOfEntIndex( 1 ) );
Assert( pPlayer );
// fail out if the player looks away or moves away.
if ( ( pPlayer->GetLocalOrigin() - GetLocalOrigin() ).Length2D() > TLK_STARE_DIST )
{
// player moved away.
TaskFail("Player moved away");
}
Vector forward;
AngleVectors( pPlayer->GetLocalAngles(), &forward );
if ( UTIL_DotPoints( pPlayer->GetLocalOrigin(), GetLocalOrigin(), forward ) < m_flFieldOfView )
{
// player looked away
TaskFail("Player looked away");
}
}
if ( gpGlobals->curtime > m_flWaitFinished )
{
TaskComplete();
}
break;
case TASK_TALKER_EYECONTACT:
if (IsMoving() || !GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
{
TaskComplete();
}
break;
case TASK_WAIT_FOR_MOVEMENT:
if (!GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
{
// override so that during walk, a scientist may talk and greet player
FIdleHello();
if (random->RandomInt(0,m_nSpeak * 20) == 0)
{
FIdleSpeak();
}
}
BaseClass::RunTask( pTask );
break;
default:
BaseClass::RunTask( pTask );
}
}
示例3: switch
void CNPCSimpleTalker::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_TALKER_WAIT_FOR_SEMAPHORE:
if ( GetExpresser()->SemaphoreIsAvailable( this ) )
TaskComplete();
break;
case TASK_TALKER_CLIENT_STARE:
case TASK_TALKER_LOOK_AT_CLIENT:
if ( pTask->iTask == TASK_TALKER_CLIENT_STARE && AI_IsSinglePlayer() )
{
// Get edict for one player
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
Assert( pPlayer );
// fail out if the player looks away or moves away.
if ( ( pPlayer->GetAbsOrigin() - GetAbsOrigin() ).Length2D() > TALKER_STARE_DIST )
{
// player moved away.
TaskFail("Player moved away");
}
Vector forward;
AngleVectors( pPlayer->GetLocalAngles(), &forward );
if ( UTIL_DotPoints( pPlayer->GetAbsOrigin(), GetAbsOrigin(), forward ) < m_flFieldOfView )
{
// player looked away
TaskFail("Player looked away");
}
}
if ( IsWaitFinished() )
{
TaskComplete();
}
break;
case TASK_TALKER_EYECONTACT:
if (IsMoving() || !GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
{
TaskComplete();
}
break;
case TASK_WAIT_FOR_MOVEMENT:
FIdleSpeakWhileMoving();
BaseClass::RunTask( pTask );
break;
default:
BaseClass::RunTask( pTask );
}
}
示例4: switch
void CRebelZombie::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_ZOMBIE_EXPRESS_ANGER:
{
if ( random->RandomInt( 1, 4 ) == 2 )
{
SetIdealActivity( (Activity)ACT_REBEL_ZOMBIE_TANTRUM );
}
else
{
TaskComplete();
}
break;
}
case TASK_ZOMBIE_YAW_TO_DOOR:
{
AssertMsg( m_hBlockingDoor != NULL, "Expected condition handling to break schedule before landing here" );
if ( m_hBlockingDoor != NULL )
{
GetMotor()->SetIdealYaw( m_flDoorBashYaw );
}
TaskComplete();
break;
}
case TASK_ZOMBIE_ATTACK_DOOR:
{
m_DurationDoorBash.Reset();
SetIdealActivity( SelectDoorBash() );
break;
}
case TASK_ZOMBIE_CHARGE_ENEMY:
{
if ( !GetEnemy() )
TaskFail( FAIL_NO_ENEMY );
else if ( GetNavigator()->SetVectorGoalFromTarget( GetEnemy()->GetLocalOrigin() ) )
{
m_vPositionCharged = GetEnemy()->GetLocalOrigin();
TaskComplete();
}
else
TaskFail( FAIL_NO_ROUTE );
break;
}
default:
BaseClass::StartTask( pTask );
break;
}
}
示例5: 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_SCRIPT_RUN_TO_TARGET:
case TASK_SCRIPT_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);
}
}
}
示例6: 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;
}
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: TaskFail
//-----------------------------------------------------------------------------
// TASK_RANGE_ATTACK1
//-----------------------------------------------------------------------------
void CAI_BaseHumanoid::StartTaskRangeAttack1( const Task_t *pTask )
{
if ( ( CapabilitiesGet() & bits_CAP_USE_SHOT_REGULATOR ) == 0 )
{
BaseClass::StartTask( pTask );
return;
}
// Can't shoot if we're in the rest interval; fail the schedule
if ( GetShotRegulator()->IsInRestInterval() )
{
TaskFail( "Shot regulator in rest interval" );
return;
}
if ( GetShotRegulator()->ShouldShoot() )
{
OnRangeAttack1();
ResetIdealActivity( ACT_RANGE_ATTACK1 );
}
else
{
// This can happen if we start while in the middle of a burst
// which shouldn't happen, but given the chaotic nature of our AI system,
// does occasionally happen.
ResetIdealActivity( ACT_IDLE_ANGRY );
}
}
示例10: 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;
}
}
示例11: 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;
}
}
示例12: switch
//------------------------------------------------------------------------------
// Purpose: routine called to start when a task initially starts
// Input : pTask - the task structure
//------------------------------------------------------------------------------
void CAI_ASW_HealOtherBehavior::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_HEAL_OTHER_FIND_TARGET:
{
if ( m_hHealTargetEnt )
{
AI_NavGoal_t goal( GOALTYPE_TARGETENT, ACT_RUN, m_flApproachDistance, AIN_YAW_TO_DEST | AIN_UPDATE_TARGET_POS, m_hHealTargetEnt );
SetTarget( m_hHealTargetEnt );
GetNavigator()->SetArrivalDistance( m_flApproachDistance );
GetNavigator()->SetGoal( goal );
}
else
{
TaskFail( FAIL_NO_TARGET );
m_flDeferUntil = gpGlobals->curtime + 3.0f;
}
break;
}
case TASK_HEAL_OTHER_MOVE_TO_TARGET:
{
break;
}
default:
BaseClass::StartTask( pTask );
break;
}
}
示例13: GetCoverActivity
//-----------------------------------------------------------------------------
// Purpose: Checks the validity of the given route's goaltype
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CAI_BaseNPC::ValidateNavGoal()
{
if (GetNavigator()->GetGoalType() == GOALTYPE_COVER)
{
// Check if this location will block my enemy's line of sight to me
if (GetEnemy())
{
Activity nCoverActivity = GetCoverActivity( GetHintNode() );
Vector vCoverLocation = GetNavigator()->GetGoalPos();
// For now we have to drop the node to the floor so we can
// get an accurate postion of the NPC. Should change once Ken checks in
float floorZ = GetFloorZ(vCoverLocation);
vCoverLocation.z = floorZ;
Vector vEyePos = vCoverLocation + EyeOffset(nCoverActivity);
if (!IsCoverPosition( GetEnemy()->EyePosition(), vEyePos ) )
{
//Msg("BADUGI\n");
TaskFail(FAIL_BAD_PATH_GOAL);
return false;
}
}
}
//Msg("BADUGI\n");
return true;
}
示例14: switch
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pTask -
//-----------------------------------------------------------------------------
void CNPC_WpnScanner::RunTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_WPNSCANNER_ATTACK:
{
CBaseEntity *pEnemy = GetEnemy();
if ( !pEnemy )
{
TaskFail( FAIL_NO_ENEMY );
return;
}
if ( m_flNextAttack > gpGlobals->curtime )
return;
m_flNextAttack = gpGlobals->curtime + 0.2;
Vector vecFirePos;
QAngle vecAngles;
GetAttachment( m_iMuzzleAttachment, vecFirePos, vecAngles );
Vector vecTarget = GetEnemy()->BodyTarget( vecFirePos );
Vector vecToTarget = (vecTarget - vecFirePos);
VectorNormalize( vecToTarget );
VectorAngles( vecToTarget, vecAngles );
Vector vecRight;
Vector vecUp;
AngleVectors( vecAngles, &vecToTarget, &vecRight, &vecUp );
// Add some inaccuracy
float x, y, z;
do {
x = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5);
y = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5);
z = x*x+y*y;
} while (z > 1);
vecToTarget = vecToTarget + x * VECTOR_CONE_20DEGREES * vecRight + y * VECTOR_CONE_20DEGREES * vecUp;
vecToTarget *= sk_wpnscanner_proj_speed.GetFloat();
baseprojectilecreate_t newProj;
newProj.vecOrigin = vecFirePos;
newProj.vecVelocity = vecToTarget;
newProj.pOwner = this;
newProj.iszModel = m_iszProjectileModel;
newProj.flDamage = sk_wpnscanner_proj_dmg.GetFloat();
newProj.iDamageType = DMG_ENERGYBEAM;
newProj.flDamageScale = 1.0;
CBaseProjectile::Create( newProj );
break;
}
default:
{
BaseClass::RunTask(pTask);
}
}
}
示例15: switch
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAI_PassengerBehaviorZombie::StartTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_FACE_HINTNODE:
case TASK_FACE_LASTPOSITION:
case TASK_FACE_SAVEPOSITION:
case TASK_FACE_TARGET:
case TASK_FACE_IDEAL:
case TASK_FACE_SCRIPT:
case TASK_FACE_PATH:
TaskComplete();
break;
case TASK_PASSENGER_ZOMBIE_RANGE_ATTACK1:
break;
case TASK_MELEE_ATTACK1:
{
// Only override this if we're "in" the vehicle
if ( GetPassengerState() != PASSENGER_STATE_INSIDE )
{
BaseClass::StartTask( pTask );
break;
}
// Swipe
GetOuter()->SetIdealActivity( (Activity) ACT_PASSENGER_MELEE_ATTACK1 );
// Randomly attack again in the future
float flWait = random->RandomFloat( 0.0f, 1.0f );
SuppressAttack( flWait );
}
break;
case TASK_PASSENGER_ZOMBIE_DISMOUNT:
{
// Start the process of dismounting from the vehicle
StartDismount();
}
break;
case TASK_PASSENGER_ZOMBIE_ATTACH:
{
if ( AttachToVehicle() )
{
TaskComplete();
return;
}
TaskFail( "Unable to attach to vehicle!" );
}
break;
default:
BaseClass::StartTask( pTask );
break;
}
}