")
-/obj/machinery/chem_dispenser/proc/recharge()
- if(stat & (BROKEN|NOPOWER)) return
- var/addenergy = 1
- var/oldenergy = energy
- energy = min(energy + addenergy, max_energy)
- if(energy != oldenergy)
- use_power(1500) // This thing uses up alot of power (this is still low as shit for creating reagents from thin air)
- SSnanoui.update_uis(src) // update all UIs attached to src
+/obj/machinery/chem_dispenser/process()
+ if(recharge_counter >= 4)
+ if(!is_operational())
+ return
+ var/usedpower = cell.give(recharge_amount)
+ if(usedpower)
+ use_power(15 * recharge_amount)
+ SSnanoui.update_uis(src) // update all UIs attached to src
+ recharge_counter = 0
+ return
+ recharge_counter++
/obj/machinery/chem_dispenser/power_change()
if(powered())
@@ -42,72 +84,19 @@
stat |= NOPOWER
SSnanoui.update_uis(src) // update all UIs attached to src
-/obj/machinery/chem_dispenser/process()
-
- if(recharged < 0)
- recharge()
- recharged = recharge_delay
- else
- recharged -= 1
-
-/obj/machinery/chem_dispenser/New()
- ..()
- recharge()
- dispensable_reagents = sortList(dispensable_reagents)
-
- if(broken_on_spawn)
- overlays.Cut()
- var/amount = pick(3,3,4)
- var/list/options = list()
- options[/obj/item/stock_parts/capacitor/adv] = "Add an advanced capacitor to fix it."
- options[/obj/item/stock_parts/console_screen] = "Replace the console screen to fix it."
- options[/obj/item/stock_parts/manipulator/pico] = "Upgrade to a pico manipulator to fix it."
- options[/obj/item/stock_parts/matter_bin/super] = "Give it a super matter bin to fix it."
- options[/obj/item/stock_parts/cell/super] = "Replace the reagent synthesizer with a super capacity cell to fix it."
- options[/obj/item/reagent_scanner/adv] = "Replace the reagent scanner with an advanced reagent scanner to fix it"
- options[/obj/item/stock_parts/micro_laser/high] = "Repair the reagent synthesizer with an high-power micro-laser to fix it"
- options[/obj/item/reagent_scanner/adv] = "Replace the reagent scanner with an advanced reagent scanner to fix it"
- options[/obj/item/stack/nanopaste] = "Apply some nanopaste to the broken nozzles to fix it."
- options[/obj/item/stack/sheet/plasteel] = "Surround the outside with a plasteel cover to fix it."
- options[/obj/item/stack/sheet/rglass] = "Insert a pane of reinforced glass to fix it."
-
- while(amount > 0)
- amount -= 1
-
- var/index = pick(options)
- broken_requirements[index] = options[index]
- options -= index
-
-
/obj/machinery/chem_dispenser/ex_act(severity)
switch(severity)
- if(1.0)
+ if(1)
qdel(src)
- return
- if(2.0)
+ if(2)
if(prob(50))
qdel(src)
- return
/obj/machinery/chem_dispenser/blob_act()
if(prob(50))
qdel(src)
- /**
- * The ui_interact proc is used to open and update Nano UIs
- * If ui_interact is not used then the UI will not update correctly
- * ui_interact is currently defined for /atom/movable
- *
- * @param user /mob The mob who is interacting with this ui
- * @param ui_key string A string key to use for this ui. Allows for multiple unique uis on one obj/mob (defaut value "main")
- *
- * @return nothing
- */
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
- if(broken_requirements.len)
- to_chat(user, "[src] is broken. [broken_requirements[broken_requirements[1]]]")
- return
-
// update the ui if it exists, returns null if no ui is passed/found
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
@@ -121,8 +110,8 @@
var/data[0]
data["amount"] = amount
- data["energy"] = round(energy)
- data["maxEnergy"] = round(max_energy)
+ data["energy"] = cell.charge ? cell.charge * powerefficiency : "0" //To prevent NaN in the UI.
+ data["maxEnergy"] = cell.maxcharge * powerefficiency
data["isBeakerLoaded"] = beaker ? 1 : 0
var/beakerContents[0]
@@ -151,26 +140,32 @@
/obj/machinery/chem_dispenser/Topic(href, href_list)
if(..())
- return 1
+ return TRUE
if(href_list["amount"])
- amount = round(text2num(href_list["amount"]), 5) // round to nearest 5
+ amount = round(text2num(href_list["amount"]), 1) // round to nearest 1
if(amount < 0) // Since the user can actually type the commands himself, some sanity checking
amount = 0
if(amount > 100)
amount = 100
if(href_list["dispense"])
- if(dispensable_reagents.Find(href_list["dispense"]) && beaker != null)
- var/obj/item/reagent_containers/glass/B = beaker
- var/datum/reagents/R = B.reagents
- var/space = R.maximum_volume - R.total_volume
+ if(!is_operational() || QDELETED(cell))
+ return
+ if(beaker && dispensable_reagents.Find(href_list["dispense"]))
+ var/datum/reagents/R = beaker.reagents
+ var/free = R.maximum_volume - R.total_volume
+ var/actual = min(amount, (cell.charge * powerefficiency) * 10, free)
- R.add_reagent(href_list["dispense"], min(amount, energy * 10, space))
- energy = max(energy - min(amount, energy * 10, space) / 10, 0)
+ if(!cell.use(actual / powerefficiency))
+ atom_say("Not enough energy to complete operation!")
+ return
+
+ R.add_reagent(href_list["dispense"], actual)
overlays.Cut()
- icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position.
- icon_beaker.pixel_x = rand(-10,5)
+ if(!icon_beaker)
+ icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position.
+ icon_beaker.pixel_x = rand(-10, 5)
overlays += icon_beaker
if(href_list["remove"])
@@ -178,75 +173,96 @@
if(href_list["removeamount"])
var/amount = text2num(href_list["removeamount"])
if(isnum(amount) && (amount > 0))
- var/obj/item/reagent_containers/glass/B = beaker
- var/datum/reagents/R = B.reagents
+ var/datum/reagents/R = beaker.reagents
var/id = href_list["remove"]
R.remove_reagent(id, amount)
+ else if(isnum(amount) && (amount == -1)) //Isolate instead
+ var/datum/reagents/R = beaker.reagents
+ var/id = href_list["remove"]
+ R.isolate_reagent(id)
if(href_list["ejectBeaker"])
if(beaker)
- var/obj/item/reagent_containers/glass/B = beaker
- B.forceMove(loc)
+ beaker.forceMove(loc)
beaker = null
overlays.Cut()
- add_fingerprint(usr)
- return 1 // update UIs attached to this object
-/obj/machinery/chem_dispenser/attackby(obj/item/reagent_containers/B, mob/user, params)
- if(isrobot(user))
+ add_fingerprint(usr)
+ return TRUE // update UIs attached to this object
+
+/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
+ if(ismultitool(I))
+ if(!hackedcheck)
+ to_chat(user, hack_message)
+ dispensable_reagents += hacked_reagents
+ hackedcheck = TRUE
+ else
+ to_chat(user, unhack_message)
+ dispensable_reagents -= hacked_reagents
+ hackedcheck = FALSE
+ SSnanoui.update_uis(src)
return
- if(broken_requirements.len && B.type == broken_requirements[1])
- if(istype(B,/obj/item/stack))
- var/obj/item/stack/S = B
- S.use(1)
- else
- if(!user.drop_item())
- to_chat(user, "[B] is stuck to you!")
- return
- qdel(B)
- broken_requirements -= broken_requirements[1]
- to_chat(user, "You fix [src].")
+ if(default_deconstruction_screwdriver(user, "[initial(icon_state)]-o", "[initial(icon_state)]", I))
+ return
+
+ if(exchange_parts(user, I))
+ SSnanoui.update_uis(src)
+ return
+
+ if(iswrench(I))
+ playsound(src, I.usesound, 50, 1)
+ if(anchored)
+ anchored = FALSE
+ to_chat(user, "[src] can now be moved.")
+ else if(!anchored)
+ anchored = TRUE
+ to_chat(user, "[src] is now secured.")
+ return
+
+ if(panel_open)
+ if(iscrowbar(I))
+ if(beaker)
+ beaker.forceMove(loc)
+ beaker = null
+ if(cell)
+ cell.forceMove(loc)
+ cell = null
+ default_deconstruction_crowbar(I)
+ return TRUE
+
+ if(isrobot(user))
return
if(beaker)
to_chat(user, "Something is already loaded into the machine.")
return
- if(istype(B, /obj/item/reagent_containers/glass) || istype(B, /obj/item/reagent_containers/food/drinks))
- beaker = B
- if(!user.drop_item())
- to_chat(user, "[B] is stuck to you!")
+ if(istype(I, /obj/item/reagent_containers/glass) || istype(I, /obj/item/reagent_containers/food/drinks))
+ if(panel_open)
+ to_chat(user, "Close the maintenance panel first.")
return
- B.forceMove(src)
- to_chat(user, "You set [B] on the machine.")
+ if(!user.drop_item())
+ to_chat(user, "[I] is stuck to you!")
+ return
+ beaker = I
+ I.forceMove(src)
+ to_chat(user, "You set [I] on the machine.")
SSnanoui.update_uis(src) // update all UIs attached to src
if(!icon_beaker)
icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position.
- icon_beaker.pixel_x = rand(-10,5)
+ icon_beaker.pixel_x = rand(-10, 5)
overlays += icon_beaker
return
+ return ..()
-/obj/machinery/chem_dispenser/attackby(obj/item/B, mob/user, params)
- ..()
- if(istype(B, /obj/item/multitool))
- if(hackedcheck == 0)
- to_chat(user, hack_message)
- dispensable_reagents += hacked_reagents
- hackedcheck = 1
- return
-
- else
- to_chat(user, unhack_message)
- dispensable_reagents -= hacked_reagents
- hackedcheck = 0
- return
/obj/machinery/chem_dispenser/attack_ai(mob/user)
return attack_hand(user)
/obj/machinery/chem_dispenser/attack_ghost(mob/user)
- return attack_hand(user)
+ if(user.can_admin_interact())
+ return attack_hand(user)
/obj/machinery/chem_dispenser/attack_hand(mob/user)
if(stat & BROKEN)
@@ -259,245 +275,45 @@
name = "soda fountain"
desc = "A drink fabricating machine, capable of producing many sugary drinks with just one touch."
ui_title = "Soda Dispens-o-matic"
- energy = 100
- max_energy = 100
dispensable_reagents = list("water", "ice", "milk", "soymilk", "coffee", "tea", "hot_coco", "cola", "spacemountainwind", "dr_gibb", "space_up",
"tonic", "sodawater", "lemon_lime", "grapejuice", "sugar", "orangejuice", "lemonjuice", "limejuice", "tomatojuice", "banana",
"watermelonjuice", "carrotjuice", "potato", "berryjuice")
- var/list/special_reagents2 = list(list(""),
- list("bananahonk", "milkshake", "cafe_latte", "cafe_mocha"),
- list("triple_citrus", "icecoffe","icetea"))
+ upgrade_reagents = list("bananahonk", "milkshake", "cafe_latte", "cafe_mocha", "triple_citrus", "icecoffe","icetea")
+ hacked_reagents = list("thirteenloko")
hack_message = "You change the mode from 'McNano' to 'Pizza King'."
unhack_message = "You change the mode from 'Pizza King' to 'McNano'."
- hacked_reagents = list("thirteenloko")
/obj/machinery/chem_dispenser/soda/New()
..()
- component_parts = list()
- component_parts += new /obj/item/circuitboard/soda(null)
+ QDEL_LIST(component_parts)
+ component_parts += new /obj/item/circuitboard/chem_dispenser/soda(null)
component_parts += new /obj/item/stock_parts/matter_bin(null)
component_parts += new /obj/item/stock_parts/matter_bin(null)
component_parts += new /obj/item/stock_parts/manipulator(null)
component_parts += new /obj/item/stock_parts/capacitor(null)
component_parts += new /obj/item/stock_parts/console_screen(null)
- component_parts += new /obj/item/stock_parts/cell/super(null)
+ component_parts += new cell_type(null)
RefreshParts()
-/obj/machinery/chem_dispenser/soda/upgraded/New()
- ..()
- component_parts = list()
- component_parts += new /obj/item/circuitboard/soda(null)
- component_parts += new /obj/item/stock_parts/matter_bin/super(null)
- component_parts += new /obj/item/stock_parts/matter_bin/super(null)
- component_parts += new /obj/item/stock_parts/manipulator/pico(null)
- component_parts += new /obj/item/stock_parts/capacitor/super(null)
- component_parts += new /obj/item/stock_parts/console_screen(null)
- component_parts += new /obj/item/stock_parts/cell/hyper(null)
- RefreshParts()
-
-/obj/machinery/chem_dispenser/soda/RefreshParts()
- for(var/obj/item/stock_parts/manipulator/M in component_parts)
- for(var/i in 1 to M.rating)
- dispensable_reagents = sortList(dispensable_reagents | special_reagents2[i])
-
-/obj/machinery/chem_dispenser/soda/attackby(obj/item/I, mob/user, params)
- if(istype(I, /obj/item/reagent_containers/glass))
- if(panel_open)
- to_chat(user, "Close the maintenance panel first.")
- return
- return ..()
- else
- ..()
-
- if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I))
- return
-
- if(exchange_parts(user, I))
- return
-
- if(iswrench(I))
- playsound(src, I.usesound, 50, 1)
- if(anchored)
- anchored = FALSE
- to_chat(user, "[src] can now be moved.")
- else if(!anchored)
- anchored = TRUE
- to_chat(user, "[src] is now secured.")
-
- if(panel_open)
- if(iscrowbar(I))
- if(beaker)
- var/obj/item/reagent_containers/glass/B = beaker
- B.forceMove(loc)
- beaker = null
- default_deconstruction_crowbar(I)
- return TRUE
-
-
/obj/machinery/chem_dispenser/beer
icon_state = "booze_dispenser"
name = "booze dispenser"
ui_title = "Booze Portal 9001"
- energy = 100
- max_energy = 100
desc = "A technological marvel, supposedly able to mix just the mixture you'd like to drink the moment you ask for one."
dispensable_reagents = list("ice", "cream", "cider", "beer", "kahlua", "whiskey", "wine", "vodka", "gin", "rum", "tequila", "vermouth", "cognac", "ale", "mead", "synthanol")
- var/list/special_reagents3 = list(list("iced_beer"),
- list("irishcream", "manhattan",),
- list("antihol", "synthignon", "bravebull"))
+ upgrade_reagents = list("iced_beer", "irishcream", "manhattan", "antihol", "synthignon", "bravebull")
+ hacked_reagents = list("goldschlager", "patron", "absinthe", "ethanol", "nothing", "sake")
hack_message = "You disable the 'nanotrasen-are-cheap-bastards' lock, enabling hidden and very expensive boozes."
unhack_message = "You re-enable the 'nanotrasen-are-cheap-bastards' lock, disabling hidden and very expensive boozes."
- hacked_reagents = list("goldschlager", "patron", "absinthe", "ethanol", "nothing", "sake")
/obj/machinery/chem_dispenser/beer/New()
..()
- component_parts = list()
- component_parts += new /obj/item/circuitboard/beer(null)
+ QDEL_LIST(component_parts)
+ component_parts += new /obj/item/circuitboard/chem_dispenser/beer(null)
component_parts += new /obj/item/stock_parts/matter_bin(null)
component_parts += new /obj/item/stock_parts/matter_bin(null)
- component_parts += new /obj/item/stock_parts/manipulator(null)
component_parts += new /obj/item/stock_parts/capacitor(null)
- component_parts += new /obj/item/stock_parts/console_screen(null)
- component_parts += new /obj/item/stock_parts/cell/super(null)
- RefreshParts()
-
-/obj/machinery/chem_dispenser/beer/upgraded/New()
- ..()
- component_parts = list()
- component_parts += new /obj/item/circuitboard/beer(null)
- component_parts += new /obj/item/stock_parts/matter_bin/super(null)
- component_parts += new /obj/item/stock_parts/matter_bin/super(null)
- component_parts += new /obj/item/stock_parts/manipulator/pico(null)
- component_parts += new /obj/item/stock_parts/capacitor/super(null)
- component_parts += new /obj/item/stock_parts/console_screen(null)
- component_parts += new /obj/item/stock_parts/cell/hyper(null)
- RefreshParts()
-
-/obj/machinery/chem_dispenser/beer/RefreshParts()
- for(var/obj/item/stock_parts/manipulator/M in component_parts)
- for(var/i in 1 to M.rating)
- dispensable_reagents = sortList(dispensable_reagents | special_reagents3[i])
-
-/obj/machinery/chem_dispenser/beer/attackby(obj/item/I, mob/user, params)
- if(istype(I, /obj/item/reagent_containers/glass))
- if(panel_open)
- to_chat(user, "Close the maintenance panel first.")
- return
- return ..()
- else
- ..()
-
- if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I))
- return
-
- if(exchange_parts(user, I))
- return
-
- if(iswrench(I))
- playsound(src, I.usesound, 50, 1)
- if(anchored)
- anchored = FALSE
- to_chat(user, "[src] can now be moved.")
- else if(!anchored)
- anchored = TRUE
- to_chat(user, "[src] is now secured.")
-
- if(panel_open)
- if(iscrowbar(I))
- if(beaker)
- var/obj/item/reagent_containers/glass/B = beaker
- B.forceMove(loc)
- beaker = null
- default_deconstruction_crowbar(I)
- return TRUE
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-/obj/machinery/chem_dispenser/constructable
- name = "portable chem dispenser"
- icon = 'icons/obj/chemical.dmi'
- icon_state = "minidispenser"
- energy = 5
- max_energy = 5
- amount = 5
- recharge_delay = 10
- dispensable_reagents = list()
- var/list/special_reagents = list(list("hydrogen", "oxygen", "silicon", "phosphorus", "sulfur", "carbon", "nitrogen", "water"),
- list("lithium", "sugar", "copper", "mercury", "sodium","iodine","bromine"),
- list("ethanol", "chlorine", "potassium", "aluminum","plasma", "radium", "fluorine", "iron", "silver"),
- list("oil", "ash", "acetone", "saltpetre", "ammonia", "diethylamine", "fuel"))
-
-/obj/machinery/chem_dispenser/constructable/New()
- ..()
- component_parts = list()
- component_parts += new /obj/item/circuitboard/chem_dispenser(null)
- component_parts += new /obj/item/stock_parts/matter_bin(null)
- component_parts += new /obj/item/stock_parts/matter_bin(null)
component_parts += new /obj/item/stock_parts/manipulator(null)
- component_parts += new /obj/item/stock_parts/capacitor(null)
component_parts += new /obj/item/stock_parts/console_screen(null)
- component_parts += new /obj/item/stock_parts/cell/super(null)
- RefreshParts()
-
-/obj/machinery/chem_dispenser/constructable/upgraded/New()
- ..()
- component_parts = list()
- component_parts += new /obj/item/circuitboard/chem_dispenser(null)
- component_parts += new /obj/item/stock_parts/matter_bin/super(null)
- component_parts += new /obj/item/stock_parts/matter_bin/super(null)
- component_parts += new /obj/item/stock_parts/manipulator/pico(null)
- component_parts += new /obj/item/stock_parts/capacitor/super(null)
- component_parts += new /obj/item/stock_parts/console_screen(null)
- component_parts += new /obj/item/stock_parts/cell/hyper(null)
- RefreshParts()
-
-/obj/machinery/chem_dispenser/constructable/RefreshParts()
- var/time = 0
- var/temp_energy = 0
- var/i
- for(var/obj/item/stock_parts/matter_bin/M in component_parts)
- temp_energy += M.rating
- temp_energy--
- max_energy = temp_energy * 5 //max energy = (bin1.rating + bin2.rating - 1) * 5, 5 on lowest 25 on highest
- for(var/obj/item/stock_parts/capacitor/C in component_parts)
- time += C.rating
- for(var/obj/item/stock_parts/cell/P in component_parts)
- time += round(P.maxcharge, 10000) / 10000
- recharge_delay = 10 / (time/2) //delay between recharges, double the usual time on lowest 33% less than usual on highest
- for(var/obj/item/stock_parts/manipulator/M in component_parts)
- for(i=1, i<=M.rating, i++)
- dispensable_reagents = sortList(dispensable_reagents | special_reagents[i])
-
-/obj/machinery/chem_dispenser/constructable/attackby(obj/item/I, mob/user, params)
- if(istype(I, /obj/item/reagent_containers/glass))
- if(panel_open)
- to_chat(user, "Close the maintenance panel first.")
- return
- ..()
- else
- ..()
-
- if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I))
- return
-
- if(exchange_parts(user, I))
- return
-
- if(istype(I, /obj/item/wrench))
- playsound(src, I.usesound, 50, 1)
- if(anchored)
- anchored = 0
- to_chat(user, "[src] can now be moved.")
- else if(!anchored)
- anchored = 1
- to_chat(user, "[src] is now secured.")
-
- if(panel_open)
- if(istype(I, /obj/item/crowbar))
- if(beaker)
- var/obj/item/reagent_containers/glass/B = beaker
- B.forceMove(loc)
- beaker = null
- default_deconstruction_crowbar(I)
- return 1
+ component_parts += new cell_type(null)
+ RefreshParts()
\ No newline at end of file
diff --git a/code/modules/research/designs/machine_designs.dm b/code/modules/research/designs/machine_designs.dm
index cc6305319c7..cc2f12e6714 100644
--- a/code/modules/research/designs/machine_designs.dm
+++ b/code/modules/research/designs/machine_designs.dm
@@ -163,8 +163,8 @@
category = list("Medical Machinery")
/datum/design/chem_dispenser
- name = "Machine Board (Portable Chem Dispenser)"
- desc = "The circuit board for a Portable Chem Dispenser."
+ name = "Machine Board (Chem Dispenser)"
+ desc = "The circuit board for a Chem Dispenser."
id = "chem_dispenser"
req_tech = list("programming" = 5, "biotech" = 3, "materials" = 4, "plasmatech" = 4)
build_type = IMPRINTER
diff --git a/icons/obj/chemical.dmi b/icons/obj/chemical.dmi
index 61390f38057..9c9f6d38e94 100644
Binary files a/icons/obj/chemical.dmi and b/icons/obj/chemical.dmi differ
diff --git a/nano/templates/chem_dispenser.tmpl b/nano/templates/chem_dispenser.tmpl
index f8988e35e43..74d694530c9 100644
--- a/nano/templates/chem_dispenser.tmpl
+++ b/nano/templates/chem_dispenser.tmpl
@@ -16,6 +16,7 @@ Used In File(s): \code\modules\reagents\Chemistry-Machinery.dm
Dispense:
+ {{:helper.link('1', 'gear', {'amount' : 1}, (data.amount == 1) ? 'selected' : null)}}
{{:helper.link('5', 'gear', {'amount' : 5}, (data.amount == 5) ? 'selected' : null)}}
{{:helper.link('10', 'gear', {'amount' : 10}, (data.amount == 10) ? 'selected' : null)}}
{{:helper.link('20', 'gear', {'amount' : 20}, (data.amount == 20) ? 'selected' : null)}}
@@ -70,6 +71,7 @@ Used In File(s): \code\modules\reagents\Chemistry-Machinery.dm
+ {{:helper.link('Isolate', null, {'remove' : value.id, 'removeamount' : -1})}}
{{:helper.link('1', null, {'remove' : value.id, 'removeamount' : 1})}}
{{:helper.link('5', null, {'remove' : value.id, 'removeamount' : 5})}}
{{:helper.link('10', null, {'remove' : value.id, 'removeamount' : 10})}}