mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 04:57:57 +01:00
Merge pull request #4331 from scoopscoop/protolatherepeater
Allows the protolathe to build multiples of items.
This commit is contained in:
@@ -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 built with the material
|
||||
switch(M)
|
||||
if("$metal")
|
||||
return (m_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (m_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$glass")
|
||||
return (g_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (g_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$gold")
|
||||
return (gold_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (gold_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$silver")
|
||||
return (silver_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (silver_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$plasma")
|
||||
return (plasma_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (plasma_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$uranium")
|
||||
return (uranium_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (uranium_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$diamond")
|
||||
return (diamond_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (diamond_amount / max(1, (being_built.materials[M]/efficiency_coeff)))
|
||||
if("$clown")
|
||||
return (clown_amount - (being_built.materials[M]/efficiency_coeff) >= 0) ? 1 : 0
|
||||
return (clown_amount / max(1, (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)
|
||||
|
||||
@@ -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<amount, i++)
|
||||
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
|
||||
linked_lathe.busy = 0
|
||||
screen = 3.1
|
||||
updateUsrDialog()
|
||||
@@ -776,17 +781,26 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
continue
|
||||
var/temp_dat = "[D.name]"
|
||||
var/temp_material
|
||||
var/check_materials = 1
|
||||
var/c = 50
|
||||
var/t
|
||||
for(var/M in D.materials)
|
||||
if (!linked_lathe.check_mat(D, M))
|
||||
check_materials = 0
|
||||
t = linked_lathe.check_mat(D, M)
|
||||
if (!t)
|
||||
temp_material += " <span style=\"color:red\">[D.materials[M]/coeff] [CallMaterialName(M)]</span>"
|
||||
else
|
||||
temp_material += " [D.materials[M]/coeff] [CallMaterialName(M)]"
|
||||
if (check_materials)
|
||||
dat += "* <A href='?src=\ref[src];build=[D.id]'>[temp_dat]</A>[temp_material]<BR>"
|
||||
c = min(c,t)
|
||||
|
||||
if (c)
|
||||
dat += "* <A href='?src=\ref[src];build=[D.id];amount=1'>[temp_dat]</A>"
|
||||
if(c >= 5.0)
|
||||
dat += "<A href='?src=\ref[src];build=[D.id];amount=5'>x5</A>"
|
||||
if(c >= 10.0)
|
||||
dat += "<A href='?src=\ref[src];build=[D.id];amount=10'>x10</A>"
|
||||
dat += "[temp_material]"
|
||||
else
|
||||
dat += "* <span class='linkOff'>[temp_dat]</span>[temp_material]<BR>"
|
||||
dat += "* <span class='linkOff'>[temp_dat]</span>[temp_material]"
|
||||
dat += "<BR>"
|
||||
dat += "</div>"
|
||||
|
||||
if(3.2) //Protolathe Material Storage Sub-menu
|
||||
|
||||
Reference in New Issue
Block a user