Topic: Efficient way to iterate over players and monsters within a radius
Provide a more efficient way to iterate over players and monsters within a given radius.
For some script and spell effects it is neccesary to iterate over all players and monsters in a radius to apply some effect. Currently this requires iterating over all possible 255 players, and the 2048 monster slots on a map. This makes it slow, so it is not used much.
Does the server hold this information on a sector level, or provide some other data structure to query this from? If so, could some more efficient way of getting a list of monsters and players in a radius be added?
Some pseudo code:
gsGetEntitiesInRadius(entity_out[], x, y, mapid, radius, filter); // returns number of entities found
new entities[MAX_ENTITIES];
new entityCount = gsGetEntitiesInRadius(entities, x, y, m, 50, FILTER_PLAYERS | FILTER_MONSTERS);
for(new i = 0; i < entityCount; i++) {
new id = entities[i];
// do things with the entity
}