Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "findradius"
From Quake Wiki
(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...") |
m (→Example) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | ''entity'' '''findradius'''(''vector'' pos, ''float'' range) | |
− | |||
− | + | == Usage == | |
− | + | Grabs all entities within range of the passed position. This compares against the center of the entities and not their origins. Entities with the solid type <code>SOLID_NONE</code> are ignored. | |
− | + | ||
− | + | '''Warning:''' This function uses the '''chain''' field to create a linked list of entities that it found. Nested calls should be avoided as only one linked list can be guaranteed active at a time and the base working list can become corrupted. | |
− | + | ||
− | : | + | === Parameters === |
− | === | + | *''pos'' |
− | The | + | :The position in the map to test from. |
− | + | *''range'' | |
− | + | :The max distance the center of an entity can be from the position. | |
− | + | ||
− | + | === Return === | |
− | + | The head of the linked list of found entities. Their '''chain''' field will point to the next entity in the list. | |
− | + | ||
− | + | == Example == | |
− | + | // Find all entities within 256 map units of the caller's origin | |
− | + | // Loop through them performing a task | |
− | + | for (entity it = findradius(self.origin, 256); it; it = it.chain) | |
− | + | PerformTask(it); | |
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Latest revision as of 15:45, 31 July 2023
entity findradius(vector pos, float range)
Contents
Usage[edit]
Grabs all entities within range of the passed position. This compares against the center of the entities and not their origins. Entities with the solid type SOLID_NONE
are ignored.
Warning: This function uses the chain field to create a linked list of entities that it found. Nested calls should be avoided as only one linked list can be guaranteed active at a time and the base working list can become corrupted.
Parameters[edit]
- pos
- The position in the map to test from.
- range
- The max distance the center of an entity can be from the position.
Return[edit]
The head of the linked list of found entities. Their chain field will point to the next entity in the list.
Example[edit]
// Find all entities within 256 map units of the caller's origin // Loop through them performing a task for (entity it = findradius(self.origin, 256); it; it = it.chain) PerformTask(it);