#define BRIDGE_LAYER 5
atom/var/elevation
turf
Enter(atom/movable/m)
//This system allows you to move between two spaces
//as normal, if they're no more than one elevation
//level different.
if (abs(m.elevation - src.elevation) > 1) return 0
return ..()
ground
elevation = 1
valley
elevation = -1
mountain
elevation = 3
down_slope
elevation = 0
up_slope
elevation = 2
bridge
elevation = 1
layer = BRIDGE_LAYER
var/bridge_level = 3
proc/is_open(elevation)
//check for dense objects at a given level.
for (var/atom/movable/m in src)
if (m.elevation == elevation && m.density)
return 0
return 1
Enter(atom/movable/m)
//bridges can be walked across...
if (m.elevation == bridge_level)
//can I step across?
if (m.density == 0 || is_open(bridge_level))
if (. && m.layer < BRIDGE_LAYER)
//yes I can, so why draw me under it?
spawn() m.layer += BRIDGE_LAYER
return 1
else return 0
//...or under
return (m.density == 0 || is_open(elevation))
Exited(atom/movable/m)
if (m.layer > BRIDGE_LAYER)
m.layer -= BRIDGE_LAYER
//no longer on the bridge, so stop drawing me so darn high!
The above code is by no means flawless... I haven't tested it in the form written. One thing to consider is that elevation would not calculated as part of distance, and mobs below or above you on a bridge would be considered to be at a distance of 0.
Kinda what u would do with building a 2 story house. Lord Raven shared this with me a while ago.