ID:1452177
 
(See the best response by Kaiochao.)
Code:
mob/verb/Attack(mob/M in obounds(usr,3))
world<<"[usr] Attacked [M]"
return


Problem description:

I'm using Pixelmovement + Bounding Thus.


I Tried get_step and when a user attacked it brought up a list of themself with user attacking so i thought hey why not obounds+get_step sadly not the fix SO THEN i tryed in obounds OH HEY IT WORKED MMMM NOPE it worked but now i can be next to them but not faceing.



so problem is how can i make it so i have to face the user.

to attack


Edit
mob/verb/Attack(mob/M in obounds(usr,3))
if(M in get_step(usr,dir))
world<<"[usr] Attacked [M]"
return



Doesn't Work Except When User And Enemy Are Facing Each Other.
Best response
get_step() isn't the best thing to use if you're trying to see if an object is facing a certain direction, since it returns a turf. You should try using get_dir() and comparing the direction from the player to the other player with the player's direction.
Same problems as get_step

mob/verb/Attack(mob/M in obounds(usr,3))
if(get_dir(usr,M))
world<<"[usr] Attacked [M]"
return
no work
mob/verb/Attack(mob/M in obounds(usr,3))
if(usr in get_dir(M,dir))
world<<"[usr] Attacked [M]"
return
no work

mob/verb/Attack(mob/M in obounds(usr,3))
if(get_dir(M,usr))
world<<"[usr] Attacked [M]"
return
no work

mob/verb/Attack(mob/M in obounds(usr,3))
if(M in get_dir(usr,dir))
world<<"[usr] Attacked [M]"
return
no work


Note:
mob/verb/Attack(mob/M)
if(get_dir(usr,M))
world<<"[usr] Attacked [M]"
return
no works also


causes a list also but attacks also like get_step
if(get_dir(usr,M)) will pass unless they're in the same location.

if(usr in get_dir(M,dir)) is checking if an object is inside a number, as if it's a list, so it's complete nonsense.

get_dir() returns a dir, a number, not a list. You have to compare it with the attacker's dir to see if they match up.

mob/verb/Attack(mob/M in obounds(usr,3))
if(get_dir(usr,M))
world<<"[usr] Attacked [M]"
return

with just in obound or even with get_dir cause im not quite getting your explaintion yet i can attack fine.

but if i stand next to someone like this and hit attack it still attacks.
mob/verb/Attack(mob/M in obounds(usr,3))
var/MsDir = get_dir(usr,M)
if(MsDir == src.dir)


Sometimes using things as vars is easier instead of using a whole proc.
Thank you Kaiochao and thank you royal. had pm help with kaiochao though but thank you though he gave same thing just shorter.
:( always the late one.
I typically go with an approach that involves using obounds() with modified arguments to grab X pixels in front of the user.