From 327086b6073d03bec99cf6d5c6c60f8f369c0bf4 Mon Sep 17 00:00:00 2001 From: scoopscoop Date: Mon, 4 Aug 2014 15:39:54 +0300 Subject: [PATCH 1/2] Allows the protolathe to build multiples of items. --- code/modules/research/protolathe.dm | 23 ++++----- code/modules/research/rdconsole.dm | 76 +++++++++++++++++------------ 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm index 4e2273b02b1..c5ceef0cfc8 100644 --- a/code/modules/research/protolathe.dm +++ b/code/modules/research/protolathe.dm @@ -23,6 +23,7 @@ Note: Must be placed west/left of and R&D console to function. var/clown_amount = 0.0 var/adamantine_amount = 0.0 var/efficiency_coeff + reagents = new() @@ -37,6 +38,7 @@ Note: Must be placed west/left of and R&D console to function. component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src) component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src) RefreshParts() + reagents.my_atom = src /obj/machinery/r_n_d/protolathe/proc/TotalMaterials() //returns the total of all the stored materials. Makes code neater. @@ -54,27 +56,26 @@ Note: Must be placed west/left of and R&D console to function. T += (M.rating/3) efficiency_coeff = max(T, 1) -/obj/machinery/r_n_d/protolathe/proc/check_mat(datum/design/being_built, var/M) +/obj/machinery/r_n_d/protolathe/proc/check_mat(datum/design/being_built, var/M) // now returns how many times the item can be build with the material switch(M) if("$metal") - return (m_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (m_amount / (being_built.materials[M]/efficiency_coeff)) if("$glass") - return (g_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (g_amount / (being_built.materials[M]/efficiency_coeff)) if("$gold") - return (gold_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (gold_amount / (being_built.materials[M]/efficiency_coeff)) if("$silver") - return (silver_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (silver_amount / (being_built.materials[M]/efficiency_coeff)) if("$plasma") - return (plasma_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (plasma_amount / (being_built.materials[M]/efficiency_coeff)) if("$uranium") - return (uranium_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (uranium_amount / (being_built.materials[M]/efficiency_coeff)) if("$diamond") - return (diamond_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (diamond_amount / (being_built.materials[M]/efficiency_coeff)) if("$clown") - return (clown_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0 + return (clown_amount / (being_built.materials[M]/efficiency_coeff)) else - return (reagents.has_reagent(M, (being_built.materials[M]/efficiency_coeff)) != 0) ? 1 : 0 - + return (reagents.has_reagent(M, (being_built.materials[M]/efficiency_coeff))) /obj/machinery/r_n_d/protolathe/attackby(var/obj/item/O as obj, var/mob/user as mob) if (shocked) diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm index 085495d7b12..90ea97309ed 100644 --- a/code/modules/research/rdconsole.dm +++ b/code/modules/research/rdconsole.dm @@ -344,8 +344,10 @@ won't update every console in existence) but it's more of a hassle to do. Also, break if(being_built) var/power = 2000 + var/amount=text2num(href_list["amount"]) + amount = max(10, min(1, amount)) for(var/M in being_built.materials) - power += round(being_built.materials[M] / 5) + power += round(being_built.materials[M] * amount / 5) power = max(2000, power) screen = 0.3 if(linked_lathe.busy) @@ -354,6 +356,8 @@ won't update every console in existence) but it's more of a hassle to do. Also, if (!(being_built.build_type & PROTOLATHE)) g2g = 0 message_admins("Protolathe exploit attempted by [key_name(usr, usr.client)]!") + + if (g2g) //If input is incorrect, nothing happens linked_lathe.busy = 1 @@ -367,43 +371,44 @@ won't update every console in existence) but it's more of a hassle to do. Also, break switch(M) if("$metal") - linked_lathe.m_amount = max(0, (linked_lathe.m_amount-(being_built.materials[M]/coeff))) + linked_lathe.m_amount = max(0, (linked_lathe.m_amount-(being_built.materials[M]/coeff * amount))) if("$glass") - linked_lathe.g_amount = max(0, (linked_lathe.g_amount-(being_built.materials[M]/coeff))) + linked_lathe.g_amount = max(0, (linked_lathe.g_amount-(being_built.materials[M]/coeff * amount))) if("$gold") - linked_lathe.gold_amount = max(0, (linked_lathe.gold_amount-(being_built.materials[M]/coeff))) + linked_lathe.gold_amount = max(0, (linked_lathe.gold_amount-(being_built.materials[M]/coeff * amount))) if("$silver") - linked_lathe.silver_amount = max(0, (linked_lathe.silver_amount-(being_built.materials[M]/coeff))) + linked_lathe.silver_amount = max(0, (linked_lathe.silver_amount-(being_built.materials[M]/coeff * amount))) if("$plasma") - linked_lathe.plasma_amount = max(0, (linked_lathe.plasma_amount-(being_built.materials[M]/coeff))) + linked_lathe.plasma_amount = max(0, (linked_lathe.plasma_amount-(being_built.materials[M]/coeff * amount))) if("$uranium") - linked_lathe.uranium_amount = max(0, (linked_lathe.uranium_amount-(being_built.materials[M]/coeff))) + linked_lathe.uranium_amount = max(0, (linked_lathe.uranium_amount-(being_built.materials[M]/coeff * amount))) if("$diamond") - linked_lathe.diamond_amount = max(0, (linked_lathe.diamond_amount-(being_built.materials[M]/coeff))) + linked_lathe.diamond_amount = max(0, (linked_lathe.diamond_amount-(being_built.materials[M]/coeff * amount))) if("$clown") - linked_lathe.clown_amount = max(0, (linked_lathe.clown_amount-(being_built.materials[M]/coeff))) + linked_lathe.clown_amount = max(0, (linked_lathe.clown_amount-(being_built.materials[M]/coeff * amount))) else - linked_lathe.reagents.remove_reagent(M, being_built.materials[M]/coeff) + linked_lathe.reagents.remove_reagent(M, being_built.materials[M]/coeff * amount) var/P = being_built.build_path //lets save these values before the spawn() just in case. Nobody likes runtimes. var/R = being_built.reliability var/O = being_built.locked - spawn(32) + spawn(32*amount) if(g2g) //And if we only fail the material requirements, we still spend time and power - var/obj/new_item = new P(src) - if( new_item.type == /obj/item/weapon/storage/backpack/holding ) - new_item.investigate_log("built by [key]","singulo") - new_item.reliability = R - new_item.m_amt /= coeff - new_item.g_amt /= coeff - if(linked_lathe.hacked) - R = max((reliability / 2), 0) - if(O) - var/obj/item/weapon/storage/lockbox/L = new/obj/item/weapon/storage/lockbox(linked_lathe.loc) - new_item.loc = L - L.name += " ([new_item.name])" - else - new_item.loc = linked_lathe.loc + for(var/i = 0, i[D.materials[M]/coeff] [CallMaterialName(M)]" else temp_material += " [D.materials[M]/coeff] [CallMaterialName(M)]" - if (check_materials) - dat += "* [temp_dat][temp_material]
" + c = min(c,t) + + if (c) + dat += "* [temp_dat]" + if(c >= 5.0) + dat += "x5" + if(c >= 10.0) + dat += "x10" + dat += "[temp_material]" else - dat += "* [temp_dat][temp_material]
" + dat += "* [temp_dat][temp_material]" + dat += "
" dat += "" if(3.2) //Protolathe Material Storage Sub-menu From d521e6e827813d8b11ab79a4af65176529b2d27f Mon Sep 17 00:00:00 2001 From: scoopscoop Date: Mon, 4 Aug 2014 15:58:30 +0300 Subject: [PATCH 2/2] Avoids division by zero --- code/modules/research/protolathe.dm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm index c5ceef0cfc8..f0c4f55f715 100644 --- a/code/modules/research/protolathe.dm +++ b/code/modules/research/protolathe.dm @@ -56,24 +56,24 @@ Note: Must be placed west/left of and R&D console to function. T += (M.rating/3) efficiency_coeff = max(T, 1) -/obj/machinery/r_n_d/protolathe/proc/check_mat(datum/design/being_built, var/M) // now returns how many times the item can be build with the material +/obj/machinery/r_n_d/protolathe/proc/check_mat(datum/design/being_built, var/M) // now returns how many times the item can be built with the material switch(M) if("$metal") - return (m_amount / (being_built.materials[M]/efficiency_coeff)) + return (m_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$glass") - return (g_amount / (being_built.materials[M]/efficiency_coeff)) + return (g_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$gold") - return (gold_amount / (being_built.materials[M]/efficiency_coeff)) + return (gold_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$silver") - return (silver_amount / (being_built.materials[M]/efficiency_coeff)) + return (silver_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$plasma") - return (plasma_amount / (being_built.materials[M]/efficiency_coeff)) + return (plasma_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$uranium") - return (uranium_amount / (being_built.materials[M]/efficiency_coeff)) + return (uranium_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$diamond") - return (diamond_amount / (being_built.materials[M]/efficiency_coeff)) + return (diamond_amount / max(1, (being_built.materials[M]/efficiency_coeff))) if("$clown") - return (clown_amount / (being_built.materials[M]/efficiency_coeff)) + return (clown_amount / max(1, (being_built.materials[M]/efficiency_coeff))) else return (reagents.has_reagent(M, (being_built.materials[M]/efficiency_coeff)))