本文整理汇总了C++中UTIL_EntitiesInBox函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_EntitiesInBox函数的具体用法?C++ UTIL_EntitiesInBox怎么用?C++ UTIL_EntitiesInBox使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UTIL_EntitiesInBox函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: radius
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHL1_Player::FindMissTargets( void )
{
if ( m_flTargetFindTime > gpGlobals->curtime )
return;
m_flTargetFindTime = gpGlobals->curtime + 1.0f;
m_nNumMissPositions = 0;
CBaseEntity *pEnts[256];
Vector radius( 80, 80, 80);
int numEnts = UTIL_EntitiesInBox( pEnts, 256, GetAbsOrigin()-radius, GetAbsOrigin()+radius, 0 );
for ( int i = 0; i < numEnts; i++ )
{
if ( pEnts[i] == NULL )
continue;
if ( m_nNumMissPositions >= 16 )
return;
//See if it's a good target candidate
if ( FClassnameIs( pEnts[i], "prop_dynamic" ) ||
FClassnameIs( pEnts[i], "dynamic_prop" ) ||
FClassnameIs( pEnts[i], "prop_physics" ) ||
FClassnameIs( pEnts[i], "physics_prop" ) )
{
//NDebugOverlay::Cross3D( pEnts[i]->WorldSpaceCenter(), -Vector(4,4,4), Vector(4,4,4), 0, 255, 0, true, 1.0f );
m_vecMissPositions[m_nNumMissPositions++] = pEnts[i]->WorldSpaceCenter();
continue;
}
}
}
示例2: TongueTouchEnt
CBaseEntity *CBarnacle :: TongueTouchEnt ( float *pflLength )
{
TraceResult tr;
float length;
// trace once to hit architecture and see if the tongue needs to change position.
UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0 , 0 , 2048 ), ignore_monsters, ENT(pev), &tr );
length = fabs( pev->origin.z - tr.vecEndPos.z );
if ( pflLength )
{
*pflLength = length;
}
Vector delta = Vector( BARNACLE_CHECK_SPACING, BARNACLE_CHECK_SPACING, 0 );
Vector mins = pev->origin - delta;
Vector maxs = pev->origin + delta;
maxs.z = pev->origin.z;
mins.z -= length;
CBaseEntity *pList[10];
int count = UTIL_EntitiesInBox( pList, 10, mins, maxs, (FL_CLIENT|FL_MONSTER) );
if ( count )
{
for ( int i = 0; i < count; i++ )
{
// only clients and monsters
if ( pList[i] != this && IRelationship( pList[i] ) > R_NO && pList[ i ]->pev->deadflag == DEAD_NO ) // this ent is one of our enemies. Barnacle tries to eat it.
{
return pList[i];
}
}
}
return NULL;
}
示例3: UTIL_EntitiesInBox
bool AvHHive::SetSolid(bool inForce)
{
// Check to make sure there aren't any players in the destination area
CBaseEntity* pList[128];
// Crank up the area just to be safe
Vector theMinArea = this->pev->origin + kHiveMinSize;
Vector theMaxArea = this->pev->origin + kHiveMaxSize;
// TODO: If players are blocking this area for too long, spawn hive and kill them
int theNumBlockingEntities = UTIL_EntitiesInBox(pList, 128, theMinArea, theMaxArea, FL_CLIENT);
if((theNumBlockingEntities == 0) || inForce)
{
this->pev->solid = SOLID_BBOX;
this->pev->movetype = MOVETYPE_NONE;
UTIL_SetSize(this->pev, kHiveMinSize, kHiveMaxSize);
// pev->frame = 0;
// pev->body = 3;
// pev->sequence = 0;
// // ResetSequenceInfo( );
// pev->framerate = 0;
//
// UTIL_SetOrigin(pev, pev->origin);
// UTIL_SetSize(pev, Vector(-20, -20, 0), Vector(20, 20, 28) );
SetTouch(&AvHHive::HiveTouch);
this->mSolid = true;
}
return this->mSolid;
}
示例4: PROFILE_START
// This function takes a lot of CPU, so make sure it's not called often! Don't call this function directly, use UpdateEnemy instead whenever possible.
CBaseEntity* AvHTurret::FindBestEnemy()
{
PROFILE_START()
CBaseEntity* theEntityList[100];
int theMaxRange = this->GetXYRange();
Vector delta = Vector(theMaxRange, theMaxRange, theMaxRange);
CBaseEntity* theCurrentEntity = NULL;
CBaseEntity* theBestPlayer = NULL;
CBaseEntity* theBestStructure = NULL;
float theCurrentEntityRange = 100000;
// Find only monsters/clients in box, NOT limited to PVS
int theCount = UTIL_EntitiesInBox(theEntityList, 100, this->pev->origin - delta, this->pev->origin + delta, FL_CLIENT | FL_MONSTER);
for(int i = 0; i < theCount; i++ )
{
theCurrentEntity = theEntityList[i];
if((theCurrentEntity != this) && theCurrentEntity->IsAlive())
{
// the looker will want to consider this entity
// don't check anything else about an entity that can't be seen, or an entity that you don't care about.
if(this->IRelationship(theCurrentEntity ) != R_NO && FInViewCone(theCurrentEntity) && !FBitSet(theCurrentEntity->pev->flags, FL_NOTARGET))
{
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theCurrentEntity);
if(!thePlayer || thePlayer->GetCanBeAffectedByEnemies())
{
if(this->GetIsValidTarget(theCurrentEntity))
{
// Find nearest enemy
float theRangeToTarget = VectorDistance2D(this->pev->origin, theCurrentEntity->pev->origin);
if(theRangeToTarget < theCurrentEntityRange)
{
// FVisible is expensive, so defer until necessary
if(!this->GetRequiresLOS() || FVisible(theCurrentEntity))
{
theCurrentEntityRange = theRangeToTarget;
if ( thePlayer )
{
theBestPlayer = theCurrentEntity;
}
else
{
theBestStructure = theCurrentEntity;
}
}
}
}
}
}
}
}
PROFILE_END(kAvHTurretFindBestEnemy);
return (theBestPlayer != NULL ) ? theBestPlayer : theBestStructure;
}
示例5: UTIL_TraceLine
//=========================================================
// TryMakeMonster- check that it's ok to drop a monster.
//=========================================================
void CMonsterMaker::TryMakeMonster( void )
{
if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren )
{// not allowed to make a new one yet. Too many live ones out right now.
return;
}
if ( !m_flGround )
{
// set altitude. Now that I'm activated, any breakables, etc should be out from under me.
TraceResult tr;
UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr );
m_flGround = tr.vecEndPos.z;
}
Vector mins = pev->origin - Vector( 34, 34, 0 );
Vector maxs = pev->origin + Vector( 34, 34, 0 );
maxs.z = pev->origin.z;
mins.z = m_flGround;
CBaseEntity *pList[2];
int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER );
if ( count )
{
// don't build a stack of monsters!
return;
}
if (m_fSpawnDelay)
{
// If I have a target, fire. (no locus)
if ( !FStringNull ( pev->target ) )
{
// delay already overloaded for this entity, so can't call SUB_UseTargets()
FireTargets( STRING(pev->target), this, this, USE_TOGGLE, 0 );
}
// ALERT(at_console,"Making Monster in %f seconds\n",m_fSpawnDelay);
SetThink(&CMonsterMaker:: MakeMonsterThink );
SetNextThink( m_fSpawnDelay );
}
else
{
// ALERT(at_console,"No delay. Making monster.\n",m_fSpawnDelay);
CBaseMonster* pMonst = MakeMonster();
// If I have a target, fire! (the new monster is the locus)
if ( !FStringNull ( pev->target ) )
{
FireTargets( STRING(pev->target), pMonst, this, USE_TOGGLE, 0 );
}
}
}
示例6: ClearConditions
void CBaseMonster::Look(int iDistance)
{
int iSighted = 0;
ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT);
m_pLink = NULL;
CBaseEntity *pSightEnt = NULL;
CBaseEntity *pList[100];
Vector delta = Vector(iDistance, iDistance, iDistance);
int count = UTIL_EntitiesInBox(pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT | FL_MONSTER);
for (int i = 0; i < count; i++)
{
pSightEnt = pList[i];
if (pSightEnt != this && pSightEnt->pev->health > 0)
{
if (IRelationship(pSightEnt) != R_NO && FInViewCone(pSightEnt) && !FBitSet(pSightEnt->pev->flags, FL_NOTARGET) && FVisible(pSightEnt))
{
if (pSightEnt->IsPlayer())
iSighted |= bits_COND_SEE_CLIENT;
pSightEnt->m_pLink = m_pLink;
m_pLink = pSightEnt;
if (pSightEnt == m_hEnemy)
iSighted |= bits_COND_SEE_ENEMY;
switch (IRelationship(pSightEnt))
{
case R_NM:
iSighted |= bits_COND_SEE_NEMESIS;
break;
case R_HT:
iSighted |= bits_COND_SEE_HATE;
break;
case R_DL:
iSighted |= bits_COND_SEE_DISLIKE;
break;
case R_FR:
iSighted |= bits_COND_SEE_FEAR;
break;
case R_AL:
break;
}
}
}
}
SetConditions(iSighted);
}
示例7: ClearBounds
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CGrenadeHopwire::KillStriders( void )
{
CBaseEntity *pEnts[128];
Vector mins, maxs;
ClearBounds( mins, maxs );
AddPointToBounds( -Vector( MAX_STRIDER_STUN_DISTANCE_HORZ, MAX_STRIDER_STUN_DISTANCE_HORZ, MAX_STRIDER_STUN_DISTANCE_HORZ ), mins, maxs );
AddPointToBounds( Vector( MAX_STRIDER_STUN_DISTANCE_HORZ, MAX_STRIDER_STUN_DISTANCE_HORZ, MAX_STRIDER_STUN_DISTANCE_HORZ ), mins, maxs );
AddPointToBounds( -Vector( MAX_STRIDER_STUN_DISTANCE_VERT, MAX_STRIDER_STUN_DISTANCE_VERT, MAX_STRIDER_STUN_DISTANCE_VERT ), mins, maxs );
AddPointToBounds( Vector( MAX_STRIDER_STUN_DISTANCE_VERT, MAX_STRIDER_STUN_DISTANCE_VERT, MAX_STRIDER_STUN_DISTANCE_VERT ), mins, maxs );
// FIXME: It's probably much faster to simply iterate over the striders in the map, rather than any entity in the radius - jdw
// Find any striders in range of us
int numTargets = UTIL_EntitiesInBox( pEnts, ARRAYSIZE( pEnts ), GetAbsOrigin()+mins, GetAbsOrigin()+maxs, FL_NPC );
float targetDistHorz, targetDistVert;
for ( int i = 0; i < numTargets; i++ )
{
// Only affect striders
if ( FClassnameIs( pEnts[i], "npc_strider" ) == false )
continue;
// We categorize our spatial relation to the strider in horizontal and vertical terms, so that we can specify both parameters separately
targetDistHorz = UTIL_DistApprox2D( pEnts[i]->GetAbsOrigin(), GetAbsOrigin() );
targetDistVert = fabs( pEnts[i]->GetAbsOrigin()[2] - GetAbsOrigin()[2] );
if ( targetDistHorz < MAX_STRIDER_KILL_DISTANCE_HORZ && targetDistHorz < MAX_STRIDER_KILL_DISTANCE_VERT )
{
// Kill the strider
float fracDamage = ( pEnts[i]->GetMaxHealth() / hopwire_strider_hits.GetFloat() ) + 1.0f;
CTakeDamageInfo killInfo( this, this, fracDamage, DMG_GENERIC );
Vector killDir = pEnts[i]->GetAbsOrigin() - GetAbsOrigin();
VectorNormalize( killDir );
killInfo.SetDamageForce( killDir * -1000.0f );
killInfo.SetDamagePosition( GetAbsOrigin() );
pEnts[i]->TakeDamage( killInfo );
}
else if ( targetDistHorz < MAX_STRIDER_STUN_DISTANCE_HORZ && targetDistHorz < MAX_STRIDER_STUN_DISTANCE_VERT )
{
// Stun the strider
CTakeDamageInfo killInfo( this, this, 200.0f, DMG_GENERIC );
pEnts[i]->TakeDamage( killInfo );
}
}
}
示例8: UTIL_EntitiesInBox
//LRC
void CBreakable::RespawnThink( void )
{
// ALERT(at_debug,"RespawnThink: ");
CBaseEntity *pList[2];
int count = UTIL_EntitiesInBox( pList, 2, pev->mins, pev->maxs, FL_MONSTER | FL_CLIENT );
if ( count )
{
// Can't respawn right now, a monster or player is in the way. Wait a bit.
// ALERT(at_debug,"Respawn failed, count is %d\n",count);
SetThink(&CBreakable:: RespawnThink );
SetNextThink( 2 ); // CONSIDER: change this number?
}
else
{
// fade in, don't just appear(?)
if (pev->spawnflags & SF_BREAK_FADE_RESPAWN)
{
SetThink(&CBreakable:: RespawnFadeThink );
SetNextThink( 0.1 );
pev->renderamt = 0;
if (m_iInitialRenderMode == kRenderNormal)
{
pev->rendermode = kRenderTransTexture;
m_iInitialRenderAmt = 255;
}
}
// ALERT(at_debug,"Respawn OK\n");
/* if (FStrEq("func_pushable",STRING(pev->classname))){ //AJH Fix for respawnable breakable pushables
pev->solid = SOLID_BBOX; //For some reason this code must be executed outside of
pev->origin.z+=1; //the RespawnThink function. Uses DoRespawn()
UTIL_SetOrigin(this,pev->origin);
}else{
pev->solid = SOLID_BSP;
}
*/
DoRespawn(); //AJH Fix for respawnable breakable pushables (BY HAWK777)
SetUse(&CBreakable:: BreakUse );
pev->effects &= ~EF_NODRAW;
pev->health = m_iInitialHealth;
if ( !FBitSet( pev->spawnflags, SF_BREAK_TRIGGER_ONLY ) )
pev->takedamage = DAMAGE_YES;
// trigger the "fire on respawn" target
FireTargets( STRING(pev->netname), this, this, USE_TOGGLE, 0);
}
}
示例9: UTIL_TraceLine
//-----------------------------------------------------------------------------
// Purpose: Returns whether or not it is OK to make an NPC at this instant.
//-----------------------------------------------------------------------------
bool CHL1NPCMaker::CanMakeNPC( void )
{
if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren )
{// not allowed to make a new one yet. Too many live ones out right now.
return false;
}
if ( !m_flGround )
{
// set altitude. Now that I'm activated, any breakables, etc should be out from under me.
trace_t tr;
UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() - Vector ( 0, 0, 2048 ), MASK_NPCSOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
m_flGround = tr.endpos.z;
}
Vector mins = GetAbsOrigin() - Vector( 34, 34, 0 );
Vector maxs = GetAbsOrigin() + Vector( 34, 34, 0 );
maxs.z = GetAbsOrigin().z;
//Only adjust for the ground if we want it
if ( ( m_spawnflags & SF_NPCMakerHL1_NO_DROP ) == false )
{
mins.z = m_flGround;
}
CBaseEntity *pList[128];
int count = UTIL_EntitiesInBox( pList, 128, mins, maxs, FL_CLIENT|FL_NPC );
if ( count )
{
//Iterate through the list and check the results
for ( int i = 0; i < count; i++ )
{
//Don't build on top of another entity
if ( pList[i] == NULL )
continue;
//If one of the entities is solid, then we can't spawn now
if ( ( pList[i]->GetSolidFlags() & FSOLID_NOT_SOLID ) == false )
return false;
}
}
return true;
}
示例10: CollisionProp
//------------------------------------------------------------------------------
// Purpose : Reset the OnGround flags for any entities that may have been
// resting on me
// Input :
// Output :
//------------------------------------------------------------------------------
void CBreakable::ResetOnGroundFlags(void)
{
// !!! HACK This should work!
// Build a box above the entity that looks like an 9 inch high sheet
Vector mins, maxs;
CollisionProp()->WorldSpaceAABB( &mins, &maxs );
mins.z -= 1;
maxs.z += 8;
// BUGBUG -- can only find 256 entities on a breakable -- should be enough
CBaseEntity *pList[256];
int count = UTIL_EntitiesInBox( pList, 256, mins, maxs, FL_ONGROUND );
if ( count )
{
for ( int i = 0; i < count; i++ )
{
pList[i]->SetGroundEntity( (CBaseEntity *)NULL );
}
}
#ifdef PORTAL
// !!! HACK This should work!
// Tell touching portals to fizzle
int iPortalCount = CProp_Portal_Shared::AllPortals.Count();
if( iPortalCount != 0 )
{
Vector vMin, vMax;
CollisionProp()->WorldSpaceAABB( &vMin, &vMax );
Vector vBoxCenter = ( vMin + vMax ) * 0.5f;
Vector vBoxExtents = ( vMax - vMin ) * 0.5f;
CProp_Portal **pPortals = CProp_Portal_Shared::AllPortals.Base();
for( int i = 0; i != iPortalCount; ++i )
{
CProp_Portal *pTempPortal = pPortals[i];
if( UTIL_IsBoxIntersectingPortal( vBoxCenter, vBoxExtents, pTempPortal ) )
{
pTempPortal->DoFizzleEffect( PORTAL_FIZZLE_KILLED, false );
pTempPortal->Fizzle();
}
}
}
#endif
}
示例11: CollisionProp
//------------------------------------------------------------------------------
// Purpose : Reset the OnGround flags for any entities that may have been
// resting on me
// Input :
// Output :
//------------------------------------------------------------------------------
void CBreakable::ResetOnGroundFlags(void)
{
// !!! HACK This should work!
// Build a box above the entity that looks like an 9 inch high sheet
Vector mins, maxs;
CollisionProp()->WorldSpaceAABB( &mins, &maxs );
mins.z -= 1;
maxs.z += 8;
// BUGBUG -- can only find 256 entities on a breakable -- should be enough
CBaseEntity *pList[256];
int count = UTIL_EntitiesInBox( pList, 256, mins, maxs, FL_ONGROUND );
if ( count )
{
for ( int i = 0; i < count; i++ )
{
pList[i]->SetGroundEntity( (CBaseEntity *)NULL );
}
}
}
示例12: CanLayCrab
BOOL CanLayCrab( void )
{
if ( m_crabTime < gpGlobals->curtime && m_crabCount < BIG_MAXCHILDREN )
{
// Don't spawn crabs inside each other
Vector mins = GetAbsOrigin() - Vector( 32, 32, 0 );
Vector maxs = GetAbsOrigin() + Vector( 32, 32, 0 );
CBaseEntity *pList[2];
int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_NPC );
for ( int i = 0; i < count; i++ )
{
if ( pList[i] != this ) // Don't hurt yourself!
return COND_NONE;
}
return COND_CAN_MELEE_ATTACK2;
}
return COND_NONE;
}
示例13: CanLayCrab
BOOL CanLayCrab( void )
{
if ( m_crabTime < gpGlobals->time && m_crabCount < BIG_MAXCHILDREN )
{
// Don't spawn crabs inside each other
Vector mins = pev->origin - Vector( 32, 32, 0 );
Vector maxs = pev->origin + Vector( 32, 32, 0 );
CBaseEntity *pList[2];
int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_MONSTER );
for ( int i = 0; i < count; i++ )
{
if ( pList[i] != this ) // Don't hurt yourself!
return FALSE;
}
return TRUE;
}
return FALSE;
}
示例14: CollisionProp
bool C_DynamicProp::TestBoneFollowers( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr )
{
// UNDONE: There is no list of the bone followers that is networked to the client
// so instead we do a search for solid stuff here. This is not really great - a list would be
// preferable.
CBaseEntity *pList[128];
Vector mins, maxs;
CollisionProp()->WorldSpaceAABB( &mins, &maxs );
int count = UTIL_EntitiesInBox( pList, ARRAYSIZE(pList), mins, maxs, 0, PARTITION_CLIENT_SOLID_EDICTS );
for ( int i = 0; i < count; i++ )
{
if ( pList[i]->GetOwnerEntity() == this )
{
if ( pList[i]->TestCollision(ray, fContentsMask, tr) )
{
return true;
}
}
}
return false;
}
示例15: UTIL_EntitiesInBox
//LRC
void CBreakable::RespawnThink( void )
{
// ALERT(at_debug,"RespawnThink: ");
CBaseEntity *pList[2];
int count = UTIL_EntitiesInBox( pList, 2, pev->mins, pev->maxs, FL_MONSTER | FL_CLIENT );
if ( count )
{
// Can't respawn right now, a monster or player is in the way. Wait a bit.
// ALERT(at_debug,"Respawn failed, count is %d\n",count);
SetThink(&CBreakable:: RespawnThink );
SetNextThink( 2 ); // CONSIDER: change this number?
}
else
{
// fade in, don't just appear(?)
if (pev->spawnflags & SF_BREAK_FADE_RESPAWN)
{
SetThink(&CBreakable:: RespawnFadeThink );
SetNextThink( 0.1 );
pev->renderamt = 0;
if (m_iInitialRenderMode == kRenderNormal)
{
pev->rendermode = kRenderTransTexture;
m_iInitialRenderAmt = 255;
}
}
// ALERT(at_debug,"Respawn OK\n");
pev->solid = SOLID_BSP;
pev->effects &= ~EF_NODRAW;
pev->health = m_iInitialHealth;
SetUse(&CBreakable:: BreakUse );
if ( !FBitSet( pev->spawnflags, SF_BREAK_TRIGGER_ONLY ) )
pev->takedamage = DAMAGE_YES;
// trigger the "fire on respawn" target
FireTargets( STRING(pev->netname), this, this, USE_TOGGLE, 0);
}
}