ID:2372299
 
Code:
mob/proc

melee()
for(var/mob/M in in_front(48,48))
world << "[M]"

in_front(var/x_size = 0, y_size = 0)
var/dx = 0, dy = 0
dy = (dir & NORTH) ? y_size : -y_size
dx = (dir & EAST) ? x_size : -x_size
return obounds(src,dx,dy)


Problem description:

I'm trying to write a function for finding mobs in front of you for stuff like melee and close ranged attacks. I can't seem to nail down a way to do it so I can customize it. As an example, for melee, i'd like it find mobs in front of me in a 48x48 box, and if the user has a sword equipped, it could extend it to 64x64. Something along those lines. The code above returns nothing and I'm not quite sure why

Edit:
Okay I'm just not understanding this at all. I've been trying for hours to get the results I want, and I'm no closer to a solution than I was at the beginning. Below are some visual representations of what I'm trying to get:

https://gyazo.com/a48df7695813b13e2974a0fcecec4df1

https://gyazo.com/1afddc174cac00f487c20a89a2b6d4fd

https://gyazo.com/63083803a5c776f58504dbeaa516c3b4

I haven't been able to get any of these to work. I can't move forward with my project until I understand this because it's heavy on combat. Does anyone have some ideas? Thanks for your time

is anyone able to help? ;-;
You may simply be forgetting the third and fourth arguments to obounds(), which handle width and height. The other two numerical arguments you're using are just offsetting the existing player bounding box by 48 pixels in a specific direction.
http://www.byond.com/forum/?post=2361708#comment24000544

See this thread. Your math is completely wrong. I laid out a lot of math for working with this kind of stuff in the above post.
Thank you much, that's very helpful.