ID:156814
 
I'm having trouble with Click(). I want to make a point and click Stab thing.. So I want to make something where if you click on something that you are facing(basically, get_step(usr,usr.dir)), it will stab them. I'm having trouble with this because I'm not sure how Click() works fully...
Click is a simple proc to understand once you grasp the basics behind it. I believe this is what you're trying to do.


mob/Player //Replace with whatever your client mob type is.
Click(mob/Player/P) //When clicked by the mob type, 'mob/Player' . .
set src in oview(1) //So it only works one tile away. .
if(P.key==src.key) return //Can't stab themself
if(P.dir!=get_dir(src,P)) return //If their not facing them, return
range(P)<<"<b>[P] stabbed [src]!" //Ouch!




It might work the other way around, I'm unsure, if it does just swap the variables. I haven't used Click() with two client instances in quite awhile.

In response to Kumorii
atom/Click() doesn't work the way you mentioned it, the arguments you have shown are based on client/Click()

And the set ... only works for verbs.
atom/Click()  //   /area, /turf, /obj, /mob, etc.
if(get_dist(src, usr) != 1) // If the person is not a tile apart, this does not happen
return
usr = the person who Click()d the object (*This is one procedure where it is safe to use usr in*)
src = the object that was Click()d (ex: if this was /obj/food/Click(), src = an existing /obj/food, etc).


mob/Haemophilia_person
Click() // when usr clicks src, a /mob/Haemophilia_person path
world << "[usr.name] killed [src.name], a poor person suffering from haemophilia"