Entity Class: entity_blocker?

When doing this

[lua]
for k,v in pairs(ents.GetAll()) do
print(v:GetClass())[/lua], there is 858 entities on the map, about 150 of those are “entity_blocker”, does anybody have a clue what these are?

It’s an entity mainly used to signify that a volume is occupied - doors, ai and the airboat are the main things that use it. Really just an invisible solid bounding box that is optionally solid.


//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "entityblocker.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

LINK_ENTITY_TO_CLASS( entity_blocker, CEntityBlocker );

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &origin - 
//			&mins - 
//			&maxs - 
//			NULL - 
// Output : CEntityBlocker
//-----------------------------------------------------------------------------
CEntityBlocker *CEntityBlocker::Create( const Vector &origin, const Vector &mins, const Vector &maxs, CBaseEntity *pOwner, bool bBlockPhysics )
{
	CEntityBlocker *pBlocker = (CEntityBlocker *) CBaseEntity::Create( "entity_blocker", origin, vec3_angle, pOwner );
	
	if ( pBlocker != NULL )
	{
		pBlocker->SetSize( mins, maxs );
		if ( bBlockPhysics )
		{
			pBlocker->VPhysicsInitStatic();
		}
	}

	return pBlocker;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEntityBlocker::Spawn( void )
{
	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_CUSTOMRAYTEST );
}

//-----------------------------------------------------------------------------
// Purpose: Entity blockers don't block tracelines so they don't screw up weapon fire, etc
//-----------------------------------------------------------------------------
bool CEntityBlocker::TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace )
{
	return false;
}

//------------------------------------------------------------------------------
// Purpose : 
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CC_Test_Entity_Blocker( void )
{
	CBasePlayer *pPlayer = UTIL_GetCommandClient();
	Vector vecForward;
	pPlayer->GetVectors( &vecForward, NULL, NULL );

	trace_t tr;
	Vector vecOrigin = pPlayer->GetAbsOrigin() + (vecForward * 256);
	UTIL_TraceHull( vecOrigin + Vector(0,0,256), vecOrigin - Vector(0,0,256), VEC_HULL_MIN, VEC_HULL_MAX, MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &tr );
	if ( !tr.allsolid && !tr.startsolid )
	{
		CEntityBlocker::Create( tr.endpos, VEC_HULL_MIN, VEC_HULL_MAX, NULL, true );
		NDebugOverlay::Box( tr.endpos, VEC_HULL_MIN, VEC_HULL_MAX, 0, 255, 0, 64, 1000.0 );
	}
}
static ConCommand test_entity_blocker("test_entity_blocker", CC_Test_Entity_Blocker, "Test command that drops an entity blocker out in front of the player.", FCVAR_CHEAT );

:smiley: You’re awesome.

Nothing bad would happen if I… removed them?

Not really; in fact, there’s an exploit revolving these, where people can just create them with jeeps and use them to block paths and stuff.

What is the point of having them if they in no way affect gameplay when removed?

I dunno, it’s some HL2 crap.

What about “predicted_viewmodel”? It doesn’t appear like they are ever removed correctly, any harm in removing those?

Edit: removed them, it appears to break all clientside view models :confused:

It doesn’t appear that they are ever properly removed by the engine though, since there’s ~300 or so on a 32 player server after 30-35 minutes of uptime.

Check if their owner is valid?