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


C++ HasCondition函数代码示例

本文整理汇总了C++中HasCondition函数的典型用法代码示例。如果您正苦于以下问题:C++ HasCondition函数的具体用法?C++ HasCondition怎么用?C++ HasCondition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HasCondition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

//---------------------------------------------------------
//---------------------------------------------------------
int CNPC_Roller::SelectSchedule ( void )
{
	if( m_fHACKJustSpawned )
	{
		m_fHACKJustSpawned = false;
		return SCHED_ROLLER_WAIT_FOR_PHYSICS;
	}

	switch( m_NPCState )
	{
	case NPC_STATE_COMBAT:
		if( HasCondition( COND_ROLLER_PHYSICS ) )
		{
			return SCHED_ROLLER_WAIT_FOR_PHYSICS;
		}
		break;

	default:
		if( HasCondition( COND_ROLLER_PHYSICS ) )
		{
			return SCHED_ROLLER_WAIT_FOR_PHYSICS;
		}

		return SCHED_IDLE_STAND;
		break;
	}

	return SCHED_IDLE_STAND;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:31,代码来源:npc_roller.cpp

示例2: SelectSchedule

//------------------------------------------------------------------------------
// Purpose: routine called to select what schedule we want to run
// Output : returns the schedule id of the schedule we want to run
//------------------------------------------------------------------------------
int CAI_ASW_ShieldBehavior::SelectSchedule()
{
	if ( !HasCondition( COND_CAN_MELEE_ATTACK2 ) )
	{
		return SCHED_SHIELD_LOWER;
	}

	if ( GetBehaviorParam( m_StatusParm ) == 0 )
	{
		return SCHED_SHIELD_PREPARE;
	}
	else
	{
		return SCHED_SHIELD_MAINTAIN;
	}

#if 0
	if ( m_bShieldLowering == true )
	{
		return SCHED_SHIELD_LOWER;
	}

	if ( GetBehaviorParam( m_StatusParm ) == 0 )
	{
		return SCHED_SHIELD_PREPARE;
	}

	if ( HasCondition( COND_SHIELD_CAN_FLICK ) )
	{
		return SCHED_SHIELD_FLICK;
	}

	return SCHED_SHIELD_MAINTAIN;
#endif
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:39,代码来源:asw_ai_behavior_shield.cpp

示例3: switch

int CNPC_Hydra::SelectSchedule ()
{
	switch ( m_NPCState )
	{
	case NPC_STATE_IDLE:
		{
			SetState( NPC_STATE_ALERT );
			return SCHED_HYDRA_DEPLOY;
		}
		break;

	case NPC_STATE_ALERT:
		{
			return SCHED_HYDRA_STAB;
		}
		break;

	case NPC_STATE_COMBAT:
		{
			if (HasCondition( COND_HYDRA_SNAGGED ))
			{
				return SCHED_HYDRA_PULLBACK;
			}
			else if (HasCondition( COND_HYDRA_OVERSTRETCH ))
			{
				return SCHED_HYDRA_STAB;
			}
			return SCHED_HYDRA_STAB;
		}
		break;	
	}

	return BaseClass::SelectSchedule();
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:34,代码来源:npc_hydra.cpp

示例4: SelectUnreachableSchedule

// note: mostly copied from shover parent (no clean way to call up and extend), with the jump part added
int	CASW_Alien_Jumper::SelectCombatSchedule( void )
{
	//Physics target
	if ( HasCondition( COND_ALIEN_SHOVER_PHYSICS_TARGET ) )
	{
		//Msg("Alien shoving physics object from selectcombatschedule\n");
		return SCHED_ALIEN_SHOVER_PHYSICS_ATTACK;
	}

	// Attack if we can
	if ( HasCondition(COND_CAN_MELEE_ATTACK1) )
		return SCHED_MELEE_ATTACK1;

	// See if we can bash what's in our way, or roar
	if ( HasCondition( COND_ENEMY_UNREACHABLE ) )
	{
		int iUnreach = SelectUnreachableSchedule();
		if (iUnreach != -1)
			return iUnreach;
	}

	// Try to jump
	if ( HasCondition( COND_ASW_ALIEN_CAN_JUMP ) )
		return SCHED_ASW_ALIEN_JUMP;

	return BaseClass::BaseClass::SelectSchedule();
}
开发者ID:BenLubar,项目名称:riflemod,代码行数:28,代码来源:asw_alien_jumper.cpp

示例5: GetBot

//================================================================================
//================================================================================
float CHuntEnemySchedule::GetDesire() const
{
    if ( !GetMemory() || !GetLocomotion() )
        return BOT_DESIRE_NONE;

    if ( !GetDecision()->CanHuntThreat() )
        return BOT_DESIRE_NONE;

    CEntityMemory *memory = GetBot()->GetPrimaryThreat();

    if ( memory == NULL )
        return BOT_DESIRE_NONE;

    // We have no vision of the enemy
    if ( HasCondition( BCOND_ENEMY_LOST ) ) {
        // But we have a vision of his last position and we are close
        if ( HasCondition( BCOND_ENEMY_LAST_POSITION_VISIBLE ) && (HasCondition( BCOND_ENEMY_TOO_NEAR ) || HasCondition( BCOND_ENEMY_NEAR )) )
            return BOT_DESIRE_NONE;
        
        return 0.65f;
    }

    // We do not have direct vision to the enemy (a person, window, etc.)
    if ( HasCondition( BCOND_ENEMY_OCCLUDED ) )
        return 0.65f;

    // We do not have range of attack
    if ( HasCondition( BCOND_TOO_FAR_TO_ATTACK ) )
        return 0.38f;

    return BOT_DESIRE_NONE;
}
开发者ID:WorldGamers,项目名称:Mobile-Forces-Source,代码行数:34,代码来源:bot_schedule_hunt_enemy.cpp

示例6: switch

NPC_STATE CNPC_Cremator::SelectIdealState( void )
{
	switch( m_NPCState )
	{
	case NPC_STATE_COMBAT:
		{
			if ( GetEnemy() == NULL )
			{
				if ( !HasCondition( COND_ENEMY_DEAD ) )
				{
					SetCondition( COND_ENEMY_DEAD ); // TODO: patrolling

				}
				return NPC_STATE_ALERT;
			}
			else if ( HasCondition( COND_ENEMY_DEAD ) )
			{
				//AnnounceEnemyKill(GetEnemy());
			}
		}
	default:
		{
			return BaseClass::SelectIdealState();
		}
	}

	return GetIdealState();
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:28,代码来源:npc_cremator.cpp

示例7: SelectScheduleUpdateWeapon

int CAI_StandoffBehavior::SelectScheduleUpdateWeapon( void )
{
	// Check if need to reload
	if ( HasCondition ( COND_NO_PRIMARY_AMMO ) || HasCondition ( COND_LOW_PRIMARY_AMMO ))
	{
		if ( m_params.fCoverOnReload )
			return SCHED_HIDE_AND_RELOAD;
		else
			return SCHED_RELOAD;
	}
	
	// Otherwise, update planned shots to fire before taking cover again
	if ( HasCondition( COND_LIGHT_DAMAGE ) )
	{
		// if hurt:
		int iPercent = random->RandomInt(0,99);

		if ( iPercent <= m_params.oddsCover && GetEnemy() != NULL )
		{
			SetReuseCurrentCover();
			m_ShotRegulator.SetShots( ( m_ShotRegulator.GetShots() > 1 ) ? 1 : 0 );
		}
	}

	m_ShotRegulator.Update();

	return SCHED_NONE;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:28,代码来源:ai_behavior_standoff.cpp

示例8: StandoffMsg

int CAI_StandoffBehavior::SelectScheduleUpdateWeapon( void )
{
	// Check if need to reload
	if ( HasCondition ( COND_NO_PRIMARY_AMMO ) || HasCondition ( COND_LOW_PRIMARY_AMMO ))
	{
		StandoffMsg( "Out of ammo, reloading\n" );
		if ( m_params.fCoverOnReload )
		{
			GetOuter()->SpeakSentence( STANDOFF_SENTENCE_OUT_OF_AMMO );
			return SCHED_HIDE_AND_RELOAD;
		}
		
		return SCHED_RELOAD;
	}
	
	// Otherwise, update planned shots to fire before taking cover again
	if ( HasCondition( COND_LIGHT_DAMAGE ) )
	{
		// if hurt:
		int iPercent = random->RandomInt(0,99);

		if ( iPercent <= m_params.oddsCover && GetEnemy() != NULL )
		{
			SetReuseCurrentCover();
			StandoffMsg( "Hurt, firing one more shot before cover\n" );
			if ( !GetOuter()->GetShotRegulator()->IsInRestInterval() )
			{
				GetOuter()->GetShotRegulator()->SetBurstShotsRemaining( 1 );
			}
		}
	}

	return SCHED_NONE;
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:34,代码来源:ai_behavior_standoff.cpp

示例9: GatherConditions

//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_GroundTurret::GatherConditions()
{
	if( !IsEnabled() )
	{
		return;
	}

	if( !IsOpen() && !UTIL_FindClientInPVS( edict() ) )
	{
		return;
	}

	// Throw away old enemies so the turret can retire
	AIEnemiesIter_t iter;

	for( AI_EnemyInfo_t *pEMemory = GetEnemies()->GetFirst(&iter); pEMemory != NULL; pEMemory = GetEnemies()->GetNext(&iter) )
	{
		if( pEMemory->timeLastSeen < gpGlobals->curtime - GROUNDTURRET_RETIRE_TIME )
		{
			pEMemory->hEnemy = NULL;
		}
	}

	BaseClass::GatherConditions();

	if( GetEnemy() && HasCondition(COND_SEE_ENEMY) )
	{
		m_flTimeLastSawEnemy = gpGlobals->curtime;
	}
	else
	{
		if( gpGlobals->curtime - m_flTimeLastSawEnemy >= GROUNDTURRET_RETIRE_TIME )
		{
			m_OnAreaClear.FireOutput(this, this);
			m_flTimeLastSawEnemy = FLT_MAX;
			return;
		}
	}

	if( HasCondition( COND_SEE_ENEMY ) )
	{
		m_bSeeEnemy = true;
	}
	else
	{
		m_bSeeEnemy = false;
	}

	if( GetEnemy() && m_bSeeEnemy && IsEnabled() )
	{
		if( m_flTimeNextShoot < gpGlobals->curtime )
		{
			Shoot();
		}
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:58,代码来源:npc_turret_ground.cpp

示例10: HasCondition

bool CAI_LeadBehavior::CanSelectSchedule()
{
 	if ( !AI_GetSinglePlayer() || AI_GetSinglePlayer()->IsDead() )
		return false;

	bool fAttacked = ( HasCondition( COND_LIGHT_DAMAGE ) || HasCondition( COND_HEAVY_DAMAGE ) );
	bool fNonCombat = ( GetNpcState() == NPC_STATE_IDLE || GetNpcState() == NPC_STATE_ALERT );
	
	return ( !fAttacked && (fNonCombat || m_args.bLeadDuringCombat) && HasGoal() );
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:10,代码来源:ai_behavior_lead.cpp

示例11: CalcIdealYaw

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &vecTarget - 
// Output : float
//-----------------------------------------------------------------------------
float CNPC_Bug_Warrior::CalcIdealYaw( const Vector &vecTarget )
{
	//If we can see our enemy but not reach them, face them always
	if ( ( GetEnemy() != NULL ) && ( HasCondition( COND_SEE_ENEMY ) && HasCondition( COND_ENEMY_UNREACHABLE ) ) )
	{
		return UTIL_VecToYaw ( GetEnemy()->GetAbsOrigin() - GetAbsOrigin() );
	}

	return BaseClass::CalcIdealYaw( vecTarget );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:15,代码来源:npc_bug_warrior.cpp

示例12: HasCondition

bool CNPC_Tentacle::HeardAnything( void )
{
	if ( HasCondition( COND_HEAR_DANGER ) || // I remove a bunch of sounds from here on purpose. Talk to me if you're changing this!(sjb)
		 HasCondition( COND_HEAR_COMBAT ) ||
		 HasCondition( COND_HEAR_WORLD )  ||
		 HasCondition( COND_HEAR_PLAYER ) )
		 return true;

	return false;
}
开发者ID:AgentAgrimar,项目名称:source-sdk-trilogy,代码行数:10,代码来源:hl1_npc_tentacle.cpp

示例13: SetCondition

//-----------------------------------------------------------------------------
// Purpose: Move the zombie to the vehicle
//-----------------------------------------------------------------------------
int CAI_PassengerBehaviorZombie::SelectSchedule( void )
{
	// See if our enemy got out
	if ( GetOuter()->GetEnemy() != NULL && EnemyInVehicle() == false  )
	{
		if ( GetPassengerState() == PASSENGER_STATE_INSIDE )
		{
			// Exit the vehicle
			SetCondition( COND_PASSENGER_EXITING );
		}
		else if ( GetPassengerState() == PASSENGER_STATE_OUTSIDE )
		{
			// Our target has left the vehicle and we're outside as well, so give up
			Disable();
			return BaseClass::SelectSchedule();
		}
	}

	// Entering schedule
	if ( HasCondition( COND_PASSENGER_ENTERING ) )
	{
		ClearCondition( COND_PASSENGER_ENTERING );
		return SCHED_PASSENGER_ZOMBIE_ENTER_VEHICLE;
	}

	// Exiting schedule
	if ( HasCondition( COND_PASSENGER_EXITING ) )
	{
		ClearCondition( COND_PASSENGER_EXITING );
		return SCHED_PASSENGER_ZOMBIE_EXIT_VEHICLE;
	}

	// Select different schedules based on our state
	PassengerState_e nState = GetPassengerState();
	int nNewSchedule = SCHED_NONE;

	if ( nState == PASSENGER_STATE_INSIDE )
	{
		nNewSchedule = SelectInsideSchedule();
		if ( nNewSchedule != SCHED_NONE )
			return nNewSchedule;
	}
	else if ( nState == PASSENGER_STATE_OUTSIDE )
	{
		nNewSchedule = SelectOutsideSchedule();
		if ( nNewSchedule != SCHED_NONE )
			return nNewSchedule;
	}

	// Worst case he just stands here
	Assert(0);
	return SCHED_IDLE_STAND;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:56,代码来源:ai_behavior_passenger_zombie.cpp

示例14: GetEnemy

//=========================================================
// CheckRangeAttack1 
//
// !!!LATER - we may want to load balance this. Several
// tracelines are done, so we may not want to do this every
// server frame. Definitely not while firing. 
//=========================================================
int CNPC_AlienGrunt::RangeAttack1Conditions ( float flDot, float flDist )
{
	if ( gpGlobals->curtime < m_flNextHornetAttackCheck )
	{
		if ( HasCondition( COND_SEE_ENEMY ) )
		{
			if ( m_fCanHornetAttack == true )
			{
				 return COND_CAN_RANGE_ATTACK1;
			}
			else
			{
				return COND_NONE;
			}
		}
		else
			return COND_NONE;
	}

	if ( flDist < AGRUNT_MELEE_DIST )
		 return COND_NONE;

	if ( flDist > 1024 )
		 return COND_NONE;

	if ( flDot < 0.5 )
		 return COND_NONE;
	
	if ( HasCondition( COND_SEE_ENEMY ) )
	{
		trace_t tr;
		Vector	vecArmPos;
		QAngle	angArmDir;
		
		// verify that a shot fired from the gun will hit the enemy before the world.
		// !!!LATER - we may wish to do something different for projectile weapons as opposed to instant-hit
		GetAttachment( "0", vecArmPos, angArmDir );
		UTIL_TraceLine( vecArmPos, GetEnemy()->BodyTarget( vecArmPos ), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr);
		
		if ( tr.fraction == 1.0 || tr.m_pEnt == GetEnemy() )
		{
			m_flNextHornetAttackCheck = gpGlobals->curtime + random->RandomFloat( 2, 5 );
			m_fCanHornetAttack = true;
			
			return COND_CAN_RANGE_ATTACK1;
		}
	}
	
	m_flNextHornetAttackCheck = gpGlobals->curtime + 0.2;// don't check for half second if this check wasn't successful
	m_fCanHornetAttack = false;
	return COND_NONE;
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:59,代码来源:hl1_npc_agrunt.cpp

示例15: AddZigZagToPath

void CNPC_Stalker::AddZigZagToPath(void) 
{
	// If already on a detour don't add a zigzag
	if (GetNavigator()->GetCurWaypointFlags() & bits_WP_TO_DETOUR)
	{
		return;
	}

	// If enemy isn't facing me or occluded, don't add a zigzag
	if (HasCondition(COND_ENEMY_OCCLUDED) || !HasCondition ( COND_ENEMY_FACING_ME ))
	{
		return;
	}

	Vector waypointPos = GetNavigator()->GetCurWaypointPos();
	Vector waypointDir = (waypointPos - GetAbsOrigin());

	// If the distance to the next node is greater than ZIG_ZAG_SIZE
	// then add a random zig/zag to the path
	if (waypointDir.LengthSqr() > ZIG_ZAG_SIZE)
	{
		// Pick a random distance for the zigzag (less that sqrt(ZIG_ZAG_SIZE)
		float distance = random->RandomFloat( 30, 60 );

		// Get me a vector orthogonal to the direction of motion
		VectorNormalize( waypointDir );
		Vector vDirUp(0,0,1);
		Vector vDir;
		CrossProduct( waypointDir, vDirUp, vDir);

		// Pick a random direction (left/right) for the zigzag
		if (random->RandomInt(0,1))
		{
			vDir = -1 * vDir;
		}

		// Get zigzag position in direction of target waypoint
		Vector zigZagPos = GetAbsOrigin() + waypointDir * 60;

		// Now offset 
		zigZagPos = zigZagPos + (vDir * distance);

		// Now make sure that we can still get to the zigzag position and the waypoint
		AIMoveTrace_t moveTrace1, moveTrace2;
		GetMoveProbe()->MoveLimit( NAV_GROUND, GetAbsOrigin(), zigZagPos, GetAITraceMask(), NULL, &moveTrace1);
		GetMoveProbe()->MoveLimit( NAV_GROUND, zigZagPos, waypointPos, GetAITraceMask(), NULL, &moveTrace2);
		if ( !IsMoveBlocked( moveTrace1 ) && !IsMoveBlocked( moveTrace2 ) )
		{
			GetNavigator()->PrependWaypoint( zigZagPos, NAV_GROUND, bits_WP_TO_DETOUR );
		}
	}
}
开发者ID:Muini,项目名称:Nag-asw,代码行数:52,代码来源:npc_stalker.cpp


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