From b6853f24f8a4497e2c7cf745c6c3c0c8419eb469 Mon Sep 17 00:00:00 2001
From: naut <55491249+nauticall@users.noreply.github.com>
Date: Thu, 25 Jul 2024 21:19:13 +0800
Subject: [PATCH] Intent-based sink/reagent dispenser filling (#19647)
Changes the sink/reagent dispenser (i.e. water tanks)' filling system to
be intent-based rather than opening a window every time. Should make
filling/emptying containers at least 10x quicker. :)
Use **HELP** intent to fill from a container. Any other intent (i.e.
HARM) will have you try to empty the container into the dispenser/sink
instead.
Additional examination info has been added to both the sink and reagent
dispensers to give such information.
---
code/game/objects/structures/watercloset.dm | 49 ++++++++---------
code/modules/reagents/reagent_dispenser.dm | 37 ++++++-------
html/changelogs/nauticall-sink_qol.yml | 58 +++++++++++++++++++++
3 files changed, 98 insertions(+), 46 deletions(-)
create mode 100644 html/changelogs/nauticall-sink_qol.yml
diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm
index fce2cefb2b7..1e934bd6dfb 100644
--- a/code/game/objects/structures/watercloset.dm
+++ b/code/game/objects/structures/watercloset.dm
@@ -296,7 +296,8 @@
icon = 'icons/obj/watercloset.dmi'
icon_state = "sink"
desc = "A sink used for washing one's hands and face."
- desc_info = "You can right-click this and change the amount transferred per use."
+ desc_info = "Use HELP intent to fill a container in your hand from this, and use any other intent to empty the container into this. \
+ You can right-click this and change the amount transferred per use."
anchored = 1
var/busy = 0 //Something's being washed at the moment
var/amount_per_transfer_from_this = 300
@@ -355,34 +356,32 @@
// Filling/emptying open reagent containers
var/obj/item/reagent_containers/RG = attacking_item
- if (istype(RG) && RG.is_open_container())
- var/atype = alert(usr, "Do you want to fill or empty \the [RG] at \the [src]?", "Fill or Empty", "Fill", "Empty", "Cancel")
-
+ if (istype(RG))
if(!usr.Adjacent(src)) return
if(RG.loc != usr && !isrobot(user)) return
if(busy)
to_chat(usr, SPAN_WARNING("Someone's already using \the [src]."))
return
+ if(!(RG.is_open_container()))
+ to_chat(usr, SPAN_WARNING("The [RG.name]'s lid is on!"))
+ return
+ if (usr.a_intent == I_HELP)
+ if(RG.reagents.total_volume >= RG.volume)
+ to_chat(usr, SPAN_WARNING("\The [RG] is already full."))
+ return
- switch(atype)
- if ("Fill")
- if(RG.reagents.total_volume >= RG.volume)
- to_chat(usr, SPAN_WARNING("\The [RG] is already full."))
- return
+ RG.reagents.add_reagent(/singleton/reagent/water, min(RG.volume - RG.reagents.total_volume, amount_per_transfer_from_this))
+ user.visible_message("[user] fills \a [RG] using \the [src].", SPAN_NOTICE("You fill \a [RG] using \the [src]."))
+ playsound(loc, 'sound/effects/sink.ogg', 75, 1)
+ else
+ if(!RG.reagents.total_volume)
+ to_chat(usr, SPAN_WARNING("\The [RG] is already empty."))
+ return
- RG.reagents.add_reagent(/singleton/reagent/water, min(RG.volume - RG.reagents.total_volume, amount_per_transfer_from_this))
- user.visible_message("[user] fills \a [RG] using \the [src].",
- SPAN_NOTICE("You fill \a [RG] using \the [src]."))
- playsound(loc, 'sound/effects/sink.ogg', 75, 1)
- if ("Empty")
- if(!RG.reagents.total_volume)
- to_chat(usr, SPAN_WARNING("\The [RG] is already empty."))
- return
-
- var/empty_amount = RG.reagents.trans_to(src, RG.amount_per_transfer_from_this)
- var/max_reagents = RG.reagents.maximum_volume
- user.visible_message("[user] empties [empty_amount == max_reagents ? "all of \the [RG]" : "some of \the [RG]"] into \a [src].")
- playsound(src.loc, /singleton/sound_category/generic_pour_sound, 10, 1)
+ var/empty_amount = RG.reagents.trans_to(src, RG.amount_per_transfer_from_this)
+ var/max_reagents = RG.reagents.maximum_volume
+ user.visible_message("[user] empties [empty_amount == max_reagents ? "all of \the [RG]" : "some of \the [RG]"] into \a [src].")
+ playsound(src.loc, /singleton/sound_category/generic_pour_sound, 10, 1)
return
// Filling/empying Syringes
@@ -396,8 +395,7 @@
var/trans = min(S.volume - S.reagents.total_volume, S.amount_per_transfer_from_this)
S.reagents.add_reagent(/singleton/reagent/water, trans)
- user.visible_message(SPAN_NOTICE("[usr] uses \the [S] to draw water from \the [src]."),
- SPAN_NOTICE("You draw [trans] units of water from \the [src]. \The [S] now contains [S.reagents.total_volume] units."))
+ user.visible_message(SPAN_NOTICE("[usr] uses \the [S] to draw water from \the [src]."), SPAN_NOTICE("You draw [trans] units of water from \the [src]. \The [S] now contains [S.reagents.total_volume] units."))
if(1) // inject
if(!S.reagents.total_volume)
to_chat(usr, SPAN_WARNING("\The [S] is already empty."))
@@ -405,8 +403,7 @@
var/trans = min(S.amount_per_transfer_from_this, S.reagents.total_volume)
S.reagents.remove_any(trans)
- user.visible_message(SPAN_NOTICE("[usr] empties \the [S] into \the [src]."),
- SPAN_NOTICE("You empty [trans] units of water into \the [src]. \The [S] now contains [S.reagents.total_volume] units."))
+ user.visible_message(SPAN_NOTICE("[usr] empties \the [S] into \the [src]."), SPAN_NOTICE("You empty [trans] units of water into \the [src]. \The [S] now contains [S.reagents.total_volume] units."))
return
else if (istype(attacking_item, /obj/item/melee/baton))
diff --git a/code/modules/reagents/reagent_dispenser.dm b/code/modules/reagents/reagent_dispenser.dm
index 8f7d1fe1011..4312980c582 100644
--- a/code/modules/reagents/reagent_dispenser.dm
+++ b/code/modules/reagents/reagent_dispenser.dm
@@ -1,7 +1,8 @@
/obj/structure/reagent_dispensers
name = "strange dispenser"
desc = "What the fuck is this?"
- desc_info = "You can right-click this and change the amount transferred per use."
+ desc_info = "Use HELP intent to fill a container in your hand from this, and use any other intent to empty the container into this. \
+ You can right-click this and change the amount transferred per use."
icon = 'icons/obj/reagent_dispensers.dmi'
icon_state = "watertank"
density = 1
@@ -42,27 +43,23 @@
/obj/structure/reagent_dispensers/attackby(obj/item/attacking_item, mob/user)
var/obj/item/reagent_containers/RG = attacking_item
- if (istype(RG) && RG.is_open_container())
-
- var/atype
- if(accept_any_reagent)
- atype = alert(user, "Do you want to fill or empty \the [RG] at \the [src]?", "Fill or Empty", "Fill", "Empty", "Cancel")
- else
- atype = alert(user, "Do you want to fill \the [RG] at \the [src]?", "Fill", "Fill", "Cancel")
-
+ if (istype(RG))
if(!user.Adjacent(src)) return
if(RG.loc != user && !isrobot(user)) return
-
- switch(atype)
- if ("Fill")
- RG.standard_dispenser_refill(user,src)
- playsound(src.loc, 'sound/machines/reagent_dispense.ogg', 25, 1)
- if ("Empty")
- if(is_open_container())
- RG.standard_pour_into(user,src)
- else
- to_chat(user,SPAN_NOTICE("The inlet cap on \the [src] is wrenched on tight!"))
- return
+ if(!(RG.is_open_container()))
+ to_chat(usr, SPAN_WARNING("The [RG.name]'s lid is on!"))
+ return
+ if (usr.a_intent == I_HELP)
+ RG.standard_dispenser_refill(user,src)
+ playsound(src.loc, 'sound/machines/reagent_dispense.ogg', 25, 1)
+ else
+ if(!accept_any_reagent)
+ to_chat(user,SPAN_WARNING("You can't refill \the [src]."))
+ return
+ if(is_open_container())
+ RG.standard_pour_into(user,src)
+ else
+ to_chat(user,SPAN_NOTICE("The inlet cap on \the [src] is wrenched on tight!"))
if (attacking_item.iswrench())
if(use_check(user, USE_DISALLOW_SPECIALS))
diff --git a/html/changelogs/nauticall-sink_qol.yml b/html/changelogs/nauticall-sink_qol.yml
new file mode 100644
index 00000000000..47ee7f0cfdd
--- /dev/null
+++ b/html/changelogs/nauticall-sink_qol.yml
@@ -0,0 +1,58 @@
+################################
+# Example Changelog File
+#
+# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
+#
+# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
+# When it is, any changes listed below will disappear.
+#
+# Valid Prefixes:
+# bugfix
+# - (fixes bugs)
+# wip
+# - (work in progress)
+# qol
+# - (quality of life)
+# soundadd
+# - (adds a sound)
+# sounddel
+# - (removes a sound)
+# rscadd
+# - (adds a feature)
+# rscdel
+# - (removes a feature)
+# imageadd
+# - (adds an image or sprite)
+# imagedel
+# - (removes an image or sprite)
+# spellcheck
+# - (fixes spelling or grammar)
+# experiment
+# - (experimental change)
+# balance
+# - (balance changes)
+# code_imp
+# - (misc internal code change)
+# refactor
+# - (refactors code)
+# config
+# - (makes a change to the config files)
+# admin
+# - (makes changes to administrator tools)
+# server
+# - (miscellaneous changes to server)
+#################################
+
+# Your name.
+author: nauticall
+
+# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
+delete-after: True
+
+# Any changes you've made. See valid prefix list above.
+# INDENT WITH TWO SPACES. NOT TABS. SPACES.
+# SCREW THIS UP AND IT WON'T WORK.
+# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
+# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
+changes:
+ - qol: "Sinks and reagent dispensers now have intent-based filling/emptying of containers like beakers/buckets. Use help intent to fill a container in your hand from a sink/tank/dispenser, any other intent to empty."