diff --git a/code/datums/autolathe/engineering.dm b/code/datums/autolathe/engineering.dm index 0921806ac0..ca40b4a6a9 100644 --- a/code/datums/autolathe/engineering.dm +++ b/code/datums/autolathe/engineering.dm @@ -74,6 +74,10 @@ name = "request console electronics" path =/obj/item/weapon/circuitboard/request +/datum/category_item/autolathe/engineering/pipelayer + name = "pipe layer electronics" + path =/obj/item/weapon/circuitboard/pipelayer + /datum/category_item/autolathe/engineering/motor name = "motor" path =/obj/item/weapon/stock_parts/motor diff --git a/code/game/machinery/pipe/pipelayer.dm b/code/game/machinery/pipe/pipelayer.dm index 0de61b4685..7c5fe5ae14 100644 --- a/code/game/machinery/pipe/pipelayer.dm +++ b/code/game/machinery/pipe/pipelayer.dm @@ -1,57 +1,101 @@ /obj/machinery/pipelayer - name = "automatic pipe layer" icon = 'icons/obj/stationobjs.dmi' icon_state = "pipe_d" density = 1 - var/turf/old_turf - var/old_dir - var/on = 0 - var/a_dis = 0 - var/P_type = 0 - var/P_type_t = "" - var/max_metal = 50 - var/metal = 10 - var/obj/item/weapon/wrench/W + circuit = /obj/item/weapon/circuitboard/pipelayer + var/turf/old_turf // Last turf we were on. + var/old_dir // Last direction we were facing. + var/on = 0 // Pipelaying online? + var/a_dis = 0 // Auto-dismantling - If enabled it will remove floor tiles + var/P_type = 0 // Currently selected pipe type + var/P_type_t = "" // Name of currently selected pipe type + var/max_metal = 50 // Max capacity for internal metal storage + var/metal = 10 // Current amount in internal metal storage + var/pipe_cost = 0.25 // Cost in steel for each pipe. + var/obj/item/weapon/wrench/W // Internal wrench used for wrenching down the pipes var/list/Pipes = list("regular pipes"=0,"scrubbers pipes"=31,"supply pipes"=29,"heat exchange pipes"=2) /obj/machinery/pipelayer/New() W = new(src) ..() + default_apply_parts() + update_icon() +/obj/machinery/pipelayer/Destroy() + qdel(W) + W = null + ..() + +/obj/machinery/pipelayer/RefreshParts() + var/mb_rating = 0 + for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts) + mb_rating += M.rating + max_metal = mb_rating * initial(max_metal) + +/obj/machinery/pipelayer/dismantle() + eject_metal() + ..() + +// Whenever we move, if enabled try and lay pipe /obj/machinery/pipelayer/Move(new_turf,M_Dir) ..() if(on && a_dis) dismantleFloor(old_turf) - layPipe(old_turf,M_Dir,old_dir) + layPipe(old_turf, M_Dir, old_dir) old_turf = new_turf - old_dir = turn(M_Dir,180) + old_dir = turn(M_Dir, 180) /obj/machinery/pipelayer/attack_hand(mob/user as mob) - if(!metal&&!on) + if(..()) + return + if(panel_open) + if(metal < 1) + user << "\The [src] is empty." + return + var/answer = alert(user, "Do you want to eject all the metal in \the [src]?", , "Yes","No") + if(answer == "Yes") + var/amount_ejected = eject_metal() + user.visible_message("[user] removes [amount_ejected] sheet\s of [DEFAULT_WALL_MATERIAL] from the \the [src].", + "You remove [amount_ejected] sheet\s of [DEFAULT_WALL_MATERIAL] from \the [src].") + return + if(!metal && !on) user << "\The [src] doesn't work without metal." return - on=!on + on = !on + old_turf = get_turf(src) + old_dir = dir user.visible_message("[user] has [!on?"de":""]activated \the [src].", "You [!on?"de":""]activate \the [src].") return /obj/machinery/pipelayer/attackby(var/obj/item/W as obj, var/mob/user as mob) - - if (istype(W, /obj/item/weapon/wrench)) + if(default_deconstruction_screwdriver(user, W)) + return + if(default_deconstruction_crowbar(user, W)) + return + if(default_part_replacement(user, W)) + return + if (!panel_open && iswrench(W)) P_type_t = input("Choose pipe type", "Pipe type") as null|anything in Pipes P_type = Pipes[P_type_t] user.visible_message("[user] has set \the [src] to manufacture [P_type_t].", "You set \the [src] to manufacture [P_type_t].") return - - if(istype(W, /obj/item/weapon/crowbar)) - a_dis=!a_dis + if(!panel_open && iscrowbar(W)) + a_dis = !a_dis user.visible_message("[user] has [!a_dis?"de":""]activated auto-dismantling.", "You [!a_dis?"de":""]activate auto-dismantling.") return - + if(istype(W, /obj/item/pipe)) + if(metal + pipe_cost > max_metal) + user << "\The [src] is full." + else + user.drop_from_inventory(W) + metal += pipe_cost + usr << "You recycle \the [W]." + qdel(W) + return if(istype(W, /obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL) - var/result = load_metal(W) if(isnull(result)) user << "Unable to load [W] - no metal found." @@ -59,23 +103,8 @@ user << "\The [src] is full." else user.visible_message("[user] has loaded metal into \the [src].", "You load metal into \the [src]") - return - if(istype(W, /obj/item/weapon/screwdriver)) - if(metal) - var/m = round(input(usr,"Please specify the amount of metal to remove","Remove metal",min(round(metal),50)) as num, 1) - m = min(m, 50) - m = min(m, round(metal)) - m = round(m) - if(m) - use_metal(m) - var/obj/item/stack/material/steel/MM = new (get_turf(src)) - MM.amount = m - user.visible_message("[user] removes [m] sheet\s of metal from the \the [src].", "You remove [m] sheet\s of metal from \the [src]") - else - user << "\The [src] is empty." - return ..() /obj/machinery/pipelayer/examine(mob/user) @@ -83,7 +112,7 @@ user << "\The [src] has [metal] sheet\s, is set to produce [P_type_t], and auto-dismantling is [!a_dis?"de":""]activated." /obj/machinery/pipelayer/proc/reset() - on=0 + on = 0 return /obj/machinery/pipelayer/proc/load_metal(var/obj/item/stack/MM) @@ -100,12 +129,22 @@ return /obj/machinery/pipelayer/proc/use_metal(amount) - if(!metal || metal= 1) + var/material/M = get_material_by_name(DEFAULT_WALL_MATERIAL) + var/obj/item/stack/material/S = new M.stack_type(get_turf(src)) + S.amount = min(metal, S.max_amount) + metal -= S.amount + amount_ejected += S.amount + return amount_ejected + /obj/machinery/pipelayer/proc/dismantleFloor(var/turf/new_turf) if(istype(new_turf, /turf/simulated/floor)) var/turf/simulated/floor/T = new_turf @@ -114,11 +153,11 @@ return new_turf.is_plating() /obj/machinery/pipelayer/proc/layPipe(var/turf/w_turf,var/M_Dir,var/old_dir) - if(!on || !(M_Dir in list(1, 2, 4, 8)) || M_Dir==old_dir) + if(!on || !(M_Dir in list(NORTH, SOUTH, EAST, WEST)) || M_Dir==old_dir) return reset() - if(!use_metal(0.25)) + if(!use_metal(pipe_cost)) return reset() - var/fdirn = turn(M_Dir,180) + var/fdirn = turn(M_Dir, 180) var/p_type var/p_dir diff --git a/code/game/objects/items/weapons/circuitboards/machinery/engineering.dm b/code/game/objects/items/weapons/circuitboards/machinery/engineering.dm new file mode 100644 index 0000000000..91aefbf6a5 --- /dev/null +++ b/code/game/objects/items/weapons/circuitboards/machinery/engineering.dm @@ -0,0 +1,13 @@ +#ifndef T_BOARD +#error T_BOARD macro is not defined but we need it! +#endif + +/obj/item/weapon/circuitboard/pipelayer + name = T_BOARD("pipe layer") + build_path = /obj/machinery/pipelayer + board_type = new /datum/frame/frame_types/machine + matter = list(DEFAULT_WALL_MATERIAL = 50, "glass" = 50) + req_components = list( + /obj/item/weapon/stock_parts/motor = 1, + /obj/item/weapon/stock_parts/gear = 1, + /obj/item/weapon/stock_parts/matter_bin = 1) diff --git a/polaris.dme b/polaris.dme index 2fd1022631..657e7835ec 100644 --- a/polaris.dme +++ b/polaris.dme @@ -862,6 +862,7 @@ #include "code\game\objects\items\weapons\circuitboards\computer\telecomms.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\biogenerator.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\cloning.dm" +#include "code\game\objects\items\weapons\circuitboards\machinery\engineering.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\jukebox.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\mech_recharger.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\mining_drill.dm"