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
+54 -107
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...