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...") |
|||
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. | |
− | while ( | + | |
+ | == Example == | ||
+ | // Find all entities within 256 map units of the caller's origin | ||
+ | entity it = findradius(self.origin, 256); | ||
+ | while (it) | ||
{ | { | ||
− | + | PerformTask(it); | |
+ | it = it.chain; | ||
} | } | ||
− | |||
− | |||
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Revision as of 15:43, 31 July 2023
entity findradius(vector pos, float range)
Contents
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 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
- pos
- 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 entity it = findradius(self.origin, 256); while (it) { PerformTask(it); it = it.chain; }