qboolean SensoryPerception::_SenseEntity( Entity *ent )
{
	// Don't want to target the enemy if he's not a valid target
	
	if (!ent)
		return false;
	
	if ( !EntityIsValidTarget(ent) )
		return false;
	
	// Don't wake ourselves up
	if ( ent->entnum == act->entnum )
		return false;
	
	if ( ent->isSubclassOf ( Actor ) )
	{
		if ( !ent->isThinkOn() )
			return false;
	}
	
	if ( gi.inPVS( ent->centroid, act->centroid ) )
	{
		auto enemyToSelf = act->origin - ent->origin;	
		auto visionDistance = GetVisionDistance();

		if ( enemyToSelf.length() < visionDistance )
		{
			if ( CanSeeEntity( act, ent, true, true ) )
				Stimuli( StimuliSight , ent );
		}         
		
	}
	
	return false;
}
示例#2
0
bool CAI_Senses::Look( CBaseEntity *pSightEnt )
{
	if ( WaitingUntilSeen( pSightEnt ) )
		return false;
	
	if ( ShouldSeeEntity( pSightEnt ) && CanSeeEntity( pSightEnt ) )
	{
		return SeeEntity( pSightEnt );
	}
	return false;
}
//
// Name:        _CanSeeComplex
// Parameters:  Vector &start - start position
//              Vector &end   - end position
//              qboolean useFOV - take FOV into consideration or not
//              qboolean useVisionDistance             
// Description: Creates a plane to do a more complex check of vision
//
qboolean SensoryPerception::_CanSeeComplex( Vector &start, Entity *target , qboolean useFOV, qboolean useVisionDistance )
{
	if ( !target )
		return false;
	
	auto d = target->centroid - start;
	d.z = 0;
	d.normalize();
	
  Vector	p1;
  Vector	p2;
	p1.x = -d.y;
	p1.y = d.x;
	p1 *= max( act->size.x, act->size.y ) * 1.44f * 0.5f;
	p2 = p1;
	
	p1.z = act->mins.z;
	p2.z = act->maxs.z;	
	if ( CanSeeEntity( start + p1, target , useFOV , useVisionDistance ) )
	{
		return true;
	}
	if ( CanSeeEntity( start + p2, target , useFOV , useVisionDistance ) )
	{
		return true;
	}
	
	p1.z = -p1.z;
	p2.z = -p2.z;
	if ( CanSeeEntity( start - p1, target , useFOV , useVisionDistance ) )
	{
		return true;
	}
	if ( CanSeeEntity( start - p2, target , useFOV , useVisionDistance ) )
	{
		return true;
	}
	
	return false;
}
示例#4
0
bool CAI_Senses::Look( CBaseEntity *pSightEnt )
{
	CNPC_BaseZombie *pZombie = dynamic_cast<CNPC_BaseZombie*>( GetOuter() );
	if ( pZombie && pSightEnt->IsPlayer() )
	{
		return SeeEntity( pSightEnt );
	}
	else
	{
		if ( WaitingUntilSeen( pSightEnt ) )
			return false;
	
		if ( ShouldSeeEntity( pSightEnt ) && CanSeeEntity( pSightEnt ) )
		{
			return SeeEntity( pSightEnt );
		}
		return false;
	}
}