Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small updates to reagent containers #6891

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions code/game/objects/items/reagent_containers/glass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 4 additions & 0 deletions code/game/objects/items/reagent_containers/hypospray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
..()

Expand Down
141 changes: 68 additions & 73 deletions code/game/objects/items/reagent_containers/reagent_container.dm
Original file line number Diff line number Diff line change
@@ -1,114 +1,109 @@
/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/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].<br>"
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

/obj/item/reagent_container/Destroy()
possible_transfer_amounts = null
return ..()

/*
// 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.
*/
var/reagent_desc = "[src] contains: "

if(user.can_see_reagents())
reagent_desc += get_reagent_list_text()
return SPAN_INFO(reagent_desc)

if(!transparent)
return
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))
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
BeagleGaming1 marked this conversation as resolved.
Show resolved Hide resolved

/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)
..()
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
13 changes: 7 additions & 6 deletions code/game/objects/items/reagent_containers/spray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading