ID:157482
 
For my Pokemon game,i was wondering if i could lock the user view...i mean that he can move in only X steps in his view,He can not get out of it..what is the code for this?
Basically, you just change what the view look at to just a tile rather then it following the player.

Look into client.eye in the DM reference.
mob
var
atom/view_source // The center of this view.
view_distance // The distance from the view that
// they are allowed to move.

Move(atom/loc)
if(view && istype(view) && (get_dist(src, view) > view_distance)
// If the view is set and it's an /atom, but if
// the new location to move to is outside their
// allowed view, block them.
return 0

// Otherwise, allow them to move as normal.
return ..()

proc
SetView(atom/source, distance = 5)
view_source = source
view_distance = distance

client.eye = source
client.perspective = EYE_PERSPECTIVE
return 1

UnsetView()
view_source = null
distance = null

client.eye = src
client.perspective = MOB_PERSPECTIVE
return 1


This won't work for views that can move (such as if it's a mob following a path for, say, an escort mission or something). This would require you to modify the moving thing's Move() proc also, to force others to follow along.