Circuit cloning balance: Timed cloning, reduced upgrade disk material cost (#35657)

* Printing compromise

* Adds fast cloning to the upgraded printer

* sorry this took so long
This commit is contained in:
Ashe Higgs
2018-02-25 15:46:33 -05:00
committed by CitadelStationBot
parent 0589c06507
commit 063fc1a7af
2 changed files with 75 additions and 25 deletions
@@ -1,13 +1,18 @@
#define MAX_CIRCUIT_CLONE_TIME 3 MINUTES //circuit slow-clones can only take up this amount of time to complete
/obj/item/device/integrated_circuit_printer
name = "integrated circuit printer"
desc = "A portable(ish) machine made to print tiny modular circuitry out of metal."
icon = 'icons/obj/assemblies/electronic_tools.dmi'
icon_state = "circuit_printer"
w_class = WEIGHT_CLASS_BULKY
var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits.
var/can_clone = FALSE // Same for above, but will allow the printer to duplicate a specific assembly.
var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits.
var/can_clone = TRUE // Allows the printer to clone circuits, either instantly or over time depending on upgrade. Set to FALSE to disable entirely.
var/fast_clone = FALSE // If this is false, then cloning will take an amount of deciseconds equal to the metal cost divided by 100.
var/debug = FALSE // If it's upgraded and can clone, even without config settings.
var/current_category = null
var/cloning = FALSE // If the printer is currently creating a circuit
var/clone_countdown = 0 // This counts down when cloning is in progress, and clones the circuit when it's ready
var/recycling = FALSE // If an assembly is being emptied into this printer
var/list/program // Currently loaded save, in form of list
@@ -17,6 +22,7 @@
/obj/item/device/integrated_circuit_printer/upgraded
upgraded = TRUE
can_clone = TRUE
fast_clone = TRUE
/obj/item/device/integrated_circuit_printer/debug //translation: "integrated_circuit_printer/local_server"
name = "debug circuit printer"
@@ -27,23 +33,39 @@
. = ..()
AddComponent(/datum/component/material_container, list(MAT_METAL), MINERAL_MATERIAL_AMOUNT * 25, TRUE, list(/obj/item/stack, /obj/item/integrated_circuit, /obj/item/device/electronic_assembly))
/obj/item/device/integrated_circuit_printer/Destroy()
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/device/integrated_circuit_printer/process()
if(!cloning)
STOP_PROCESSING(SSprocessing, src)
clone_countdown--
if(!clone_countdown || fast_clone)
var/turf/T = get_turf(src)
T.visible_message("<span class='notice'>[src] has finished printing its assembly!</span>")
playsound(get_turf(T), 'sound/items/poster_being_created.ogg', 50, TRUE)
SScircuit.load_electronic_assembly(T, program)
cloning = FALSE
STOP_PROCESSING(SSprocessing, src)
/obj/item/device/integrated_circuit_printer/attackby(obj/item/O, mob/user)
if(istype(O, /obj/item/disk/integrated_circuit/upgrade/advanced))
if(upgraded)
to_chat(user, "<span class='warning'>\The [src] already has this upgrade. </span>")
to_chat(user, "<span class='warning'>[src] already has this upgrade. </span>")
return TRUE
to_chat(user, "<span class='notice'>You install \the [O] into \the [src]. </span>")
to_chat(user, "<span class='notice'>You install [O] into [src]. </span>")
upgraded = TRUE
qdel(O)
interact(user)
return TRUE
if(istype(O, /obj/item/disk/integrated_circuit/upgrade/clone))
if(can_clone)
to_chat(user, "<span class='warning'>\The [src] already has this upgrade. </span>")
if(fast_clone)
to_chat(user, "<span class='warning'>[src] already has this upgrade. </span>")
return TRUE
to_chat(user, "<span class='notice'>You install \the [O] into \the [src]. </span>")
can_clone = TRUE
to_chat(user, "<span class='notice'>You install [O] into [src]. Circuit cloning will now be instant. </span>")
fast_clone = TRUE
qdel(O)
interact(user)
return TRUE
@@ -103,8 +125,8 @@
else
HTML += "Metal: [materials.total_amount]/[materials.max_amount].<br><br>"
if(CONFIG_GET(flag/ic_printing) && !debug)
HTML += "Assembly cloning: [can_clone ? "Available": "Unavailable"].<br>"
if(CONFIG_GET(flag/ic_printing) || debug)
HTML += "Assembly cloning: [can_clone ? (fast_clone ? "Instant" : "Available") : "Unavailable"].<br>"
HTML += "Circuits available: [upgraded || debug ? "Advanced":"Regular"]."
if(!upgraded)
@@ -113,11 +135,16 @@
HTML += "<hr>"
if((can_clone && CONFIG_GET(flag/ic_printing)) || debug)
HTML += "Here you can load script for your assembly.<br>"
HTML += " <A href='?src=[REF(src)];print=load'>{Load Program}</a> "
if(!program)
HTML += " {Print Assembly}"
if(!cloning)
HTML += " <A href='?src=[REF(src)];print=load'>{Load Program}</a> "
else
HTML += " <A href='?src=[REF(src)];print=print'>{Print Assembly}</a>"
HTML += " {Load Program}"
if(!program)
HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}"
else if(cloning)
HTML += " <A href='?src=[REF(src)];print=cancel'>{Cancel Print}</a> - [clone_countdown] second(s) remaining until completion"
else
HTML += " <A href='?src=[REF(src)];print=print'>{[fast_clone ? "Print" : "Begin Printing"] Assembly}</a>"
HTML += "<br><hr>"
HTML += "Categories:"
@@ -229,11 +256,11 @@
if(!program)
return
if(program["requires_upgrades"] && !upgraded)
if(program["requires_upgrades"] && !upgraded && !debug)
to_chat(usr, "<span class='warning'>This program uses unknown component designs. Printer upgrade is required to proceed.</span>")
if(program["unsupported_circuit"])
if(program["unsupported_circuit"] && !debug)
to_chat(usr, "<span class='warning'>This program uses components not supported by the specified assembly. Please change the assembly type in the save file to a supported one.</span>")
else
else if(fast_clone || debug)
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
if(debug || materials.use_amount_type(program["metal_cost"], MAT_METAL))
var/obj/item/assembly = SScircuit.load_electronic_assembly(get_turf(src), program)
@@ -241,6 +268,30 @@
playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE)
else
to_chat(usr, "<span class='warning'>You need [program["metal_cost"]] metal to build that!</span>")
else
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
if(!materials.use_amount_type(program["metal_cost"], MAT_METAL))
to_chat(usr, "<span class='warning'>You need [program["metal_cost"]] metal to build that!</span>")
return
var/cloning_time = program["metal_cost"] / 150
cloning_time = min(cloning_time, MAX_CIRCUIT_CLONE_TIME)
cloning = TRUE
clone_countdown = cloning_time
to_chat(usr, "<span class='notice'>You begin printing a custom assembly. This will take approximately [round(cloning_time / 60, 0.1)] minute(s). You can still print \
off normal parts during this time.</span>")
playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE)
START_PROCESSING(SSprocessing, src)
if("cancel")
if(!cloning || !program)
return
to_chat(usr, "<span class='notice'>Cloning has been canceled. Metal cost has been refunded.</span>")
cloning = FALSE
clone_countdown = FALSE
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
materials.use_amount_type(-program["metal_cost"], MAT_METAL) //use negative amount to regain the cost
interact(usr)
@@ -258,8 +309,7 @@
name = "integrated circuit printer upgrade disk - advanced designs"
desc = "Install this into your integrated circuit printer to enhance it. This one adds new, advanced designs to the printer."
// To be implemented later.
/obj/item/disk/integrated_circuit/upgrade/clone
name = "integrated circuit printer upgrade disk - circuit cloner"
desc = "Install this into your integrated circuit printer to enhance it. This one allows the printer to duplicate assemblies."
name = "integrated circuit printer upgrade disk - instant cloner"
desc = "Install this into your integrated circuit printer to enhance it. This one allows the printer to duplicate assemblies instantaneously."
icon_state = "upgrade_disk_clone"
@@ -57,17 +57,17 @@
departmental_flags = DEPARTMENTAL_FLAG_SCIENCE
/datum/design/integrated_printer
name = "Integrated circuits printer"
name = "Integrated circuit printer"
desc = "This machine provides all neccesary things for circuitry."
id = "icprinter"
build_type = PROTOLATHE
materials = list(MAT_GLASS = 5000, MAT_METAL = 5000)
materials = list(MAT_GLASS = 5000, MAT_METAL = 10000)
build_path = /obj/item/device/integrated_circuit_printer
category = list("Electronics")
departmental_flags = DEPARTMENTAL_FLAG_SCIENCE
/datum/design/IC_printer_upgrade_advanced
name = "Integrated Circuits printer upgrade: Advanced Designs"
name = "Integrated circuit printer upgrade: Advanced Designs"
desc = "This disk allows for integrated circuit printers to print advanced circuitry designs."
id = "icupgadv"
build_type = PROTOLATHE
@@ -77,8 +77,8 @@
departmental_flags = DEPARTMENTAL_FLAG_SCIENCE
/datum/design/IC_printer_upgrade_clone
name = "Integrated Circuits printer upgrade: Clone Ability"
desc = "This disk allows for integrated circuit printers to clone designs."
name = "Integrated circuit printer upgrade: Instant Cloning"
desc = "This disk allows for integrated circuit printers to clone designs instantaneously."
id = "icupgclo"
build_type = PROTOLATHE
materials = list(MAT_GLASS = 10000, MAT_METAL = 10000)