ID:138883
 
Code:
        AttackStab()
set hidden = 1
if(roundIs=="Ring Around The Zodiac"&&canFight==0||usr.style=="Spectating"||usr.stabSpam)
return
if(usr.insane==1||roundIs=="Psycho Hunt"||roundIs=="Ring Around The Zodiac"||roundIs=="The Mystery Zodiac")
for(var/mob/M in get_step(usr,usr.dir))//Problem
if(usr.insane==0&&M.insane==0&&roundIs!="Ring Around The Zodiac")
usr<<"Can't hurt someone who isn't insane!"
return
if(M.style=="Spectating")
return
usr.stabSpam=1
M.Health-=1
if(usr.wepselect==1)
flick("Attack",usr)
view(usr)<<"<font color = green>[usr] stabbed [M] with a knife!"
if(usr.wepselect==2)
view(usr)<<"<font color = green>[usr] hits [M] with a [usr.secondWeapon]!"
M.Death(usr)
spawn(10)
usr.stabSpam=0


Problem description:
It works if I'm a distance away from the person, but if I'm up on them it doesn't recognize them so I can't stab them. Anyone know a workaround to get this right? I've also had problems where I've stabbed myself. I've done a test with the following:

        Check()
for(var/mob/M in get_step(usr,usr.dir))
world<<"[M]"


And here's what I get (video: ignore the poor pixel movement, was trying to fix it):
http://screencast.com/t/gOn7UuhMef
No, get_step() does not work with pixel movement. You should use bounds or obounds.
In response to Megablaze
Megablaze wrote:
No, get_step() does not work with pixel movement. You should use bounds or obounds.

Would you mind an example? Not exactly sure how to use bounds or obounds correctly.
In response to Ganing
var/bx=0
var/by=0
if(src.dir==EAST)
bx=src.bound_width
else if(src.dir==WEST)
bx=-src.bound_width
else if(src.dir==NORTH)
by=src.bound_height
else if(src.dir==SOUTH)
by=-src.bound_height
for(var/mob/M in obounds(src, bx, by))
world << M


There's a very basic method to check one body space in front of your character. The size of the area that it checks is the size of your character. If you want to alter the size of the box that it checks, you'll need to add arguments to obounds().