ID:143463
 
Code:
mob/verb/attack(var/mob/M)
if(!M) M = locate(/mob/) in get_step(usr, usr.dir)
if(!M) return
M << "YOU WERE HIT FOR 25 LOL"
usr << "YOU ATTACKED [M.name] for 25 LOL"


Problem description:
I don't want to feel like an idiot posting a bug report on a coding problem. So, to make sure it is a bug, I'm posting here. Anyway, get_step() does not seem to be working correctly. Every time I click attack, I attack myself. I can't possibly be in two places at once (meaning my location and the location before me), so can anyone enlighten me? Perhaps it is something I am overlooking.

It's doing the same thing for me.
mob/verb/attack(var/mob/M)
if(!M)
world << "Called"
M = locate(/mob/) in get_step(usr, usr.dir)
if(!M) return
M << "YOU WERE HIT FOR 25 LOL"
usr << "YOU ATTACKED [M.name] for 25 LOL"


Perhaps that will clear up your misunderstanding.
The main problem is that you are selecting yourself to be attacked via the argument. Since you're the only mob in the world (assumption here), it picks you without your consent... and since you are only using locate() if M is null, it doesn't happen.

Solution: Take out var/mob/M from the argument. Instead, make it
var/mob/M = locate() in get_step(usr, usr.dir) // locate() uses the path in the variable due to the null value entered: var/__path__/__var shortcut__ = locate() is the same as = locate(__path__)
Are you sure that you aren't accidentally passing something to attack?
In response to Audeuro (#4)
Apparently when you put var/mob/M as an argument like that, it picks a mob in the world rather than just sit like it really should.
In response to GhostAnime (#3)
Yeah, just remembered that when I was replying to Auddy. :P
In response to CaptFalcon33035 (#5)
CaptFalcon33035 wrote:
Apparently when you put var/mob/M as an argument like that, it picks a mob in the world rather than just sit like it really should.

Yeah, that's what verbs are MEANT to do. They're not procs, they don't (usually) TAKE arguments, they define them.