Adds Multi-Z Test Map

This commit is contained in:
Neerti
2017-03-03 09:40:34 -05:00
parent bb2adf1290
commit 0f781e36a7
20 changed files with 702 additions and 283 deletions
+176 -33
View File
@@ -1,51 +1,194 @@
/obj/item/weapon/tank/jetpack/verb/moveup()
/mob/verb/up()
set name = "Move Upwards"
set category = "Object"
set category = "IC"
. = 1
if(!allow_thrust(0.01, usr))
usr << "<span class='warning'>\The [src] is disabled.</span>"
if(zMove(UP))
to_chat(usr, "<span class='notice'>You move upwards.</span>")
/mob/verb/down()
set name = "Move Down"
set category = "IC"
if(zMove(DOWN))
to_chat(usr, "<span class='notice'>You move down.</span>")
/mob/proc/zMove(direction)
if(eyeobj)
return eyeobj.zMove(direction)
if(!can_ztravel())
to_chat(usr, "<span class='warning'>You lack means of travel in that direction.</span>")
return
var/turf/above = GetAbove(src)
if(!istype(above))
usr << "<span class='notice'>There is nothing of interest in this direction.</span>"
return
var/turf/destination = (direction == UP) ? GetAbove(src) : GetBelow(src)
if(!istype(above, /turf/space) && !istype(above, /turf/simulated/open))
usr << "<span class='warning'>You bump against \the [above].</span>"
return
if(!destination)
to_chat(usr, "<span class='notice'>There is nothing of interest in this direction.</span>")
return 0
for(var/atom/A in above)
if(A.density)
usr << "<span class='warning'>\The [A] blocks you.</span>"
return
var/turf/start = get_turf(src)
if(!start.CanZPass(src, direction))
to_chat(usr, "<span class='warning'>\The [start] is in the way.</span>")
return 0
if(!destination.CanZPass(src, direction))
to_chat(usr, "<span class='warning'>\The [destination] blocks your way.</span>")
return 0
usr.Move(above)
usr << "<span class='notice'>You move upwards.</span>"
var/area/area = get_area(src)
if(direction == UP && area.has_gravity)
var/obj/structure/lattice/lattice = locate() in destination.contents
if(lattice)
var/pull_up_time = max(5 SECONDS + (src.movement_delay() * 10), 1)
to_chat(src, "<span class='notice'>You grab \the [lattice] and start pulling yourself upward...</span>")
destination.audible_message("<span class='notice'>You hear something climbing up \the [lattice].</span>")
if(do_after(src, pull_up_time))
to_chat(src, "<span class='notice'>You pull yourself up.</span>")
else
to_chat(src, "<span class='warning'>You gave up on pulling yourself up.</span>")
return 0
else
to_chat(usr, "<span class='warning'>Gravity stops you from moving upward.</span>")
return 0
/obj/item/weapon/tank/jetpack/verb/movedown()
set name = "Move Downwards"
set category = "Object"
for(var/atom/A in destination)
if(!A.CanPass(src, start, 1.5, 0))
to_chat(usr, "<span class='warning'>\The [A] blocks you.</span>")
return 0
Move(destination)
return 1
. = 1
if(!allow_thrust(0.01, usr))
usr << "<span class='warning'>\The [src] is disabled.</span>"
/mob/observer/zMove(direction)
var/turf/destination = (direction == UP) ? GetAbove(src) : GetBelow(src)
if(destination)
forceMove(destination)
else
to_chat(usr, "<span class='notice'>There is nothing of interest in this direction.</span>")
/mob/observer/eye/zMove(direction)
var/turf/destination = (direction == UP) ? GetAbove(src) : GetBelow(src)
if(destination)
setLoc(destination)
else
to_chat(usr, "<span class='notice'>There is nothing of interest in this direction.</span>")
/mob/proc/can_ztravel()
return 0
/mob/observer/can_ztravel()
return 1
/mob/living/carbon/human/can_ztravel()
if(incapacitated())
return 0
if(Process_Spacemove())
return 1
if(Check_Shoegrip()) //scaling hull with magboots
for(var/turf/simulated/T in trange(1,src))
if(T.density)
return 1
/mob/living/silicon/robot/can_ztravel()
if(incapacitated() || is_dead())
return 0
if(Process_Spacemove()) //Checks for active jetpack
return 1
for(var/turf/simulated/T in trange(1,src)) //Robots get "magboots"
if(T.density)
return 1
//FALLING STUFF
//Holds fall checks that should not be overriden by children
/atom/movable/proc/fall()
if(!isturf(loc))
return
var/turf/below = GetBelow(src)
if(!istype(below))
usr << "<span class='notice'>There is nothing of interest in this direction.</span>"
if(!below)
return
if(below.density)
usr << "<span class='warning'>You bump against \the [below].</span>"
var/turf/T = loc
if(!T.CanZPass(src, DOWN) || !below.CanZPass(src, DOWN))
return
// No gravity in space, apparently.
var/area/area = get_area(src)
if(!area.has_gravity())
return
if(throwing)
return
if(can_fall())
handle_fall(below)
//For children to override
/atom/movable/proc/can_fall()
if(anchored)
return FALSE
if(locate(/obj/structure/lattice, loc))
return FALSE
// See if something prevents us from falling.
var/turf/below = GetBelow(src)
for(var/atom/A in below)
if(A.density)
usr << "<span class='warning'>\The [A] blocks you.</span>"
return
if(!A.CanPass(src, src.loc))
return FALSE
usr.Move(below)
usr << "<span class='notice'>You move downwards.</span>"
return TRUE
/obj/effect/can_fall()
return FALSE
/obj/effect/decal/cleanable/can_fall()
return TRUE
/obj/item/pipe/can_fall()
var/turf/simulated/open/below = loc
below = below.below
. = ..()
if(anchored)
return FALSE
if((locate(/obj/structure/disposalpipe/up) in below) || locate(/obj/machinery/atmospherics/pipe/zpipe/up in below))
return FALSE
/mob/living/simple_animal/parrot/can_fall() // Poly can fly.
return FALSE
/mob/living/simple_animal/hostile/carp/can_fall() // So can carp apparently.
return FALSE
/atom/movable/proc/handle_fall(var/turf/landing)
Move(landing)
if(locate(/obj/structure/stairs) in landing)
return 1
if(istype(landing, /turf/simulated/open))
visible_message("\The [src] falls from the deck above through \the [landing]!", "You hear a whoosh of displaced air.")
else
visible_message("\The [src] falls from the deck above and slams into \the [landing]!", "You hear something slam into the deck.")
/mob/living/carbon/human/handle_fall(var/turf/landing)
if(..())
return
to_chat(src, "<span class='danger'>You fall off and hit \the [landing]!</span>")
playsound(loc, "punch", 25, 1, -1)
var/damage = 20 // Because wounds heal rather quickly, 20 should be enough to discourage jumping off but not be enough to ruin you, at least for the first time.
apply_damage(rand(0, damage), BRUTE, BP_HEAD)
apply_damage(rand(0, damage), BRUTE, BP_TORSO)
apply_damage(rand(0, damage), BRUTE, BP_L_LEG)
apply_damage(rand(0, damage), BRUTE, BP_R_LEG)
apply_damage(rand(0, damage), BRUTE, BP_L_ARM)
apply_damage(rand(0, damage), BRUTE, BP_R_ARM)
Weaken(4)
updatehealth()
+145 -68
View File
@@ -4,54 +4,127 @@
/obj/structure/ladder
name = "ladder"
desc = "A ladder. You can climb it up and down."
icon_state = "ladderdown"
desc = "A ladder. You can climb it up and down."
icon_state = "ladder01"
icon = 'icons/obj/structures.dmi'
density = 0
opacity = 0
anchored = 1
var/obj/structure/ladder/target
var/allowed_directions = DOWN
var/obj/structure/ladder/target_up
var/obj/structure/ladder/target_down
initialize()
// the upper will connect to the lower
if(icon_state == "ladderup")
return
var/const/climb_time = 2 SECONDS
/obj/structure/ladder/initialize()
// the upper will connect to the lower
if(allowed_directions & DOWN) //we only want to do the top one, as it will initialize the ones before it.
for(var/obj/structure/ladder/L in GetBelow(src))
if(L.icon_state == "ladderup")
target = L
L.target = src
if(L.allowed_directions & UP)
target_down = L
L.target_up = src
return
update_icon()
Destroy()
if(target && icon_state == "ladderdown")
qdel(target)
return ..()
/obj/structure/ladder/Destroy()
if(target_down)
target_down.target_up = null
target_down = null
if(target_up)
target_up.target_down = null
target_up = null
return ..()
attackby(obj/item/C as obj, mob/user as mob)
. = ..()
attack_hand(user)
/obj/structure/ladder/attackby(obj/item/C as obj, mob/user as mob)
attack_hand(user)
return
/obj/structure/ladder/attack_hand(var/mob/M)
if(!M.may_climb_ladders(src))
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>"
var/obj/structure/ladder/target_ladder = getTargetLadder(M)
if(!target_ladder)
return
if(!M.Move(get_turf(src)))
to_chat(M, "<span class='notice'>You fail to reach \the [src].</span>")
return
var/direction = target_ladder == target_up ? "up" : "down"
M.visible_message("<span class='notice'>\The [M] begins climbing [direction] \the [src]!</span>",
"You begin climbing [direction] \the [src]!",
"You hear the grunting and clanging of a metal ladder being used.")
target_ladder.audible_message("<span class='notice'>You hear something coming [direction] \the [src]</span>")
if(do_after(M, climb_time, src))
climbLadder(M, target_ladder)
/obj/structure/ladder/attack_ghost(var/mob/M)
var/target_ladder = getTargetLadder(M)
if(target_ladder)
M.forceMove(get_turf(target_ladder))
/obj/structure/ladder/proc/getTargetLadder(var/mob/M)
if((!target_up && !target_down) || (target_up && !istype(target_up.loc, /turf) || (target_down && !istype(target_down.loc,/turf))))
to_chat(M, "<span class='notice'>\The [src] is incomplete and can't be climbed.</span>")
return
if(target_down && target_up)
var/direction = alert(M,"Do you want to go up or down?", "Ladder", "Up", "Down", "Cancel")
if(direction == "Cancel")
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
if(!M.may_climb_ladders(src))
return
switch(direction)
if("Up")
return target_up
if("Down")
return target_down
else
return target_down || target_up
/mob/proc/may_climb_ladders(var/ladder)
if(!Adjacent(ladder))
to_chat(src, "<span class='warning'>You need to be next to \the [ladder] to start climbing.</span>")
return FALSE
if(incapacitated())
to_chat(src, "<span class='warning'>You are physically unable to climb \the [ladder].</span>")
return FALSE
return TRUE
/mob/observer/ghost/may_climb_ladders(var/ladder)
return TRUE
/obj/structure/ladder/proc/climbLadder(var/mob/M, var/target_ladder)
var/turf/T = get_turf(target_ladder)
for(var/atom/A in T)
if(!A.CanPass(M, M.loc, 1.5, 0))
to_chat(M, "<span class='notice'>\The [A] is blocking \the [src].</span>")
return FALSE
return M.Move(T)
/obj/structure/ladder/CanPass(obj/mover, turf/source, height, airflow)
return airflow || !density
/obj/structure/ladder/update_icon()
icon_state = "ladder[!!(allowed_directions & UP)][!!(allowed_directions & DOWN)]"
/obj/structure/ladder/up
allowed_directions = UP
icon_state = "ladder10"
/obj/structure/ladder/updown
allowed_directions = UP|DOWN
icon_state = "ladder11"
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"
@@ -61,46 +134,50 @@
opacity = 0
anchored = 1
initialize()
for(var/turf/turf in locs)
var/turf/simulated/open/above = GetAbove(turf)
if(!above)
warning("Stair created without level above: ([loc.x], [loc.y], [loc.z])")
return qdel(src)
if(!istype(above))
above.ChangeTurf(/turf/simulated/open)
/obj/structure/stairs/initialize()
for(var/turf/turf in locs)
var/turf/simulated/open/above = GetAbove(turf)
if(!above)
warning("Stair created without level above: ([loc.x], [loc.y], [loc.z])")
return qdel(src)
if(!istype(above))
above.ChangeTurf(/turf/simulated/open)
Uncross(atom/movable/A)
if(A.dir == dir)
// This is hackish but whatever.
var/turf/target = get_step(GetAbove(A), dir)
var/turf/source = A.loc
if(target.Enter(A, source))
A.loc = target
target.Entered(A, source)
return 0
return 1
/obj/structure/stairs/Uncross(atom/movable/A)
if(A.dir == dir)
// This is hackish but whatever.
var/turf/target = get_step(GetAbove(A), dir)
var/turf/source = A.loc
if(target.Enter(A, source))
A.loc = target
target.Entered(A, source)
if(isliving(A))
var/mob/living/L = A
if(L.pulling)
L.pulling.forceMove(target)
return 0
return 1
CanPass(obj/mover, turf/source, height, airflow)
return airflow || !density
/obj/structure/stairs/CanPass(obj/mover, turf/source, height, airflow)
return airflow || !density
// type paths to make mapping easier.
north
dir = NORTH
bound_height = 64
bound_y = -32
pixel_y = -32
// type paths to make mapping easier.
/obj/structure/stairs/north
dir = NORTH
bound_height = 64
bound_y = -32
pixel_y = -32
south
dir = SOUTH
bound_height = 64
/obj/structure/stairs/south
dir = SOUTH
bound_height = 64
east
dir = EAST
bound_width = 64
bound_x = -32
pixel_x = -32
/obj/structure/stairs/east
dir = EAST
bound_width = 64
bound_x = -32
pixel_x = -32
west
dir = WEST
bound_width = 64
/obj/structure/stairs/west
dir = WEST
bound_width = 64
+66 -64
View File
@@ -1,87 +1,79 @@
/turf/proc/CanZPass(atom/A, direction)
if(z == A.z) //moving FROM this turf
return direction == UP //can't go below
else
if(direction == UP) //on a turf below, trying to enter
return 0
if(direction == DOWN) //on a turf above, trying to enter
return !density
/turf/simulated/open/CanZPass(atom, direction)
return 1
/turf/space/CanZPass(atom, direction)
return 1
/turf/simulated/open
name = "open space"
icon = 'icons/turf/space.dmi'
icon_state = "black"
alpha = 16
icon_state = ""
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/post_change()
..()
update()
/turf/simulated/open/initialize()
..()
below = GetBelow(src)
ASSERT(HasBelow(z))
update()
/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
..()
mover.fall()
// 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(mover.anchored || 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))
mover.visible_message("\The [mover] falls from the deck above through \the [below]!", "You hear a whoosh of displaced air.")
else
mover.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, BP_HEAD)
H.apply_damage(rand(0, damage), BRUTE, BP_TORSO)
H.apply_damage(rand(0, damage), BRUTE, BP_L_LEG)
H.apply_damage(rand(0, damage), BRUTE, BP_R_LEG)
H.apply_damage(rand(0, damage), BRUTE, BP_L_ARM)
H.apply_damage(rand(0, damage), BRUTE, BP_R_ARM)
H.weakened = max(H.weakened,2)
H.updatehealth()
/turf/simulated/open/proc/update()
below = GetBelow(src)
turf_changed_event.register(below, src, /turf/simulated/open/update_icon)
var/turf/simulated/T = get_step(src,NORTH)
if(T)
turf_changed_event.register(T, src, /turf/simulated/open/update_icon)
levelupdate()
for(var/atom/movable/A in src)
A.fall()
update_icon()
// override to make sure nothing is hidden
/turf/simulated/open/levelupdate()
for(var/obj/O in src)
O.hide(0)
/turf/simulated/open/update_icon()
if(below)
underlays = list(image(icon = below.icon, icon_state = below.icon_state))
underlays += below.overlays.Copy()
var/list/noverlays = list()
if(!istype(below,/turf/space))
noverlays += image(icon =icon, icon_state = "empty", layer = 2.2)
var/turf/simulated/T = get_step(src,NORTH)
if(istype(T) && !istype(T,/turf/simulated/open))
noverlays += image(icon ='icons/turf/cliff.dmi', icon_state = "metal", layer = 2.2)
var/obj/structure/stairs/S = locate() in below
if(S && S.loc == below)
var/image/I = image(icon = S.icon, icon_state = "below", dir = S.dir, layer = 2.2)
I.pixel_x = S.pixel_x
I.pixel_y = S.pixel_y
noverlays += I
overlays = noverlays
// Straight copy from space.
/turf/simulated/open/attackby(obj/item/C as obj, mob/user as mob)
if (istype(C, /obj/item/stack/rods))
@@ -108,4 +100,14 @@
return
else
user << "<span class='warning'>The plating is going to need some support.</span>"
return
//To lay cable.
if(istype(C, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/coil = C
coil.turf_place(src, user)
return
return
//Most things use is_plating to test if there is a cover tile on top (like regular floors)
/turf/simulated/open/is_plating()
return 1