ID:265113
 
Here's something I've been playing with. It's untested, and probably won't copy/paste even with the DM tags, as I spaced everything by hand... but it's something people have asked if BYOND could handle, so I thought I'd share.

#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.
Lesbian Assassin wrote:
Here's something I've been playing with. It's untested, and probably won't copy/paste even with the DM tags, as I spaced everything by hand... but it's something people have asked if BYOND could handle, so I thought I'd share.

> #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.
In response to Green Lime
I can't really see this technique being used for that... in a house, the top level sits over the bottom level. This is more like diagonal slopes. Most two-story house codes I've seen use different maps/z-levels, and "teleportation". This is more like having a mountains, plains, and valleys or canyons on the same map...so a player on the mountain can see one down in the valley, but they can't reach each other unless they walk up or down slopes to each other's levels.

I've seen things like it before, but having multiple levels within the same square, where you can have one player standing on a bridge and another player walking below it, isn't something I've seen anyone do.
In response to Lesbian Assassin
Lesbian Assassin wrote:
I can't really see this technique being used for that... in a house, the top level sits over the bottom level. This is more like diagonal slopes. Most two-story house codes I've seen use different maps/z-levels, and "teleportation". This is more like having a mountains, plains, and valleys or canyons on the same map...so a player on the mountain can see one down in the valley, but they can't reach each other unless they walk up or down slopes to each other's levels.

I've seen things like it before, but having multiple levels within the same square, where you can have one player standing on a bridge and another player walking below it, isn't something I've seen anyone do.

Lord Ravens Lost souls has done that a long time ago. Matter a fact go on his game right now its up and u will see what I mean.
In response to Green Lime
Will do... if only to see if you and I are talking about the same thing.

[EDIT]

Downloaded the game... as soon as I ran it, I was error-spammed about ork aggression. Anyways, I found a multi-story building... and I was right, his does not do what mine does.

When you get on the roof, try stepping across the square you come up from under... you'll notice you go under it, even though you're coming at it from the side! You can also step to the left or the right of the stairs, while on the staircase, with the result that you seem to be coming up through the floor. That's the point of my bridge snippet... it allows you to create turfs that differentiate between walking across and walking under.
In response to Lesbian Assassin
Lesbian Assassin wrote:
Will do... if only to see if you and I are talking about the same thing.

[EDIT]

Downloaded the game... as soon as I ran it, I was error-spammed about ork aggression. Anyways, I found a multi-story building... and I was right, his does not do what mine does.

When you get on the roof, try stepping across the square you come up from under... you'll notice you go under it, even though you're coming at it from the side! You can also step to the left or the right of the stairs, while on the staircase, with the result that you seem to be coming up through the floor. That's the point of my bridge snippet... it allows you to create turfs that differentiate between walking across and walking under.

Hrm, I believe this was done in Ebonshadow's Movement library all to long ago, the lib should be sitting around somewhere but I know it has features so you can have a bridge with a mob under and over it.
In response to Darkness
In that case, I may have drastically overestimated the demand for this code... anyways, my primary reason for posting was to demonstrate that it's possible, since I've had a lot of people a) ask me if it is, b) insist that it isn't, and c) ask me how to do it. So, if anyone else has any more examples to share... the more the merrier!
In response to Lesbian Assassin
Lesbian Assassin wrote:
In that case, I may have drastically overestimated the demand for this code... anyways, my primary reason for posting was to demonstrate that it's possible, since I've had a lot of people a) ask me if it is, b) insist that it isn't, and c) ask me how to do it. So, if anyone else has any more examples to share... the more the merrier!

Haven has had a working system of this for a while as well, but I have an almost infallible policy of not sharing my code, especially in public forums. ;-)

Heck, when people ask me for examples of code I always code one up from scratch, even if I already had a working sample in one of my games. The only people who have seen any of my source code (aside from my libraries and aside from Switcheroo, which are -- by nature -- open-source) are Dantom, or in rarer instances, some forum-dwellers when I had a seemingly unsurmountable code problem. Even then, they'd only be snippets, with relevant names and stuff stripped out.
My movement library has built in capability to do this.


Lesbian Assassin wrote:
Here's something I've been playing with. It's untested, and probably won't copy/paste even with the DM tags, as I spaced everything by hand... but it's something people have asked if BYOND could handle, so I thought I'd share.

> #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.
In response to Lesbian Assassin
Lesbian Assassin wrote:
Will do... if only to see if you and I are talking about the same thing.

[EDIT]

Downloaded the game... as soon as I ran it, I was error-spammed about ork aggression. Anyways, I found a multi-story building... and I was right, his does not do what mine does.

When you get on the roof, try stepping across the square you come up from under... you'll notice you go under it, even though you're coming at it from the side! You can also step to the left or the right of the stairs, while on the staircase, with the result that you seem to be coming up through the floor. That's the point of my bridge snippet... it allows you to create turfs that differentiate between walking across and walking under.

...I know this post was from several months ago but i just now found it and i felt like saying that my code DOES do exactly that; I believe that the stairs to the arena bleachers is bugged but try going to other buildings like the mages guild or the inn. It does differentiate between layers. I thought bout releasing it as a library but not much demand for it so i didn't. Green Lime's bout the only person who's asked me how i did it. Just felt like defending myself.