From 1f95519602404b1d4be27bcbac49ed662fdeb1d9 Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:06:21 -0400 Subject: [PATCH 1/6] initial --- .../objects/items/reagent_containers/glass.dm | 4 - .../reagent_containers/reagent_container.dm | 136 +++++++++--------- .../objects/items/reagent_containers/spray.dm | 13 +- code/modules/mob/mob_helpers.dm | 2 +- 4 files changed, 73 insertions(+), 82 deletions(-) diff --git a/code/game/objects/items/reagent_containers/glass.dm b/code/game/objects/items/reagent_containers/glass.dm index a8b0ac1d6202..0ffcb30bf89d 100644 --- a/code/game/objects/items/reagent_containers/glass.dm +++ b/code/game/objects/items/reagent_containers/glass.dm @@ -552,10 +552,6 @@ return . = ..() -/obj/item/reagent_container/glass/pressurized_canister/set_APTFT() - to_chat(usr, SPAN_WARNING("[src] has no transfer control valve! Use a dispenser to fill it!")) - return - /obj/item/reagent_container/glass/pressurized_canister/on_reagent_change() update_icon() diff --git a/code/game/objects/items/reagent_containers/reagent_container.dm b/code/game/objects/items/reagent_containers/reagent_container.dm index 37029ff247d6..cb53a01b9c85 100644 --- a/code/game/objects/items/reagent_containers/reagent_container.dm +++ b/code/game/objects/items/reagent_containers/reagent_container.dm @@ -1,114 +1,108 @@ /obj/item/reagent_container name = "Container" - desc = "" icon = 'icons/obj/items/chemistry.dmi' - icon_state = null throwforce = 3 w_class = SIZE_SMALL - throw_speed = SPEED_FAST throw_range = 5 attack_speed = 3 - var/amount_per_transfer_from_this = 5 - var/possible_transfer_amounts = list(5,10,15,25,30) - var/volume = 30 - var/transparent = FALSE //can we see what's in it? - var/reagent_desc_override = FALSE //does it have a special examining mechanic that should override the normal /reagent_containers examine proc? - actions_types = list(/datum/action/item_action/reagent_container/set_transfer_amount) ground_offset_x = 7 ground_offset_y = 7 + /// How many units of reagent get transfered out of the container at a time + var/amount_per_transfer_from_this = 5 + /// A list of possible amounts that can be transferred + var/possible_transfer_amounts = list(5, 10, 15, 25, 30) + /// The maximum volume the container can hold + var/volume = 30 + /// Can we see what's in it? + var/transparent = FALSE + /// Does it have a special examining mechanic that should override the normal /reagent_containers examine proc? + var/reagent_desc_override = FALSE + /// Whether the container can have the set transfer amount action at all + var/has_set_transfer_action = TRUE /obj/item/reagent_container/Initialize() - if(!possible_transfer_amounts) - actions_types -= /datum/action/item_action/reagent_container/set_transfer_amount + if(has_set_transfer_action && LAZYLEN(possible_transfer_amounts)) + LAZYADD(actions_types, /datum/action/item_action/reagent_container/set_transfer_amount) . = ..() - if(!possible_transfer_amounts) - verbs -= /obj/item/reagent_container/verb/set_APTFT //which objects actually uses it? create_reagents(volume) +/obj/item/reagent_container/Destroy() + possible_transfer_amounts = null + return ..() + /obj/item/reagent_container/get_examine_text(mob/user) . = ..() var/reagent_info = show_reagent_info(user) if(reagent_info) . += reagent_info +/// Whether the user can see the amount or reagents inside /obj/item/reagent_container/proc/show_reagent_info(mob/user) - if(isxeno(user) || reagent_desc_override) + if(reagent_desc_override) return - var/list/reagent_desc - if(reagents && (transparent || user.can_see_reagents())) - reagent_desc += "It contains : " - if(!user.can_see_reagents()) - if(get_dist(user, src) > 2 && user != loc) //we have a distance check with this - return SPAN_WARNING("It's too far away for you to see what's in it!") - if(!length(reagents.reagent_list)) - reagent_desc += "nothing." - else - reagent_desc += "[reagents.total_volume] units of liquid." - return SPAN_INFO("[reagent_desc]") - else //when wearing science goggles, you can see what's in something from any range - if(!length(reagents.reagent_list)) - reagent_desc += "nothing." - else - for(var/datum/reagent/current_reagent as anything in reagents.reagent_list) - reagent_desc += "[round(current_reagent.volume, 0.01)] units of [current_reagent.name].
" - return SPAN_INFO("[reagent_desc]") - -/obj/item/reagent_container/verb/set_APTFT() //set amount_per_transfer_from_this - set name = "Set transfer amount" - set category = "Object" - set src in usr - if(!ishuman(usr)) + if(!reagents) return - var/mob/living/carbon/human/user = usr - var/obj/item/reagent_container/R = user.get_active_hand() - if(!istype(R)) + if(isxeno(user)) return - var/N = tgui_input_list(usr, "Amount per transfer from this:","[R]", possible_transfer_amounts) - if (N) - R.amount_per_transfer_from_this = N + var/reagent_desc = "[src] contains: " -/obj/item/reagent_container/Destroy() - possible_transfer_amounts = null - return ..() + if(user.can_see_reagents()) + reagent_desc += get_reagent_list_text() + return SPAN_INFO(reagent_desc) + + if(!transparent) + return + if(user != loc && get_dist(user, src) >2) + return SPAN_WARNING("[src] is too far away for you to see what's in it!") -/* -// Used on examine for properly skilled people to see contents. -// this is separate from show_reagent_info, as that proc is intended for use with science goggles -// this proc is general-purpose and primarily for medical items that you shouldn't need scigoggles to scan - ie pills, syringes, etc. -*/ + if(!LAZYLEN(reagents.reagent_list)) + reagent_desc += "Nothing" + return SPAN_INFO(reagent_desc) + + reagent_desc += "[reagents.total_volume] units of liquid" + return SPAN_INFO(reagent_desc) + +// this proc is general-purpose and primarily for medical items that you shouldn't need scigoggles to scan +/// Shows the reagent amount if the examining user is sufficiently skilled /obj/item/reagent_container/proc/display_contents(mob/user) if(isxeno(user)) return - if(skillcheck(user, SKILL_MEDICAL, SKILL_MEDICAL_TRAINED)) - return "[src] contains: [get_reagent_list_text()]."//this the pill - else + + if(!skillcheck(user, SKILL_MEDICAL, SKILL_MEDICAL_TRAINED)) return "You don't know what's in it." -//returns a text listing the reagents (and their volume) in the atom. Used by Attack logs for reagents in pills + return "[src] contains: [get_reagent_list_text()]." + +/// Returns a string listing all reagents (and their volume) in the container /obj/item/reagent_container/proc/get_reagent_list_text() - if(reagents && LAZYLEN(reagents.reagent_list)) - var/datum/reagent/R = reagents.reagent_list[1] - . = "[R.name]([R.volume]u)" - if(length(reagents.reagent_list) < 2) return - for (var/i in 2 to length(reagents.reagent_list)) - R = reagents.reagent_list[i] - if(!R) continue - . += "; [R.name]([R.volume]u)" - else - . = "No reagents" + if(!reagents || !LAZYLEN(reagents.reagent_list)) + return "No reagents" + + var/total_reagent_desc = "" + for(var/datum/reagent/current_reagent as anything in reagents.reagent_list) + if(total_reagent_desc != "") + total_reagent_desc += ", " + total_reagent_desc += "[current_reagent.name] ([current_reagent.volume]u)" + return total_reagent_desc /datum/action/item_action/reagent_container/set_transfer_amount + name = "Set Transfer Amount" + /// The container that transfer amount will be set on + var/obj/item/reagent_container/container /datum/action/item_action/reagent_container/set_transfer_amount/New(mob/living/user, obj/item/holder) ..() - name = "Set Transfer Amount" button.name = name button.overlays.Cut() - var/image/IMG = image(holder_item.icon, button, holder_item.icon_state) - button.overlays += IMG + var/image/button_overlay = image(holder_item.icon, button, holder_item.icon_state) + button.overlays += button_overlay + container = holder_item /datum/action/item_action/reagent_container/set_transfer_amount/action_activate() . = ..() - var/obj/item/reagent_container/cont = holder_item - cont.set_APTFT() + var/new_reagent_amount = tgui_input_list(owner, "Amount per transfer from this:","[container]", container.possible_transfer_amounts) + if(!new_reagent_amount) + return + to_chat(owner, SPAN_NOTICE("You change [container]'s reagent transfer amount to [new_reagent_amount].")) + container.amount_per_transfer_from_this = new_reagent_amount diff --git a/code/game/objects/items/reagent_containers/spray.dm b/code/game/objects/items/reagent_containers/spray.dm index 138e6ad01a3d..46328a160ba0 100644 --- a/code/game/objects/items/reagent_containers/spray.dm +++ b/code/game/objects/items/reagent_containers/spray.dm @@ -15,18 +15,19 @@ possible_transfer_amounts = list(5,10) //Set to null instead of list, if there is only one. matter = list("plastic" = 500) transparent = TRUE + volume = 250 + has_set_transfer_action = FALSE + ///How many tiles the spray will move var/spray_size = 3 + /// The spray_size based on the transfer amount var/list/spray_sizes = list(1,3) + /// Whether you can spray the bottle var/safety = FALSE - volume = 250 + /// The world.time it was last used var/last_use = 1 + /// The delay between uses var/use_delay = 0.5 SECONDS - -/obj/item/reagent_container/spray/Initialize() - . = ..() - verbs -= /obj/item/reagent_container/verb/set_APTFT - /obj/item/reagent_container/spray/afterattack(atom/A, mob/user, proximity) //this is what you get for using afterattack() TODO: make is so this is only called if attackby() returns 0 or something if(isstorage(A) || istype(A, /obj/structure/surface/table) || istype(A, /obj/structure/surface/rack) || istype(A, /obj/structure/closet) \ diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 37a6c46c23cc..79c0b89761f1 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -475,7 +475,7 @@ GLOBAL_LIST_INIT(limb_types_by_name, list( return TRUE /mob/proc/can_see_reagents() - return stat == DEAD || issynth(src) ||HAS_TRAIT(src, TRAIT_REAGENT_SCANNER) //Dead guys and synths can always see reagents + return stat == DEAD || issynth(src) || HAS_TRAIT(src, TRAIT_REAGENT_SCANNER) //Dead guys and synths can always see reagents /** * Examine a mob From 9193bec3f78a2c0b21c64a48d8f766bf89d54b09 Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:37:16 -0400 Subject: [PATCH 2/6] maybe this fixes it? --- code/game/objects/items/reagent_containers/hypospray.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/game/objects/items/reagent_containers/hypospray.dm b/code/game/objects/items/reagent_containers/hypospray.dm index 05b76568d702..aae40820fcc8 100644 --- a/code/game/objects/items/reagent_containers/hypospray.dm +++ b/code/game/objects/items/reagent_containers/hypospray.dm @@ -25,6 +25,10 @@ var/next_inject = 0 var/inject_cd = 0.75 SECONDS +/obj/item/reagent_container/hypospray/Destroy() + . = ..() + QDEL_NULL(mag) + /obj/item/reagent_container/hypospray/attack_self(mob/user) ..() From 16a0cbac789cce0592e51f05db05b7e6bdc20abb Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:34:19 -0400 Subject: [PATCH 3/6] Update code/game/objects/items/reagent_containers/hypospray.dm --- code/game/objects/items/reagent_containers/hypospray.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/reagent_containers/hypospray.dm b/code/game/objects/items/reagent_containers/hypospray.dm index aae40820fcc8..94477520daef 100644 --- a/code/game/objects/items/reagent_containers/hypospray.dm +++ b/code/game/objects/items/reagent_containers/hypospray.dm @@ -26,8 +26,8 @@ var/inject_cd = 0.75 SECONDS /obj/item/reagent_container/hypospray/Destroy() - . = ..() QDEL_NULL(mag) + . = ..() /obj/item/reagent_container/hypospray/attack_self(mob/user) ..() From 19989452982fcc9392456740100030313be9514e Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:34:31 -0400 Subject: [PATCH 4/6] Update code/game/objects/items/reagent_containers/reagent_container.dm Co-authored-by: Zonespace <41448081+Zonespace27@users.noreply.github.com> --- code/game/objects/items/reagent_containers/reagent_container.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/reagent_containers/reagent_container.dm b/code/game/objects/items/reagent_containers/reagent_container.dm index cb53a01b9c85..6ac5d8c5ff23 100644 --- a/code/game/objects/items/reagent_containers/reagent_container.dm +++ b/code/game/objects/items/reagent_containers/reagent_container.dm @@ -52,7 +52,7 @@ if(!transparent) return - if(user != loc && get_dist(user, src) >2) + if(user != loc && !in_range(src, user) return SPAN_WARNING("[src] is too far away for you to see what's in it!") if(!LAZYLEN(reagents.reagent_list)) From 056f022ca14d568353b0098bfe2d017a184fc519 Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:35:13 -0400 Subject: [PATCH 5/6] Update code/game/objects/items/reagent_containers/reagent_container.dm --- .../game/objects/items/reagent_containers/reagent_container.dm | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/game/objects/items/reagent_containers/reagent_container.dm b/code/game/objects/items/reagent_containers/reagent_container.dm index 6ac5d8c5ff23..1f1438324e53 100644 --- a/code/game/objects/items/reagent_containers/reagent_container.dm +++ b/code/game/objects/items/reagent_containers/reagent_container.dm @@ -26,9 +26,6 @@ . = ..() create_reagents(volume) -/obj/item/reagent_container/Destroy() - possible_transfer_amounts = null - return ..() /obj/item/reagent_container/get_examine_text(mob/user) . = ..() From 78a15a7688d7ed69c14db062059a9c94d12f8d07 Mon Sep 17 00:00:00 2001 From: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:41:21 -0400 Subject: [PATCH 6/6] pain --- .../objects/items/reagent_containers/reagent_container.dm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/reagent_containers/reagent_container.dm b/code/game/objects/items/reagent_containers/reagent_container.dm index 1f1438324e53..b39bc9975ace 100644 --- a/code/game/objects/items/reagent_containers/reagent_container.dm +++ b/code/game/objects/items/reagent_containers/reagent_container.dm @@ -49,7 +49,7 @@ if(!transparent) return - if(user != loc && !in_range(src, user) + if(user != loc && !in_range(src, user)) return SPAN_WARNING("[src] is too far away for you to see what's in it!") if(!LAZYLEN(reagents.reagent_list)) @@ -88,6 +88,10 @@ /// The container that transfer amount will be set on var/obj/item/reagent_container/container +/datum/action/item_action/reagent_container/set_transfer_amount/Destroy() + container = null + . = ..() + /datum/action/item_action/reagent_container/set_transfer_amount/New(mob/living/user, obj/item/holder) ..() button.name = name