ID:167596
 
Can anyone think of a way to conditionally allow movement such as allow the environment to move a mob but not let the mob or any other procs (such as a walking AI proc to move the mob).

For example say you have a conveyor belt and you want to lock the movement for all mobs (not just actual players) when they are on the belt so the only thing that can effect their movement is the belt, until they get off the belt. I was tinkering around with locking the direction of the mob to the direction that the turf is making them go but this became to large of an undertaking once I considered the possibility of the turfs not having any direction, such as ice, or turfs that changed direction, such as a bumper or a curved wall.

The solution that came to my mind would be a modified Move() proc that would only allow movement if whatever calling it passed a certain test, for example you could give AI walking and client movement a priority of two and the conveyor belt a priority or one. That way if a mob is already moving and that movement had a higher priority than one that is trying to be called the movement would not change and so on.
I don't really know how to efficiently do this so I would appreciate everyone's input.

[EDIT]
After thinking about it, I guess what I could use is perhaps an intermediate step between the step procs (any of the procs that end up calling Move) and Move, something that would check to see if that step had a higher priority and if it did then call move if not then ignore it.
Just give it a parameter and pass true/false to it.
mob/var
paralyzed = 0; frozen = 0; unconcious = 0
mob/Move(loc, dir, allow = 1)
if(!allow) return 0
.=..()

client/Move(loc, dir)
.=..(loc, dir, ~(mob.paralyzed|mob.frozen|mob.unconcious))

obj/conveyer_belt
proc/push()
var/turf/T
var/obj/belt_trap
for(var/mob/M in loc)
T = get_step(M, dir)
belt_trap = locate()in loc
M.Move(T, 0, belt_trap?0:1)
obj/belt_trap
In response to Loduwijk
I think I understand how that works. Thanks for your input.