findradius

From Quake Wiki

Syntax:[edit]

entity findradius(vector org, float rad)

Finds all entities in a sphere of the given radius and origin.

Parameters:[edit]

org - The center of the sphere to perform the search.
rad - The radius of the sphere to perform the search.

Returns:[edit]

Returns an entity that is the first in a list of entities linked together by the .chain field.

Other Details:[edit]

The point at which findradius considers an entity to be 'in range' is computed based on the center of an entity's bounding box, not its origin. Entities with SOLID_NOT are completely ignored. When this function is run, it builds the list of entities by setting the .chain field on all entities it finds. This means that if other findradius functions are called and they affect the same entities, the entity links for the previous list will be broken. Make sure you do not call findradius when it is nested inside a previous findradius loop.

Example:[edit]

local	entity	head;
head = findradius(self.origin, 200);
while (head)
{
	head = head.chain;
}

In this example, findradius searches 200 units around self and creates a list of entities linked together with .chain and returns the first in the list. The while loop then continues to move through the list until it reaches the end where .chain is world.