Merge pull request #6691 from davipatury/rcl

Port's RCL from /vg/
This commit is contained in:
Crazy Lemon
2017-03-11 15:30:48 -08:00
committed by GitHub
8 changed files with 219 additions and 76 deletions
+4
View File
@@ -199,6 +199,10 @@
var/atom/O = mob.loc
return O.relaymove(mob, direct)
if(istype(mob.get_active_hand(), /obj/item))
var/obj/item/I = mob.get_active_hand()
I.moved(mob, n, direct)
if(!mob.Process_Spacemove(direct))
return 0
+44 -67
View File
@@ -114,7 +114,7 @@ By design, d1 is the smallest direction and d2 is the highest
//
/obj/structure/cable/attackby(obj/item/W, mob/user)
var/turf/T = src.loc
var/turf/T = get_turf(src)
if(T.intact)
return
@@ -149,7 +149,7 @@ By design, d1 is the smallest direction and d2 is the highest
if(c.d1 == 12 || c.d2 == 12)
c.qdel()*/
///// Z-Level Stuff
investigate_log("was cut by [key_name(usr, usr.client)] in [user.loc.loc]([T.x], [T.y], [T.z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[T.x];Y=[T.y];Z=[T.z]'>JMP</a>)","wires")
investigate_log("was cut by [key_name(usr, usr.client)] in [get_area(user)]([T.x], [T.y], [T.z] - [ADMIN_JMP(T)])","wires")
qdel(src) // qdel
return
@@ -162,6 +162,12 @@ By design, d1 is the smallest direction and d2 is the highest
return
coil.cable_join(src, user)
else if(istype(W, /obj/item/weapon/twohanded/rcl))
var/obj/item/weapon/twohanded/rcl/R = W
if(R.loaded)
R.loaded.cable_join(src, user)
R.is_empty(user)
else if(istype(W, /obj/item/device/multitool))
if(powernet && (powernet.avail > 0)) // is it powered?
@@ -197,12 +203,12 @@ By design, d1 is the smallest direction and d2 is the highest
qdel(src) // qdel
if(2.0)
if(prob(50))
new/obj/item/stack/cable_coil(src.loc, src.d1 ? 2 : 1, color)
new/obj/item/stack/cable_coil(get_turf(src), src.d1 ? 2 : 1, color)
qdel(src) // qdel
if(3.0)
if(prob(25))
new/obj/item/stack/cable_coil(src.loc, src.d1 ? 2 : 1, color)
new/obj/item/stack/cable_coil(get_turf(src), src.d1 ? 2 : 1, color)
qdel(src) // qdel
return
@@ -505,7 +511,7 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list(
// General procedures
///////////////////////////////////
//you can use wires to heal robotics
/obj/item/stack/cable_coil/attack(mob/M as mob, mob/user as mob)
/obj/item/stack/cable_coil/attack(mob/M, mob/user)
if(ishuman(M))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/S = H.organs_by_name[user.zone_sel.selecting]
@@ -613,11 +619,11 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list(
return C
// called when cable_coil is clicked on a turf/simulated/floor
/obj/item/stack/cable_coil/proc/place_turf(turf/T, mob/user)
/obj/item/stack/cable_coil/proc/place_turf(turf/T, mob/user, dirnew)
if(!isturf(user.loc))
return
if(!T.can_have_cabling())
if(!isturf(T) || T.intact || !T.can_have_cabling())
to_chat(user, "<span class='warning'>You can only lay cables on catwalks and plating!</span>")
return
@@ -629,44 +635,46 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list(
to_chat(user, "<span class='warning'>You can't lay cable at a place that far away!</span>")
return
else
var/dirn
var/dirn = null
if(!dirnew) //If we weren't given a direction, come up with one! (Called as null from catwalk.dm and floor.dm)
if(user.loc == T)
dirn = user.dir // if laying on the tile we're on, lay in the direction we're facing
dirn = user.dir //If laying on the tile we're on, lay in the direction we're facing
else
dirn = get_dir(T, user)
else
dirn = dirnew
for(var/obj/structure/cable/LC in T)
if(LC.d2 == dirn && LC.d1 == 0)
to_chat(user, "<span class='warning'>There's already a cable at that position!</span>")
return
for(var/obj/structure/cable/LC in T)
if(LC.d2 == dirn && LC.d1 == 0)
to_chat(user, "<span class='warning'>There's already a cable at that position!</span>")
return
var/obj/structure/cable/C = get_new_cable(T)
var/obj/structure/cable/C = get_new_cable(T)
//set up the new cable
C.d1 = 0 //it's a O-X node cable
C.d2 = dirn
C.add_fingerprint(user)
C.updateicon()
//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)
//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
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)
if(C.d2 & (C.d2 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.mergeDiagonalsNetworks(C.d2)
use(1)
use(1)
if(C.shock(user, 50))
if(prob(50)) //fail
new /obj/item/stack/cable_coil(get_turf(C), 1, C.color)
qdel(C) // qdel
if(C.shock(user, 50))
if(prob(50)) //fail
new/obj/item/stack/cable_coil(C.loc, 1, C.color)
qdel(C) // qdel
return C
// called when cable_coil is click on an installed obj/cable
// or click on a turf that already contains a "node" cable
@@ -675,7 +683,7 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list(
if(!isturf(U))
return
var/turf/T = C.loc
var/turf/T = get_turf(C)
if(!isturf(T) || T.intact) // sanity checks, also stop use interacting with T-scanner revealed cable
return
@@ -700,38 +708,7 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list(
// cable is pointing at us, we're standing on an open tile
// so create a stub pointing at the clicked cable on our tile
var/fdirn = turn(dirn, 180) // the opposite direction
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)
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) // qdel
place_turf(T, user, turn(dirn, 180))
return
// exisiting cable doesn't point at our position, so see if it's a stub
@@ -777,7 +754,7 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list(
if(C.shock(user, 50))
if(prob(50)) //fail
new/obj/item/stack/cable_coil(C.loc, 2, C.color)
new/obj/item/stack/cable_coil(get_turf(C), 2, C.color)
qdel(C) // qdel
return