Skip to content
Open
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
17 changes: 5 additions & 12 deletions code/datums/research_upgrade_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,31 @@
behavior = RESEARCH_UPGRADE_ITEM
value_upgrade = 100
clearance_req = 1

/datum/research_upgrades/machinery/autodoc/internal_bleed/on_purchase(turf/machine_loc)
new /obj/item/research_upgrades/autodoc(machine_loc)
item_reference = /obj/item/research_upgrades/autodoc

/datum/research_upgrades/machinery/autodoc/broken_bone
name = "AutoDoc Bone Fracture Repair"
desc = "A data and instruction set for the AutoDoc, making it capable of setting fractures and applying bonegel."
behavior = RESEARCH_UPGRADE_ITEM
value_upgrade = 1500
clearance_req = 3

/datum/research_upgrades/machinery/autodoc/broken_bone/on_purchase(turf/machine_loc)
new /obj/item/research_upgrades/autodoc/tier2(machine_loc)
item_reference = /obj/item/research_upgrades/autodoc/tier2

/datum/research_upgrades/machinery/autodoc/organ_damage
name = "AutoDoc Broken Organ Repair"
desc = "A data and instruction set for the AutoDoc, making it capable of fixing organ damage."
behavior = RESEARCH_UPGRADE_ITEM
value_upgrade = 1500
clearance_req = 2

/datum/research_upgrades/machinery/autodoc/organ_damage/on_purchase(turf/machine_loc)
new /obj/item/research_upgrades/autodoc/tier3(machine_loc)
item_reference = /obj/item/research_upgrades/autodoc/tier3

/datum/research_upgrades/machinery/autodoc/larva_removal
name = "AutoDoc Embryo Removal"
desc = "Data and instruction set for AutoDoc making it mildly proficient in removing parasites left by unknown organism."
behavior = RESEARCH_UPGRADE_ITEM
value_upgrade = 4000
clearance_req = 6

/datum/research_upgrades/machinery/autodoc/larva_removal/on_purchase(turf/machine_loc)
new /obj/item/research_upgrades/autodoc/tier4(machine_loc)
item_reference = /obj/item/research_upgrades/autodoc/tier4

/datum/research_upgrades/machinery/grinderspeed
name = "Reagent-Grinder Upgrade"
Expand Down Expand Up @@ -146,6 +138,7 @@
minimum_price = 100
behavior = RESEARCH_UPGRADE_ITEM
upgrade_type = ITEM_ACCESSORY_UPGRADE
item_reference = /obj/item/stack/medical/splint/nano/research

/datum/research_upgrades/item/nanosplints/on_purchase(turf/machine_loc)
new /obj/item/stack/medical/splint/nano/research(machine_loc, 5)//adjust this to change amount of nanosplints in a stack, can't be higher than five, go change max_amount in the nanosplint itself, then change it.
Expand Down
33 changes: 31 additions & 2 deletions code/game/machinery/computer/research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@
for(var/category in GLOB.chemical_data.research_documents)
pool += category
pool = sortAssoc(pool)
response = tgui_input_list(usr,"Select a category:", "Categories", pool)
if(!length(pool))
to_chat(user, SPAN_WARNING("No saved research categories exist yet. Please create a new category."))
response = input(usr,"Please enter the category of the paper:")
else
response = tgui_input_list(usr,"Select a category:", "Categories", pool)
else if(response == "New")
response = input(usr,"Please enter the category of the paper:")
if(!response)
Expand All @@ -64,6 +68,31 @@
GLOB.chemical_data.reroll_chemicals()
visible_message(SPAN_NOTICE("[user] inserts [reroll] in [src], Rerolling contract chemicals."))
qdel(reroll)
return

var/research_item_name = GLOB.chemical_data.get_announceable_research_item_name(B)
if(research_item_name)
if(world.time < GLOB.chemical_data.next_research_item_announcement)
var/time_remaining = max(GLOB.chemical_data.next_research_item_announcement - world.time, 0)
to_chat(user, SPAN_WARNING("Relays re-calibrating. Please standby for [DisplayTimeText(time_remaining)]."))
return
var/default_amount = 1
if(istype(B, /obj/item/stack))
var/obj/item/stack/stack_item = B
default_amount = max(stack_item.amount, 1)
var/amount_available = tgui_input_number(user, "How Many?", "Research Update", default_amount, 1000, 1, 20 SECONDS, TRUE)
if(!amount_available)
return
if(!GLOB.chemical_data.announce_research_item_available(research_item_name, amount_available, user))
var/time_remaining = max(GLOB.chemical_data.next_research_item_announcement - world.time, 0)
to_chat(user, SPAN_WARNING("Relays re-calibrating. Please standby for [DisplayTimeText(time_remaining)]."))
return

if(GET_DEFAULT_ROLE(user.job) == JOB_RESEARCHER)
if(!GLOB.chemical_data.announce_novel_product_caution(user))
var/time_remaining = max(GLOB.chemical_data.next_novel_research_item_announcement - world.time, 0)
to_chat(user, SPAN_WARNING("Relays re-calibrating. Please standby for [DisplayTimeText(time_remaining)]."))
return

/obj/structure/machinery/computer/research/ui_state(mob/user)
return GLOB.not_incapacitated_and_adjacent_strict_state
Expand Down Expand Up @@ -181,7 +210,7 @@
if(!report)
to_chat(usr, SPAN_WARNING("Report data corrupted. Unable to transmit."))
return
GLOB.chemical_data.publish_document(report, print_type, print_title)
GLOB.chemical_data.publish_document(report, print_type, print_title, user)
if("unpublish_document")
var/print_title = params["print_title"]
var/print_type = params["print_type"]
Expand Down
93 changes: 91 additions & 2 deletions code/modules/reagents/chemical_research/Chemical-Research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,26 @@ GLOBAL_DATUM_INIT(chemical_data, /datum/chemical_data, new)
var/list/chemical_not_completed_objective_list = list() //List of not completed objective reagents indexed by ID associated with the objective value
var/list/chemical_identified_list = list() //List of all identified objective reagents indexed by ID associated with the objective value
var/list/research_computers = list()
var/next_research_item_announcement = 0
var/next_novel_research_item_announcement = 0

/datum/chemical_data/proc/update_credits(change)
rsc_credits = max(0, rsc_credits + change)

/datum/chemical_data/proc/get_announceable_research_item_name(obj/item/research_item)
if(!research_item || istype(research_item, /obj/item/research_upgrades/reroll))
return null
for(var/upgrade_type in subtypesof(/datum/research_upgrades))
var/datum/research_upgrades/upgrade = upgrade_type
if(upgrade.behavior != RESEARCH_UPGRADE_ITEM)
continue
var/announce_path = upgrade.item_reference
if(!announce_path || announce_path == /obj/item/research_upgrades/reroll)
continue
if(research_item.type == announce_path)
return upgrade.name
return null

/datum/chemical_data/proc/save_document(obj/item/paper/research_report/R, document_type, title)
if(!research_documents["[document_type]"])
research_documents["[document_type]"] = list()
Expand All @@ -48,7 +64,7 @@ GLOBAL_DATUM_INIT(chemical_data, /datum/chemical_data, new)
break
return report

/datum/chemical_data/proc/publish_document(obj/item/paper/research_report/R, document_type, title)
/datum/chemical_data/proc/publish_document(obj/item/paper/research_report/R, document_type, title, mob/living/carbon/human/publisher = null)
if(!research_publications["[document_type]"])
research_publications["[document_type]"] = list()
var/save_time = worldtime2text()
Expand All @@ -59,6 +75,8 @@ GLOBAL_DATUM_INIT(chemical_data, /datum/chemical_data, new)
"document"=R
)
research_publications["[document_type]"] += list(new_document)
if(is_stim_report(R))
announce_published_stim(R, publisher)

/datum/chemical_data/proc/unpublish_document(document_type, title)
if(!research_publications["[document_type]"])
Expand All @@ -85,6 +103,78 @@ GLOBAL_DATUM_INIT(chemical_data, /datum/chemical_data, new)
published_docs -= list(published_doc)
return TRUE

/datum/chemical_data/proc/is_stim_report(obj/item/paper/research_report/R)
var/datum/reagent/stim = R?.data
if(!istype(stim))
return FALSE
if(stim.flags & REAGENT_TYPE_STIMULANT)
return TRUE
for(var/datum/chem_property/property in stim.properties)
if(property.category & PROPERTY_TYPE_STIMULANT)
return TRUE
return FALSE

/datum/chemical_data/proc/get_all_marine_research_targets()
. = list()
for(var/mob/living/carbon/human/recipient as anything in GLOB.alive_human_list)
if(!recipient.client || recipient.stat != CONSCIOUS || isyautja(recipient))
continue
if(recipient.faction != FACTION_MARINE && !(FACTION_MARINE in recipient.faction_group))
continue
.[recipient] = TRUE

/datum/chemical_data/proc/send_research_update(list/targets, screen_message, chat_message)
if(!length(targets) || !screen_message || !chat_message)
return
for(var/mob/living/carbon/human/recipient as anything in targets)
playsound_client(recipient.client, 'sound/effects/radiostatic.ogg', recipient.loc, 25, FALSE)
to_chat(recipient, SPAN_BLUE("<B>Research Update:</B> [chat_message]"), type = MESSAGE_TYPE_RADIO)
recipient.play_screen_text("<span class='langchat' style=font-size:16pt;text-align:center valign='top'><u>Research Update</u></span><br>[screen_message]", /atom/movable/screen/text/screen_text/command_order, "#67d692")

/datum/chemical_data/proc/announce_published_stim(obj/item/paper/research_report/R, mob/living/carbon/human/publisher = null)
var/datum/reagent/stim = R?.data
if(!istype(stim))
return
var/list/targets = get_all_marine_research_targets()
if(!length(targets))
return

var/duration_multiplier = stim.custom_metabolism ? round(REAGENTS_METABOLISM / stim.custom_metabolism, 0.1) : 0
var/duration_text = duration_multiplier ? "[duration_multiplier]x" : "Unknown"
var/publisher_name = publisher ? publisher.real_name : "Unknown"
var/screen_message = "[stim.name] | OD [stim.overdose]u | Dur [duration_text]<br>Publisher: [publisher_name]"
var/chat_message = "[stim.name] published by [publisher_name]. OD [stim.overdose]u. Duration [duration_text]."
send_research_update(targets, screen_message, chat_message)

/datum/chemical_data/proc/announce_research_item_available(item_name, amount_available, mob/living/carbon/human/announcer = null)
if(!item_name || !amount_available || !announcer)
return FALSE
if(world.time < next_research_item_announcement)
return FALSE
var/list/targets = get_all_marine_research_targets()
if(!length(targets))
return FALSE

var/quantity_suffix = amount_available > 0 ? " (x[amount_available])" : ""
var/screen_message = "[announcer.real_name] has made [item_name] available[quantity_suffix]."
var/chat_message = "[announcer.real_name] has made [item_name] available[quantity_suffix]."
next_research_item_announcement = world.time + 2 MINUTES
send_research_update(targets, screen_message, chat_message)
return TRUE

/datum/chemical_data/proc/announce_novel_product_caution(mob/living/carbon/human/announcer = null)
if(!announcer)
return FALSE
if(world.time < next_novel_research_item_announcement)
return FALSE
var/list/targets = get_all_marine_research_targets()
if(!length(targets))
return FALSE

next_novel_research_item_announcement = world.time + 10 MINUTES
send_research_update(targets, "Novel product developed, advise caution.", "Novel product developed, advise caution.")
return TRUE

/datum/chemical_data/proc/save_new_properties(list/properties)
var/list/property_names = list()
for(var/datum/chem_property/P in properties) //just save the names
Expand Down Expand Up @@ -214,4 +304,3 @@ GLOBAL_DATUM_INIT(chemical_data, /datum/chemical_data, new)
clue["text"] = chem.name

return clue

Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,3 @@
attempt_process_queue(user)
else
queue_proccessing = FALSE

2 changes: 1 addition & 1 deletion tgui/packages/tgui/interfaces/ResearchTerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const CompoundRecord = (props: CompoundRecordProps) => {
</Button>
</Flex.Item>
)}
{isMainTerminal && !compound.isPublished && (
{!compound.isPublished && (
<Flex.Item>
<Button
icon="upload"
Expand Down
Loading