ID:1649862
 
(See the best response by FKI.)
Code:


Problem description:

SO FRUSTRATED!!!!!!!!!!!!

okay got that out. So with byonds tiles and basic combat ussually you can do something like

for(var/mob/m in get_step(usr,usr.dir))
...attack code

but when you are moving less then a tile at a time thats when that method of attacking an enemy infront of you becomes wonky. My characters move 5 pixels at a time. So this means that sometimes even whens hes facing an enemy he can not attack with that code. This is because through through the five pixel movement when you start to go to up or down and attack your tile location moves down. Meaning that even when he may appear in front of you he is infact not in the direct tile space.

So my question is. IS there a way to counteract this. I don't need a fledged out example, just a place to start.

I've already tried multiple methods and after some thought realized they were a waste of resources and too complicated for something too simple.

Best response
Here are two procs I took directly out of my own project that uses pixel movement:

proc/get_pixel_step(var/atom/A, var/pixels)
var/x = 0
var/y = 0

if(A.dir & NORTH) y += pixels
if(A.dir & SOUTH) y -= pixels
if(A.dir & EAST) x += pixels
if(A.dir & WEST) x -= pixels

. = obounds(A, x, y, 0, 0)

proc/get_pixel_steps(var/atom/A, var/pixels, var/steps)
var/x = 0
var/y = 0
. = list()

for(, steps > 0; steps--)
if(A.dir & NORTH) y += pixels
if(A.dir & SOUTH) y -= pixels
if(A.dir & EAST) x += pixels
if(A.dir & WEST) x -= pixels

. += obounds(A, x, y, 0, 0)
thanks thats good help but im cofused about what this is

. = obounds(A, x, y, 0, 0)

i dont know what obounds is or does
i found bounds in reference, but what does adding o onto it do
oh nvm i found it thanks alot never used bounds before
you should probably pass a direction to get_pixel_step() rather than an atom (as the original get_step() is). It's more versatile that way.