From c77abe6979f01ee8ff946aa58bb648f42d0407ce Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sat, 4 May 2024 10:47:43 -0700 Subject: [PATCH 01/10] Edits ammo racks and moves them to their own DM file --- nsv13.dme | 1 + .../ballistic_weapons/revision2/ammo_rack.dm | 363 +++++++++++++++++ .../ballistic_weapons/revision2/automation.dm | 368 ------------------ .../designs/nsv_circuitboard_designs.dm | 19 + 4 files changed, 383 insertions(+), 368 deletions(-) create mode 100644 nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm diff --git a/nsv13.dme b/nsv13.dme index 2273da4cc7f..ee6ce024ce5 100644 --- a/nsv13.dme +++ b/nsv13.dme @@ -3978,6 +3978,7 @@ #include "nsv13\code\modules\munitions\ship_weapons\ballistic_weapons\railgun_construction.dm" #include "nsv13\code\modules\munitions\ship_weapons\ballistic_weapons\torpedo_launcher.dm" #include "nsv13\code\modules\munitions\ship_weapons\ballistic_weapons\torpedo_launcher_construction.dm" +#include "nsv13\code\modules\munitions\ship_weapons\ballistic_weapons\revision2\ammo_rack.dm" #include "nsv13\code\modules\munitions\ship_weapons\ballistic_weapons\revision2\automation.dm" #include "nsv13\code\modules\munitions\ship_weapons\ballistic_weapons\revision2\vls.dm" #include "nsv13\code\modules\munitions\ship_weapons\energy_weapons\bsa.dm" diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm new file mode 100644 index 00000000000..77b1408e0c5 --- /dev/null +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -0,0 +1,363 @@ +/** + * This file contains the ammo rack and ammo rack control console. + * Each rack is linked to a console, which allows for remote dispensation and management of the rack. + * Ammo racks can be loaded via hand, dragging, or bumping, and they can be maintained using oil. + */ + +// Ammo rack control console +/obj/machinery/computer/ammo_sorter + name = "ammo rack control console" + icon_screen = "ammorack" + circuit = /obj/item/circuitboard/computer/ammo_sorter + var/id = null + var/list/linked_sorters = list() + +/obj/machinery/computer/ammo_sorter/Initialize(mapload, obj/item/circuitboard/C) + . = ..() + if(mapload) + return INITIALIZE_HINT_LATELOAD + +/obj/machinery/computer/ammo_sorter/LateInitialize() + . = ..() + for(var/obj/machinery/ammo_sorter/W in GLOB.machines) + if(istype(W) && W.id == id) + linkSorter(W) + sortList(linked_sorters) //Alphabetise the list initially... + +/obj/machinery/computer/ammo_sorter/Destroy() + for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) + AS.linked_consoles -= src + . = ..() + +/obj/machinery/computer/ammo_sorter/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "AmmoSorter") + ui.open() + +/obj/machinery/computer/ammo_sorter/ui_act(action, params, datum/tgui/ui) + if(..()) + return + var/obj/machinery/ammo_sorter/AS = locate(params["id"]) + switch(action) + if("unload_all") + unload_all() + if("unload") + if(!AS) + return + AS.pop() + if("unlink") + if(!AS) + return + unlinkSorter(AS) + if("rename") + if(!AS) + return + var/new_name = stripped_input(usr, message="Enter a new name for [AS]", max_length=MAX_CHARTER_LEN) + + if(!new_name) + return + + AS.name = new_name + message_admins("[key_name(usr)] renamed an ammo rack to [new_name].") + log_game("[key_name(usr)] renamed an ammo rack to [new_name].") + if("moveup") + if(!AS) + return + var/id = linked_sorters.Find(AS) + if (id <= 1) + return + linked_sorters.Swap(id,id-1) + if("movedown") + if(!AS) + return + var/id = linked_sorters.Find(AS) + if (id >= linked_sorters.len) + return + linked_sorters.Swap(id,id+1) + // update UI + ui_interact(usr) + +/obj/machinery/computer/ammo_sorter/proc/unload_all() + for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) + AS.unload() + +/obj/machinery/computer/ammo_sorter/multitool_act(mob/living/user, obj/item/I) + if(!multitool_check_buffer(user, I)) + return TRUE + var/obj/item/multitool/M = I + M.buffer = src + to_chat(user, "You add [src] to [M]'s buffer.") + return TRUE + +/obj/machinery/computer/ammo_sorter/proc/linkSorter(var/obj/machinery/ammo_sorter/AS) + linked_sorters += AS + AS.linked_consoles += src + ui_update() + +/obj/machinery/computer/ammo_sorter/proc/unlinkSorter(var/obj/machinery/ammo_sorter/AS) + linked_sorters -= AS + AS.linked_consoles -= src + ui_update() + +/obj/machinery/computer/ammo_sorter/ui_data(mob/user) + . = ..() + var/list/data = list() + var/list/racks_info = list() + for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) + var/atom/what = null + var/loadedlen = length(AS.loaded) + if(loadedlen) + what = AS.loaded[loadedlen] + racks_info[++racks_info.len] = list("name"=AS.name, "has_loaded"=loadedlen > 0, "id"="\ref[AS]", "top"=(what ? what.name : "Nothing")) + data["racks_info"] = racks_info + return data + +// The ammo rack itself +/obj/machinery/ammo_sorter + name = "Ammo Rack" + desc = "A machine that allows you to compartmentalise your ship's ammo stores, controlled by a central console. Drag and drop items onto it to load them." + icon = 'nsv13/icons/obj/munitions.dmi' + icon_state = "ammorack" + circuit = /obj/item/circuitboard/machine/ammo_sorter + density = TRUE + anchored = TRUE + var/id = null + var/list/linked_consoles = list() //to help with unlinking after destruction + var/list/loaded = list() //What's loaded in? + var/max_capacity = 12 //Max cap for holding. + var/durability = 100 + var/max_durability = 100 + var/repair_multiplier = 10 // How many points of durability we repair per unit of oil + var/jammed = FALSE //if at 0 durability, jam it, handled in weardown(). + var/jamchance = 0 //probability to jam every weardown + var/busy = FALSE + +/obj/machinery/ammo_sorter/Initialize(mapload) + . = ..() + for(var/obj/item/I in get_turf(src)) + if(istype(I, /obj/item/ship_weapon/ammunition) || istype(I, /obj/item/powder_bag)) + load(I, force = TRUE) + +/obj/machinery/ammo_sorter/Exited(atom/movable/gone, direction) + . = ..() + loaded -= gone + +/obj/machinery/ammo_sorter/attackby(obj/item/I, mob/user, params) + if(default_unfasten_wrench(user, I)) + return + if(default_deconstruction_screwdriver(user, icon_state, icon_state, I)) + busy = FALSE // Just in case it gets stuck somehow, you can reset it + update_icon() + return + // Makes sure you can't accidentally decon a jammed machine + if(!jammed && default_deconstruction_crowbar(I)) + return + if(busy) + to_chat(user, "Someone's already working on [src]!") + return TRUE + if(panel_open && istype(I, /obj/item/reagent_containers)) + if(!jammed) + if(durability < 100) + if(I.reagents.has_reagent(/datum/reagent/oil)) + // get how much oil we have + var/oil_amount = min(I.reagents.get_reagent_amount(/datum/reagent/oil), max_durability/repair_multiplier) + var/oil_needed = CLAMP(ROUND_UP((max_durability-durability)/repair_multiplier), 1, oil_amount) + oil_amount = min(oil_amount, oil_needed) + to_chat(user, "You start lubricating the inner workings of [src]...") + busy = TRUE + if(!do_after(user, 5 SECONDS, target=src)) + busy = FALSE + return + if(!I.reagents.has_reagent(/datum/reagent/oil, oil_amount)) //things can change, check again. + to_chat(user, "You don't have enough oil left to lubricate [src]!") + busy = FALSE + return TRUE + to_chat(user, "You lubricate the inner workings of [src].") + durability = min(durability + (oil_amount * repair_multiplier), max_durability) + I.reagents.remove_reagent(/datum/reagent/oil, oil_amount) + busy = FALSE + return TRUE + else + to_chat(user, "You need oil to lubricate this!") + return TRUE + else + to_chat(user, "[src] doesn't need any oil right now!") + return TRUE + else + to_chat(user, "You can't lubricate a jammed machine!") + return TRUE + if(jammed && I.tool_behaviour == TOOL_CROWBAR) + if(!panel_open) + busy = TRUE + to_chat(user, "You begin clearing the jam...") + if(!do_after(user, 10 SECONDS, target=src)) + busy = FALSE + to_chat(user, "You were interrupted!") + return + to_chat(user, "You clear the jam with the crowbar.") + playsound(src, 'nsv13/sound/effects/ship/mac_load_unjam.ogg', 100, 1) + jammed = FALSE + durability += rand(0,5) //give the poor fools a few more uses if they're lucky + busy = FALSE + else + to_chat(user, "You need to close the panel to get at the jammed machinery.") + return TRUE + return ..() + +/obj/machinery/ammo_sorter/AltClick(mob/user) + . = ..() + setDir(turn(src.dir, -90)) + +/obj/machinery/ammo_sorter/ex_act(severity, target) + for(var/obj/item/X in loaded) + X.ex_act(severity, target) + . = ..() + +/obj/machinery/ammo_sorter/multitool_act(mob/living/user, obj/item/I) + var/obj/item/multitool/M = I + if(M.buffer && istype(M.buffer, /obj/machinery/computer/ammo_sorter)) + var/obj/machinery/computer/ammo_sorter/C = M.buffer + if(LAZYFIND(C.linked_sorters, src)) + to_chat(user, "This sorter is already linked to [C]!") + return TRUE + C.linkSorter(src) + to_chat(user, "You link [src] to [C].") + else + to_chat(user, "There is no control console in [M]'s buffer.") + return TRUE + +/obj/machinery/ammo_sorter/Destroy() + for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) + AS.linked_sorters -= src + AS.ui_update() + . = ..() + +/obj/machinery/ammo_sorter/examine(mob/user) + . = ..() + if(panel_open) + . += "It's maintenance panel is open, you could probably add some oil to lubricate it." //it didnt tell the players if this was the case before. + if(jammed) + . += "It's jammed shut." //if it's jammed, don't show durability. only thing they need to know is that it's jammed. + else + switch(durability) + if(71 to 100) + . += "It doesn't need any maintenance right now." + if(31 to 70) + . += "It might need some maintenance done soon." + if(11 to 30) + . += "It could really do with some maintenance." + if(0 to 10) + . += "It's completely wrecked." + . += "
It's currently holding [length(loaded)]/[max_capacity] items:" + if(length(loaded)) + var/listofitems = list() + for(var/obj/item/C in loaded) + var/path = C.type + if (listofitems[path]) + listofitems[path]["amount"]++ + else + listofitems[path] = list("name" = C.name, "amount" = 1) + for(var/i in listofitems) + . += "[listofitems[i]["name"]] x[listofitems[i]["amount"]]" + +/obj/machinery/ammo_sorter/RefreshParts() + max_capacity = 0 + for(var/obj/item/stock_parts/matter_bin/MB in component_parts) + max_capacity += MB.rating+3 + if(max_capacity < length(loaded)) + pop() + +/obj/machinery/ammo_sorter/MouseDrop_T(atom/movable/A, mob/user) + . = ..() + if(!isliving(user)) + return FALSE + //You can store any kind of ammo here for now. + if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) + to_chat(user, "You start to load [src] with [A].") + if(do_after(user, 2 SECONDS , target = src)) + load(A, user) + +/obj/machinery/ammo_sorter/Bumped(atom/movable/AM) + . = ..() + load(AM) //Try load + +/obj/machinery/ammo_sorter/proc/pop() + var/length = length(loaded) + if(length) + unload(loaded[length]) + +/obj/machinery/ammo_sorter/proc/unload(atom/movable/AM) + if(!loaded.len) + return FALSE + if(jammed) + return FALSE + else + playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) + flick("ammorack_dispense", src) + loaded -= AM + //Load it out the back. + AM.forceMove(get_turf(get_step(src, dir))) + weardown() + +/obj/machinery/ammo_sorter/proc/load(atom/movable/A, mob/user, force) + if(force && length(loaded) < max_capacity) + A.forceMove(src) + loaded += A + for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) + AS.ui_update() + return TRUE + if(length(loaded) >= max_capacity) + if(user) + to_chat(user, "[src] is full!") + return FALSE + if(jammed) + if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) + return FALSE + else + if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) + playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) + flick("ammorack_dispense", src) + A.forceMove(src) + loaded += A + weardown() + for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) + AS.ui_update() + return TRUE + else + return FALSE + +/obj/machinery/ammo_sorter/proc/weardown() + if(jammed) // we're already jammed, no + return + + if(durability > 0) //don't go under 0, that's bad + durability -= 1 //using it wears it down. + else + jammed = TRUE // if it's at 0, jam it. + durability = 0 // in case an admin plays with this and doesn't know how to use it, we reset it here for good measure. + + jamchance = CLAMP(-50*log(50, durability/50), 0, 100) //logarithmic function; at 50 it starts increasing from 0 + if(prob(jamchance) || jammed) + jammed = TRUE + + if(jammed) // Play a warning sound if the loader jams. + playsound(src, 'nsv13/sound/effects/ship/mac_load_jam.ogg', 100, 1) + +/obj/machinery/ammo_sorter/upgraded + circuit = /obj/item/circuitboard/machine/ammo_sorter/upgraded + max_capacity = 21 + +// Circuits for ammunition sorters +/obj/item/circuitboard/computer/ammo_sorter + name = "ammo sorter console (circuitboard)" + build_path = /obj/machinery/computer/ammo_sorter + +/obj/item/circuitboard/machine/ammo_sorter + name = "ammo sorter (circuitboard)" + req_components = list(/obj/item/stock_parts/matter_bin = 3) + build_path = /obj/machinery/ammo_sorter + needs_anchored = FALSE + +/obj/item/circuitboard/machine/ammo_sorter/upgraded + def_components = list(/obj/item/stock_parts/matter_bin = /obj/item/stock_parts/matter_bin/bluespace) //item capacity of 21 (12+9) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm index 6c8ef2f73e1..5a45349d2e8 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/automation.dm @@ -305,371 +305,3 @@ for(var/obj/item/ship_weapon/parts/missile/P in A) P.forceMove(src) held_components += P - -/datum/design/board/ammo_sorter_computer - name = "Ammo sorter console (circuitboard)" - desc = "The central control console for ammo sorters.." - id = "ammo_sorter_computer" - materials = list(/datum/material/glass = 2000, /datum/material/copper = 1000, /datum/material/gold = 500) - build_path = /obj/item/circuitboard/computer/ammo_sorter - category = list("Advanced Munitions") - departmental_flags = DEPARTMENTAL_FLAG_MUNITIONS - -/datum/design/board/ammo_sorter - name = "Ammo sorter (circuitboard)" - desc = "A helpful storage unit that allows for mass storage of ammunition, with the ability to retrieve it all from a central console." - id = "ammo_sorter" - materials = list(/datum/material/glass = 2000, /datum/material/copper = 1000, /datum/material/gold = 500) - build_path = /obj/item/circuitboard/machine/ammo_sorter - category = list("Advanced Munitions") - departmental_flags = DEPARTMENTAL_FLAG_MUNITIONS - -/obj/item/circuitboard/computer/ammo_sorter - name = "ammo sorter console (circuitboard)" - build_path = /obj/machinery/computer/ammo_sorter - -/obj/item/circuitboard/machine/ammo_sorter - name = "ammo sorter (circuitboard)" - req_components = list(/obj/item/stock_parts/matter_bin = 3) - build_path = /obj/machinery/ammo_sorter - needs_anchored = FALSE - -/obj/item/circuitboard/machine/ammo_sorter/upgraded - def_components = list(/obj/item/stock_parts/matter_bin = /obj/item/stock_parts/matter_bin/bluespace) //item capacity of 21 (12+9) - -/obj/machinery/computer/ammo_sorter - name = "ammo rack control console" - icon_screen = "ammorack" - circuit = /obj/item/circuitboard/computer/ammo_sorter - var/id = null - var/list/linked_sorters = list() - -/obj/machinery/computer/ammo_sorter/Initialize(mapload, obj/item/circuitboard/C) - . = ..() - if(mapload) - return INITIALIZE_HINT_LATELOAD - -/obj/machinery/computer/ammo_sorter/LateInitialize() - . = ..() - for(var/obj/machinery/ammo_sorter/W in GLOB.machines) - if(istype(W) && W.id == id) - linkSorter(W) - sortList(linked_sorters) //Alphabetise the list initially... - -/obj/machinery/computer/ammo_sorter/ui_interact(mob/user, datum/tgui/ui) - ui = SStgui.try_update_ui(user, src, ui) - if(!ui) - ui = new(user, src, "AmmoSorter") - ui.open() - -/obj/machinery/computer/ammo_sorter/ui_act(action, params, datum/tgui/ui) - if(..()) - return - var/obj/machinery/ammo_sorter/AS = locate(params["id"]) - switch(action) - if("unload_all") - unload_all() - if("unload") - if(!AS) - return - AS.pop() - if("unlink") - if(!AS) - return - unlinkSorter(AS) - if("rename") - if(!AS) - return - var/new_name = stripped_input(usr, message="Enter a new name for [AS]", max_length=MAX_CHARTER_LEN) - - if(!new_name) - return - - AS.name = new_name - message_admins("[key_name(usr)] renamed an ammo rack to [new_name].") - log_game("[key_name(usr)] renamed an ammo rack to [new_name].") - if("moveup") - if(!AS) - return - var/id = linked_sorters.Find(AS) - if (id <= 1) - return - linked_sorters.Swap(id,id-1) - if("movedown") - if(!AS) - return - var/id = linked_sorters.Find(AS) - if (id >= linked_sorters.len) - return - linked_sorters.Swap(id,id+1) - // update UI - ui_interact(usr) - -/obj/machinery/computer/ammo_sorter/proc/unload_all() - for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) - AS.unload() - -/obj/machinery/computer/ammo_sorter/proc/linkSorter(var/obj/machinery/ammo_sorter/AS) - linked_sorters += AS - AS.linked_consoles += src - ui_update() - -/obj/machinery/computer/ammo_sorter/proc/unlinkSorter(var/obj/machinery/ammo_sorter/AS) - linked_sorters -= AS - AS.linked_consoles -= src - ui_update() - -/obj/machinery/computer/ammo_sorter/ui_data(mob/user) - . = ..() - var/list/data = list() - var/list/racks_info = list() - for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) - var/atom/what = null - var/loadedlen = length(AS.loaded) - if(loadedlen) - what = AS.loaded[loadedlen] - racks_info[++racks_info.len] = list("name"=AS.name, "has_loaded"=loadedlen > 0, "id"="\ref[AS]", "top"=(what ? what.name : "Nothing")) - data["racks_info"] = racks_info - return data - -/obj/machinery/ammo_sorter - name = "Ammo Rack" - desc = "A machine that allows you to compartmentalise your ship's ammo stores, controlled by a central console. Drag and drop items onto it to load them." - icon = 'nsv13/icons/obj/munitions.dmi' - icon_state = "ammorack" - circuit = /obj/item/circuitboard/machine/ammo_sorter - density = TRUE - anchored = TRUE - var/id = null - var/list/linked_consoles = list() //to help with unlinking after destruction - var/list/loaded = list() //What's loaded in? - var/max_capacity = 12 //Max cap for holding. - var/loading = FALSE - var/durability = 100 - var/max_durability = 100 - var/repair_multiplier = 10 // How many points of durability we repair per unit of oil - var/jammed = FALSE //if at 0 durability, jam it, handled in weardown(). - var/jamchance = 0 //probability to jam every weardown - var/busy = FALSE - -/obj/machinery/ammo_sorter/attackby(obj/item/I, mob/user, params) - if(default_unfasten_wrench(user, I)) - return - if(default_deconstruction_screwdriver(user, icon_state, icon_state, I)) - busy = FALSE // Just in case it gets stuck somehow, you can reset it - update_icon() - return - if(default_deconstruction_crowbar(I)) - return - if(busy) - to_chat(user, "Someone's already working on [src]!") - return TRUE - if(panel_open && istype(I, /obj/item/reagent_containers)) - if(!jammed) - if(durability < 100) - if(I.reagents.has_reagent(/datum/reagent/oil)) - // get how much oil we have - var/oil_amount = min(I.reagents.get_reagent_amount(/datum/reagent/oil), max_durability/repair_multiplier) - var/oil_needed = CLAMP(round((max_durability-durability)/repair_multiplier), 1, oil_amount) - oil_amount = min(oil_amount, oil_needed) - to_chat(user, "You start lubricating the inner workings of [src]...") - busy = TRUE - if(!do_after(user, 5 SECONDS, target=src)) - busy = FALSE - return - if(!I.reagents.has_reagent(/datum/reagent/oil, oil_amount)) //things can change, check again. - to_chat(user, "You don't have enough oil left to lubricate [src]!") - busy = FALSE - return TRUE - to_chat(user, "You lubricate the inner workings of [src].") - durability = min(durability + (oil_amount * repair_multiplier), max_durability) - I.reagents.remove_reagent(/datum/reagent/oil, oil_amount) - busy = FALSE - return TRUE - else - to_chat(user, "You need oil to lubricate this!") - return TRUE - else - to_chat(user, "[src] doesn't need any oil right now!") - return TRUE - else - to_chat(user, "You can't lubricate a jammed machine!") - return TRUE - if(jammed && I.tool_behaviour == TOOL_CROWBAR) - if(!panel_open) - busy = TRUE - to_chat(user, "You begin clearing the jam...") - if(!do_after(user, 10 SECONDS, target=src)) - busy = FALSE - return - to_chat(user, "You clear the jam with the crowbar.") - playsound(src, 'nsv13/sound/effects/ship/mac_load_unjam.ogg', 100, 1) - jammed = FALSE - durability += rand(0,5) //give the poor fools a few more uses if they're lucky - busy = FALSE - else - to_chat(user, "You need to close the panel to get at the jammed machinery.") - return TRUE - return ..() - -/obj/machinery/ammo_sorter/AltClick(mob/user) - . = ..() - setDir(turn(src.dir, -90)) - -/obj/machinery/ammo_sorter/ex_act(severity, target) - for(var/obj/item/X in loaded) - X.ex_act(severity, target) - . = ..() - -/obj/machinery/ammo_sorter/Initialize(mapload) - . = ..() - for(var/obj/item/I in get_turf(src)) - if(istype(I, /obj/item/ship_weapon/ammunition) || istype(I, /obj/item/powder_bag)) - load(I, force = TRUE) - -/obj/machinery/ammo_sorter/multitool_act(mob/living/user, obj/item/I) - var/obj/item/multitool/M = I - if(M.buffer && istype(M.buffer, /obj/machinery/computer/ammo_sorter)) - var/obj/machinery/computer/ammo_sorter/C = M.buffer - if(LAZYFIND(C.linked_sorters, src)) - to_chat(user, "This sorter is already linked to [C]...") - return TRUE - C.linkSorter(src) - to_chat(user, "You've linked [src] to [C]...") - else - to_chat(user, "There is no control console in [M]'s buffer.") - return TRUE - -/obj/machinery/computer/ammo_sorter/multitool_act(mob/living/user, obj/item/I) - if(!multitool_check_buffer(user, I)) - return TRUE - var/obj/item/multitool/M = I - M.buffer = src - to_chat(user, "You add [src] to [M]'s buffer.") - return TRUE - -/obj/machinery/computer/ammo_sorter/Destroy() - for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) - AS.linked_consoles -= src - . = ..() - -/obj/machinery/ammo_sorter/Destroy() - for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) - AS.linked_sorters -= src - AS.ui_update() - . = ..() - -/obj/machinery/ammo_sorter/examine(mob/user) - . = ..() - if(panel_open) - . += "Its maintenance panel is open, you could probably add some oil to lubricate it." //it didnt tell the players if this was the case before. - if(jammed) - . += "It's jammed shut." //if it's jammed, don't show durability. only thing they need to know is that it's jammed. - else - switch(durability) - if(71 to 100) - . += "It doesn't need any maintenance right now." - if(31 to 70) - . += "It might need some maintenance done soon." - if(11 to 30) - . += "It could really do with some maintenance." - if(0 to 10) - . += "It's completely wrecked." - . += "
It's currently holding [loaded.len]/[max_capacity] items:" - if(loaded.len) - var/listofitems = list() - for(var/obj/item/C in loaded) - var/path = C.type - if (listofitems[path]) - listofitems[path]["amount"]++ - else - listofitems[path] = list("name" = C.name, "amount" = 1) - for(var/i in listofitems) - . += "[listofitems[i]["name"]] x[listofitems[i]["amount"]]" - -/obj/machinery/ammo_sorter/RefreshParts() - max_capacity = 0 - for(var/obj/item/stock_parts/matter_bin/MB in component_parts) - max_capacity += MB.rating+3 - if(max_capacity < length(loaded)) - pop() - -/obj/machinery/ammo_sorter/MouseDrop_T(atom/movable/A, mob/user) - . = ..() - if(!isliving(user)) - return FALSE - //You can store any kind of ammo here for now. - if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) - to_chat(user, "You start to load [src] with [A]") - if(do_after(user, 2 SECONDS , target = src)) - load(A, user) - -/obj/machinery/ammo_sorter/Bumped(atom/movable/AM) - . = ..() - load(AM) //Try load - -/obj/machinery/ammo_sorter/proc/pop() - var/length = length(loaded) - if(length) - unload(loaded[length]) - -/obj/machinery/ammo_sorter/proc/unload(atom/movable/AM) - if(!loaded.len) - return FALSE - if(jammed) - playsound(src, 'nsv13/sound/effects/ship/mac_load_jam.ogg', 100, 1) - return FALSE - else - playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) - flick("ammorack_dispense", src) - loaded -= AM - //Load it out the back. - AM.forceMove(get_turf(get_step(src, dir))) - weardown() - - -/obj/machinery/ammo_sorter/proc/load(atom/movable/A, mob/user, force) - if(force && length(loaded) < max_capacity) - A.forceMove(src) - loaded += A - for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) - AS.ui_update() - return TRUE - if(length(loaded) >= max_capacity) - if(user) - to_chat(user, "[src] is full!") - loading = FALSE - return FALSE - if(jammed) - if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) - playsound(src, 'nsv13/sound/effects/ship/mac_load_jam.ogg', 100, 1) - loading = FALSE - return FALSE - else - if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) - playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) - flick("ammorack_dispense", src) - A.forceMove(src) - loading = FALSE - loaded += A - weardown() - for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) - AS.ui_update() - return TRUE - else - loading = FALSE - return FALSE - -/obj/machinery/ammo_sorter/proc/weardown() - if(durability > 0) //don't go under 0, that's bad - durability -= 1 //using it wears it down. - else - jammed = TRUE // if it's at 0, jam it. - durability = 0 // in case an admin plays with this and doesn't know how to use it, we reset it here for good measure. - jamchance = CLAMP(-50*log(50, durability/50), 0, 100) //logarithmic function; at 50 it starts increasing from 0 - if(prob(jamchance)) - jammed = TRUE - -/obj/machinery/ammo_sorter/upgraded - circuit = /obj/item/circuitboard/machine/ammo_sorter/upgraded - max_capacity = 21 diff --git a/nsv13/code/modules/research/designs/nsv_circuitboard_designs.dm b/nsv13/code/modules/research/designs/nsv_circuitboard_designs.dm index fe3d9edd61b..9f4fd686b8d 100644 --- a/nsv13/code/modules/research/designs/nsv_circuitboard_designs.dm +++ b/nsv13/code/modules/research/designs/nsv_circuitboard_designs.dm @@ -130,3 +130,22 @@ build_path = /obj/item/circuitboard/machine/navbeacon category = list ("Research Machinery") departmental_flags = DEPARTMENTAL_FLAG_SCIENCE | DEPARTMENTAL_FLAG_ENGINEERING + +// Ammo sorter circuit designs +/datum/design/board/ammo_sorter_computer + name = "Ammo sorter console (circuitboard)" + desc = "The central control console for ammo sorters.." + id = "ammo_sorter_computer" + materials = list(/datum/material/glass = 2000, /datum/material/copper = 1000, /datum/material/gold = 500) + build_path = /obj/item/circuitboard/computer/ammo_sorter + category = list("Advanced Munitions") + departmental_flags = DEPARTMENTAL_FLAG_MUNITIONS + +/datum/design/board/ammo_sorter + name = "Ammo sorter (circuitboard)" + desc = "A helpful storage unit that allows for mass storage of ammunition, with the ability to retrieve it all from a central console." + id = "ammo_sorter" + materials = list(/datum/material/glass = 2000, /datum/material/copper = 1000, /datum/material/gold = 500) + build_path = /obj/item/circuitboard/machine/ammo_sorter + category = list("Advanced Munitions") + departmental_flags = DEPARTMENTAL_FLAG_MUNITIONS From ee6f0128a3ffde7f54b5a44842a54a78f1429a82 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sat, 4 May 2024 12:07:18 -0700 Subject: [PATCH 02/10] Updates weardown proc --- .../ballistic_weapons/revision2/ammo_rack.dm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index 77b1408e0c5..0d2f9ec0b10 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -328,20 +328,21 @@ return FALSE /obj/machinery/ammo_sorter/proc/weardown() - if(jammed) // we're already jammed, no + if(jammed) return - if(durability > 0) //don't go under 0, that's bad - durability -= 1 //using it wears it down. - else - jammed = TRUE // if it's at 0, jam it. - durability = 0 // in case an admin plays with this and doesn't know how to use it, we reset it here for good measure. + // Subtract durability + if(durability > 0) + durability -= 1 - jamchance = CLAMP(-50*log(50, durability/50), 0, 100) //logarithmic function; at 50 it starts increasing from 0 - if(prob(jamchance) || jammed) + // see if we're going to jam + jamchance = (durability > 0 ? CLAMP(-50*log(50, durability/50), 0, 100) : 100) + if(prob(jamchance)) jammed = TRUE + durability = 0 - if(jammed) // Play a warning sound if the loader jams. + // Play a warning sound if the loader jams. + if(jammed) playsound(src, 'nsv13/sound/effects/ship/mac_load_jam.ogg', 100, 1) /obj/machinery/ammo_sorter/upgraded From 8f7fd5aa322c7b3749e6a95512a9c7189787229e Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sat, 4 May 2024 12:28:24 -0700 Subject: [PATCH 03/10] Adds a message and updates some organization --- .../ballistic_weapons/revision2/ammo_rack.dm | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index 0d2f9ec0b10..29d37854312 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -45,7 +45,8 @@ if("unload") if(!AS) return - AS.pop() + if(!AS.pop()) + to_chat(usr, "[src] displays an error message!") if("unlink") if(!AS) return @@ -78,6 +79,19 @@ // update UI ui_interact(usr) +/obj/machinery/computer/ammo_sorter/ui_data(mob/user) + . = ..() + var/list/data = list() + var/list/racks_info = list() + for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) + var/atom/what = null + var/loadedlen = length(AS.loaded) + if(loadedlen) + what = AS.loaded[loadedlen] + racks_info[++racks_info.len] = list("name"=AS.name, "has_loaded"=loadedlen > 0, "id"="\ref[AS]", "top"=(what ? what.name : "Nothing")) + data["racks_info"] = racks_info + return data + /obj/machinery/computer/ammo_sorter/proc/unload_all() for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) AS.unload() @@ -100,19 +114,6 @@ AS.linked_consoles -= src ui_update() -/obj/machinery/computer/ammo_sorter/ui_data(mob/user) - . = ..() - var/list/data = list() - var/list/racks_info = list() - for(var/obj/machinery/ammo_sorter/AS as() in linked_sorters) - var/atom/what = null - var/loadedlen = length(AS.loaded) - if(loadedlen) - what = AS.loaded[loadedlen] - racks_info[++racks_info.len] = list("name"=AS.name, "has_loaded"=loadedlen > 0, "id"="\ref[AS]", "top"=(what ? what.name : "Nothing")) - data["racks_info"] = racks_info - return data - // The ammo rack itself /obj/machinery/ammo_sorter name = "Ammo Rack" @@ -285,20 +286,22 @@ /obj/machinery/ammo_sorter/proc/pop() var/length = length(loaded) if(length) - unload(loaded[length]) + return unload(loaded[length]) + return FALSE /obj/machinery/ammo_sorter/proc/unload(atom/movable/AM) if(!loaded.len) return FALSE if(jammed) return FALSE - else - playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) - flick("ammorack_dispense", src) - loaded -= AM - //Load it out the back. - AM.forceMove(get_turf(get_step(src, dir))) - weardown() + // do visuals/sound + playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) + flick("ammorack_dispense", src) + //Load it out the back. + loaded -= AM + AM.forceMove(get_turf(get_step(src, dir))) + weardown() + return TRUE /obj/machinery/ammo_sorter/proc/load(atom/movable/A, mob/user, force) if(force && length(loaded) < max_capacity) @@ -311,21 +314,16 @@ if(user) to_chat(user, "[src] is full!") return FALSE - if(jammed) - if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) - return FALSE - else - if(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag)) - playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) - flick("ammorack_dispense", src) - A.forceMove(src) - loaded += A - weardown() - for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) - AS.ui_update() - return TRUE - else - return FALSE + if(jammed || !(istype(A, /obj/item/ship_weapon/ammunition) || istype(A, /obj/item/powder_bag))) + return FALSE + playsound(src, 'nsv13/sound/effects/ship/mac_load.ogg', 100, 1) + flick("ammorack_dispense", src) + A.forceMove(src) + loaded += A + weardown() + for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) + AS.ui_update() + return TRUE /obj/machinery/ammo_sorter/proc/weardown() if(jammed) From 5c68fee7abe5375d7fc93f9b9bf5f22fb140ea9e Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sat, 4 May 2024 22:58:24 -0700 Subject: [PATCH 04/10] Removes some nested if chains --- .../ballistic_weapons/revision2/ammo_rack.dm | 98 +++++++++---------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index 29d37854312..224f63c0332 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -131,7 +131,6 @@ var/max_durability = 100 var/repair_multiplier = 10 // How many points of durability we repair per unit of oil var/jammed = FALSE //if at 0 durability, jam it, handled in weardown(). - var/jamchance = 0 //probability to jam every weardown var/busy = FALSE /obj/machinery/ammo_sorter/Initialize(mapload) @@ -158,51 +157,48 @@ to_chat(user, "Someone's already working on [src]!") return TRUE if(panel_open && istype(I, /obj/item/reagent_containers)) - if(!jammed) - if(durability < 100) - if(I.reagents.has_reagent(/datum/reagent/oil)) - // get how much oil we have - var/oil_amount = min(I.reagents.get_reagent_amount(/datum/reagent/oil), max_durability/repair_multiplier) - var/oil_needed = CLAMP(ROUND_UP((max_durability-durability)/repair_multiplier), 1, oil_amount) - oil_amount = min(oil_amount, oil_needed) - to_chat(user, "You start lubricating the inner workings of [src]...") - busy = TRUE - if(!do_after(user, 5 SECONDS, target=src)) - busy = FALSE - return - if(!I.reagents.has_reagent(/datum/reagent/oil, oil_amount)) //things can change, check again. - to_chat(user, "You don't have enough oil left to lubricate [src]!") - busy = FALSE - return TRUE - to_chat(user, "You lubricate the inner workings of [src].") - durability = min(durability + (oil_amount * repair_multiplier), max_durability) - I.reagents.remove_reagent(/datum/reagent/oil, oil_amount) - busy = FALSE - return TRUE - else - to_chat(user, "You need oil to lubricate this!") - return TRUE - else - to_chat(user, "[src] doesn't need any oil right now!") - return TRUE - else + if(jammed) to_chat(user, "You can't lubricate a jammed machine!") return TRUE - if(jammed && I.tool_behaviour == TOOL_CROWBAR) - if(!panel_open) - busy = TRUE - to_chat(user, "You begin clearing the jam...") - if(!do_after(user, 10 SECONDS, target=src)) - busy = FALSE - to_chat(user, "You were interrupted!") - return - to_chat(user, "You clear the jam with the crowbar.") - playsound(src, 'nsv13/sound/effects/ship/mac_load_unjam.ogg', 100, 1) - jammed = FALSE - durability += rand(0,5) //give the poor fools a few more uses if they're lucky + if(durability >= 100) + to_chat(user, "[src] doesn't need any oil right now!") + return TRUE + if(!I.reagents.has_reagent(/datum/reagent/oil)) + to_chat(user, "You need oil to lubricate this!") + return TRUE + // get how much oil we have + var/oil_amount = min(I.reagents.get_reagent_amount(/datum/reagent/oil), max_durability/repair_multiplier) + var/oil_needed = CLAMP(ROUND_UP((max_durability-durability)/repair_multiplier), 1, oil_amount) + oil_amount = min(oil_amount, oil_needed) + to_chat(user, "You start lubricating the inner workings of [src]...") + busy = TRUE + if(!do_after(user, 5 SECONDS, target=src)) + busy = FALSE + to_chat(user, "You were interrupted!") + return TRUE + if(!I.reagents.has_reagent(/datum/reagent/oil, oil_amount)) //things can change, check again. + to_chat(user, "You don't have enough oil left to lubricate [src]!") busy = FALSE - else + return TRUE + to_chat(user, "You lubricate the inner workings of [src].") + durability = min(durability + (oil_amount * repair_multiplier), max_durability) + I.reagents.remove_reagent(/datum/reagent/oil, oil_amount) + busy = FALSE + return TRUE + if(jammed && I.tool_behaviour == TOOL_CROWBAR) + if(panel_open) to_chat(user, "You need to close the panel to get at the jammed machinery.") + busy = TRUE + to_chat(user, "You begin clearing the jam...") + if(!do_after(user, 10 SECONDS, target=src)) + busy = FALSE + to_chat(user, "You were interrupted!") + return TRUE + to_chat(user, "You clear the jam with the crowbar.") + playsound(src, 'nsv13/sound/effects/ship/mac_load_unjam.ogg', 100, 1) + jammed = FALSE + durability += rand(0,5) //give the poor fools a few more uses if they're lucky + busy = FALSE return TRUE return ..() @@ -217,15 +213,15 @@ /obj/machinery/ammo_sorter/multitool_act(mob/living/user, obj/item/I) var/obj/item/multitool/M = I - if(M.buffer && istype(M.buffer, /obj/machinery/computer/ammo_sorter)) - var/obj/machinery/computer/ammo_sorter/C = M.buffer - if(LAZYFIND(C.linked_sorters, src)) - to_chat(user, "This sorter is already linked to [C]!") - return TRUE - C.linkSorter(src) - to_chat(user, "You link [src] to [C].") - else + if(!(M.buffer && istype(M.buffer, /obj/machinery/computer/ammo_sorter))) to_chat(user, "There is no control console in [M]'s buffer.") + return TRUE + var/obj/machinery/computer/ammo_sorter/C = M.buffer + if(LAZYFIND(C.linked_sorters, src)) + to_chat(user, "This sorter is already linked to [C]!") + return TRUE + C.linkSorter(src) + to_chat(user, "You link [src] to [C].") return TRUE /obj/machinery/ammo_sorter/Destroy() @@ -334,7 +330,7 @@ durability -= 1 // see if we're going to jam - jamchance = (durability > 0 ? CLAMP(-50*log(50, durability/50), 0, 100) : 100) + var/jamchance = (durability > 0 ? CLAMP(-50*log(50, durability/50), 0, 100) : 100) if(prob(jamchance)) jammed = TRUE durability = 0 From a1711a35472a5b17b6bf837054890561feb64c35 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sun, 5 May 2024 12:24:40 -0700 Subject: [PATCH 05/10] Updates messages and adds an attack check --- .../ballistic_weapons/revision2/ammo_rack.dm | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index 224f63c0332..e35b9fde3b9 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -142,6 +142,8 @@ /obj/machinery/ammo_sorter/Exited(atom/movable/gone, direction) . = ..() loaded -= gone + for(var/obj/machinery/computer/ammo_sorter/AS as() in linked_consoles) + AS.ui_update() /obj/machinery/ammo_sorter/attackby(obj/item/I, mob/user, params) if(default_unfasten_wrench(user, I)) @@ -153,6 +155,9 @@ // Makes sure you can't accidentally decon a jammed machine if(!jammed && default_deconstruction_crowbar(I)) return + // Smacking + if(user.a_intent == INTENT_HARM) + return if(busy) to_chat(user, "Someone's already working on [src]!") return TRUE @@ -170,7 +175,8 @@ var/oil_amount = min(I.reagents.get_reagent_amount(/datum/reagent/oil), max_durability/repair_multiplier) var/oil_needed = CLAMP(ROUND_UP((max_durability-durability)/repair_multiplier), 1, oil_amount) oil_amount = min(oil_amount, oil_needed) - to_chat(user, "You start lubricating the inner workings of [src]...") + visible_message("[user] begins lubricating [src]...", \ + "You start lubricating the inner workings of [src]...") busy = TRUE if(!do_after(user, 5 SECONDS, target=src)) busy = FALSE @@ -180,7 +186,8 @@ to_chat(user, "You don't have enough oil left to lubricate [src]!") busy = FALSE return TRUE - to_chat(user, "You lubricate the inner workings of [src].") + visible_message("[user] lubricates [src].", \ + "You lubricate the inner workings of [src].") durability = min(durability + (oil_amount * repair_multiplier), max_durability) I.reagents.remove_reagent(/datum/reagent/oil, oil_amount) busy = FALSE @@ -188,18 +195,27 @@ if(jammed && I.tool_behaviour == TOOL_CROWBAR) if(panel_open) to_chat(user, "You need to close the panel to get at the jammed machinery.") + return TRUE busy = TRUE - to_chat(user, "You begin clearing the jam...") + visible_message("[user] begins clearing the jam in [src].", \ + "You being clearing the jam in [src].") if(!do_after(user, 10 SECONDS, target=src)) busy = FALSE to_chat(user, "You were interrupted!") return TRUE - to_chat(user, "You clear the jam with the crowbar.") + visible_message("[user] clears the jam in [src].", \ + "You clear the jam in [src].") playsound(src, 'nsv13/sound/effects/ship/mac_load_unjam.ogg', 100, 1) jammed = FALSE durability += rand(0,5) //give the poor fools a few more uses if they're lucky busy = FALSE return TRUE + if(istype(I, /obj/item/ship_weapon/ammunition) || istype(I, /obj/item/powder_bag)) + to_chat(user, "You start to load [src] with [I].") + if(!do_after(user, 1 SECONDS , target = src)) + to_chat(user, "You were interrupted!") + return TRUE + load(I, user) return ..() /obj/machinery/ammo_sorter/AltClick(mob/user) From 2fad913a4e187691ebb20e73a80ba5dda471df62 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sun, 5 May 2024 15:10:05 -0700 Subject: [PATCH 06/10] Fixes a visible_message thing --- .../ship_weapons/ballistic_weapons/revision2/ammo_rack.dm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index e35b9fde3b9..ffbd8e0e77e 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -175,7 +175,7 @@ var/oil_amount = min(I.reagents.get_reagent_amount(/datum/reagent/oil), max_durability/repair_multiplier) var/oil_needed = CLAMP(ROUND_UP((max_durability-durability)/repair_multiplier), 1, oil_amount) oil_amount = min(oil_amount, oil_needed) - visible_message("[user] begins lubricating [src]...", \ + user.visible_message("[user] begins lubricating [src]...", \ "You start lubricating the inner workings of [src]...") busy = TRUE if(!do_after(user, 5 SECONDS, target=src)) @@ -186,7 +186,7 @@ to_chat(user, "You don't have enough oil left to lubricate [src]!") busy = FALSE return TRUE - visible_message("[user] lubricates [src].", \ + user.visible_message("[user] lubricates [src].", \ "You lubricate the inner workings of [src].") durability = min(durability + (oil_amount * repair_multiplier), max_durability) I.reagents.remove_reagent(/datum/reagent/oil, oil_amount) @@ -197,13 +197,13 @@ to_chat(user, "You need to close the panel to get at the jammed machinery.") return TRUE busy = TRUE - visible_message("[user] begins clearing the jam in [src].", \ + user.visible_message("[user] begins clearing the jam in [src].", \ "You being clearing the jam in [src].") if(!do_after(user, 10 SECONDS, target=src)) busy = FALSE to_chat(user, "You were interrupted!") return TRUE - visible_message("[user] clears the jam in [src].", \ + user.visible_message("[user] clears the jam in [src].", \ "You clear the jam in [src].") playsound(src, 'nsv13/sound/effects/ship/mac_load_unjam.ogg', 100, 1) jammed = FALSE From a872a78f8e68ea21c9e9fb2fbf3f359d41a5fd69 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sun, 5 May 2024 15:25:20 -0700 Subject: [PATCH 07/10] Adds a return --- .../ship_weapons/ballistic_weapons/revision2/ammo_rack.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index ffbd8e0e77e..2d88f3253e9 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -216,6 +216,7 @@ to_chat(user, "You were interrupted!") return TRUE load(I, user) + return TRUE return ..() /obj/machinery/ammo_sorter/AltClick(mob/user) From 73d3adfde6507c05e1fc266ecead07fbe7a832f6 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Sun, 5 May 2024 17:01:44 -0700 Subject: [PATCH 08/10] A change --- .../ship_weapons/ballistic_weapons/revision2/ammo_rack.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index 2d88f3253e9..3a3534ba651 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -212,7 +212,7 @@ return TRUE if(istype(I, /obj/item/ship_weapon/ammunition) || istype(I, /obj/item/powder_bag)) to_chat(user, "You start to load [src] with [I].") - if(!do_after(user, 1 SECONDS , target = src)) + if(!do_after(user, 0.5 SECONDS , target = src)) to_chat(user, "You were interrupted!") return TRUE load(I, user) From 2f5d4c508befb21313698491b16efb39e2624fe1 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Mon, 6 May 2024 22:50:58 -0700 Subject: [PATCH 09/10] Oops, dropped that --- .../ship_weapons/ballistic_weapons/revision2/ammo_rack.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index 3a3534ba651..b8c6293b5b3 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -157,7 +157,7 @@ return // Smacking if(user.a_intent == INTENT_HARM) - return + return ..() if(busy) to_chat(user, "Someone's already working on [src]!") return TRUE From 0f5e365cf07f6e136e6325eb6161403fa2b7e451 Mon Sep 17 00:00:00 2001 From: benbot16 <9423435+benbot16@users.noreply.github.com> Date: Mon, 6 May 2024 22:52:52 -0700 Subject: [PATCH 10/10] Improves a thing very slightly --- .../ship_weapons/ballistic_weapons/revision2/ammo_rack.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm index b8c6293b5b3..7a8f1c019cc 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/revision2/ammo_rack.dm @@ -165,7 +165,7 @@ if(jammed) to_chat(user, "You can't lubricate a jammed machine!") return TRUE - if(durability >= 100) + if(durability >= max_durability) to_chat(user, "[src] doesn't need any oil right now!") return TRUE if(!I.reagents.has_reagent(/datum/reagent/oil))