Files
Paradise/code/modules/power/cables/cable_coil.dm
T
MigratingcocofruitandGitHub db555b4c28 Powernet separation (#29348)
* Adds reinforced APCs and frames for them.

* farragus WIP

* more farragus stuff

* more faragus stuff

* more farragus

* uses plastic for insulation instead

* box and faragus changes

* Box changes

* cerebron changes

* more meta updates

* fixes short on box station

* fixes shorts on meta station

* delta changes

* adds reinforced apcs with bigger cells

* emerald things

* more diagoras

* cleaning up cables in diagoras

* switches elecmaints smes to the engineering type on diagoras

* adds more grid monitors to cyberiad

* various corrections

* 2 doors on cyberiad electrical maints

* boxstation fixes

* Kerberos fixes

* cerebron fixes

* some faragus fixes

* more cyberiad fixes

* meta fixes

* more kerberos fixes

* faragus and cyberiad fixes

* emerald fixes

* farragus fixes

* emerald fixes

* farragus fixes

* emerald fixes

* diagoras fix

* more map fixes

* more CI fixes

* final fixes I hope

* Update emeraldstation.dmm

* finish merging metastation

* reset meta to master version

* redoing some of the meta changes

* Update metastation.dmm

* clear merge conflict

* Update metastation.dmm

* Update metastation.dmm

* Update metastation.dmm

* meta resolution

* emerald resolution

* delta resolution

* fartgas resolution

* box box

* stay out stay out

* metastation fixes

* faragus fix

* delta fix

* meta changes

* Starting over with farragus

* Starting over in faragus

* faragus changes

* Update cerestation.dmm

* Update cerestation.dmm

* Update cerestation.dmm

* Update cerestation.dmm

* Update cerestation.dmm

* resolving some faragus conflicts

* resolve faragus conflicts

* resolves delta conflicts

* resolves cyberiad conflicts

* resolves emerald conflicts

* fixes cables in faragus

* fixes meta cables

* fixes delta cables

* more meta fixes

* more farragus cable fixes

* more cable fixes

* meta and faragus fixes

* box and delta fixes

* more mapping fixes

* hopefully the last fix

* Update metastation.dmm

* Update metastation.dmm

* fixes shorts on cyberiad cerebron and farragus

* CI fixes

* Update cerestation.dmm

* resolve faragus conflicts

* resolve emerald conflict

* fix some faragus cabling

* more cabling correction in faragus

* more cable fixes

* Update cerestation.dmm

* remove doubled scrubber pipe on tile

* resolves faragus conflict

* changes the default power input of engineering SMES to 200kw and 80kW respectively

* connects power monitoring computers to the grid that weren't

* meta station elec maints improvements

* adds missing power monitoring computers on box and delta

* removes dirt from wall

* corrects area boundry on meta

* adds missing cable on box sci

* removes dirt from wall on box

* connects cyberiad bridge to the rest of the powernet

* connects box brig to powernet

* Adds catwalks to box maints

* adds catwalks to meta

* Adds catwalks to delta

* Update deltastation.dmm

* adds ability to insulate cables

* Moves stations to using extra insulated cables for high power network

* Removes catwalks from meta

* Removes catwalks from box

* Removes catwalks from delta

* resolves box conflicts

* Update cable.dm

* remove floating request console

* corrects position of fire alarm and removes extra intercom on metastation

* resolves faragus conflict

* fixes a stray light bulb and light switch in maints as well as a doubled power

* wires kerberos security checkpoint to the grid

* Update cerestation.dmm

* Removes stray extinguisher cabinet from meta station

* resolves area conflict on faragus

* resolves more faragus issues

* fixes faragus cabling issues

* Update cerestation.dmm

* removes another stray fire extinguisher cabinet

* insulates the APC in delta PTL room

* connect delta fore starboard solars to the high power grid instead of the low power

* Update deltastation.dmm

* deconflict

* solves some unconnected cables

* connects delta customs to network and finishes resolving conflicts

* Update deltastation.dmm

* adds the new cables. needs coils and mapping

* moves connection perms to the heavy duty cables. toggled with engineering permission ID. box gets new cables

* sorts cables on stations

* faragus cable connections

* cable corrections. Adds heavy duty cables to the autolathe

* CI fix

* more fixes and makes the new cables show up on t ray scanners

* box station mapping fixes

* delta mapping fixes

* meta fix

* Update deltastation.dmm

* delta and faragus fixes

* Update emeraldstation.dmm

* adds diagonal sprites to heavy duty cables. allows sillicons to toggle them and

* Makes borg versions of the heavy duty cable coil

* palete consolidation

* Improves visibility of high power cables

* fixes a wrong wire under the pet store maints door in delta station

* resolve conflicts

* migrates new cable type to new attack chain

* Update cable_coil.dm
2025-09-22 12:52:15 +00:00

455 lines
14 KiB
Plaintext

///////////////////////////////////////////////
// The cable coil object, used for laying cable
///////////////////////////////////////////////
#define HEALPERCABLE 3
#define MAXCABLEPERHEAL 8
GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe/cable_restraints("cable restraints", /obj/item/restraints/handcuffs/cable, 15)))
/obj/item/stack/cable_coil
name = "cable coil"
singular_name = "cable"
icon = 'icons/obj/power.dmi'
icon_state = "coil"
inhand_icon_state = "coil"
belt_icon = "cable_coil"
amount = MAXCOIL
max_amount = MAXCOIL
merge_type = /obj/item/stack/cable_coil // This is here to let its children merge between themselves
color = COLOR_RED
w_class = WEIGHT_CLASS_SMALL
throw_range = 5
materials = list(MAT_METAL = 15, MAT_GLASS = 10)
flags = CONDUCT
slot_flags = ITEM_SLOT_BELT
attack_verb = list("whipped", "lashed", "disciplined", "flogged")
usesound = 'sound/items/deconstruct.ogg'
/// Type of cable this coil makes
var/cable_type = /obj/structure/cable
/// Bitflag of the types of cable we can add cable to with this coil.
/// This is different to the cable connection flag since it only governs connecting on the same tile
var/cable_merge_id = CABLE_MERGE_LOW_POWER
/obj/item/stack/cable_coil/Initialize(mapload, length, paramcolor)
. = ..()
if(paramcolor)
color = paramcolor
update_icon()
recipes = GLOB.cable_coil_recipes
update_wclass()
/obj/item/stack/cable_coil/random/change_stack(mob/user, amount)
var/obj/item/stack/cable_coil/new_stack = ..()
new_stack.color = color
return new_stack
/obj/item/stack/cable_coil/update_name()
. = ..()
if(amount > 2)
name = "cable coil"
else
name = "cable piece"
/obj/item/stack/cable_coil/update_icon_state()
if(amount == 1)
icon_state = "coil1"
else if(amount == 2)
icon_state = "coil2"
else
icon_state = "coil"
/obj/item/stack/cable_coil/proc/update_wclass()
if(amount == 1)
w_class = WEIGHT_CLASS_TINY
else
w_class = WEIGHT_CLASS_SMALL
/obj/item/stack/cable_coil/examine(mob/user)
. = ..()
if(!in_range(user, src) || is_cyborg)
return
if(get_amount() == 1)
. += "A short piece of power cable."
else if(get_amount() == 2)
. += "A piece of power cable."
else
. += "A coil of power cables."
/obj/item/stack/cable_coil/can_merge(obj/item/stack/check, inhand = FALSE)
. = FALSE
if(istype(check, merge_type))
var/obj/item/stack/cable_coil/coil_check = check
. = coil_check.cable_merge_id == cable_merge_id
return . && ..()
//you can use wires to heal robotics
/obj/item/stack/cable_coil/attack__legacy__attackchain(mob/M, mob/user)
if(!ishuman(M))
return ..()
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/S = H.bodyparts_by_name[user.zone_selected]
if(!S && ismachineperson(M) && user.a_intent == INTENT_HELP)
to_chat(user, "<span class='notice'>[M.p_they(TRUE)] [M.p_are()] missing that limb!</span>")
return
if(!S?.is_robotic() || user.a_intent != INTENT_HELP || S.open == ORGAN_SYNTHETIC_OPEN)
return ..()
if(S.burn_dam > ROBOLIMB_SELF_REPAIR_CAP)
to_chat(user, "<span class='danger'>The damage is far too severe to patch over externally.</span>")
return
if(!S.burn_dam)
to_chat(user, "<span class='notice'>Nothing to fix!</span>")
return
if(H == user)
if(!do_mob(user, H, 10))
return FALSE
var/cable_used = 0
var/childlist
if(!isnull(S.children))
childlist = S.children.Copy()
var/parenthealed = FALSE
while(cable_used <= MAXCABLEPERHEAL && amount >= 1)
var/obj/item/organ/external/E
if(S.burn_dam)
E = S
else if(LAZYLEN(childlist))
E = pick_n_take(childlist)
if(!E.burn_dam || E.burn_dam >= ROBOLIMB_SELF_REPAIR_CAP || !E.is_robotic())
continue
else if(S.parent && !parenthealed)
E = S.parent
parenthealed = TRUE
if(!E.burn_dam || E.burn_dam >= ROBOLIMB_SELF_REPAIR_CAP || !E.is_robotic())
break
else
break
while(cable_used <= MAXCABLEPERHEAL && E.burn_dam && amount >= 1)
use(1)
cable_used += 1
E.heal_damage(0, HEALPERCABLE, 0, TRUE)
H.UpdateDamageIcon()
user.visible_message("<span class='alert'>[user] repairs some burn damage on [M]'s [E.name] with [src].</span>")
return TRUE
/obj/item/stack/cable_coil/split()
var/obj/item/stack/cable_coil/C = ..()
C.color = color
return C
// Items usable on a cable coil :
// - Wirecutters : cut them duh !
// - Cable coil : merge cables
/obj/item/stack/cable_coil/attackby__legacy__attackchain(obj/item/W, mob/user)
. = ..()
if(istype(W, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/C = W
// Cable merging is handled by parent proc
if(C.cable_merge_id != cable_merge_id)
to_chat(user, "These coils are of different types.")
return
if(C.get_amount() >= MAXCOIL)
to_chat(user, "The coil is as long as it will get.")
return
if((C.get_amount() + get_amount() <= MAXCOIL))
to_chat(user, "You join the cable coils together.")
return
else
to_chat(user, "You transfer [get_amount_transferred()] length\s of cable from one coil to the other.")
return
if(istype(W, /obj/item/toy/crayon))
var/obj/item/toy/crayon/C = W
cable_color(C.dye_color)
///////////////////////////////////////////////
// Cable laying procedures
//////////////////////////////////////////////
/obj/item/stack/cable_coil/proc/get_new_cable(location)
var/obj/structure/cable/C = new cable_type(location)
C.cable_color(color)
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, cable_direction)
if(!isturf(user.loc))
return
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
if(get_amount() < 1) // Out of cable
to_chat(user, "<span class='warning'>There is no cable left!</span>")
return
if(get_dist(T, user) > 1) // Too far
to_chat(user, "<span class='warning'>You can't lay cable at a place that far away!</span>")
return
if(!cable_direction) //If we weren't given a direction, come up with one! (Called as null from catwalk.dm and floor.dm)
if(user.loc == T)
cable_direction = user.dir //If laying on the tile we're on, lay in the direction we're facing
else
cable_direction = get_dir(T, user) //otherwise get direction from us to the turf we've clicked
for(var/obj/structure/cable/LC in T)
if(LC.d2 == cable_direction && LC.d1 == NO_DIRECTION) //there's already a cable here that would be exactly what we just placed!
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)
//set up the new cable
C.d1 = NO_DIRECTION //it's a O-X node cable
C.d2 = cable_direction
C.add_fingerprint(user)
C.update_icon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/regional_powernet/new_powernet = new()
new_powernet.add_cable(C)
C.merge_connected_networks(C.d2) //merge the powernet with adjacents powernets
C.merge_connected_networks_on_turf() //merge the powernet with on turf powernets
if(IS_DIR_DIAGONAL(C.d2))// if the cable is layed diagonally, check the others 2 possible directions
C.merge_diagonal_networks(C.d2)
use(1)
if(C.shock(user, 50))
if(prob(50)) //fail
new /obj/item/stack/cable_coil(get_turf(C), 1, C.color)
C.deconstruct()
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CABLE_UPDATED, T)
return C
/// called when cable_coil is click on an installed obj/cable or click on a turf that already contains a "node" cable
/obj/item/stack/cable_coil/proc/cable_join(obj/structure/cable/C, mob/user)
if(C.merge_id != cable_merge_id)
return
var/turf/U = user.loc
if(!isturf(U))
return
var/turf/T = get_turf(C)
// sanity checks, also stop use interacting with T-scanner revealed cable
if(!isturf(T) || T.intact || T.transparent_floor)
return
// make sure it's close enough
if(get_dist(C, user) > 1)
to_chat(user, "<span class='warning'>You can't lay cable at a place that far away!</span>")
return
//if clicked on the turf we're standing on, try to put a cable in the direction we're facing
if(U == T)
place_turf(T,user)
return
var/new_direction = get_dir(C, user)
// one end of the clicked cable is pointing towards us
if(C.d1 == new_direction || C.d2 == new_direction)
if(U.intact || U.transparent_floor) // can't place a cable if the floor is complete
to_chat(user, "<span class='warning'>You can't lay cable there unless the floor tiles are removed!</span>")
return
// 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/direction_flipped = turn(new_direction, 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 == direction_flipped || LC.d2 == direction_flipped)
to_chat(user, "<span class='warning'>There's already a cable at that position!</span>")
return
var/obj/structure/cable/NC = get_new_cable (U)
NC.d1 = 0
NC.d2 = direction_flipped
NC.add_fingerprint(user)
NC.update_icon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/regional_powernet/newPN = new()
newPN.add_cable(NC)
NC.merge_connected_networks(NC.d2) //merge the powernet with adjacents powernets
NC.merge_connected_networks_on_turf() //merge the powernet with on turf powernets
if(IS_DIR_DIAGONAL(NC.d2)) // if the cable is layed diagonally, check the others 2 possible directions
NC.merge_diagonal_networks(NC.d2)
use(1)
if(NC.shock(user, 50))
if(prob(50)) //fail
NC.deconstruct()
return
// exisiting cable doesn't point at our position, so see if it's a stub
else if(C.d1 == 0)
// if so, make it a full cable pointing from it's old direction to our new_direction
var/nd1 = C.d2 // these will be the new directions
var/nd2 = new_direction
if(nd1 > nd2) // swap directions to match icons/states
nd1 = new_direction
nd2 = C.d2
for(var/obj/structure/cable/LC in T) // check to make sure there's no matching cable
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
to_chat(user, "<span class='warning'>There's already a cable at that position!</span>")
return
C.cable_color(color)
C.d1 = nd1
C.d2 = nd2
C.add_fingerprint()
C.update_icon()
C.merge_connected_networks(C.d1) //merge the powernets...
C.merge_connected_networks(C.d2) //...in the two new cable directions
C.merge_connected_networks_on_turf()
if(C.d1 & (C.d1 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.merge_connected_networks(C.d1)
if(C.d2 & (C.d2 - 1))// if the cable is layed diagonally, check the others 2 possible directions
C.merge_connected_networks(C.d2)
use(1)
if(C.shock(user, 50))
if(prob(50)) //fail
C.deconstruct()
return
C.denode()// this call may have disconnected some cables that terminated on the centre of the turf, if so split the powernets.
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CABLE_UPDATED, T)
//////////////////////////////
// Misc.
/////////////////////////////
/obj/item/stack/cable_coil/proc/cable_color(colorC)
if(!colorC)
color = COLOR_RED
else if(colorC == "rainbow")
color = color_rainbow()
else if(colorC == "orange") // byond only knows 16 colors by name, and orange isn't one of them
color = COLOR_ORANGE
else if(colorC == "pink")
color = COLOR_PINK // nor is pink.. thanks byond
else
color = colorC
/obj/item/stack/cable_coil/suicide_act(mob/user)
if(locate(/obj/structure/chair/stool) in user.loc)
user.visible_message("<span class='suicide'>[user] is making a noose with [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
else
user.visible_message("<span class='suicide'>[user] is strangling [user.p_themselves()] with [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
return OXYLOSS
/obj/item/stack/cable_coil/proc/color_rainbow()
color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
return color
/obj/item/stack/cable_coil/five
amount = 5
/obj/item/stack/cable_coil/ten
amount = 10
/obj/item/stack/cable_coil/yellow
color = COLOR_YELLOW
/obj/item/stack/cable_coil/blue
color = COLOR_BLUE
/obj/item/stack/cable_coil/green
color = COLOR_GREEN
/obj/item/stack/cable_coil/pink
color = COLOR_PINK
/obj/item/stack/cable_coil/orange
color = COLOR_ORANGE
/obj/item/stack/cable_coil/cyan
color = COLOR_CYAN
/obj/item/stack/cable_coil/white
color = COLOR_WHITE
/obj/item/stack/cable_coil/random/Initialize(mapload)
. = ..()
color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN, COLOR_ORANGE)
/obj/item/stack/cable_coil/extra_insulated
name = "heavy duty cable coil"
singular_name = "heavy duty cable"
icon = 'icons/obj/cable_coils/heavy_duty.dmi'
color = null
cable_type = /obj/structure/cable/extra_insulated
cable_merge_id = CABLE_MERGE_HIGH_POWER
req_one_access = list(ACCESS_ENGINE, ACCESS_CE)
/obj/item/stack/cable_coil/extra_insulated/proc/toggle_connection(user)
if(allowed(user))
if(cable_type == /obj/structure/cable/extra_insulated/pre_connect)
cable_type = /obj/structure/cable/extra_insulated
icon = 'icons/obj/cable_coils/heavy_duty.dmi'
else
cable_type = /obj/structure/cable/extra_insulated/pre_connect
icon = 'icons/obj/cable_coils/heavy_duty_connected.dmi'
/obj/item/stack/cable_coil/extra_insulated/attackby__legacy__attackchain(obj/item/I, mob/living/user)
if(I.GetID())
toggle_connection(user)
return ..()
/obj/item/stack/cable_coil/cut
icon_state = "coil2"
/obj/item/stack/cable_coil/cut/Initialize(mapload)
. = ..()
src.amount = rand(1,2)
update_appearance(UPDATE_NAME|UPDATE_ICON_STATE)
update_wclass()
/obj/item/stack/cable_coil/cyborg
energy_type = /datum/robot_storage/energy/cable
is_cyborg = TRUE
/obj/item/stack/cable_coil/cyborg/update_icon_state()
return // icon_state should always be a full cable
/obj/item/stack/cable_coil/cyborg/attack_self__legacy__attackchain(mob/user)
var/cablecolor = tgui_input_list(usr, "Pick a cable color.", "Cable Color", list("red","yellow","green","blue","pink","orange","cyan","white"))
cable_color(cablecolor)
update_icon()
/obj/item/stack/cable_coil/extra_insulated/cyborg
energy_type = /datum/robot_storage/energy/cable
is_cyborg = TRUE
/obj/item/stack/cable_coil/extra_insulated/cyborg/attack_self__legacy__attackchain(mob/user)
toggle_connection(user)
update_icon()
/obj/item/stack/cable_coil/extra_insulated/cyborg/update_icon_state()
return // icon_state should always be a full cable
#undef HEALPERCABLE
#undef MAXCABLEPERHEAL