ID:2844985
 
Hello, devs!

I have a doubt about how to get more tha one turf in a map topdown format which I have a obj 250x250 (icon size). I'm learning about physics and I already can centralize the physical start point. But how can I get all turfs in the obj area?
If the object has physical bounds set up, you can just grab object.locs.

If the object does not have physical bounds, you can get a block of turfs with block(), or a list of all atoms underneath an object or a rectangle with obounds()/bounds().

I'd have to know more about what you are trying to accomplish to point you in the right direction.
I have a skill in a game which is basically a circle area with the player in the center. I want to get all mobs in the circle area if they touch the obj created by that skill. So, Maybe I'm thinking wrong, but I want that object (is only one object) to check if has some mob in his area and then fire a damage proc. Something like that!
Disregard the visual object, then. It's irrelevant. We just need to know the point at the center, and the radius. The visual object is just purely visual, and located over the spot you wanna to some target finding within.

BYOND only give you the ability to get the objects that intersect with rectangles. So we need to apply a little theory here. If we know the center and radius of the circle, we can create an AABB that will contain the circle:

var/circle_d = circle_r * 2
var/list/testing = bounds(center_x-circle_r,center_y-circle_r,circle_d,circle_d,z)


So for each mob you find in testing, you are going to need to determine whether it's inside or outside the circle using the math below:

//define the collision rectangle from ref's bounds
var/aabb_half_x = ref.bound_width / 2
var/aabb_half_y = ref.bound_height / 2
var/aabb_cx = ref.step_x - ref.bound_x + (ref.x-1) * TILE_WIDTH + aabb_half_x
var/aabb_cy = ref.step_y - ref.bound_y + (ref.y-1) * TILE_HEIGHT + aabb_half_y

//find the closest point on the AABB to center of the circle
var/closest_x = aabb_cx + clamp(circle_x - aabb_cx,-aabb_half_x,aabb_half_x)
var/closest_y = aabb_cy + clamp(circle_y - aabb_cy,-aabb_half_y,aabb_half_y)

//find the offset to the closest point
var/dx = closest_x - circle_x
var/dy = closest_y - circle_y

if(dx*dx + dy*dy < circle_r*circle_r)
//The object is in the circle
else
//The object is not in the circle