diff --git a/code/modules/reagents/machinery/dispenser/dispenser2.dm b/code/modules/reagents/machinery/dispenser/dispenser2.dm
index 2d229f73aad..f13e84b4a8d 100644
--- a/code/modules/reagents/machinery/dispenser/dispenser2.dm
+++ b/code/modules/reagents/machinery/dispenser/dispenser2.dm
@@ -12,11 +12,11 @@
var/ui_title = "Chemical Dispenser"
- var/accept_drinking = 0
+ var/accept_drinking = FALSE
var/amount = 30
use_power = USE_POWER_IDLE
- idle_power_usage = 100
+ idle_power_usage = 0.1 KILOWATTS
anchored = TRUE
unacidable = TRUE
@@ -29,6 +29,44 @@
/obj/machinery/chemical_dispenser/examine(mob/user)
. = ..()
. += "It has [cartridges.len] cartridges installed, and has space for [DISPENSER_MAX_CARTRIDGES - cartridges.len] more."
+ . += "Use a crowbar to retrieve installed cartridges"
+
+/obj/machinery/chemical_dispenser/update_icon()
+ if(accept_drinking) //drink dispensors don't have fancy sprites, so this is a very handy checker
+ icon_state = initial(icon_state) //just in case some weirdness happens I guess.
+ return
+
+ cut_overlays()
+ icon_state = initial(icon_state)
+ if(panel_open)
+ add_overlay("[initial(icon_state)]_panel-o")
+ if(container)
+ icon_state = "[initial(icon_state)]_working"
+ if(istype(container, /obj/item/weapon/reagent_containers/glass/beaker/bluespace))
+ add_overlay("[initial(icon_state)]_bsbeaker")
+ else if(istype(container, /obj/item/weapon/reagent_containers/glass/beaker/noreact))
+ add_overlay("[initial(icon_state)]_nrbeaker")
+ else //the only see-through one gets filling updates, and we can only do glass and subtypes of glass anyway.
+ var/obj/item/weapon/reagent_containers/glass/C = container
+ if(C.reagents && C.reagents.total_volume)
+ var/mutable_appearance/filling = mutable_appearance('icons/obj/reagentfillings.dmi', "[initial(icon_state)]_1")
+ var/percent = round((C.reagents.total_volume / C.volume) * 100)
+ switch(percent)
+ if(0 to 35) filling.icon_state = "[initial(icon_state)]_1"
+ if(36 to 74) filling.icon_state = "[initial(icon_state)]_5"
+ if(75 to INFINITY) filling.icon_state = "[initial(icon_state)]_10"
+ filling.color = C.reagents.get_color()
+ //Add our filling, if any.
+ add_overlay(filling)
+ //Then overlay the beaker atop of the filling, so it appears behind it.
+ add_overlay("[initial(icon_state)]_beaker")
+
+ if(stat & NOPOWER)
+ icon_state = "[initial(icon_state)]_nopower"
+
+ if(stat & BROKEN)
+ icon_state = "[initial(icon_state)]_broken"
+ return
/obj/machinery/chemical_dispenser/verb/rotate_clockwise()
set name = "Rotate Dispenser Clockwise"
@@ -37,36 +75,36 @@
if (src.anchored || usr:stat)
to_chat(usr, "It is fastened down!")
- return 0
+ return FALSE
src.set_dir(turn(src.dir, 270))
- return 1
+ return TRUE
/obj/machinery/chemical_dispenser/proc/add_cartridge(obj/item/weapon/reagent_containers/chem_disp_cartridge/C, mob/user)
if(!istype(C))
if(user)
- to_chat(user, "\The [C] will not fit in \the [src]!")
+ to_chat(user, span_warning("[C] will not fit in [src]!"))
return
if(cartridges.len >= DISPENSER_MAX_CARTRIDGES)
if(user)
- to_chat(user, "\The [src] does not have any slots open for \the [C] to fit into!")
+ to_chat(user, span_warning("[src] does not have any slots open for [C] to fit into!"))
return
if(!C.label)
if(user)
- to_chat(user, "\The [C] does not have a label!")
+ to_chat(user, span_warning("[C] does not have a label!"))
return
if(cartridges[C.label])
if(user)
- to_chat(user, "\The [src] already contains a cartridge with that label!")
+ to_chat(user, span_warning("[src] already contains a cartridge with that label!"))
return
if(user)
- user.drop_from_inventory(C)
- to_chat(user, "You add \the [C] to \the [src].")
+ user.drop_from_inventory(C, src)
+ to_chat(user, span_notice("You add [C] to [src]."))
- C.loc = src
+ C.forceMove(src)
cartridges[C.label] = C
cartridges = sortAssoc(cartridges)
SStgui.update_uis(src)
@@ -77,52 +115,74 @@
SStgui.update_uis(src)
/obj/machinery/chemical_dispenser/attackby(obj/item/weapon/W, mob/user)
- if(W.is_wrench())
- playsound(src, W.usesound, 50, 1)
- to_chat(user, "You begin to [anchored ? "un" : ""]fasten \the [src].")
- if (do_after(user, 20 * W.toolspeed))
- user.visible_message(
- "\The [user] [anchored ? "un" : ""]fastens \the [src].",
- "You have [anchored ? "un" : ""]fastened \the [src].",
- "You hear a ratchet.")
- anchored = !anchored
- else
- to_chat(user, "You decide not to [anchored ? "un" : ""]fasten \the [src].")
+ if(default_unfasten_wrench(user, W, 5 SECONDS))
+ return
- else if(istype(W, /obj/item/weapon/reagent_containers/chem_disp_cartridge))
+ if(istype(W, /obj/item/weapon/reagent_containers/chem_disp_cartridge))
+ if(!panel_open)
+ to_chat(user, span_notice("You need to open the access hatch first!"))
+ return
add_cartridge(W, user)
- else if(W.is_screwdriver())
- var/label = tgui_input_list(user, "Which cartridge would you like to remove?", "Chemical Dispenser", cartridges)
- if(!label) return
- var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = remove_cartridge(label)
- if(C)
- to_chat(user, "You remove \the [C] from \the [src].")
- C.loc = loc
- playsound(src, W.usesound, 50, 1)
-
- else if(istype(W, /obj/item/weapon/reagent_containers/glass) || istype(W, /obj/item/weapon/reagent_containers/food))
+ if(istype(W, /obj/item/weapon/reagent_containers/glass) || istype(W, /obj/item/weapon/reagent_containers/food))
if(container)
- to_chat(user, "There is already \a [container] on \the [src]!")
+ to_chat(user, span_warning("There is already \a [container] on [src]!"))
return
var/obj/item/weapon/reagent_containers/RC = W
if(!accept_drinking && istype(RC,/obj/item/weapon/reagent_containers/food))
- to_chat(user, "This machine only accepts beakers!")
+ to_chat(user, span_warning("This machine only accepts beakers!"))
return
if(!RC.is_open_container())
- to_chat(user, "You don't see how \the [src] could dispense reagents into \the [RC].")
+ to_chat(user, span_warning("You don't see how [src] could dispense reagents into [RC] with the lid on."))
return
- container = RC
- user.drop_from_inventory(RC)
- RC.loc = src
- to_chat(user, "You set \the [RC] on \the [src].")
+ replace_container(user, RC)
+ to_chat(user, span_notice("You add [RC] to [src]."))
+ updateUsrDialog()
+ update_icon()
+
+ if(default_deconstruction_screwdriver(user, W))
+ update_icon()
+ return
+
+ if(panel_open)
+ if(W.has_tool_quality(TOOL_CROWBAR)) //I would make the deconstructable, but the cartridge system makes this... unwise.
+ var/label = tgui_input_list(user, "Which cartridge would you like to remove?", "Chemical Dispenser", cartridges)
+ if(!label) return
+ var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = remove_cartridge(label)
+ if(C)
+ to_chat(user, span_notice("You remove [C] from [src]."))
+ C.forceMove(get_turf(src))
+ playsound(src, W.usesound, 50, 1)
+
else
return ..()
+/obj/machinery/chemical_dispenser/AltClick(mob/user)
+ if(container)
+ container.forceMove(get_turf(src))
+ if(Adjacent(usr)) // So the AI doesn't get a beaker somehow.
+ user.put_in_hands(container)
+ container = null
+ update_icon()
+
+/obj/machinery/chemical_dispenser/proc/replace_container(mob/living/user, obj/item/weapon/reagent_containers/new_container)
+ if(container)
+ container.forceMove(drop_location())
+ if(user && Adjacent(user))
+ user.put_in_hands(container)
+ if(new_container)
+ if(user && Adjacent(user))
+ user.drop_from_inventory(new_container, src)
+ container = new_container
+ else
+ container = null
+ update_icon()
+ return TRUE
+
/obj/machinery/chemical_dispenser/tgui_interact(mob/user, datum/tgui/ui = null)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
@@ -134,7 +194,7 @@
data["amount"] = amount
data["isBeakerLoaded"] = container ? 1 : 0
data["glass"] = accept_drinking
-
+
var/beakerContents[0]
if(container && container.reagents && container.reagents.reagent_list.len)
for(var/datum/reagent/R in container.reagents.reagent_list)
@@ -169,6 +229,7 @@
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = cartridges[label]
playsound(src, 'sound/machines/reagent_dispense.ogg', 25, 1)
C.reagents.trans_to(container, amount)
+ update_icon()
if("remove")
var/amount = text2num(params["amount"])
if(!container || !amount)
@@ -179,14 +240,10 @@
R.remove_reagent(id, amount)
else if(amount == -1) // Isolate
R.isolate_reagent(id)
+ update_icon()
if("ejectBeaker")
- if(container)
- container.forceMove(get_turf(src))
-
- if(Adjacent(usr)) // So the AI doesn't get a beaker somehow.
- usr.put_in_hands(container)
-
- container = null
+ replace_container(usr)
+ . = TRUE //no afterattack
else
return FALSE
diff --git a/code/modules/reagents/machinery/dispenser/dispenser_presets.dm b/code/modules/reagents/machinery/dispenser/dispenser_presets.dm
index 916c506a2e8..2aeabc7cfd2 100644
--- a/code/modules/reagents/machinery/dispenser/dispenser_presets.dm
+++ b/code/modules/reagents/machinery/dispenser/dispenser_presets.dm
@@ -63,7 +63,7 @@
desc = "A soda machine."
icon_state = "soda_dispenser"
ui_title = "Soda Dispenser"
- accept_drinking = 1
+ accept_drinking = TRUE
/obj/machinery/chemical_dispenser/bar_soft/full
spawn_cartridges = list(
@@ -93,7 +93,7 @@
desc = "A beer machine. Like a soda machine, but more fun!"
icon_state = "booze_dispenser"
ui_title = "Booze Dispenser"
- accept_drinking = 1
+ accept_drinking = TRUE
/obj/machinery/chemical_dispenser/bar_alc/full
spawn_cartridges = list(
@@ -125,7 +125,7 @@
desc = "Driving crack dealers out of employment since 2280."
icon_state = "coffee_dispenser"
ui_title = "Coffee Dispenser"
- accept_drinking = 1
+ accept_drinking = TRUE
/obj/machinery/chemical_dispenser/bar_coffee/full
spawn_cartridges = list(
diff --git a/code/modules/reagents/machinery/dispenser/dispenser_presets_vr.dm b/code/modules/reagents/machinery/dispenser/dispenser_presets_vr.dm
index f03f746d93d..926b18fb2aa 100644
--- a/code/modules/reagents/machinery/dispenser/dispenser_presets_vr.dm
+++ b/code/modules/reagents/machinery/dispenser/dispenser_presets_vr.dm
@@ -1,5 +1,6 @@
/obj/machinery/chemical_dispenser/xenoflora
name = "xenoflora chem dispenser"
+ icon_state = "minidispenser"
ui_title = "Xenoflora Chemical Dispenser"
dispense_reagents = list(
"water", "sugar", "ethanol", "radium", "ammonia", "diethylamine", "plantbgone", "mutagen", "calcium"
@@ -20,6 +21,7 @@
/obj/machinery/chemical_dispenser/biochemistry
name = "bioproduct dispenser"
+ icon_state = "minidispenser"
ui_title = "Bioproduct Dispenser"
dispense_reagents = list(
"nutriment", "protein", "milk"
@@ -70,4 +72,4 @@
name = "chemical dispenser"
icon = 'icons/obj/abductor_vr.dmi'
icon_state = "dispenser_2way"
- desc = "A mysterious machine which can fabricate many chemicals."
\ No newline at end of file
+ desc = "A mysterious machine which can fabricate many chemicals."
diff --git a/icons/obj/chemical.dmi b/icons/obj/chemical.dmi
index 5b3576b9eae..4c1ea9e6c2b 100644
Binary files a/icons/obj/chemical.dmi and b/icons/obj/chemical.dmi differ
diff --git a/icons/obj/reagentfillings.dmi b/icons/obj/reagentfillings.dmi
index 222a7190921..7d6175fd4c3 100644
Binary files a/icons/obj/reagentfillings.dmi and b/icons/obj/reagentfillings.dmi differ