Command bug?: getObjectsInRangeWithFlags
Posted: Thu Jun 30, 2011 8:14 pm
There are a couple similar script functions for getting the objects in range of a location based on the item flags.
getNumAllObjectsInRangewithFlags: returns the number of items with matching flags that are in range
getObjectsInRangeWithFlags: returns a list (of serials) of the items in range of the location.
Both of these functions use a function (currently) called MapObject_GetObjectsInRange, which like the script commands take a location and a range.
The function of MapObject_GetObjectsInRange is to resolve the range to a list of map sectors (8x8 grid) and return all of the items in those sectors. So the name of this function is somewhat of a misnomer as all of the items returned are not necessarily in range, but only "roughly" in range.
The getNumAllObjectsInRangewithFlags function checks each obtained items specific range before returning the count of objects that are in range; but getObjectsInRangeWithFlags does not perform this check, and may return items that are out of the range specified by the call.
Of course, this might be considered more of an inconsistency than a bug, as the first function simply returns a count of the items, and it would not be possible to verify range after the fact; while the function which populates a list does allow for checking of the literal range after the call.
getNumAllObjectsInRangewithFlags: returns the number of items with matching flags that are in range
getObjectsInRangeWithFlags: returns a list (of serials) of the items in range of the location.
Both of these functions use a function (currently) called MapObject_GetObjectsInRange, which like the script commands take a location and a range.
The function of MapObject_GetObjectsInRange is to resolve the range to a list of map sectors (8x8 grid) and return all of the items in those sectors. So the name of this function is somewhat of a misnomer as all of the items returned are not necessarily in range, but only "roughly" in range.
The getNumAllObjectsInRangewithFlags function checks each obtained items specific range before returning the count of objects that are in range; but getObjectsInRangeWithFlags does not perform this check, and may return items that are out of the range specified by the call.
Of course, this might be considered more of an inconsistency than a bug, as the first function simply returns a count of the items, and it would not be possible to verify range after the fact; while the function which populates a list does allow for checking of the literal range after the call.