Fixes multi-z things.

This commit is contained in:
Joseph Heinemeyer
2015-08-30 15:43:32 -07:00
committed by SkyMarshal
parent 772c320303
commit 8c61c3ab6f
17 changed files with 251 additions and 655 deletions

View File

@@ -1410,8 +1410,12 @@
#include "code\modules\mob\new_player\preferences_setup.dm"
#include "code\modules\mob\new_player\skill.dm"
#include "code\modules\mob\new_player\sprite_accessories.dm"
#include "code\modules\multiz\_stubs.dm"
#include "code\modules\multiz\basic.dm"
#include "code\modules\multiz\stubs.dm"
#include "code\modules\multiz\movement.dm"
#include "code\modules\multiz\pipes.dm"
#include "code\modules\multiz\structures.dm"
#include "code\modules\multiz\turf.dm"
#include "code\modules\nano\_JSON.dm"
#include "code\modules\nano\JSON Reader.dm"
#include "code\modules\nano\JSON Writer.dm"
@@ -1785,11 +1789,6 @@
#include "code\modules\virus2\items_devices.dm"
#include "code\modules\xgm\xgm_gas_data.dm"
#include "code\modules\xgm\xgm_gas_mixture.dm"
#include "code\TriDimension\Movement.dm"
#include "code\TriDimension\Pipes.dm"
#include "code\TriDimension\Structures.dm"
#include "code\TriDimension\Structures_presets.dm"
#include "code\TriDimension\Turfs.dm"
#include "code\ZAS\_docs.dm"
#include "code\ZAS\Airflow.dm"
#include "code\ZAS\Atom.dm"

View File

@@ -1,263 +0,0 @@
///////////////////////////////////////
//Contents: Ladders, Hatches, Stairs.//
///////////////////////////////////////
/obj/multiz
icon = 'icons/obj/structures.dmi'
density = 0
opacity = 0
anchored = 1
CanPass(obj/mover, turf/source, height, airflow)
return airflow || !density
/obj/multiz/ladder
icon_state = "ladderdown"
name = "ladder"
desc = "A ladder. You climb up and down it."
var/d_state = 1
var/obj/multiz/target
New()
. = ..()
proc/connect()
if(icon_state == "ladderdown") // the upper will connect to the lower
d_state = 1
for(var/obj/multiz/ladder/L in GetBelow(src))
if(L.icon_state == "ladderup")
target = L
L.target = src
d_state = 0
return
/* ex_act(severity)
switch(severity)
if(1.0)
if(icon_state == "ladderup" && prob(10))
qdel(src)
if(2.0)
if(prob(50))
qdel(src)
if(3.0)
qdel(src)
return*/
Destroy()
spawn(1)
if(target && icon_state == "ladderdown")
qdel(target)
return ..()
attackby(obj/item/C as obj, mob/user as mob)
(..)
// construction commented out for balance concerns
/* if (!target && istype(C, /obj/item/stack/rods))
var/turf/controllerlocation = locate(1, 1, z)
var/found = 0
var/obj/item/stack/rods/S = C
if(S.amount < 2)
user << "You dont have enough rods to finish the ladder."
return
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.down)
found = 1
var/turf/below = locate(src.x, src.y, controller.down_target)
var/blocked = 0
for(var/atom/A in below.contents)
if(A.density)
blocked = 1
break
if(!blocked && !istype(below, /turf/simulated/wall))
var/obj/multiz/ladder/X = new /obj/multiz/ladder(below)
S.amount = S.amount - 2
if(S.amount == 0) qdel(S)
X.icon_state = "ladderup"
connect()
user << "You finish the ladder."
else
user << "The area below is blocked."
if(!found)
user << "You cant build a ladder down there."
return
else if (icon_state == "ladderdown" && d_state == 0 && istype(C, /obj/item/weapon/wrench))
user << "<span class='notice'>You start loosening the anchoring bolts which secure the ladder to the frame.</span>"
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
sleep(30)
if(!user || !C) return
src.d_state = 1
if(target)
var/obj/item/stack/rods/R = PoolOrNew(/obj/item/stack/rods, target.loc)
R.amount = 2
qdel(Target)
user << "<span class='notice'>You remove the bolts anchoring the ladder.</span>"
return
else if (icon_state == "ladderdown" && d_state == 1 && istype(C, /obj/item/weapon/weldingtool) )
var/obj/item/weapon/weldingtool/WT = C
if( WT.remove_fuel(0,user) )
user << "<span class='notice'>You begin to remove the ladder.</span>"
playsound(src.loc, 'sound/items/Welder.ogg', 100, 1)
sleep(60)
if(!user || !WT || !WT.isOn()) return
var/obj/item/stack/material/steel/S = new /obj/item/stack/material/steel( src )
S.amount = 2
user << "<span class='notice'>You remove the ladder and close the hole.</span>"
qdel(src)
else
user << "<span class='notice'>You need more welding fuel to complete this task.</span>"
return
else
src.attack_hand(user)
return*/
src.attack_hand(user)
return
attack_hand(var/mob/M)
if(!target || !istype(target.loc, /turf))
M << "The ladder is incomplete and can't be climbed."
else
var/turf/T = target.loc
var/blocked = 0
for(var/atom/A in T.contents)
if(A.density)
blocked = 1
break
if(blocked || istype(T, /turf/simulated/wall))
M << "Something is blocking the ladder."
else
M.visible_message("<span class='notice'>\The [M] climbs [src.icon_state == "ladderup" ? "up" : "down"] \the [src]!</span>", "You climb [src.icon_state == "ladderup" ? "up" : "down"] \the [src]!", "You hear some grunting, and clanging of a metal ladder being used.")
M.Move(target.loc)
/* hatch
icon_state = "hatchdown"
name = "hatch"
desc = "A hatch. You climb down it, and it will automatically seal against pressure loss behind you."
top_icon_state = "hatchdown"
var/top_icon_state_open = "hatchdown-open"
var/top_icon_state_close = "hatchdown-close"
bottom_icon_state = "ladderup"
var/image/green_overlay
var/image/red_overlay
var/active = 0
New()
. = ..()
red_overlay = image(icon, "red-ladderlight")
green_overlay = image(icon, "green-ladderlight")
attack_hand(var/mob/M)
if(!target || !istype(target.loc, /turf))
qdel(src)
if(active)
M << "That [src] is being used."
return // It is a tiny airlock, only one at a time.
active = 1
var/obj/multiz/ladder/hatch/top_hatch = target
var/obj/multiz/ladder/hatch/bottom_hatch = src
if(icon_state == top_icon_state)
top_hatch = src
bottom_hatch = target
flick(top_icon_state_open, top_hatch)
bottom_hatch.overlays += green_overlay
spawn(7)
if(!target || !istype(target.loc, /turf))
qdel(src)
if(M.z == z && get_dist(src,M) <= 1)
var/list/adjacent_to_me = global_adjacent_z_levels["[z]"]
M.visible_message("<span class='notice'>\The [M] scurries [target.z == adjacent_to_me["up"] ? "up" : "down"] \the [src]!</span>", "You scramble [target.z == adjacent_to_me["up"] ? "up" : "down"] \the [src]!", "You hear some grunting, and a hatch sealing.")
M.Move(target.loc)
flick(top_icon_state_close,top_hatch)
bottom_hatch.overlays -= green_overlay
bottom_hatch.overlays += red_overlay
spawn(7)
top_hatch.icon_state = top_icon_state
bottom_hatch.overlays -= red_overlay
active = 0*/
/obj/multiz/stairs
name = "Stairs"
desc = "Stairs. You walk up and down them."
icon_state = "rampbottom"
var/obj/multiz/stairs/connected
var/turf/target
var/turf/target2
var/suggest_dir // try this dir first when finding stairs; this is the direction to walk *down* the stairs
New()
..()
var/turf/above = GetAbove(src)
if(istype(above, /turf/space))
above.ChangeTurf(/turf/simulated/open)
spawn(1)
var/turf/T
if(suggest_dir)
T = get_step(src.loc,suggest_dir)
find_stair_connection(T, suggest_dir, 1)
if(!target)
for(var/dir in cardinal)
T = get_step(src.loc,dir)
find_stair_connection(T, dir)
if(target)
break
Bumped(var/atom/movable/M)
if(connected && target && istype(src, /obj/multiz/stairs) && locate(/obj/multiz/stairs) in M.loc)
var/obj/multiz/stairs/Con = locate(/obj/multiz/stairs) in M.loc
if(Con == src.connected) //make sure the atom enters from the approriate lower stairs tile
M.Move(target)
return
proc/find_stair_connection(var/turf/T, var/dir, var/suggested=0)
for(var/obj/multiz/stairs/S in T)
if(S && S.icon_state == "rampbottom" && !S.connected)
if(!S.suggest_dir || S.suggest_dir == dir) // it doesn't have a suggested direction, or it's the same direction as we're trying, so we connect to it
initialise_stair_connection(src, S, dir)
else if(!suggested) // we're trying directions, so it could be a reverse stair (i.e. we're the bottom stair rather than the top)
var/inv_dir = 0
switch(dir)
if(1)
inv_dir = 2
if(2)
inv_dir = 1
if(4)
inv_dir = 8
if(8)
inv_dir = 4
if(S.suggest_dir == inv_dir)
initialise_stair_connection(S, src, inv_dir)
proc/initialise_stair_connection(var/obj/multiz/stairs/top, var/obj/multiz/stairs/bottom, var/dir)
top.set_dir(dir)
bottom.set_dir(dir)
top.connected = bottom
bottom.connected = top
top.icon_state = "ramptop"
top.density = 1
var/turf/above = GetAbove(top)
if(istype(above,/turf/space) || istype(above,/turf/simulated/open))
top.target = above
above = GetAbove(bottom)
if(istype(above, /turf/space) || istype(above,/turf/simulated/open))
top.target2 = above
return

View File

@@ -1,11 +0,0 @@
/obj/multiz/stairs/north_up
suggest_dir = SOUTH
/obj/multiz/stairs/south_up
suggest_dir = NORTH
/obj/multiz/stairs/east_up
suggest_dir = WEST
/obj/multiz/stairs/west_up
suggest_dir = EAST

View File

@@ -1,114 +0,0 @@
/turf/simulated/open
name = "open space"
density = 0
alpha = 0
icon_state = "black"
pathweight = 100000 //Seriously, don't try and path over this one numbnuts
var/icon/darkoverlays
var/turf/below
var/list/overlay_references
New()
..()
// Unhide shit.
for(var/obj/obj in src)
if(obj.level == 1)
obj.hide(0)
ASSERT(HasBelow(z))
below = GetBelow(src)
return
Entered(var/atom/movable/mover)
// only fall down in defined areas (read: areas with artificial gravitiy)
if(!istype(below)) //make sure that there is actually something below
below = GetBelow(src)
if(!below)
return
// No gravity in space, apparently.
var/area/area = get_area(src)
if(area.name == "Space")
return
// Prevent pipes from falling into the void... if there is a pipe to support it.
if(istype(mover, /obj/item/pipe) && \
(locate(/obj/structure/disposalpipe/up) in below) || \
locate(/obj/machinery/atmospherics/pipe/zpipe/up in below))
return
// See if something prevents us from falling.
var/soft = 0
for(var/atom/A in below)
if(A.density)
if(!istype(A, /obj/structure/window))
return
else
var/obj/structure/window/W = A
if(W.is_fulltile())
return
// Dont break here, since we still need to be sure that it isnt blocked
if(istype(A, /obj/multiz/stairs))
soft = 1
// We've made sure we can move, now.
mover.Move(below)
if(!soft)
if(!istype(mover, /mob))
if(istype(below, /turf/simulated/open))
below.visible_message("\The [mover] falls from the deck above through \the [below]!", "You hear a whoosh of displaced air.")
else
below.visible_message("\The [mover] falls from the deck above and slams into \the [below]!", "You hear something slam into the deck.")
else
var/mob/M = mover
if(istype(below, /turf/simulated/open))
below.visible_message("\The [mover] falls from the deck above through \the [below]!", "You hear a soft whoosh.[M.stat ? "" : ".. and some screaming."]")
else
M.visible_message("\The [mover] falls from the deck above and slams into \the [below]!", "You land on \the [below].", "You hear a soft whoosh and a crunch")
// Handle people getting hurt, it's funny!
if (istype(mover, /mob/living/carbon/human))
var/mob/living/carbon/human/H = mover
var/damage = 5
H.apply_damage(rand(0, damage), BRUTE, "head")
H.apply_damage(rand(0, damage), BRUTE, "chest")
H.apply_damage(rand(0, damage), BRUTE, "l_leg")
H.apply_damage(rand(0, damage), BRUTE, "r_leg")
H.apply_damage(rand(0, damage), BRUTE, "l_arm")
H.apply_damage(rand(0, damage), BRUTE, "r_arm")
H.weakened = max(H.weakened,2)
H.updatehealth()
// override to make sure nothing is hidden
/turf/simulated/open/levelupdate()
for(var/obj/O in src)
O.hide(0)
// Straight copy from space.
/turf/simulated/open/attackby(obj/item/C as obj, mob/user as mob)
if (istype(C, /obj/item/stack/rods))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
return
var/obj/item/stack/rods/R = C
if (R.use(1))
user << "<span class='notice'>Constructing support lattice ...</span>"
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
ReplaceWithLattice()
return
if (istype(C, /obj/item/stack/tile/floor))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
var/obj/item/stack/tile/floor/S = C
if (S.get_amount() < 1)
return
qdel(L)
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
S.use(1)
ChangeTurf(/turf/simulated/floor/airless)
return
else
user << "<span class='warning'>The plating is going to need some support.</span>"
return

View File

@@ -1,189 +0,0 @@
/obj/effect/landmark/zcontroller
name = "Z-Level Controller"
var/initialized = 0 // when set to 1, turfs will report to the controller
var/up = 0 // 1 allows up movement
var/up_target = 0 // the Z-level that is above the current one
var/down = 0 // 1 allows down movement
var/down_target = 0 // the Z-level that is below the current one
var/list/slow = list()
var/list/normal = list()
var/list/fast = list()
var/slow_time
var/normal_time
var/fast_time
/obj/effect/landmark/zcontroller/New()
..()
for (var/turf/T in world)
if (T.z == z)
fast += T
slow_time = world.time + 3000
normal_time = world.time + 600
fast_time = world.time + 10
processing_objects.Add(src)
initialized = 1
return 1
/obj/effect/landmark/zcontroller/Destroy()
processing_objects.Remove(src)
return ..()
/obj/effect/landmark/zcontroller/process()
if (world.time > fast_time)
calc(fast)
fast_time = world.time + 10
if (world.time > normal_time)
calc(normal)
normal_time = world.time + 600
/* if (world.time > slow_time)
calc(slow)
slow_time = world.time + 3000 */
return
/obj/effect/landmark/zcontroller/proc/add(var/list/L, var/I, var/transfer)
while (L.len)
var/turf/T = pick(L)
L -= T
slow -= T
normal -= T
fast -= T
if(!T || !istype(T, /turf))
continue
switch (I)
if(1) slow += T
if(2) normal += T
if(3) fast += T
if(transfer > 0)
if(up)
var/turf/controller_up = locate(1, 1, up_target)
for(var/obj/effect/landmark/zcontroller/c_up in controller_up)
var/list/temp = list()
temp += locate(T.x, T.y, up_target)
c_up.add(temp, I, transfer-1)
if(down)
var/turf/controller_down = locate(1, 1, down_target)
for(var/obj/effect/landmark/zcontroller/c_down in controller_down)
var/list/temp = list()
temp += locate(T.x, T.y, down_target)
c_down.add(temp, I, transfer-1)
return
/turf
var/list/z_overlays = list()
/turf/New()
..()
var/turf/controller = locate(1, 1, z)
for(var/obj/effect/landmark/zcontroller/c in controller)
if(c.initialized)
var/list/turf = list()
turf += src
c.add(turf,3,1)
atom/movable/Move() //Hackish
. = ..()
var/turf/controllerlocation = locate(1, 1, src.z)
for(var/obj/effect/landmark/zcontroller/controller in controllerlocation)
if(controller.up || controller.down)
var/list/temp = list()
temp += locate(src.x, src.y, src.z)
controller.add(temp,3,1)
/obj/effect/landmark/zcontroller/proc/calc(var/list/L)
var/list/slowholder = list()
var/list/normalholder = list()
var/list/fastholder = list()
var/new_list
while(L.len)
var/turf/T = pick(L)
new_list = 0
if(!T || !istype(T, /turf))
L -= T
continue
T.overlays -= T.z_overlays
T.z_overlays -= T.z_overlays
if(down && (istype(T, /turf/space) || istype(T, /turf/simulated/open)))
var/turf/below = locate(T.x, T.y, down_target)
if(below)
if(!(istype(below, /turf/space) || istype(below, /turf/simulated/open)))
var/image/t_img = list()
new_list = 1
var/image/temp = image(below, dir=below.dir, layer = TURF_LAYER + 0.04)
temp.color = rgb(127,127,127)
temp.overlays += below.overlays
t_img += temp
T.overlays += t_img
T.z_overlays += t_img
// get objects
var/image/o_img = list()
for(var/obj/o in below)
// ingore objects that have any form of invisibility
if(o.invisibility) continue
new_list = 2
var/image/temp2 = image(o, dir=o.dir, layer = TURF_LAYER+0.05*o.layer)
temp2.color = rgb(127,127,127)
temp2.overlays += o.overlays
o_img += temp2
// you need to add a list to .overlays or it will not display any because space
T.overlays += o_img
T.z_overlays += o_img
// get mobs
var/image/m_img = list()
for(var/mob/m in below)
// ingore mobs that have any form of invisibility
if(m.invisibility) continue
// only add this tile to fastprocessing if there is a living mob, not a dead one
if(istype(m, /mob/living)) new_list = 3
var/image/temp2 = image(m, dir=m.dir, layer = TURF_LAYER+0.05*m.layer)
temp2.color = rgb(127,127,127)
temp2.overlays += m.overlays
m_img += temp2
// you need to add a list to .overlays or it will not display any because space
T.overlays += m_img
T.z_overlays += m_img
T.overlays -= below.z_overlays
T.z_overlays -= below.z_overlays
L -= T
if(new_list == 1)
slowholder += T
if(new_list == 2)
normalholder += T
if(new_list == 3)
fastholder += T
for(var/d in cardinal)
var/turf/mT = get_step(T,d)
if(!(mT in fastholder))
fastholder += mT
for(var/f in cardinal)
var/turf/nT = get_step(mT,f)
if(!(nT in fastholder))
fastholder += nT
add(slowholder,1, 0)
add(normalholder, 2, 0)
add(fastholder, 3, 0)
return

View File

@@ -1,37 +0,0 @@
/obj/effect/landmark/zcontroller/level_1_bottom
up = 1
up_target = 2
/obj/effect/landmark/zcontroller/level_2_mid
up = 1
up_target = 3
down = 1
down_target = 1
/obj/effect/landmark/zcontroller/level_3_mid
up = 1
up_target = 4
down = 1
down_target = 2
/obj/effect/landmark/zcontroller/level_4_mid
up = 1
up_target = 5
down = 1
down_target = 3
/obj/effect/landmark/zcontroller/level_2_top
down = 1
down_target = 1
/obj/effect/landmark/zcontroller/level_3_top
down = 1
down_target = 2
/obj/effect/landmark/zcontroller/level_4_top
down = 1
down_target = 3
/obj/effect/landmark/zcontroller/level_5_top
down = 1
down_target = 4

View File

@@ -153,8 +153,6 @@ var/global/datum/controller/gameticker/ticker
processScheduler.start()
for(var/obj/multiz/ladder/L in world) L.connect() //Lazy hackfix for ladders. TODO: move this to an actual controller. ~ Z
if(config.sql_enabled)
statistic_cycle() // Polls population totals regularly and stores them in an SQL DB -- TLE

View File

@@ -34,8 +34,7 @@
if (istype(A,/mob/living))
var/mob/living/M = A
if(M.lying)
..()
return
return ..()
// Ugly hack :( Should never have multiple plants in the same tile.
var/obj/effect/plant/plant = locate() in contents

View File

@@ -70,6 +70,9 @@
if(movement_disabled && usr.ckey != movement_disabled_exception)
usr << "<span class='warning'>Movement is admin-disabled.</span>" //This is to identify lag problems
return
..()
if (!mover || !isturf(mover.loc))
return 1

View File

@@ -9,8 +9,8 @@
// FOR THE LOVE OF GOD USE THESE. DO NOT FUCKING SPAGHETTIFY THIS.
// Use the Has*() functions if you ONLY need to check.
// If you need to do something, use Get*().
proc/HasAbove(var/z)
proc/HasBelow(var/z)
HasAbove(var/z)
HasBelow(var/z)
// These give either the turf or null.
proc/GetAbove(var/turf/turf)
proc/GetBelow(var/turf/turf)
GetAbove(var/atom/atom)
GetBelow(var/atom/atom)

View File

@@ -4,28 +4,32 @@ var/z_levels = 0 // Each bit represents a connection between adjacent levels. S
// If the height is more than 1, we mark all contained levels as connected.
/obj/effect/landmark/map_data/New()
for(var/i = z - 1 to height - 2)
z_levels |= 1 << i
del src
ASSERT(height <= z)
// Due to the offsets of how connections are stored v.s. how z-levels are indexed, some magic number silliness happened.
for(var/i = (z - height) to (z - 2))
z_levels |= (1 << i)
qdel(src)
HasAbove(z)
if(z > world.maxz || z > 17 || z < 2)
// The storage of connections between adjacent levels means some bitwise magic is needed.
proc/HasAbove(var/z)
if(z >= world.maxz || z > 16 || z < 1)
return 0
return z_levels & (1 << (z - 1))
HasBelow(z)
if(z >= world.maxz || z > 16 || z < 1)
proc/HasBelow(var/z)
if(z > world.maxz || z > 17 || z < 2)
return 0
return z_levels & (1 << z)
return z_levels & (1 << (z - 2))
GetAbove(var/atom/thing)
var/turf/turf = get_turf(thing)
if(!istype(turf))
// Thankfully, no bitwise magic is needed here.
proc/GetAbove(var/atom/atom)
var/turf/turf = get_turf(atom)
if(!turf)
return null
return HasBelow(turf.z) ? locate(turf.z, turf.y, turf.z - 1) : null
return HasAbove(turf.z) ? get_step(turf, UP) : null
GetBelow(var/atom/thing)
var/turf/turf = get_turf(thing)
if(!istype(turf))
proc/GetBelow(var/atom/atom)
var/turf/turf = get_turf(atom)
if(!turf)
return null
return HasBelow(turf.z) ? locate(turf.z, turf.y, turf.z + 1) : null
return HasBelow(turf.z) ? get_step(turf, DOWN) : null

View File

@@ -0,0 +1,10 @@
proc/HasAbove(var/z)
return 0
proc/HasBelow(var/z)
return 0
// These give either the turf or null.
proc/GetAbove(var/turf/turf)
return null
proc/GetBelow(var/turf/turf)
return null

View File

@@ -3,8 +3,8 @@
set category = "Object"
. = 1
if(allow_thrust(0.01, usr))
usr << "<span class='warning'>Your [src] is disabled.</span>"
if(!allow_thrust(0.01, usr))
usr << "<span class='warning'>\The [src] is disabled.</span>"
return
var/turf/above = GetAbove(src)
@@ -29,23 +29,23 @@
set category = "Object"
. = 1
if(allow_thrust(0.01, usr))
usr << "<span class='warning'>Your [src] is disabled.</span>"
if(!allow_thrust(0.01, usr))
usr << "<span class='warning'>\The [src] is disabled.</span>"
return
var/turf/above = GetBelow(src)
if(!istype(above))
var/turf/below = GetBelow(src)
if(!istype(below))
usr << "<span class='notice'>There is nothing of interest in this direction.</span>"
return
if(!istype(above, /turf/space) && !istype(above, /turf/simulated/open))
usr << "<span class='warning'>You bump against \the [above].</span>"
if(below.density)
usr << "<span class='warning'>You bump against \the [below].</span>"
return
for(var/atom/A in above)
for(var/atom/A in below)
if(A.density)
usr << "<span class='warning'>\The [A] blocks you.</span>"
return
usr.Move(above)
usr << "<span class='notice'>You move upwards.</span>"
usr.Move(below)
usr << "<span class='notice'>You move downwards.</span>"

View File

@@ -0,0 +1,86 @@
//////////////////////////////
//Contents: Ladders, Stairs.//
//////////////////////////////
/obj/structure/ladder
name = "ladder"
desc = "A ladder. You can climb it up and down."
icon_state = "ladderdown"
icon = 'icons/obj/structures.dmi'
density = 0
opacity = 0
anchored = 1
var/obj/structure/ladder/target
initialize()
// the upper will connect to the lower
if(icon_state == "ladderup")
return
for(var/obj/structure/ladder/L in GetBelow(src))
if(L.icon_state == "ladderup")
target = L
L.target = src
return
Destroy()
if(target && icon_state == "ladderdown")
qdel(target)
return ..()
attackby(obj/item/C as obj, mob/user as mob)
. = ..()
attack_hand(user)
return
attack_hand(var/mob/M)
if(!target || !istype(target.loc, /turf))
M << "<span class='notice'>\The [src] is incomplete and can't be climbed.</span>"
return
var/turf/T = target.loc
for(var/atom/A in T)
if(A.density)
M << "<span class='notice'>\A [A] is blocking \the [src].</span>"
return
M.visible_message("<span class='notice'>\A [M] climbs [icon_state == "ladderup" ? "up" : "down"] \a [src]!</span>",
"You climb [icon_state == "ladderup" ? "up" : "down"] \the [src]!",
"You hear the grunting and clanging of a metal ladder being used.")
M.Move(T)
CanPass(obj/mover, turf/source, height, airflow)
return airflow || !density
/obj/structure/stairs
name = "Stairs"
desc = "Stairs. You walk up and down them."
icon_state = "rampbottom"
icon = 'icons/obj/structures.dmi'
density = 0
opacity = 0
anchored = 1
var/obj/structure/stairs/connected
New()
..()
var/turf/above = GetAbove(src)
if(istype(above, /turf/space))
above.ChangeTurf(/turf/simulated/open)
initialize()
var/updown = icon_state == "rampbottom" ? UP : DOWN
var/turf/T = get_step(src, dir | updown)
connected = locate() in T
ASSERT(connected)
Uncross(var/atom/movable/M)
if(connected && M.dir == dir)
M.loc = connected.loc
return 1
CanPass(obj/mover, turf/source, height, airflow)
return airflow || !density

111
code/modules/multiz/turf.dm Normal file
View File

@@ -0,0 +1,111 @@
/turf/simulated/open
name = "open space"
icon = 'icons/turf/space.dmi'
icon_state = "black"
alpha = 16
layer = 0
density = 0
pathweight = 100000 //Seriously, don't try and path over this one numbnuts
var/turf/below
var/list/underlay_references
var/global/overlay_map = list()
/turf/simulated/open/New()
. = ..()
ASSERT(HasBelow(z))
below = GetBelow(src)
/turf/simulated/open/Entered(var/atom/movable/mover)
// only fall down in defined areas (read: areas with artificial gravitiy)
if(!istype(below)) //make sure that there is actually something below
below = GetBelow(src)
if(!below)
return
// No gravity in space, apparently.
var/area/area = get_area(src)
if(area.name == "Space")
return
// Prevent pipes from falling into the void... if there is a pipe to support it.
if(istype(mover, /obj/item/pipe) && \
(locate(/obj/structure/disposalpipe/up) in below) || \
locate(/obj/machinery/atmospherics/pipe/zpipe/up in below))
return
// See if something prevents us from falling.
var/soft = 0
for(var/atom/A in below)
if(A.density)
if(!istype(A, /obj/structure/window))
return
else
var/obj/structure/window/W = A
if(W.is_fulltile())
return
// Dont break here, since we still need to be sure that it isnt blocked
if(istype(A, /obj/structure/stairs))
soft = 1
// We've made sure we can move, now.
mover.Move(below)
if(!soft)
if(!istype(mover, /mob))
if(istype(below, /turf/simulated/open))
below.visible_message("\The [mover] falls from the deck above through \the [below]!", "You hear a whoosh of displaced air.")
else
below.visible_message("\The [mover] falls from the deck above and slams into \the [below]!", "You hear something slam into the deck.")
else
var/mob/M = mover
if(istype(below, /turf/simulated/open))
below.visible_message("\The [mover] falls from the deck above through \the [below]!", "You hear a soft whoosh.[M.stat ? "" : ".. and some screaming."]")
else
M.visible_message("\The [mover] falls from the deck above and slams into \the [below]!", "You land on \the [below].", "You hear a soft whoosh and a crunch")
// Handle people getting hurt, it's funny!
if (istype(mover, /mob/living/carbon/human))
var/mob/living/carbon/human/H = mover
var/damage = 5
H.apply_damage(rand(0, damage), BRUTE, "head")
H.apply_damage(rand(0, damage), BRUTE, "chest")
H.apply_damage(rand(0, damage), BRUTE, "l_leg")
H.apply_damage(rand(0, damage), BRUTE, "r_leg")
H.apply_damage(rand(0, damage), BRUTE, "l_arm")
H.apply_damage(rand(0, damage), BRUTE, "r_arm")
H.weakened = max(H.weakened,2)
H.updatehealth()
// override to make sure nothing is hidden
/turf/simulated/open/levelupdate()
for(var/obj/O in src)
O.hide(0)
// Straight copy from space.
/turf/simulated/open/attackby(obj/item/C as obj, mob/user as mob)
if (istype(C, /obj/item/stack/rods))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
return
var/obj/item/stack/rods/R = C
if (R.use(1))
user << "<span class='notice'>Constructing support lattice ...</span>"
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
ReplaceWithLattice()
return
if (istype(C, /obj/item/stack/tile/floor))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
var/obj/item/stack/tile/floor/S = C
if (S.get_amount() < 1)
return
qdel(L)
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
S.use(1)
ChangeTurf(/turf/simulated/floor/airless)
return
else
user << "<span class='warning'>The plating is going to need some support.</span>"
return

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 101 KiB