From 266b4cb11363f4170b681a569b10bd504fe8c95e Mon Sep 17 00:00:00 2001 From: Markolie Date: Mon, 22 Dec 2014 17:38:22 +0100 Subject: [PATCH] R&D UI rework --- code/datums/wires/autolathe.dm | 58 + code/game/area/areas.dm | 12 +- code/game/machinery/autolathe.dm | 356 +--- code/game/mecha/mech_fabricator.dm | 845 +++----- code/game/mecha/mecha_construction_paths.dm | 1825 +++++++++-------- .../game/objects/items/stacks/sheets/glass.dm | 12 +- .../objects/items/stacks/sheets/sheets.dm | 2 +- code/modules/research/circuitprinter.dm | 230 +-- code/modules/research/designs.dm | 30 +- .../designs/mechfabricator_designs.dm | 757 +++++-- code/modules/research/destructive_analyzer.dm | 71 +- code/modules/research/protolathe.dm | 158 +- code/modules/research/rdconsole.dm | 692 ++++--- code/modules/research/rdmachines.dm | 3 +- code/modules/research/research.dm | 86 +- code/setup.dm | 11 +- maps/cyberiad.dmm | 30 +- paradise.dme | 1 + 18 files changed, 2686 insertions(+), 2493 deletions(-) create mode 100644 code/datums/wires/autolathe.dm diff --git a/code/datums/wires/autolathe.dm b/code/datums/wires/autolathe.dm new file mode 100644 index 00000000000..e382ce620f1 --- /dev/null +++ b/code/datums/wires/autolathe.dm @@ -0,0 +1,58 @@ +/datum/wires/autolathe + + holder_type = /obj/machinery/autolathe + wire_count = 10 + +var/const/AUTOLATHE_HACK_WIRE = 1 +var/const/AUTOLATHE_SHOCK_WIRE = 2 +var/const/AUTOLATHE_DISABLE_WIRE = 4 + +/datum/wires/autolathe/GetInteractWindow() + var/obj/machinery/autolathe/A = holder + . += ..() + . += text("
The red light is [A.disabled ? "off" : "on"].
The green light is [A.shocked ? "off" : "on"].
The blue light is [A.hacked ? "off" : "on"].
") + +/datum/wires/autolathe/CanUse() + var/obj/machinery/autolathe/A = holder + if(A.panel_open) + return 1 + return 0 + +/datum/wires/autolathe/Interact(var/mob/living/user) + if(CanUse(user)) + var/obj/machinery/autolathe/V = holder + V.attack_hand(user) + +/datum/wires/autolathe/UpdateCut(index, mended) + var/obj/machinery/autolathe/A = holder + switch(index) + if(AUTOLATHE_HACK_WIRE) + A.hacked = !mended + if(AUTOLATHE_SHOCK_WIRE) + A.shocked = !mended + if(AUTOLATHE_DISABLE_WIRE) + A.disabled = !mended + +/datum/wires/autolathe/UpdatePulsed(index) + if(IsIndexCut(index)) + return + var/obj/machinery/autolathe/A = holder + switch(index) + if(AUTOLATHE_HACK_WIRE) + A.hacked = !A.hacked + spawn(50) + if(A && !IsIndexCut(index)) + A.hacked = 0 + Interact(usr) + if(AUTOLATHE_SHOCK_WIRE) + A.shocked = !A.shocked + spawn(50) + if(A && !IsIndexCut(index)) + A.shocked = 0 + Interact(usr) + if(AUTOLATHE_DISABLE_WIRE) + A.disabled = !A.disabled + spawn(50) + if(A && !IsIndexCut(index)) + A.disabled = 0 + Interact(usr) \ No newline at end of file diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index eb8a458c865..3c04e9cf951 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -1,6 +1,16 @@ // Areas.dm - +// Added to fix mech fabs 05/2013 ~Sayu +// This is necessary due to lighting subareas. If you were to go in assuming that things in +// the same logical /area have the parent /area object... well, you would be mistaken. If you +// want to find machines, mobs, etc, in the same logical area, you will need to check all the +// related areas. This returns a master contents list to assist in that. +/proc/area_contents(var/area/A) + if(!istype(A)) return null + var/list/contents = list() + for(var/area/LSA in A.related) + contents += LSA.contents + return contents // === /area diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 2f3a569a6d0..4f33a2b71a3 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -1,26 +1,29 @@ //This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31 var/global/list/autolathe_recipes = list( \ - new /obj/item/stack/sheet/metal(), \ - new /obj/item/stack/sheet/glass(), \ - new /obj/item/stack/sheet/rglass(), \ - new /obj/item/stack/sheet/fur(), \ - new /obj/item/stack/rods(), \ + /* screwdriver removed*/ \ + new /obj/item/weapon/reagent_containers/glass/bucket(), \ new /obj/item/weapon/crowbar(), \ - new /obj/item/weapon/screwdriver(), \ - new /obj/item/weapon/weldingtool(), \ - new /obj/item/weapon/wirecutters(), \ - new /obj/item/weapon/wrench(), \ + new /obj/item/device/flashlight(), \ + new /obj/item/weapon/extinguisher(), \ new /obj/item/device/multitool(), \ new /obj/item/device/analyzer(), \ new /obj/item/device/t_scanner(), \ - new /obj/item/device/flashlight(), \ - new /obj/item/weapon/extinguisher(), \ + new /obj/item/weapon/weldingtool(), \ + new /obj/item/weapon/screwdriver(), \ + new /obj/item/weapon/wirecutters(), \ + new /obj/item/weapon/wrench(), \ new /obj/item/clothing/head/welding(), \ new /obj/item/weapon/stock_parts/console_screen(), \ new /obj/item/weapon/airlock_electronics(), \ new /obj/item/weapon/airalarm_electronics(), \ new /obj/item/weapon/firealarm_electronics(), \ + new /obj/item/device/pipe_painter(), \ + new /obj/item/stack/sheet/metal(), \ + new /obj/item/stack/sheet/glass(), \ + new /obj/item/stack/sheet/rglass(), \ + new /obj/item/stack/rods(), \ + new /obj/item/weapon/rcd_ammo(), \ new /obj/item/weapon/kitchenknife(), \ new /obj/item/weapon/scalpel(), \ new /obj/item/weapon/circular_saw(), \ @@ -30,7 +33,8 @@ var/global/list/autolathe_recipes = list( \ new /obj/item/weapon/hemostat(),\ new /obj/item/weapon/reagent_containers/glass/beaker(), \ new /obj/item/weapon/reagent_containers/glass/beaker/large(), \ - new /obj/item/weapon/reagent_containers/glass/bucket(), \ + new /obj/item/ammo_casing/shotgun/beanbag(), \ + new /obj/item/ammo_box/c38(), \ new /obj/item/device/taperecorder(), \ new /obj/item/device/assembly/igniter(), \ new /obj/item/device/assembly/signaler(), \ @@ -38,20 +42,12 @@ var/global/list/autolathe_recipes = list( \ new /obj/item/device/radio/off(), \ new /obj/item/device/assembly/infra(), \ new /obj/item/device/assembly/timer(), \ - new /obj/item/device/assembly/prox_sensor(), \ new /obj/item/device/assembly/voice(), \ new /obj/item/weapon/light/tube(), \ new /obj/item/weapon/light/bulb(), \ new /obj/item/weapon/camera_assembly(), \ - new /obj/item/weapon/rcd_ammo(), \ - new /obj/item/ammo_casing/shotgun/beanbag(), \ - new /obj/item/ammo_box/c38(), \ - new /obj/item/clothing/ears/earmuffs/tribblemuffs(), \ - new /obj/item/clothing/gloves/furgloves(), \ - new /obj/item/clothing/head/furcap(), \ - new /obj/item/clothing/shoes/furboots(), \ - new /obj/item/clothing/suit/furcoat(), \ - new /obj/item/clothing/suit/furcape(), \ + new /obj/item/weapon/reagent_containers/syringe(), \ + new /obj/item/device/assembly/prox_sensor(), \ ) var/global/list/autolathe_recipes_hidden = list( \ @@ -60,7 +56,6 @@ var/global/list/autolathe_recipes_hidden = list( \ new /obj/item/device/radio/electropack(), \ new /obj/item/weapon/weldingtool/largetank(), \ new /obj/item/weapon/handcuffs(), \ - new /obj/item/weapon/hatchet(), \ new /obj/item/ammo_box/a357(), \ new /obj/item/ammo_box/c10mm(), \ new /obj/item/ammo_box/c45(), \ @@ -69,8 +64,9 @@ var/global/list/autolathe_recipes_hidden = list( \ new /obj/item/ammo_casing/shotgun/buckshot(), \ new /obj/item/ammo_casing/shotgun/dart(), \ new /obj/item/ammo_casing/shotgun/incendiary(), \ -/* new /obj/item/weapon/shield/riot(),*/ \ + /* new /obj/item/weapon/shield/riot(), */ \ ) + /obj/machinery/autolathe name = "autolathe" desc = "It produces items using metal and glass." @@ -83,18 +79,13 @@ var/global/list/autolathe_recipes_hidden = list( \ var/g_amount = 0.0 var/max_g_amount = 75000.0 - var/f_amount = 0.0 - var/max_f_amount = 50000.0 - var/operating = 0.0 - var/opened = 0.0 anchored = 1.0 var/list/L = list() var/list/LL = list() var/hacked = 0 var/disabled = 0 var/shocked = 0 - var/list/wires = list() var/hack_wire var/disable_wire var/shock_wire @@ -103,169 +94,71 @@ var/global/list/autolathe_recipes_hidden = list( \ active_power_usage = 100 var/busy = 0 var/prod_coeff - - l_color = "#7BF9FF" - power_change() - ..() - if(!(stat & (BROKEN|NOPOWER))) - SetLuminosity(2) - else - SetLuminosity(0) + var/datum/wires/autolathe/wires = null /obj/machinery/autolathe/New() ..() component_parts = list() - component_parts += new /obj/item/weapon/circuitboard/autolathe(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/manipulator(src) - component_parts += new /obj/item/weapon/stock_parts/console_screen(src) + component_parts += new /obj/item/weapon/circuitboard/autolathe(null) + component_parts += new /obj/item/weapon/stock_parts/matter_bin(null) + component_parts += new /obj/item/weapon/stock_parts/matter_bin(null) + component_parts += new /obj/item/weapon/stock_parts/matter_bin(null) + component_parts += new /obj/item/weapon/stock_parts/manipulator(null) + component_parts += new /obj/item/weapon/stock_parts/console_screen(null) RefreshParts() wires = new(src) src.L = autolathe_recipes src.LL = autolathe_recipes_hidden -/obj/machinery/autolathe/proc/wires_win(mob/user as mob) - var/dat as text - dat += "Autolathe Wires:
" - for(var/wire in src.wires) - dat += text("[wire] Wire: [src.wires[wire] ? "Mend" : "Cut"] Pulse
") - - dat += text("The red light is [src.disabled ? "off" : "on"].
") - dat += text("The green light is [src.shocked ? "off" : "on"].
") - dat += text("The blue light is [src.hacked ? "off" : "on"].
") - user << browse("Autolathe Hacking[dat]","window=autolathe_hack") - onclose(user, "autolathe_hack") - -/obj/machinery/autolathe/proc/regular_win(mob/user as mob) - var/coeff = 2 ** prod_coeff - var/dat as text - dat = text("Metal Amount: [src.m_amount] cm3 (MAX: [max_m_amount])
\nGlass Amount: [src.g_amount] cm3 (MAX: [max_g_amount])
\nFur Amount: [src.f_amount] cm3 (MAX: [max_f_amount])
") - var/list/objs = list() - objs += src.L - if (src.hacked) - objs += src.LL - for(var/obj/t in objs) - var/title = "[t.name] ([t.m_amt/coeff] m / [t.g_amt/coeff] g / [t.f_amt/coeff] f)" - if (m_amount" - continue - dat += "[title]" - if (istype(t, /obj/item/stack)) - var/obj/item/stack/S = t - var/max_multiplier = min(S.max_amount, S.m_amt?round(m_amount/S.m_amt):INFINITY, S.g_amt?round(g_amount/S.g_amt):INFINITY, S.f_amt?round(f_amount/S.f_amt):INFINITY) - if (max_multiplier>1) - dat += " |" - if (max_multiplier>10) - dat += " x[10]" - if (max_multiplier>25) - dat += " x[25]" - if (max_multiplier>1) - dat += " x[max_multiplier]" - dat += "
" - user << browse("Autolathe Control Panel[dat]", "window=autolathe_regular") - onclose(user, "autolathe_regular") - -/obj/machinery/autolathe/proc/shock(mob/user, prb) - if(stat & (BROKEN|NOPOWER)) // unpowered, no shock - return 0 - if(!prob(prb)) - return 0 - var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread - s.set_up(5, 1, src) - s.start() - if (electrocute_mob(user, get_area(src), src, 0.7)) - return 1 - else - return 0 - -/obj/machinery/autolathe/interact(mob/user as mob) - if(..()) - return - - if (src.shocked) - src.shock(user,50) - - if (src.panel_open) - wires_win(user,50) - return - - if (src.disabled) - user << "\red You press the button, but nothing happens." - return - +/obj/machinery/autolathe/interact(mob/user) + if(shocked && !(stat & NOPOWER)) + shock(user,50) regular_win(user) return -/obj/machinery/autolathe/attackby(var/obj/item/O as obj, var/mob/user as mob) - if (stat) - return 1 - +/obj/machinery/autolathe/attackby(obj/item/O, mob/user) if (busy) - user << "\red The autolathe is busy. Please wait for completion of previous operation." + user << "The autolathe is busy. Please wait for completion of previous operation." return 1 - if (istype(O, /obj/item/weapon/screwdriver)) - default_deconstruction_screwdriver(user, "autolathe_t", "autolathe", O) - return 1 + if(default_deconstruction_screwdriver(user, "autolathe_t", "autolathe", O)) + updateUsrDialog() + return if(exchange_parts(user, O)) return if (panel_open) - //Don't eat multitools or wirecutters used on an open lathe. - if(istype(O, /obj/item/device/multitool) || istype(O, /obj/item/weapon/wirecutters)) - attack_hand(user) - return - - //Dismantle the frame. if(istype(O, /obj/item/weapon/crowbar)) - for(var/obj/I in component_parts) - if(I.reliability != 100 && crit_fail) - I.crit_fail = 1 - I.loc = src.loc - if(m_amount >= 3750) + if(m_amount >= MINERAL_MATERIAL_AMOUNT) var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal(src.loc) - G.amount = round(m_amount / 3750) - if(g_amount >= 3750) + G.amount = round(m_amount / MINERAL_MATERIAL_AMOUNT) + if(g_amount >= MINERAL_MATERIAL_AMOUNT) var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc) - G.amount = round(g_amount / 3750) + G.amount = round(g_amount / MINERAL_MATERIAL_AMOUNT) default_deconstruction_crowbar(O) return 1 else - user.set_machine(src) - interact(user) + attack_hand(user) return 1 + if (stat) + return 1 if (src.m_amount + O.m_amt > max_m_amount) - user << "\red The autolathe is full. Please remove metal from the autolathe in order to insert more." + user << "The autolathe is full. Please remove metal from the autolathe in order to insert more." return 1 if (src.g_amount + O.g_amt > max_g_amount) - user << "\red The autolathe is full. Please remove glass from the autolathe in order to insert more." + user << "The autolathe is full. Please remove glass from the autolathe in order to insert more." return 1 - if (src.f_amount + O.f_amt > max_f_amount) - user << "\red The autolathe is full. Please remove fur from the autolathe in order to insert more." + if (O.m_amt == 0 && O.g_amt == 0) + user << "This object does not contain significant amounts of metal or glass, or cannot be accepted by the autolathe due to size or hazardous materials." return 1 - if (O.m_amt == 0 && O.g_amt == 0 && O.f_amt == 0) - user << "\red This object does not contain significant amounts of metal or glass, or cannot be accepted by the autolathe due to size or hazardous materials." - return 1 - /* - if (istype(O, /obj/item/weapon/grab) && src.hacked) - var/obj/item/weapon/grab/G = O - if (prob(25) && G.affecting) - G.affecting.gib() - m_amount += 50000 - f_amount += 1000 - return - */ var/amount = 1 var/obj/item/stack/stack var/m_amt = O.m_amt var/g_amt = O.g_amt - var/f_amt = O.f_amt if (istype(O, /obj/item/stack)) stack = O amount = stack.amount @@ -275,38 +168,33 @@ var/global/list/autolathe_recipes_hidden = list( \ if (g_amt) amount = min(amount, round((max_g_amount-src.g_amount)/g_amt)) flick("autolathe_r",src)//plays glass insertion animation - if (f_amt) - amount = min(amount, round((max_f_amount-src.f_amount)/f_amt)) - flick("autolathe_f",src)//plays fur insertion animation stack.use(amount) else - usr.before_take_item(O) + if(!user.before_take_item(O)) + user << "/the [O] is stuck to your hand, you can't put it in \the [src]!" O.loc = src icon_state = "autolathe" busy = 1 use_power(max(1000, (m_amt+g_amt)*amount/10)) src.m_amount += m_amt * amount src.g_amount += g_amt * amount - src.f_amount += f_amt * amount user << "You insert [amount] sheet[amount>1 ? "s" : ""] to the autolathe." if (O && O.loc == src) - del(O) + qdel(O) busy = 0 src.updateUsrDialog() -/obj/machinery/autolathe/attack_paw(mob/user as mob) - return src.attack_hand(user) +/obj/machinery/autolathe/attack_paw(mob/user) + return attack_hand(user) -/obj/machinery/autolathe/attack_hand(mob/user as mob) - user.set_machine(src) +/obj/machinery/autolathe/attack_hand(mob/user) + if(..(user, 0)) + return interact(user) - /obj/machinery/autolathe/Topic(href, href_list) if(..()) return - usr.set_machine(src) - src.add_fingerprint(usr) if (!busy) if(href_list["make"]) var/coeff = 2 ** prod_coeff @@ -347,8 +235,8 @@ var/global/list/autolathe_recipes_hidden = list( \ log_admin("EXPLOIT : [key_name(usr)] tried to exploit an autolathe with multiplier set to [multiplier] on [template] !") return - var/power = max(2000, (template.m_amt+template.g_amt+template.f_amt)*multiplier/5) - if(src.m_amount >= template.m_amt*multiplier/coeff && src.g_amount >= template.g_amt*multiplier/coeff && src.f_amount >= template.f_amt*multiplier/coeff) + var/power = max(2000, (template.m_amt+template.g_amt)*multiplier/5) + if(src.m_amount >= template.m_amt*multiplier/coeff && src.g_amount >= template.g_amt*multiplier/coeff) busy = 1 use_power(power) icon_state = "autolathe" @@ -358,61 +246,22 @@ var/global/list/autolathe_recipes_hidden = list( \ if(istype(template, /obj/item/stack)) src.m_amount -= template.m_amt*multiplier src.g_amount -= template.g_amt*multiplier - src.f_amount -= template.f_amt*multiplier - var/obj/new_item = new template.type(T) + var/obj/item/new_item = new template.type(T) var/obj/item/stack/S = new_item S.amount = multiplier else src.m_amount -= template.m_amt/coeff src.g_amount -= template.g_amt/coeff - src.f_amount -= template.f_amt/coeff var/obj/item/new_item = new template.type(T) new_item.m_amt /= coeff new_item.g_amt /= coeff - new_item.f_amt /= coeff if(src.m_amount < 0) src.m_amount = 0 if(src.g_amount < 0) src.g_amount = 0 - if(src.f_amount < 0) - src.f_amount = 0 busy = 0 - - if(href_list["act"]) - var/temp_wire = href_list["wire"] - if(href_list["act"] == "pulse") - if (!istype(usr.get_active_hand(), /obj/item/device/multitool)) - usr << "You need a multitool!" - else - if(src.wires[temp_wire]) - usr << "You can't pulse a cut wire." - else - if(src.hack_wire == temp_wire) - src.hacked = !src.hacked - spawn(100) src.hacked = !src.hacked - if(src.disable_wire == temp_wire) - src.disabled = !src.disabled - src.shock(usr,50) - spawn(100) src.disabled = !src.disabled - if(src.shock_wire == temp_wire) - src.shocked = !src.shocked - src.shock(usr,50) - spawn(100) src.shocked = !src.shocked - if(href_list["act"] == "wire") - if (!istype(usr.get_active_hand(), /obj/item/weapon/wirecutters)) - usr << "You need wirecutters!" - else - wires[temp_wire] = !wires[temp_wire] - if(src.hack_wire == temp_wire) - src.hacked = !src.hacked - if(src.disable_wire == temp_wire) - src.disabled = !src.disabled - src.shock(usr,50) - if(src.shock_wire == temp_wire) - src.shocked = !src.shocked - src.shock(usr,50) else - usr << "\red The autolathe is busy. Please wait for completion of previous operation." + usr << "The autolathe is busy. Please wait for completion of previous operation." src.updateUsrDialog() return @@ -424,47 +273,58 @@ var/global/list/autolathe_recipes_hidden = list( \ tot_rating *= 25000 max_m_amount = tot_rating * 2 max_g_amount = tot_rating - max_f_amount = tot_rating for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts) prod_coeff += M.rating - 1 -/obj/machinery/autolathe/RefreshParts() - ..() - var/tot_rating = 0 - for(var/obj/item/weapon/stock_parts/matter_bin/MB in component_parts) - tot_rating += MB.rating - tot_rating *= 25000 - max_m_amount = tot_rating * 2 - max_g_amount = tot_rating - max_f_amount = tot_rating +/obj/machinery/autolathe/proc/regular_win(mob/user) + var/dat + if(!panel_open) + if(stat) + return + var/coeff = 2 ** prod_coeff + dat = "
Metal amount: [src.m_amount] / [max_m_amount] cm3
" + dat += "Glass amount: [src.g_amount] / [max_g_amount] cm3
" + var/list/objs = list() + objs += src.L + if(src.hacked) + objs += src.LL + for(var/obj/item/t in objs) + if(disabled || m_amount[t]", "The ", "") + else + dat += replacetext("[t]", "The ", "") -/obj/machinery/autolathe/New() - ..() - component_parts = list() - component_parts += new /obj/item/weapon/circuitboard/autolathe(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/manipulator(src) - component_parts += new /obj/item/weapon/stock_parts/console_screen(src) - RefreshParts() + if(istype(t, /obj/item/stack)) + var/obj/item/stack/S = t + var/max_multiplier = min(S.max_amount, S.m_amt?round(m_amount/S.m_amt):INFINITY, S.g_amt?round(g_amount/S.g_amt):INFINITY) + if (max_multiplier>10 && !disabled) + dat += " x[10]" + if (max_multiplier>25 && !disabled) + dat += " x[25]" + if (max_multiplier>1 && !disabled) + dat += " x[max_multiplier]" + dat += " [t.m_amt] m / [t.g_amt] g" + else + dat += " [t.m_amt/coeff] m / [t.g_amt/coeff] g" + dat += "
" + dat += "" + else + dat = wires.GetInteractWindow() - src.L = autolathe_recipes - src.LL = autolathe_recipes_hidden - src.wires["Light Red"] = 0 - src.wires["Dark Red"] = 0 - src.wires["Blue"] = 0 - src.wires["Green"] = 0 - src.wires["Yellow"] = 0 - src.wires["Black"] = 0 - src.wires["White"] = 0 - src.wires["Gray"] = 0 - src.wires["Orange"] = 0 - src.wires["Pink"] = 0 - var/list/w = list("Light Red","Dark Red","Blue","Green","Yellow","Black","White","Gray","Orange","Pink") - src.hack_wire = pick(w) - w -= src.hack_wire - src.shock_wire = pick(w) - w -= src.shock_wire - src.disable_wire = pick(w) - w -= src.disable_wire + var/datum/browser/popup = new(user, "autolathe", name, 400, 500) + popup.set_content(dat) + popup.open() + return + +/obj/machinery/autolathe/proc/shock(mob/user, prb) + if(stat & (BROKEN|NOPOWER)) // unpowered, no shock + return 0 + if(!prob(prb)) + return 0 + var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread + s.set_up(5, 1, src) + s.start() + if (electrocute_mob(user, get_area(src), src, 0.7)) + return 1 + else + return 0 diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm index 72d77cd5a60..159217bc259 100644 --- a/code/game/mecha/mech_fabricator.dm +++ b/code/game/mecha/mech_fabricator.dm @@ -1,11 +1,7 @@ -///////////////////////////// -///// Part Fabricator /////// -///////////////////////////// - /obj/machinery/mecha_part_fabricator icon = 'icons/obj/robotics.dmi' icon_state = "fab-idle" - name = "Exosuit Fabricator" + name = "exosuit fabricator" desc = "Nothing is being built." density = 1 anchored = 1 @@ -18,367 +14,187 @@ var/time_coeff_tech = 1 var/resource_coeff_tech = 1 var/list/resources = list( - "metal"=0, - "glass"=0, - "gold"=0, - "silver"=0, - "diamond"=0, - "plasma"=0, - "uranium"=0, - "bananium"=0 - ) + "$metal"=0, + "$glass"=0, + "$bananium"=0, + "$diamond"=0, + "$gold"=0, + "$plasma"=0, + "$silver"=0, + "$uranium"=0 + ) var/res_max_amount = 200000 var/datum/research/files var/id var/sync = 0 var/part_set - var/obj/being_built + var/datum/design/being_built var/list/queue = list() var/processing_queue = 0 var/screen = "main" - var/opened = 0 var/temp - var/list/part_sets = list( //set names must be unique - "Robot"=list( - /obj/item/robot_parts/robot_suit, - /obj/item/robot_parts/chest, - /obj/item/robot_parts/head, - /obj/item/robot_parts/l_arm, - /obj/item/robot_parts/r_arm, - /obj/item/robot_parts/l_leg, - /obj/item/robot_parts/r_leg - ), - -"Robot Repair"=list( - /obj/item/robot_parts/robot_component/binary_communication_device, - /obj/item/robot_parts/robot_component/radio, - /obj/item/robot_parts/robot_component/actuator, - /obj/item/robot_parts/robot_component/diagnosis_unit, - /obj/item/robot_parts/robot_component/camera, - /obj/item/robot_parts/robot_component/armour - ), - "Ripley"=list( - /obj/item/mecha_parts/chassis/ripley, - /obj/item/mecha_parts/part/ripley_torso, - /obj/item/mecha_parts/part/ripley_left_arm, - /obj/item/mecha_parts/part/ripley_right_arm, - /obj/item/mecha_parts/part/ripley_left_leg, - /obj/item/mecha_parts/part/ripley_right_leg - ), - "Odysseus"=list( - /obj/item/mecha_parts/chassis/odysseus, - /obj/item/mecha_parts/part/odysseus_torso, - /obj/item/mecha_parts/part/odysseus_head, - /obj/item/mecha_parts/part/odysseus_left_arm, - /obj/item/mecha_parts/part/odysseus_right_arm, - /obj/item/mecha_parts/part/odysseus_left_leg, - /obj/item/mecha_parts/part/odysseus_right_leg - ), - - "Gygax"=list( - /obj/item/mecha_parts/chassis/gygax, - /obj/item/mecha_parts/part/gygax_torso, - /obj/item/mecha_parts/part/gygax_head, - /obj/item/mecha_parts/part/gygax_left_arm, - /obj/item/mecha_parts/part/gygax_right_arm, - /obj/item/mecha_parts/part/gygax_left_leg, - /obj/item/mecha_parts/part/gygax_right_leg, - /obj/item/mecha_parts/part/gygax_armour - ), - "Durand"=list( - /obj/item/mecha_parts/chassis/durand, - /obj/item/mecha_parts/part/durand_torso, - /obj/item/mecha_parts/part/durand_head, - /obj/item/mecha_parts/part/durand_left_arm, - /obj/item/mecha_parts/part/durand_right_arm, - /obj/item/mecha_parts/part/durand_left_leg, - /obj/item/mecha_parts/part/durand_right_leg, - /obj/item/mecha_parts/part/durand_armor - ), - "Phazon"=list( - /obj/item/mecha_parts/chassis/phazon, - /obj/item/mecha_parts/part/phazon_torso, - /obj/item/mecha_parts/part/phazon_head, - /obj/item/mecha_parts/part/phazon_left_arm, - /obj/item/mecha_parts/part/phazon_right_arm, - /obj/item/mecha_parts/part/phazon_left_leg, - /obj/item/mecha_parts/part/phazon_right_leg, - /obj/item/mecha_parts/part/phazon_armor - ), - "H.O.N.K"=list( - /obj/item/mecha_parts/chassis/honker, - /obj/item/mecha_parts/part/honker_torso, - /obj/item/mecha_parts/part/honker_head, - /obj/item/mecha_parts/part/honker_left_arm, - /obj/item/mecha_parts/part/honker_right_arm, - /obj/item/mecha_parts/part/honker_left_leg, - /obj/item/mecha_parts/part/honker_right_leg - ), - "Exosuit Equipment"=list( - /obj/item/mecha_parts/mecha_equipment/tool/hydraulic_clamp, - /obj/item/mecha_parts/mecha_equipment/tool/drill, - /obj/item/mecha_parts/mecha_equipment/tool/extinguisher, - /obj/item/mecha_parts/mecha_equipment/tool/cable_layer, - /obj/item/mecha_parts/mecha_equipment/tool/sleeper, - /obj/item/mecha_parts/mecha_equipment/tool/syringe_gun, - /obj/item/mecha_parts/chassis/firefighter, - ///obj/item/mecha_parts/mecha_equipment/repair_droid, - /obj/item/mecha_parts/mecha_equipment/generator, - ///obj/item/mecha_parts/mecha_equipment/jetpack, //TODO MECHA JETPACK SPRITE MISSING - /obj/item/mecha_parts/mecha_equipment/weapon/energy/taser, - /obj/item/mecha_parts/mecha_equipment/weapon/ballistic/lmg, - /obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/mousetrap_mortar, - /obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/banana_mortar, - /obj/item/mecha_parts/mecha_equipment/weapon/honker - ), - - "Robotic Upgrade Modules" = list( - /obj/item/borg/upgrade/reset, - /obj/item/borg/upgrade/rename, - /obj/item/borg/upgrade/restart, - /obj/item/borg/upgrade/vtec, - /obj/item/borg/upgrade/tasercooler, - /obj/item/borg/upgrade/jetpack - ), - - "Space Pod" = list( - /obj/item/pod_parts/core - ), - - "Misc"=list(/obj/item/mecha_parts/mecha_tracking) - ) - - - + var/list/part_sets = list( + "Cyborg", + "Ripley", + "Firefighter", + "Odysseus", + "Gygax", + "Durand", + "H.O.N.K", + "Phazon", + "Exosuit Equipment", + "Cyborg Upgrade Modules", + "Misc" + ) /obj/machinery/mecha_part_fabricator/New() ..() component_parts = list() - component_parts += new /obj/item/weapon/circuitboard/mechfab(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) - component_parts += new /obj/item/weapon/stock_parts/manipulator(src) - component_parts += new /obj/item/weapon/stock_parts/micro_laser(src) - component_parts += new /obj/item/weapon/stock_parts/console_screen(src) + component_parts += new /obj/item/weapon/circuitboard/mechfab(null) + component_parts += new /obj/item/weapon/stock_parts/matter_bin(null) + component_parts += new /obj/item/weapon/stock_parts/matter_bin(null) + component_parts += new /obj/item/weapon/stock_parts/manipulator(null) + component_parts += new /obj/item/weapon/stock_parts/micro_laser(null) + component_parts += new /obj/item/weapon/stock_parts/console_screen(null) RefreshParts() - - // part_sets["Cyborg Upgrade Modules"] = typesof(/obj/item/borg/upgrade/) - /obj/item/borg/upgrade/ // Eh. This does it dymaically, but to support having the items referenced otherwhere in the code but not being constructable, going to do it manaully. - - for(var/part_set in part_sets) - convert_part_set(part_set) files = new /datum/research(src) //Setup the research data holder. - /* - if(!id) - for(var/obj/machinery/r_n_d/server/centcom/S in world) - S.initialize() - break - */ - return /obj/machinery/mecha_part_fabricator/RefreshParts() var/T = 0 + + //maximum stocking amount (max 412000) for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts) T += M.rating - res_max_amount = (187500+(T * 37500)) - T = 0 + res_max_amount = (187000+(T * 37500)) + + //ressources adjustment coefficient (1 -> 0.88 -> 0.75) + T = -1 for(var/obj/item/weapon/stock_parts/micro_laser/Ma in component_parts) T += Ma.rating - T -= 1 - var/diff - diff = round(initial(resource_coeff) - (initial(resource_coeff)*(T))/8,0.01) - if(resource_coeff!=diff) - resource_coeff = diff - T = 0 + resource_coeff = round(initial(resource_coeff) - (initial(resource_coeff)*(T))/8,0.01) + + //building time adjustment coefficient (1 -> 0.8 -> 0.6) + T = -1 for(var/obj/item/weapon/stock_parts/manipulator/Ml in component_parts) T += Ml.rating - T -= 1 - diff = round(initial(time_coeff) - (initial(time_coeff)*(T))/5,0.01) - if(time_coeff!=diff) - time_coeff = diff + time_coeff = round(initial(time_coeff) - (initial(time_coeff)*(T))/5,0.01) -/obj/machinery/mecha_part_fabricator/Destroy() - for(var/atom/A in src) - del A - ..() - return - -/obj/machinery/mecha_part_fabricator/proc/operation_allowed(mob/M) - if(isrobot(M) || isAI(M)) - return 1 - if(!istype(req_access) || !req_access.len) - return 1 - else if(istype(M, /mob/living/carbon/human)) - var/mob/living/carbon/human/H = M - for(var/ID in list(H.get_active_hand(), H.wear_id, H.belt)) - if(src.check_access(ID)) - return 1 - M << "You don't have required permissions to use [src]" - return 0 +/obj/machinery/mecha_part_fabricator/check_access(obj/item/weapon/card/id/I) + if(istype(I, /obj/item/device/pda)) + var/obj/item/device/pda/pda = I + I = pda.id + if(!istype(I) || !I.access) //not ID or no access + return 0 + for(var/req in req_access) + if(!(req in I.access)) //doesn't have this access + return 0 + return 1 /obj/machinery/mecha_part_fabricator/proc/emag() - sleep() switch(emagged) if(0) emagged = 0.5 - src.visible_message("\icon[src] [src] beeps: \"DB error \[Code 0x00F1\]\"") + visible_message("\icon[src] \The [src] beeps: \"DB error \[Code 0x00F1\]\"") sleep(10) - src.visible_message("\icon[src] [src] beeps: \"Attempting auto-repair\"") + visible_message("\icon[src] \The [src] beeps: \"Attempting auto-repair\"") sleep(15) - src.visible_message("\icon[src] [src] beeps: \"User DB corrupted \[Code 0x00FA\]. Truncating data structure...\"") + visible_message("\icon[src] \The [src] beeps: \"User DB corrupted \[Code 0x00FA\]. Truncating data structure...\"") sleep(30) - src.visible_message("\icon[src] [src] beeps: \"User DB truncated. Please contact your Nanotrasen system operator for future assistance.\"") + visible_message("\icon[src] \The [src] beeps: \"User DB truncated. Please contact your Nanotrasen system operator for future assistance.\"") req_access = null emagged = 1 if(0.5) - src.visible_message("\icon[src] [src] beeps: \"DB not responding \[Code 0x0003\]...\"") + visible_message("\icon[src] \The [src] beeps: \"DB not responding \[Code 0x0003\]...\"") if(1) - src.visible_message("\icon[src] [src] beeps: \"No records in User DB\"") - return - -/obj/machinery/mecha_part_fabricator/proc/convert_part_set(set_name as text) - var/list/parts = part_sets[set_name] - if(istype(parts, /list)) - for(var/i=1;i<=parts.len;i++) - var/path = parts[i] - var/part = new path(src) - if(part) - parts[i] = part - //debug below - if(!istype(parts[i],/obj/item)) return 0 - return - - -/obj/machinery/mecha_part_fabricator/proc/add_part_set(set_name as text,parts=null) - if(set_name in part_sets)//attempt to create duplicate set - return 0 - if(isnull(parts)) - part_sets[set_name] = list() - else - part_sets[set_name] = parts - convert_part_set(set_name) - return 1 - -/obj/machinery/mecha_part_fabricator/proc/add_part_to_set(set_name as text,part) - if(!part) return 0 - src.add_part_set(set_name)//if no "set_name" set exists, create - var/list/part_set = part_sets[set_name] - var/atom/apart - if(ispath(part)) - apart = new part(src) - else - apart = part - if(!istype(apart)) return 0 - for(var/obj/O in part_set) - if(O.type == apart.type) - del apart - return 0 - part_set[++part_set.len] = apart - return 1 - -/obj/machinery/mecha_part_fabricator/proc/remove_part_set(set_name as text) - for(var/i=1,i<=part_sets.len,i++) - if(part_sets[i]==set_name) - part_sets.Cut(i,++i) + visible_message("\icon[src] \The [src] beeps: \"No records in User DB\"") return /obj/machinery/mecha_part_fabricator/proc/output_parts_list(set_name) var/output = "" - var/list/part_set = listgetindex(part_sets, set_name) - if(istype(part_set)) - for(var/obj/item/part in part_set) - var/resources_available = check_resources(part) - output += "
[output_part_info(part)]
\[[resources_available?"Build | ":null]Add to queue\]\[?\]
" + for(var/datum/design/D in files.known_designs) + if(D.build_type & MECHFAB) + if(!(set_name in D.category)) + continue + var/resources_available = check_resources(D) + output += "
[output_part_info(D)]
\[[resources_available?"Build | ":null]Add to queue\]\[?\]
" return output -/obj/machinery/mecha_part_fabricator/proc/output_part_info(var/obj/item/part) - var/output = "[part.name] (Cost: [output_part_cost(part)]) [get_construction_time_w_coeff(part)/10]sec" +/obj/machinery/mecha_part_fabricator/proc/output_part_info(datum/design/D) + var/output = "[initial(D.name)] (Cost: [output_part_cost(D)]) [get_construction_time_w_coeff(D)/10]sec" return output -/obj/machinery/mecha_part_fabricator/proc/output_part_cost(var/obj/item/part) +/obj/machinery/mecha_part_fabricator/proc/output_part_cost(datum/design/D) var/i = 0 var/output - if(part.vars.Find("construction_time") && part.vars.Find("construction_cost"))//The most efficient way to go about this. Not all objects have these vars, but if they don't then they CANNOT be made by the mech fab. Doing it this way reduces a major amount of typecasting and switches, while cutting down maintenece for them as well -Sieve - for(var/c in part:construction_cost)//The check should ensure that anything without the var doesn't make it to this point - if(c in resources) - output += "[i?" | ":null][get_resource_cost_w_coeff(part,c)] [c]" - i++ - return output - else - return 0 + for(var/c in D.materials) + if(c in resources) + output += "[i?" | ":null][get_resource_cost_w_coeff(D,c)] [material2name(c)]" + i++ + return output /obj/machinery/mecha_part_fabricator/proc/output_available_resources() var/output for(var/resource in resources) var/amount = min(res_max_amount, resources[resource]) - output += "[resource]: [amount] cm³" + output += "[material2name(resource)]: [amount] cm³" if(amount>0) - output += " - Remove \[1\] | \[10\] | \[All\]" + output += " - Remove \[1\] | \[10\] | \[All\]" output += "
" return output -/obj/machinery/mecha_part_fabricator/proc/remove_resources(var/obj/item/part) -//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) - for(var/resource in part:construction_cost) - if(resource in src.resources) - src.resources[resource] -= get_resource_cost_w_coeff(part,resource) - else - return +/obj/machinery/mecha_part_fabricator/proc/remove_resources(datum/design/D) + for(var/resource in D.materials) + if(resource in resources) + resources[resource] -= get_resource_cost_w_coeff(D,resource) -/obj/machinery/mecha_part_fabricator/proc/check_resources(var/obj/item/part) -// if(istype(part, /obj/item/robot_parts) || istype(part, /obj/item/mecha_parts) || istype(part,/obj/item/borg/upgrade)) -//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) - for(var/resource in part:construction_cost) - if(resource in src.resources) - if(src.resources[resource] < get_resource_cost_w_coeff(part,resource)) - return 0 - return 1 - else - return 0 +/obj/machinery/mecha_part_fabricator/proc/check_resources(datum/design/D) + for(var/R in D.materials) + if(R in resources) + if(resources[R] < get_resource_cost_w_coeff(D, R)) + return 0 + else + return 0 + return 1 -/obj/machinery/mecha_part_fabricator/proc/build_part(var/obj/item/part) - if(!part) return +/obj/machinery/mecha_part_fabricator/proc/build_part(datum/design/D) + being_built = D + desc = "It's building \a [initial(D.name)]." + remove_resources(D) + overlays += "fab-active" + use_power = 2 + updateUsrDialog() + sleep(get_construction_time_w_coeff(D)) + use_power = 1 + overlays -= "fab-active" + desc = initial(desc) - // critical exploit prevention, do not remove unless you replace it -walter0o - if( !(locate(part, src.contents)) || !(part.vars.Find("construction_time")) || !(part.vars.Find("construction_cost")) ) // these 3 are the current requirements for an object being buildable by the mech_fabricator - return + var/obj/item/I = new D.build_path + I.loc = get_step(src,SOUTH) + I.m_amt = get_resource_cost_w_coeff(D,"$metal") + I.g_amt = get_resource_cost_w_coeff(D,"$glass") + visible_message("\icon[src] \The [src] beeps, \"\The [I] is complete.\"") + being_built = null - src.being_built = new part.type(src) - src.desc = "It's building [src.being_built]." - src.remove_resources(part) - src.overlays += "fab-active" - src.use_power = 2 - src.updateUsrDialog() - sleep(get_construction_time_w_coeff(part)) - src.use_power = 1 - src.overlays -= "fab-active" - src.desc = initial(src.desc) - if(being_built) - src.being_built.Move(get_step(src,SOUTH)) - src.visible_message("\icon[src] [src] beeps, \"The following has been completed: [src.being_built] is built\".") - src.being_built = null - src.updateUsrDialog() + updateUsrDialog() return 1 /obj/machinery/mecha_part_fabricator/proc/update_queue_on_page() - send_byjax(usr,"mecha_fabricator.browser","queue",src.list_queue()) + send_byjax(usr,"mecha_fabricator.browser","queue",list_queue()) return /obj/machinery/mecha_part_fabricator/proc/add_part_set_to_queue(set_name) if(set_name in part_sets) - var/list/part_set = part_sets[set_name] - if(islist(part_set)) - for(var/obj/item/part in part_set) - add_to_queue(part) - return + for(var/datum/design/D in files.known_designs) + if(D.build_type & MECHFAB) + if(set_name in D.category) + add_to_queue(D) -/obj/machinery/mecha_part_fabricator/proc/add_to_queue(part) +/obj/machinery/mecha_part_fabricator/proc/add_to_queue(D) if(!istype(queue)) queue = list() - if(part) - queue[++queue.len] = part + if(D) + queue[++queue.len] = D return queue.len /obj/machinery/mecha_part_fabricator/proc/remove_from_queue(index) @@ -388,30 +204,26 @@ return 1 /obj/machinery/mecha_part_fabricator/proc/process_queue() - var/obj/item/part = listgetindex(src.queue, 1) - if(!part) + var/datum/design/D = queue[1] + if(!D) remove_from_queue(1) - if(src.queue.len) + if(queue.len) return process_queue() else return - if(!(part.vars.Find("construction_time")) || !(part.vars.Find("construction_cost")))//If it shouldn't be printed - remove_from_queue(1)//Take it out of the quene - return process_queue()//Then reprocess it temp = null - while(part) + while(D) if(stat&(NOPOWER|BROKEN)) return 0 - if(!check_resources(part)) - src.visible_message("\icon[src] [src] beeps, \"Not enough resources. Queue processing stopped\".") - temp = {"Not enough resources to build next part.
+ if(!check_resources(D)) + visible_message("\icon[src] \The [src] beeps, \"Not enough resources. Queue processing stopped.\"") + temp = {"Not enough resources to build next part.
Try again | Return"} return 0 remove_from_queue(1) - build_part(part) - part = listgetindex(src.queue, 1) - src.visible_message("\icon[src] [src] beeps, \"Queue processing finished successfully\".") - return 1 + build_part(D) + D = listgetindex(queue, 1) + visible_message("\icon[src] \The [src] beeps, \"Queue processing finished successfully.\"") /obj/machinery/mecha_part_fabricator/proc/list_queue() var/output = "Queue contains:" @@ -419,67 +231,45 @@ output += "
Nothing" else output += "
    " - for(var/i=1;i<=queue.len;i++) - var/obj/item/part = listgetindex(src.queue, i) - if(istype(part)) - if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) - output += "[part.name] - [i>1?"":null] [i↓":null] Remove" - else//Prevents junk items from even appearing in the list, and they will be silently removed when the fab processes - remove_from_queue(i)//Trash it - return list_queue()//Rebuild it + var/i = 0 + for(var/datum/design/D in queue) + i++ + var/obj/part = D.build_path + output += "[initial(part.name)] - [i>1?"":null] [i↓":null] Remove" + output += "
" output += "\[Process queue | Clear queue\]" return output -/obj/machinery/mecha_part_fabricator/proc/convert_designs() - if(!files) return - var/i = 0 - for(var/datum/design/D in files.known_designs) - if(D.build_type&16) - if(D.category in part_sets)//Checks if it's a valid category - if(add_part_to_set(D.category, text2path(D.build_path)))//Adds it to said category - i++ - else - if(add_part_to_set("Misc", text2path(D.build_path)))//If in doubt, chunk it into the Misc - i++ - return i - /obj/machinery/mecha_part_fabricator/proc/update_tech() - if(!files) return + if(!files) + return var/output for(var/datum/tech/T in files.known_tech) if(T && T.level > 1) var/diff - switch(T.id) //bad, bad formulas + switch(T.id) if("materials") - var/pmat = 0//Calculations to make up for the fact that these parts and tech modify the same thing - for(var/obj/item/weapon/stock_parts/micro_laser/Ml in component_parts) - pmat += Ml.rating - if(pmat >= 1) - pmat -= 1//So the equations don't have to be reworked, upgrading a single part from T1 to T2 is == to 1 tech level - diff = round(initial(resource_coeff_tech) - (initial(resource_coeff_tech)*(T.level+pmat))/30,0.01) - if(resource_coeff_tech > diff) + //one materials level is 1/32, so that max level is 0.75 coefficient + diff = round(initial(resource_coeff_tech) - (initial(resource_coeff_tech)*(T.level-1))/32,0.01) + if(resource_coeff_tech>diff) resource_coeff_tech = diff - output += "Production efficiency increased.
" + output+="Production efficiency increased.
" if("programming") - var/ptime = 0 - for(var/obj/item/weapon/stock_parts/manipulator/Ma in component_parts) - ptime += Ma.rating - if(ptime >= 2) - ptime -= 2 - diff = round(initial(time_coeff_tech) - (initial(time_coeff_tech)*(T.level+ptime))/25,0.1) - if(time_coeff_tech > diff) + //one materials level is 1/40, so that max level is 0.8 coefficient + diff = round(initial(time_coeff_tech) - (initial(time_coeff_tech)*(T.level-1))/40,0.1) + if(time_coeff_tech>diff) time_coeff_tech = diff - output += "Production routines updated.
" + output+="Production routines updated.
" return output -/obj/machinery/mecha_part_fabricator/proc/sync(silent=null) - if(!silent) - temp = "Updating local R&D database..." - src.updateUsrDialog() - sleep(30) //only sleep if called by user - for(var/obj/machinery/computer/rdconsole/RDC in get_area(src)) +/obj/machinery/mecha_part_fabricator/proc/sync() + temp = "Updating local R&D database..." + updateUsrDialog() + sleep(30) //only sleep if called by user + + for(var/obj/machinery/computer/rdconsole/RDC in area_contents(get_area(src))) if(!RDC.sync) continue for(var/datum/tech/T in RDC.files.known_tech) @@ -487,48 +277,43 @@ for(var/datum/design/D in RDC.files.known_designs) files.AddDesign2Known(D) files.RefreshResearch() - var/i = src.convert_designs() - var/tech_output = update_tech() - if(!silent) - temp = "Processed [i] equipment designs.
" - temp += tech_output - temp += "Return" - src.updateUsrDialog() - if(i || tech_output) - src.visible_message("\icon[src] [src] beeps, \"Succesfully synchronized with R&D server. New data processed.\"") + temp = "Processed equipment designs.
" + //check if the tech coefficients have changed + temp += update_tech() + temp += "Return" + + updateUsrDialog() + visible_message("\icon[src] \The [src] beeps, \"Successfully synchronized with R&D server.\"") + return + + temp = "Unable to connect to local R&D Database.
Please check your connections and try again.
Return" + updateUsrDialog() return -/obj/machinery/mecha_part_fabricator/proc/get_resource_cost_w_coeff(var/obj/item/part as obj,var/resource as text, var/roundto=1) - if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) - if (resource=="iron" && !("iron" in part:construction_cost)) - resource="metal" - return round(part:construction_cost[resource]*resource_coeff*resource_coeff_tech, roundto) - else - return 0 +/obj/machinery/mecha_part_fabricator/proc/get_resource_cost_w_coeff(datum/design/D, resource, roundto = 1) + return round(D.materials[resource]*resource_coeff*resource_coeff_tech, roundto) -/obj/machinery/mecha_part_fabricator/proc/get_construction_time_w_coeff(var/obj/item/part as obj, var/roundto=1) -//Be SURE to add any new equipment to this switch, but don't be suprised if it spits out children objects - if(part.vars.Find("construction_time") && part.vars.Find("construction_cost")) - return round(part:construction_time*time_coeff*time_coeff_tech, roundto) - else - return 0 +/obj/machinery/mecha_part_fabricator/proc/get_construction_time_w_coeff(datum/design/D, roundto = 1) //aran + return round(initial(D.construction_time)*time_coeff*time_coeff_tech, roundto) +/obj/machinery/mecha_part_fabricator/attack_hand(mob/user) + if(!(..())) + return interact(user) -/obj/machinery/mecha_part_fabricator/attack_hand(mob/user as mob) +/obj/machinery/mecha_part_fabricator/interact(mob/user as mob) var/dat, left_part if (..()) return - if(!operation_allowed(user)) - return user.set_machine(src) var/turf/exit = get_step(src,SOUTH) if(exit.density) - src.visible_message("\icon[src] [src] beeps, \"Error! Part outlet is obstructed\".") + visible_message("\icon[src] \The [src] beeps, \"Error! Part outlet is obstructed.\"") return if(temp) left_part = temp - else if(src.being_built) - left_part = {"Building [src.being_built.name].
+ else if(being_built) + var/obj/I = being_built.build_path + left_part = {"Building [initial(I.name)].
Please wait until completion...
"} else switch(screen) @@ -536,13 +321,13 @@ left_part = output_available_resources()+"
" left_part += "Sync with R&D servers
" for(var/part_set in part_sets) - left_part += "[part_set] - \[Add all parts to queue\]
" + left_part += "
[part_set] - \[Add all parts to queue\]
" if("parts") left_part += output_parts_list(part_set) left_part += "
Return" dat = {" - [src.name] + [name]