ID:1868922
 
So, I've managed to cobble together a grab verb and it seems to work fine say for that when I kill the mob I'm still stuck in place. So I was wondering if I can get some help coming up with something that would reset my move back to 0 when the mob dies or is no longer adjacent to the src.


mob
var
grabvar = 0 // 0 = allow move 1 = block move
Move()
if(grabvar)
return 0
else
..()

mob
verb
Grab(mob/M in get_step(usr,usr.dir))
set category="Taijutsu"
if(!M || !ismob(M))return
if(usr.tai+usr.cbat+(rand (3,18)-2)<=M.eva+M.spd+(rand (3,18)))
src<<"<font color=\"blue\">Your attack was evaded!</font>"
else
M.grabvar = !M.grabvar
src.grabvar = !src.grabvar




You can set 'grabvar' to be the mob you are grabbing, then run if(grabvar in orange(1, src)) return

You could even reset grabvar if it isn't beside the character.
You can set 'grabvar' to be the mob you are grabbing, then run if(grabvar in orange(1, src)) return

That's an O(N) complexity. It can be done in O(1) complexity.

#ifdef TILE_MODE
proc
inRange(atom/obj1,atom/obj2,range)
if(obj1.loc&&obj2.loc&&obj1.z==obj2.z)
return max(abs(obj1.x - obj2.x),abs(obj1.y - obj2.y))<=range
else
return 1#INF
#elif
proc
inRange(atom/obj1,atom/obj2,range)
return bounds_dist(obj1,obj2)<=range
#endif
In response to Ter13
I'm still pretty new, could you point me in the direction of where atoms are explained in the DM so that I might get a better understanding?
Area
Turf
Object
Mob
In response to Rickoshay
thank you!