From b89385144adeee5bb89469f3b0884c8989ef2199 Mon Sep 17 00:00:00 2001 From: Artorp Date: Tue, 17 Feb 2015 17:27:42 +0100 Subject: [PATCH 1/2] Added queue functionality to the autolathe --- code/game/machinery/autolathe.dm | 285 ++++++++++++++++++++++--------- 1 file changed, 203 insertions(+), 82 deletions(-) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 143853269dc..37610ddadc6 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -15,6 +15,9 @@ var/max_g_amount = 75000.0 var/operating = 0.0 + var/list/queue = list() + var/queue_max_len = 10 + var/turf/BuildTurf anchored = 1.0 var/list/L = list() var/list/LL = list() @@ -92,7 +95,7 @@ if(AUTOLATHE_SEARCH_MENU) dat = search_win(user) - var/datum/browser/popup = new(user, "autolathe", name, 500, 500) + var/datum/browser/popup = new(user, "autolathe", name, 800, 500) popup.set_content(dat) popup.open() @@ -151,7 +154,7 @@ flick("autolathe_r",src)//plays glass insertion animation stack.use(amount) else - if(!user.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" @@ -176,77 +179,65 @@ /obj/machinery/autolathe/Topic(href, href_list) if(..()) return 1 - if (!busy) - if(href_list["menu"]) - screen = text2num(href_list["menu"]) + if(href_list["menu"]) + screen = text2num(href_list["menu"]) - if(href_list["category"]) - selected_category = href_list["category"] + if(href_list["category"]) + selected_category = href_list["category"] - if(href_list["make"]) + if(href_list["make"]) + BuildTurf = get_step(src.loc, get_dir(src,usr)) - var/turf/T = get_step(src.loc, get_dir(src,usr)) + ///////////////// + //href protection + being_built = files.FindDesignByID(href_list["make"]) //check if it's a valid design + if(!being_built) + return + if(!(being_built.build_type & AUTOLATHE)) + return - ///////////////// - //href protection - being_built = files.FindDesignByID(href_list["make"]) //check if it's a valid design - if(!being_built) - return + //multiplier checks : only stacks can have one and its value is 1, 10 ,25 or max_multiplier + var/multiplier = text2num(href_list["multiplier"]) + var/max_multiplier = min(50, being_built.materials["$metal"] ?round(m_amount/being_built.materials["$metal"]):INFINITY,being_built.materials["$glass"]?round(g_amount/being_built.materials["$glass"]):INFINITY) + var/is_stack = ispath(being_built.build_path, /obj/item/stack) - //multiplier checks : only stacks can have one and its value is 1, 10 ,25 or max_multiplier - var/multiplier = text2num(href_list["multiplier"]) - var/max_multiplier = min(50, being_built.materials["$metal"] ?round(m_amount/being_built.materials["$metal"]):INFINITY,being_built.materials["$glass"]?round(g_amount/being_built.materials["$glass"]):INFINITY) - var/is_stack = ispath(being_built.build_path, /obj/item/stack) - - if(!is_stack && (multiplier > 1)) - return - if (!(multiplier in list(1,10,25,max_multiplier))) //"enough materials ?" is checked further down - return - ///////////////// - - var/coeff = (is_stack ? 1 : 2 ** prod_coeff) //stacks are unaffected by production coefficient - var/metal_cost = being_built.materials["$metal"] - var/glass_cost = being_built.materials["$glass"] - - var/power = max(2000, (metal_cost+glass_cost)*multiplier/5) - - if((m_amount >= metal_cost*multiplier/coeff) && (g_amount >= glass_cost*multiplier/coeff)) - busy = 1 - use_power(power) - icon_state = "autolathe" - flick("autolathe_n",src) - spawn(32/coeff) - use_power(power) - if(is_stack) - m_amount -= metal_cost*multiplier - g_amount -= glass_cost*multiplier - var/obj/item/stack/S = new being_built.build_path(T) - S.amount = multiplier - else - m_amount -= metal_cost/coeff - g_amount -= glass_cost/coeff - var/obj/item/new_item = new being_built.build_path(T) - new_item.m_amt /= coeff - new_item.g_amt /= coeff - if(m_amount < 0) - m_amount = 0 - if(g_amount < 0) - g_amount = 0 - busy = 0 - src.updateUsrDialog() - - if(href_list["search"]) - matching_designs.Cut() - - for(var/datum/design/D in files.known_designs) - if(findtext(D.name,href_list["to_search"])) - matching_designs.Add(D) - - else - usr << "The autolathe is busy. Please wait for completion of previous operation." + if(!is_stack && (multiplier > 1)) + return + if (!(multiplier in list(1,10,25,max_multiplier))) //"enough materials ?" is checked in the build proc + return + ///////////////// + + if(queue.len1) + output += "[initial(part.name)][is_stack?" (x[multiplier])":null] - [i>1?"":null] [i↓":null] Remove" + temp_metal = max(temp_metal-LL[1],1) + temp_glass = max(temp_glass-LL[2],1) + + output += "" + output += "Clear queue" + output += "" + return output + +/obj/machinery/autolathe/proc/add_to_queue(D,var/multiplier) + if(!istype(queue)) + queue = list() + if(D) + queue.Add(list(list(D,multiplier))) + return queue.len + +/obj/machinery/autolathe/proc/remove_from_queue(index) + if(!isnum(index) || !istype(queue) || (index<1 || index>queue.len)) + return 0 + queue.Cut(index,++index) + return 1 + +/obj/machinery/autolathe/proc/process_queue() + var/datum/design/D = queue[1][1] + var/multiplier = queue[1][2] + if(!D) + remove_from_queue(1) + if(queue.len) + return process_queue() + else + return + while(D) + if(stat&(NOPOWER|BROKEN)) + return 0 + if(!can_build(D,multiplier)) + visible_message("\icon[src] \The [src] beeps, \"Not enough resources. Queue processing terminated.\"") + queue = list() + return 0 + + remove_from_queue(1) + build_item(D,multiplier) + D = listgetindex(listgetindex(queue, 1),1) + multiplier = listgetindex(listgetindex(queue,1),2) + //visible_message("\icon[src] \The [src] beeps, \"Queue processing finished successfully.\"") + /obj/machinery/autolathe/proc/main_win(mob/user) - var/dat = "

Autolathe Menu:


" + var/dat = "" + dat += "
" + dat += "

Autolathe Menu:


" dat += "Metal amount: [src.m_amount] / [max_m_amount] cm3
" dat += "Glass amount: [src.g_amount] / [max_g_amount] cm3" @@ -285,11 +402,16 @@ line_length++ dat += "
" + dat += "" + dat += get_queue() + dat += "" return dat /obj/machinery/autolathe/proc/category_win(mob/user,var/selected_category) - var/dat = "Return to main menu" - dat += "

Browsing [selected_category]:


" + var/dat = "" + dat += get_queue() + dat += "
" + dat += "
" + dat += "Return to main menu" + dat += "

Browsing [selected_category]:


" dat += "Metal amount: [src.m_amount] / [max_m_amount] cm3
" dat += "Glass amount: [src.g_amount] / [max_g_amount] cm3
" @@ -314,11 +436,16 @@ dat += "[get_design_cost(D)]
" dat += "
" + dat += "
" return dat /obj/machinery/autolathe/proc/search_win(mob/user) - var/dat = "Return to main menu" - dat += "

Search results:


" + var/dat = "" + dat += get_queue() + dat += "
" + dat += "
" + dat += "Return to main menu" + dat += "

Search results:


" dat += "Metal amount: [src.m_amount] / [max_m_amount] cm3
" dat += "Glass amount: [src.g_amount] / [max_g_amount] cm3
" @@ -340,19 +467,13 @@ dat += "[get_design_cost(D)]
" dat += "
" + dat += "
" return dat -/obj/machinery/autolathe/proc/can_build(var/datum/design/D) - var/coeff = (ispath(D.build_path,/obj/item/stack) ? 1 : 2 ** prod_coeff) - - if(D.materials["$metal"] && (m_amount < (D.materials["$metal"] / coeff))) - return 0 - if(D.materials["$glass"] && (g_amount < (D.materials["$glass"] / coeff))) - return 0 - return 1 - /obj/machinery/autolathe/proc/get_design_cost(var/datum/design/D) - var/coeff = (ispath(D.build_path,/obj/item/stack) ? 1 : 2 ** prod_coeff) + var/coeff = get_coeff(D) var/dat if(D.materials["$metal"]) dat += "[D.materials["$metal"] / coeff] metal " @@ -378,7 +499,7 @@ if(hack) for(var/datum/design/D in files.possible_designs) - if((D.build_type & 4) && ("hacked" in D.category)) + if((D.build_type & AUTOLATHE) && ("hacked" in D.category)) files.known_designs += D else for(var/datum/design/D in files.known_designs) From e1eb2b9a1d6e9ed2ccc1c608fb7bc335ee042e28 Mon Sep 17 00:00:00 2001 From: Artorp Date: Tue, 17 Feb 2015 18:52:31 +0100 Subject: [PATCH 2/2] Updated m_amt and g_amt to match their design --- code/game/machinery/camera/camera_assembly.dm | 4 ++-- .../objects/items/weapons/surgery_tools.dm | 20 +++++++++---------- code/game/objects/items/weapons/tools.dm | 2 +- code/modules/assembly/signaler.dm | 4 ++-- .../reagents/reagent_containers/glass.dm | 2 +- .../research/designs/autolathe_designs.dm | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index 7b72b5bc3f4..e8c7656032a 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -5,8 +5,8 @@ icon_state = "cameracase" w_class = 2 anchored = 0 - m_amt = 700 - g_amt = 300 + m_amt = 400 + g_amt = 250 // Motion, EMP-Proof, X-Ray var/list/obj/item/possible_upgrades = list(/obj/item/device/assembly/prox_sensor, /obj/item/stack/sheet/mineral/osmium, /obj/item/weapon/stock_parts/scanning_module) diff --git a/code/game/objects/items/weapons/surgery_tools.dm b/code/game/objects/items/weapons/surgery_tools.dm index dab630f188a..d323fe0d7cb 100644 --- a/code/game/objects/items/weapons/surgery_tools.dm +++ b/code/game/objects/items/weapons/surgery_tools.dm @@ -16,8 +16,8 @@ desc = "Retracts stuff." icon = 'icons/obj/surgery.dmi' icon_state = "retractor" - m_amt = 10000 - g_amt = 5000 + m_amt = 6000 + g_amt = 3000 flags = FPRINT | TABLEPASS | CONDUCT w_class = 2.0 origin_tech = "materials=1;biotech=1" @@ -265,8 +265,8 @@ LOOK FOR SURGERY.DM*/ desc = "This stops bleeding." icon = 'icons/obj/surgery.dmi' icon_state = "cautery" - m_amt = 5000 - g_amt = 2500 + m_amt = 2500 + g_amt = 750 flags = FPRINT | TABLEPASS | CONDUCT w_class = 2.0 origin_tech = "materials=1;biotech=1" @@ -356,8 +356,8 @@ LOOK FOR SURGERY.DM*/ icon = 'icons/obj/surgery.dmi' icon_state = "drill" hitsound = 'sound/weapons/circsawhit.ogg' - m_amt = 15000 - g_amt = 10000 + m_amt = 10000 + g_amt = 6000 flags = FPRINT | TABLEPASS | CONDUCT force = 15.0 w_class = 2.0 @@ -385,8 +385,8 @@ LOOK FOR SURGERY.DM*/ throwforce = 5.0 throw_speed = 3 throw_range = 5 - m_amt = 10000 - g_amt = 5000 + m_amt = 4000 + g_amt = 1000 origin_tech = "materials=1;biotech=1" attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut") @@ -637,8 +637,8 @@ LOOK FOR SURGERY.DM*/ throwforce = 9.0 throw_speed = 3 throw_range = 5 - m_amt = 20000 - g_amt = 10000 + m_amt = 10000 + g_amt = 6000 origin_tech = "materials=1;biotech=1" attack_verb = list("attacked", "slashed", "sawed", "cut") sharp = 1 diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 747fc89183e..a1985a93050 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -147,7 +147,7 @@ //Cost to make in the autolathe m_amt = 70 - g_amt = 30 + g_amt = 20 //R&D tech level origin_tech = "engineering=1" diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index 7f2d7c8f731..4d24559ef0c 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -3,8 +3,8 @@ desc = "Used to remotely activate devices." icon_state = "signaller" item_state = "signaler" - m_amt = 1000 - g_amt = 200 + m_amt = 400 + g_amt = 120 origin_tech = "magnets=1" wires = WIRE_RECEIVE | WIRE_PULSE | WIRE_RADIO_PULSE | WIRE_RADIO_RECEIVE diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index 0d1b64dacd3..50c5c1ba848 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -226,7 +226,7 @@ name = "large beaker" desc = "A large beaker. Can hold up to 100 units." icon_state = "beakerlarge" - g_amt = 5000 + g_amt = 2500 volume = 100 amount_per_transfer_from_this = 10 possible_transfer_amounts = list(5,10,15,25,30,50,100) diff --git a/code/modules/research/designs/autolathe_designs.dm b/code/modules/research/designs/autolathe_designs.dm index 5620f5dcd7a..cd3acea26fe 100644 --- a/code/modules/research/designs/autolathe_designs.dm +++ b/code/modules/research/designs/autolathe_designs.dm @@ -230,7 +230,7 @@ name = "Metal" id = "metal" build_type = AUTOLATHE - materials = list("$metal" = MINERAL_MATERIAL_AMOUNT) + materials = list("$metal" = 3750) build_path = /obj/item/stack/sheet/metal category = list("initial","Construction") @@ -254,7 +254,7 @@ name = "Reinforced Glass" id = "rglass" build_type = AUTOLATHE - materials = list("$metal" = 1000, "$glass" = MINERAL_MATERIAL_AMOUNT) + materials = list("$metal" = 1875, "$glass" = MINERAL_MATERIAL_AMOUNT) build_path = /obj/item/stack/sheet/rglass category = list("initial","Construction") @@ -262,7 +262,7 @@ name = "Metal Rod" id = "rods" build_type = AUTOLATHE - materials = list("$metal" = 1000) + materials = list("$metal" = 1875) build_path = /obj/item/stack/rods category = list("initial","Construction")