Adds Multi-Z Test Map

This commit is contained in:
Neerti
2017-03-02 18:44:57 -05:00
parent bb2adf1290
commit 0f781e36a7
20 changed files with 702 additions and 283 deletions

View File

@@ -0,0 +1,28 @@
// Observer Pattern Implementation: Turf Changed
// Registration type: /turf
//
// Raised when: A turf has been changed using the ChangeTurf proc.
//
// Arguments that the called proc should expect:
// /turf/affected: The turf that has changed
// /old_density: Density before the change
// /new_density: Density after the change
// /old_opacity: Opacity before the change
// /new_opacity: Opacity after the change
var/decl/observ/turf_changed/turf_changed_event = new()
/decl/observ/turf_changed
name = "Turf Changed"
expected_type = /turf
/************************
* Turf Changed Handling *
************************/
/turf/ChangeTurf()
var/old_density = density
var/old_opacity = opacity
. = ..()
if(.)
turf_changed_event.raise_event(src, old_density, density, old_opacity, opacity)

View File

@@ -73,7 +73,7 @@
visible_message("A red light flashes on \the [src].")
return
cable.use(amount)
if(deleted(cable))
if(deleted(cable))
cable = null
return 1
@@ -104,13 +104,13 @@
NC.cableColor("red")
NC.d1 = 0
NC.d2 = fdirn
NC.updateicon()
NC.update_icon()
var/datum/powernet/PN
if(last_piece && last_piece.d2 != M_Dir)
last_piece.d1 = min(last_piece.d2, M_Dir)
last_piece.d2 = max(last_piece.d2, M_Dir)
last_piece.updateicon()
last_piece.update_icon()
PN = last_piece.powernet
if(!PN)

View File

@@ -348,13 +348,13 @@
NC.cableColor("red")
NC.d1 = 0
NC.d2 = fdirn
NC.updateicon()
NC.update_icon()
var/datum/powernet/PN
if(last_piece && last_piece.d2 != chassis.dir)
last_piece.d1 = min(last_piece.d2, chassis.dir)
last_piece.d2 = max(last_piece.d2, chassis.dir)
last_piece.updateicon()
last_piece.update_icon()
PN = last_piece.powernet
if(!PN)

View File

@@ -333,7 +333,7 @@ steam.start() -- spawns the effect
spawn(0)
var/turf/T = get_turf(src.holder)
if(T != src.oldposition)
if(istype(T, /turf/space))
if(istype(T, /turf/simulated))
var/obj/effect/effect/ion_trails/I = PoolOrNew(/obj/effect/effect/ion_trails, src.oldposition)
src.oldposition = T
I.set_dir(src.holder.dir)

View File

@@ -34,6 +34,11 @@
if(locate(/obj/structure/lattice, get_step(src, dir)))
L = locate(/obj/structure/lattice, get_step(src, dir))
L.updateOverlays(src.loc)
if(istype(loc, /turf/simulated/open))
var/turf/simulated/open/O = loc
spawn(1)
if(O) // If we built a new floor with the lattice, the open turf won't exist anymore.
O.update() // This lattice may be supporting things on top of it. If it's being deleted, they need to fall down.
..()
/obj/structure/lattice/ex_act(severity)

View File

@@ -9,6 +9,13 @@
if(L)
qdel(L)
// Called after turf replaces old one
/turf/proc/post_change()
levelupdate()
var/turf/simulated/open/T = GetAbove(src)
if(istype(T))
T.update_icon()
//Creates a new turf
/turf/proc/ChangeTurf(var/turf/N, var/tell_universe=1, var/force_lighting_update = 0)
if (!N)
@@ -60,6 +67,7 @@
W.levelupdate()
W.update_icon(1)
W.post_change()
. = W
else
@@ -83,6 +91,7 @@
W.levelupdate()
W.update_icon(1)
W.post_change()
. = W
lighting_overlay = old_lighting_overlay

View File

@@ -392,11 +392,12 @@
if(holder.buildmode.coordA && holder.buildmode.coordB)
user << "<span class='notice'>Ladder locations set, building ladders.</span>"
var/obj/structure/ladder/A = new /obj/structure/ladder(holder.buildmode.coordA)
var/obj/structure/ladder/A = new /obj/structure/ladder/up(holder.buildmode.coordA)
var/obj/structure/ladder/B = new /obj/structure/ladder(holder.buildmode.coordB)
A.target = B
B.target = A
B.icon_state = "ladderup"
A.target_up = B
B.target_down = A
A.update_icon()
B.update_icon()
holder.buildmode.coordA = null
holder.buildmode.coordB = null
if(7) // Move into contents

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()

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

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

View File

@@ -129,12 +129,12 @@ var/list/possible_cable_coil_colours = list(
/obj/structure/cable/hide(var/i)
if(istype(loc, /turf))
invisibility = i ? 101 : 0
updateicon()
update_icon()
/obj/structure/cable/hides_under_flooring()
return 1
/obj/structure/cable/proc/updateicon()
/obj/structure/cable/update_icon()
icon_state = "[d1]-[d2]"
alpha = invisibility ? 127 : 255
@@ -635,102 +635,75 @@ obj/structure/cable/proc/cableColor(var/colorC)
//////////////////////////////////////////////
// called when cable_coil is clicked on a turf/simulated/floor
/obj/item/stack/cable_coil/proc/turf_place(turf/simulated/floor/F, mob/user)
/obj/item/stack/cable_coil/proc/turf_place(turf/simulated/F, mob/user)
if(!isturf(user.loc))
return
if(get_amount() < 1) // Out of cable
user << "There is no cable left."
to_chat(user, "There is no cable left.")
return
if(get_dist(F,user) > 1) // Too far
user << "You can't lay cable at a place that far away."
to_chat(user, "You can't lay cable at a place that far away.")
return
if(!F.is_plating()) // Ff floor is intact, complain
user << "You can't lay cable there unless the floor tiles are removed."
to_chat(user, "You can't lay cable there unless the floor tiles are removed.")
return
var/dirn
if(user.loc == F)
dirn = user.dir // if laying on the tile we're on, lay in the direction we're facing
else
var/dirn
dirn = get_dir(F, user)
if(user.loc == F)
dirn = user.dir // if laying on the tile we're on, lay in the direction we're facing
else
dirn = get_dir(F, user)
var/end_dir = 0
if(istype(F, /turf/simulated/open))
if(!can_use(2))
to_chat(user, "You don't have enough cable to do this!")
return
end_dir = DOWN
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == 0 ) || ( LC.d2 == dirn && LC.d1 == 0))
user << "<span class='warning'>There's already a cable at that position.</span>"
return
///// Z-Level Stuff
// check if the target is open space
if(istype(F, /turf/simulated/open))
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == 11 ) || ( LC.d2 == dirn && LC.d1 == 11))
user << "<span class='warning'>There's already a cable at that position.</span>"
return
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == end_dir ) || ( LC.d2 == dirn && LC.d1 == end_dir))
to_chat(user, "<span class='warning'>There's already a cable at that position.</span>")
return
var/obj/structure/cable/C = new(F)
var/obj/structure/cable/D = new(GetBelow(F))
put_cable(F, user, end_dir, dirn)
if(end_dir == DOWN)
put_cable(GetBelow(F), user, UP, 0)
to_chat(user, "You slide some cable downward.")
C.cableColor(color)
/obj/item/stack/cable_coil/proc/put_cable(turf/simulated/F, mob/user, d1, d2)
if(!istype(F))
return
C.d1 = 11
C.d2 = dirn
C.add_fingerprint(user)
C.updateicon()
var/obj/structure/cable/C = new(F)
C.cableColor(color)
C.d1 = d1
C.d2 = d2
C.add_fingerprint(user)
C.update_icon()
var/datum/powernet/PN = new()
PN.add_cable(C)
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/PN = new()
PN.add_cable(C)
C.mergeConnectedNetworks(C.d2)
C.mergeConnectedNetworksOnTurf()
C.mergeConnectedNetworks(C.d1) //merge the powernets...
C.mergeConnectedNetworks(C.d2) //...in the two new cable directions
C.mergeConnectedNetworksOnTurf()
D.cableColor(color)
if(C.d1 & (C.d1 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.mergeDiagonalsNetworks(C.d1)
D.d1 = 12
D.d2 = 0
D.add_fingerprint(user)
D.updateicon()
if(C.d2 & (C.d2 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.mergeDiagonalsNetworks(C.d2)
PN.add_cable(D)
D.mergeConnectedNetworksOnTurf()
// do the normal stuff
else
///// Z-Level Stuff
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == 0 ) || ( LC.d2 == dirn && LC.d1 == 0))
user << "There's already a cable at that position."
return
var/obj/structure/cable/C = new(F)
C.cableColor(color)
//set up the new cable
C.d1 = 0 //it's a O-X node cable
C.d2 = dirn
C.add_fingerprint(user)
C.updateicon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/PN = new()
PN.add_cable(C)
C.mergeConnectedNetworks(C.d2) //merge the powernet with adjacents powernets
C.mergeConnectedNetworksOnTurf() //merge the powernet with on turf powernets
if(C.d2 & (C.d2 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.mergeDiagonalsNetworks(C.d2)
use(1)
if (C.shock(user, 50))
if (prob(50)) //fail
new/obj/item/stack/cable_coil(C.loc, 1, C.color)
qdel(C)
use(1)
if (C.shock(user, 50))
if (prob(50)) //fail
new/obj/item/stack/cable_coil(C.loc, 1, C.color)
qdel(C)
// called when cable_coil is click on an installed obj/cable
// or click on a turf that already contains a "node" cable
@@ -745,10 +718,9 @@ obj/structure/cable/proc/cableColor(var/colorC)
return
if(get_dist(C, user) > 1) // make sure it's close enough
user << "You can't lay cable at a place that far away."
to_chat(user, "You can't lay cable at a place that far away.")
return
if(U == T) //if clicked on the turf we're standing on, try to put a cable in the direction we're facing
turf_place(T,user)
return
@@ -758,7 +730,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
// one end of the clicked cable is pointing towards us
if(C.d1 == dirn || C.d2 == dirn)
if(!U.is_plating()) // can't place a cable if the floor is complete
user << "You can't lay cable there unless the floor tiles are removed."
to_chat(user, "You can't lay cable there unless the floor tiles are removed.")
return
else
// cable is pointing at us, we're standing on an open tile
@@ -768,34 +740,9 @@ obj/structure/cable/proc/cableColor(var/colorC)
for(var/obj/structure/cable/LC in U) // check to make sure there's not a cable there already
if(LC.d1 == fdirn || LC.d2 == fdirn)
user << "There's already a cable at that position."
to_chat(user, "There's already a cable at that position.")
return
var/obj/structure/cable/NC = new(U)
NC.cableColor(color)
NC.d1 = 0
NC.d2 = fdirn
NC.add_fingerprint()
NC.updateicon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/newPN = new()
newPN.add_cable(NC)
NC.mergeConnectedNetworks(NC.d2) //merge the powernet with adjacents powernets
NC.mergeConnectedNetworksOnTurf() //merge the powernet with on turf powernets
if(NC.d2 & (NC.d2 - 1))// if the cable is layed diagonally, check the others 2 possible directions
NC.mergeDiagonalsNetworks(NC.d2)
use(1)
if (NC.shock(user, 50))
if (prob(50)) //fail
new/obj/item/stack/cable_coil(NC.loc, 1, NC.color)
qdel(NC)
put_cable(U,user,0,fdirn)
return
// exisiting cable doesn't point at our position, so see if it's a stub
@@ -814,7 +761,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
if(LC == C) // skip the cable we're interacting with
continue
if((LC.d1 == nd1 && LC.d2 == nd2) || (LC.d1 == nd2 && LC.d2 == nd1) ) // make sure no cable matches either direction
user << "There's already a cable at that position."
to_chat(user, "There's already a cable at that position.")
return
@@ -824,7 +771,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
C.d2 = nd2
C.add_fingerprint()
C.updateicon()
C.update_icon()
C.mergeConnectedNetworks(C.d1) //merge the powernets...