Exemplo n.º 1
0
edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius) {
	if (!pStart) pStart = NULL;

	pStart = FIND_ENTITY_IN_SPHERE(pStart, vecCenter, flRadius);

	if (!FNullEnt(pStart)) return pStart;
	return NULL;
}
Exemplo n.º 2
0
edict_t *FindEntityInSphere(edict_t *pentStart, edict_t *origin, float radius)
{
	edict_t* temp = FIND_ENTITY_IN_SPHERE(pentStart, origin->v.origin, radius);

	if(!temp)
		return NULL;

	return temp;
}
Exemplo n.º 3
0
edict_t *UTIL_FindEntityInSphere( edict_t *pentStart, const Vector &vecCenter, float flRadius )
{
   edict_t  *pentEntity;

   pentEntity = FIND_ENTITY_IN_SPHERE( pentStart, vecCenter, flRadius);

   if (!FNullEnt(pentEntity))
      return pentEntity;

   return NULL;
}
Exemplo n.º 4
0
CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius )
{
	edict_t	*pentEntity;

	if (pStartEntity)
		pentEntity = pStartEntity->edict();
	else
		pentEntity = NULL;

	pentEntity = FIND_ENTITY_IN_SPHERE( pentEntity, vecCenter, flRadius);

	if (!FNullEnt(pentEntity))
		return CBaseEntity::Instance(pentEntity);
	return NULL;
}
Exemplo n.º 5
0
static cell AMX_NATIVE_CALL find_ent_in_sphere(AMX *amx, cell *params)
{
	int idx = params[1];

	edict_t *pEnt = INDEXENT2(idx);
	cell *cAddr = MF_GetAmxAddr(amx, params[2]);
	float origin[3] = {
		amx_ctof(cAddr[0]),
		amx_ctof(cAddr[1]),
		amx_ctof(cAddr[2])
	};
	REAL radius = amx_ctof(params[3]);

	int returnEnt = ENTINDEX(FIND_ENTITY_IN_SPHERE(pEnt, origin, radius));

	if (FNullEnt(returnEnt))
		return 0;

	return returnEnt;
}
Exemplo n.º 6
0
static cell AMX_NATIVE_CALL find_sphere_class(AMX *amx, cell *params) // find_sphere_class(aroundent, _lookforclassname[], Float:radius, entlist[], maxents, Float:origin[3] = {0.0, 0.0, 0.0}); // 6 params
{
	// params[1] = index to find around, if this is less than 1 then use around origin in last parameter.
	// params[2] = classname to find
	int len;
	char* classToFind = MF_GetAmxString(amx, params[2], 0, &len);
	// params[3] = radius, float...
	REAL radius =amx_ctof(params[3]);
	// params[4] = store ents in this list
	cell *entList = MF_GetAmxAddr(amx, params[4]);
	// params[5] = maximum ents to store in entlist[] in params[4]
	// params[6] = origin, use this if params[1] is less than 1

	vec3_t vecOrigin;
	if (params[1] > 0) {
		CHECK_ENTITY(params[1]);

		edict_t* pEntity = INDEXENT2(params[1]);
		vecOrigin = pEntity->v.origin;
	} else {
		cell *cAddr = MF_GetAmxAddr(amx, params[6]);
		vecOrigin = Vector(amx_ctof(cAddr[0]), amx_ctof(cAddr[1]), amx_ctof(cAddr[2]));
	}
	
	int entsFound = 0;
	edict_t* pSearchEnt = INDEXENT2(0);

	while (entsFound < params[5]) {
		pSearchEnt = FIND_ENTITY_IN_SPHERE(pSearchEnt, vecOrigin, radius); // takes const float origin
		if (FNullEnt(pSearchEnt))
			break;
		else {
			if (strcmp(STRING(pSearchEnt->v.classname), classToFind) == 0) {
				// Add to entlist (params[4])
				entList[entsFound++] = ENTINDEX(pSearchEnt); // raise entsFound
			}
		}
	}

	return entsFound;
}