From 7e9ad626e97da45618741fae6ea2a7ff22e36666 Mon Sep 17 00:00:00 2001 From: Dax Dupont Date: Wed, 27 Jun 2018 16:00:55 +0200 Subject: [PATCH] [READY] General Circuit Improvements (#38742) * [WIP] General circuit improvements * Fix * s * Adds sound logging * oops * mob user --- code/__DEFINES/logging.dm | 1 + code/modules/admin/admin_investigate.dm | 2 +- .../integrated_electronics/core/assemblies.dm | 8 ++++ .../core/integrated_circuit.dm | 2 +- .../integrated_electronics/core/printer.dm | 44 +++++++++---------- .../integrated_electronics/subtypes/output.dm | 8 +++- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index 197c315f780..485cfa65c1f 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -14,6 +14,7 @@ #define INVESTIGATE_HALLUCINATIONS "hallucinations" #define INVESTIGATE_RADIATION "radiation" #define INVESTIGATE_EXONET "exonet" +#define INVESTIGATE_CIRCUIT "circuit" //Individual logging defines #define INDIVIDUAL_ATTACK_LOG "Attack log" diff --git a/code/modules/admin/admin_investigate.dm b/code/modules/admin/admin_investigate.dm index b5fead892f0..94efce6059d 100644 --- a/code/modules/admin/admin_investigate.dm +++ b/code/modules/admin/admin_investigate.dm @@ -4,7 +4,7 @@ var/F = file("[GLOB.log_directory]/[subject].html") WRITE_FILE(F, "[time_stamp()] [REF(src)] ([x],[y],[z]) || [src] [message]
") -/client/proc/investigate_show(subject in list("notes, memos, watchlist", INVESTIGATE_RESEARCH, INVESTIGATE_EXONET, INVESTIGATE_PORTAL, INVESTIGATE_SINGULO, INVESTIGATE_WIRES, INVESTIGATE_TELESCI, INVESTIGATE_GRAVITY, INVESTIGATE_RECORDS, INVESTIGATE_CARGO, INVESTIGATE_SUPERMATTER, INVESTIGATE_ATMOS, INVESTIGATE_EXPERIMENTOR, INVESTIGATE_BOTANY, INVESTIGATE_HALLUCINATIONS, INVESTIGATE_RADIATION) ) +/client/proc/investigate_show(subject in list("notes, memos, watchlist", INVESTIGATE_RESEARCH, INVESTIGATE_EXONET, INVESTIGATE_PORTAL, INVESTIGATE_SINGULO, INVESTIGATE_WIRES, INVESTIGATE_TELESCI, INVESTIGATE_GRAVITY, INVESTIGATE_RECORDS, INVESTIGATE_CARGO, INVESTIGATE_SUPERMATTER, INVESTIGATE_ATMOS, INVESTIGATE_EXPERIMENTOR, INVESTIGATE_BOTANY, INVESTIGATE_HALLUCINATIONS, INVESTIGATE_RADIATION, INVESTIGATE_CIRCUIT) ) set name = "Investigate" set category = "Admin" if(!holder) diff --git a/code/modules/integrated_electronics/core/assemblies.dm b/code/modules/integrated_electronics/core/assemblies.dm index fdc8d62f4b0..0ba56833a2b 100644 --- a/code/modules/integrated_electronics/core/assemblies.dm +++ b/code/modules/integrated_electronics/core/assemblies.dm @@ -10,6 +10,7 @@ icon_state = "setup_small" item_flags = NOBLUDGEON materials = list() // To be filled later + datum_flags = DF_USE_TAG var/list/assembly_components = list() var/list/ckeys_allowed_to_scan = list() // Players who built the circuit can scan it as a ghost. var/max_components = IC_MAX_SIZE_BASE @@ -30,6 +31,8 @@ var/combat_circuits = 0 //number of combat cicuits in the assembly, used for diagnostic hud var/long_range_circuits = 0 //number of long range cicuits in the assembly, used for diagnostic hud var/prefered_hud_icon = "hudstat" // Used by the AR circuit to change the hud icon. + var/creator // circuit creator if any + var/static/next_assembly_id = 0 hud_possible = list(DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_TRACK_HUD, DIAG_CIRCUIT_HUD) //diagnostic hud overlays max_integrity = 50 pass_flags = 0 @@ -56,6 +59,9 @@ COLOR_ASSEMBLY_PURPLE ) +/obj/item/electronic_assembly/GenerateTag() + tag = "assembly_[next_assembly_id++]" + /obj/item/electronic_assembly/examine(mob/user) . = ..() if(can_anchor) @@ -351,6 +357,7 @@ to_chat(user, "You slide [IC] inside [src].") playsound(src, 'sound/items/Deconstruct.ogg', 50, 1) add_allowed_scanner(user.ckey) + investigate_log("had [IC]([IC.type]) inserted by [key_name(user)].", INVESTIGATE_CIRCUIT) add_component(IC) return TRUE @@ -390,6 +397,7 @@ playsound(src, 'sound/items/crowbar.ogg', 50, 1) user.put_in_hands(IC) add_allowed_scanner(user.ckey) + investigate_log("had [IC]([IC.type]) removed by [key_name(user)].", INVESTIGATE_CIRCUIT) return TRUE diff --git a/code/modules/integrated_electronics/core/integrated_circuit.dm b/code/modules/integrated_electronics/core/integrated_circuit.dm index d5ebeb30018..57ad917246f 100644 --- a/code/modules/integrated_electronics/core/integrated_circuit.dm +++ b/code/modules/integrated_electronics/core/integrated_circuit.dm @@ -24,7 +24,7 @@ var/category_text = "NO CATEGORY THIS IS A BUG" // To show up on circuit printer, and perhaps other places. var/removable = TRUE // Determines if a circuit is removable from the assembly. var/displayed_name = "" - + /* Integrated circuits are essentially modular machines. Each circuit has a specific function, and combining them inside Electronic Assemblies allows a creative player the means to solve many problems. Circuits are held inside an electronic assembly, and are wired using special tools. diff --git a/code/modules/integrated_electronics/core/printer.dm b/code/modules/integrated_electronics/core/printer.dm index 2cab5ad3b93..f8d1424160e 100644 --- a/code/modules/integrated_electronics/core/printer.dm +++ b/code/modules/integrated_electronics/core/printer.dm @@ -12,7 +12,6 @@ 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 // Timestamp for when to print the circuit var/recycling = FALSE // If an assembly is being emptied into this printer var/list/program // Currently loaded save, in form of list @@ -29,26 +28,22 @@ debug = TRUE upgraded = TRUE can_clone = TRUE + fast_clone = TRUE w_class = WEIGHT_CLASS_TINY /obj/item/integrated_circuit_printer/Initialize() . = ..() AddComponent(/datum/component/material_container, list(MAT_METAL), MINERAL_MATERIAL_AMOUNT * 25, TRUE, list(/obj/item/stack, /obj/item/integrated_circuit, /obj/item/electronic_assembly)) -/obj/item/integrated_circuit_printer/Destroy() - STOP_PROCESSING(SSprocessing, src) - return ..() - -/obj/item/integrated_circuit_printer/process() +/obj/item/integrated_circuit_printer/proc/print_program(mob/user) if(!cloning) - STOP_PROCESSING(SSprocessing, src) - if(world.time >= clone_countdown || fast_clone) - var/turf/T = get_turf(src) - T.visible_message("[src] has finished printing its assembly!") - playsound(get_turf(T), 'sound/items/poster_being_created.ogg', 50, TRUE) - SScircuit.load_electronic_assembly(T, program) - cloning = FALSE - STOP_PROCESSING(SSprocessing, src) + return + visible_message("[src] has finished printing its assembly!") + playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) + var/obj/item/electronic_assembly/assembly = SScircuit.load_electronic_assembly(get_turf(src), program) + assembly.creator = key_name(user) + assembly.investigate_log("was printed by [assembly.creator].", INVESTIGATE_CIRCUIT) + cloning = FALSE /obj/item/integrated_circuit_printer/attackby(obj/item/O, mob/user) if(istype(O, /obj/item/disk/integrated_circuit/upgrade/advanced)) @@ -141,7 +136,7 @@ if(!program) HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}" else if(cloning) - HTML += " {Cancel Print} - [DisplayTimeText(max(0, clone_countdown - world.time))] remaining until completion" + HTML += " {Cancel Print}" else HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}" @@ -206,6 +201,7 @@ if(istype(built, /obj/item/electronic_assembly)) var/obj/item/electronic_assembly/E = built + E.creator = key_name(usr) E.opened = TRUE E.update_icon() //reupdate diagnostic hud because it was put_in_hands() and not pickup()'ed @@ -213,6 +209,7 @@ E.diag_hud_set_circuitcell() E.diag_hud_set_circuitstat() E.diag_hud_set_circuittracking() + E.investigate_log("was printed by [E.creator].", INVESTIGATE_CIRCUIT) to_chat(usr, "[capitalize(built.name)] printed.") playsound(src, 'sound/items/jaws_pry.ogg', 50, TRUE) @@ -226,8 +223,10 @@ return switch(href_list["print"]) if("load") + if(cloning) + return var/input = input("Put your code there:", "loading", null, null) as message | null - if(!check_interactivity(usr)) + if(!check_interactivity(usr) || cloning) return if(!input) program = null @@ -254,7 +253,7 @@ to_chat(usr, "Metal cost: [program["metal_cost"]].") if("print") - if(!program) + if(!program || cloning) return if(program["requires_upgrades"] && !upgraded && !debug) @@ -263,12 +262,11 @@ if(program["unsupported_circuit"] && !debug) to_chat(usr, "This program uses components not supported by the specified assembly. Please change the assembly type in the save file to a supported one.") return - else if(fast_clone || debug) + else if(fast_clone) 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) - to_chat(usr, "[assembly] has been printed from the provided template!") - playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) + cloning = TRUE + print_program(usr) else to_chat(usr, "You need [program["metal_cost"]] metal to build that!") else @@ -279,11 +277,10 @@ var/cloning_time = round(program["metal_cost"] / 15) cloning_time = min(cloning_time, MAX_CIRCUIT_CLONE_TIME) cloning = TRUE - clone_countdown = world.time + cloning_time to_chat(usr, "You begin printing a custom assembly. This will take approximately [DisplayTimeText(cloning_time)]. You can still print \ off normal parts during this time.") playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) - START_PROCESSING(SSprocessing, src) + addtimer(CALLBACK(src, .proc/print_program, usr), cloning_time) if("cancel") if(!cloning || !program) @@ -291,7 +288,6 @@ to_chat(usr, "Cloning has been canceled. Metal cost has been refunded.") 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 diff --git a/code/modules/integrated_electronics/subtypes/output.dm b/code/modules/integrated_electronics/subtypes/output.dm index 2d820b016ee..354ca17b940 100644 --- a/code/modules/integrated_electronics/subtypes/output.dm +++ b/code/modules/integrated_electronics/subtypes/output.dm @@ -151,6 +151,8 @@ return vol = CLAMP(vol ,0 , 100) playsound(get_turf(src), selected_sound, vol, freq, -1) + if(assembly) + assembly.investigate_log("played a sound ([selected_sound]) with [type].", INVESTIGATE_CIRCUIT) /obj/item/integrated_circuit/output/sound/on_data_written() power_draw_per_use = get_pin_data(IC_INPUT, 2) * 15 @@ -234,8 +236,10 @@ text = get_pin_data(IC_INPUT, 1) if(!isnull(text)) var/atom/movable/A = get_object() - A.say(sanitize(text)) - + var/sanitized_text = sanitize(text) + A.say(sanitized_text) + if (assembly) + log_say("[assembly] [REF(assembly)] : [sanitized_text]") /obj/item/integrated_circuit/output/video_camera name = "video camera circuit"