Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

findradius

From Quake Wiki

Revision as of 02:00, 26 March 2013 by Necros (talk | contribs) (Created page with "====Syntax:==== <code>entity findradius(vector org, float rad)</code> Finds all entities in a sphere of the given radius and origin. ====Parameters:==== :<code>org</code> - T...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Syntax:

entity findradius(vector org, float rad)

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

Parameters:

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

Returns:

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

Other Details:

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:

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.