ID:261422
 
I can't seem to get this to work. The bump teleports you when you bump any mob. Help Please

mob
Bump(mob/M)
if(/mob/NPC/Monster)
usr.loc =locate(1,1,1)
M.loc =locate(1,2,1)
else
return
Shouldn't it be:
mob
Bump(mob/M)
if(M == /mob/NPC/Monster)
usr.loc =locate(1,1,1)
M.loc =locate(1,2,1)
else
return


That should work...
In response to Dreq
Thank you the way you did it didi't work right but I came up with a way useing vars but you gave me the idea. Thank you ;P
In response to Little Sally
Yeah basically saying if(/mob/NPC/Monster) is the same as saying if(1) which is ALWAYS true. mob/M in your proc's () is given the value of the mob thats calling it (usuially), so you use that to check. But to learn good practice early, ALWAYS say:
if (M)
yourcode

Because BYOND has a habbit of calling procs with M as null, in which case you'll be slammed with ugly runtime errors :)


Edit:
That if(M==whatever) will work too, just as long as your checking for ~something~ :)
Dreq's code isn't the best way of doing this:

mob/Bump(mob/M as mob)
if(istype(M,/mob/monster))
...
In response to Nadrew
I simply added 'M =' to her code ;)