03-18-2016, 10:51 PM
Radius for search can be done in a custom CBOT function pretty easily.
Returning an array of all objects of certain category is even easier.
I bet angular limitations are possible as well. Tho I don't see much of a use for those. You can choose a percise spot to look at anyway.
Example:
I didn't post in a while now did I?
Returning an array of all objects of certain category is even easier.
I bet angular limitations are possible as well. Tho I don't see much of a use for those. You can choose a percise spot to look at anyway.
Example:
Code:
object object::bettersearch(int cat, point pos, float rmin, float rmax)
{
// Generate objects list
object objects[];
int i = 0;
float range = 0;
int size;
while(true)
{
objects[i] = radar(cat, 0, 360, range);
if(objects[i] == null)
{
size = i;
break;
}
range = distance(this.position,objects[i].position)+0.1;
i++;
}
// Objects list ready
// One could 'return objects;' here to get searchAll
float distances[];
int result = nan;
for(i=0;i<size;i++)
{
distances[i] = distance(pos,objects[i].position); // Determine distances
if (distances[i] < rmin) distances[i] = 1000; // Trim objects too close
if (distances[i] < rmax) // Locate closest object
{
rmax = distances[i];
result = i;
}
}
// Return the result
if (result == nan)
{
message("Object not found",DisplayError);
return null;
}
else return objects[result];
}
I didn't post in a while now did I?
My Code Battle League program: MhrodeBattle.txt
Welcome back, Mrocza. You last visited: Sunday, July 7th, 2013, 02:12 pm
http://imgur.com/L3Y8bQz
Welcome back, Mrocza. You last visited: Sunday, July 7th, 2013, 02:12 pm
http://imgur.com/L3Y8bQz