From 296c996434f34084fa2ef035541a2c82cbfce460 Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Thu, 9 Mar 2023 01:11:50 -0600 Subject: [PATCH] Completing experiments after their associated nodes have been researched gives back a partial refund of the discount lost (#73814) ## About The Pull Request So we're like simultaneously moving two vague directions with research. One being "experisci grants discounts for prohibitively expensive nodes so you want to do the experiments to discount them" and the other being "Let's give Heads of Staff a way to research anything they want without any communication to the research department, including the very expensive nodes that scientists may be working on" You already see the issue, right? You can't have your cake and eat it too. It sucks for scientists to be working on a complex experiment like weapons tech for that huge 90% discount only for the HoS to stumble onto the bridge and research it anyways. Your time is wasted and RND is slowed down massively. We can do something to assuage that. This PR makes it so completing an experiment which discounts already completed nodes will refund a partial amount of the discount that would've applied. For example, researching industrial engineering without scanning the iron toilets will refund ~5000 points. This can only apply once per experiment, so if an experiment discounts multiple technologies, they will only get a refund based on the first technology researched. ## Why It's Good For The Game This accomplishes the following: - Expensive research nodes with difficult experiments remain expensive without completing the experiments. If no one does the experiment, they act the same as before. - Expensive research nodes with very easy experiments (but time consuming) no longer put RND on a time crunch to beat the itchy trigger finger of the Heads of Staff. Stuff like scanning lathes allow the scientists to work more at their own pace: they can talk to people or maybe stop at the bar or kitchen between departments without feeling pressure to get it done urgently. - Scientists are able to complete experiments which previously were no longer deemed relevant if they need a point injection. Experiments left behind are no longer completely useless bricks. Maybe even gives latejoin scientists something to do. - Scientists mid experiment can still complete it to not feel like their time is wasted. Overall I think this has many benefits to the current science system where many have complaints. ## Changelog :cl: Melbert qol: Completing an experiment which discounts a researched tech node will give a partial refund of the discount lost. For example, researching the industrial engineering research without scanning iron toilets will refund ~5000 points if you complete it afterwards. This only applies once per experiment, so experiments which discount multiple nodes only refund the first researched. /:cl: --------- Co-authored-by: san7890 --- .../experisci/experiment/types/experiment.dm | 4 +- code/modules/research/techweb/_techweb.dm | 53 +++++++++++++++---- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/code/modules/experisci/experiment/types/experiment.dm b/code/modules/experisci/experiment/types/experiment.dm index efbf488426c..f760723f8db 100644 --- a/code/modules/experisci/experiment/types/experiment.dm +++ b/code/modules/experisci/experiment/types/experiment.dm @@ -83,6 +83,6 @@ */ /datum/experiment/proc/finish_experiment(datum/component/experiment_handler/experiment_handler) completed = TRUE - experiment_handler.announce_message_to_all("The [name] has been completed!") experiment_handler.selected_experiment = null - experiment_handler.linked_web.complete_experiment(src) + var/announcetext = experiment_handler.linked_web.complete_experiment(src) + experiment_handler.announce_message_to_all(announcetext) diff --git a/code/modules/research/techweb/_techweb.dm b/code/modules/research/techweb/_techweb.dm index d5f127aae7d..6b40449fe7b 100644 --- a/code/modules/research/techweb/_techweb.dm +++ b/code/modules/research/techweb/_techweb.dm @@ -38,10 +38,19 @@ var/list/discovered_mutations = list() /// Assoc list, id = number, 1 is available, 2 is all reqs are 1, so on var/list/tiers = list() - /// Available experiments - var/list/available_experiments = list() - /// Completed experiments - var/list/completed_experiments = list() + /// This is a list of all incomplete experiment datums that are accessible for scientists to complete + var/list/datum/experiment/available_experiments = list() + /// A list of all experiment datums that have been complete + var/list/datum/experiment/completed_experiments = list() + /// Assoc list of all experiment datums that have been skipped, to tech point reward for completing them - + /// That is, upon researching a node without completing its associated discounts, their experiments go here. + /// Completing these experiments will have a refund. + var/list/datum/experiment/skipped_experiment_types = list() + + /// If science researches something without completing its discount experiments, + /// they have the option to complete them later for a refund + /// This ratio determines how much of the original discount is refunded + var/skipped_experiment_refund_ratio = 0.66 ///All RD consoles connected to this individual techweb. var/list/obj/machinery/computer/rdconsole/consoles_accessing = list() @@ -294,7 +303,19 @@ /datum/techweb/proc/complete_experiment(datum/experiment/completed_experiment) available_experiments -= completed_experiment completed_experiments[completed_experiment.type] = completed_experiment - log_research("[completed_experiment.name] ([completed_experiment.type]) has been completed on techweb [id]/[organization]") + + var/result_text = "[completed_experiment] has been completed" + var/refund = skipped_experiment_types[completed_experiment.type] || 0 + if(refund > 0) + add_point_list(list(TECHWEB_POINT_TYPE_GENERIC = refund)) + result_text += ", refunding [refund] points." + // Nothing more to gain here, but we keep it in the list to prevent double dipping + skipped_experiment_types[completed_experiment.type] = -1 + else + result_text += "!" + + log_research("[completed_experiment.name] ([completed_experiment.type]) has been completed on techweb [id]/[organization][refund ? ", refunding [refund] points" : ""].") + return result_text /datum/techweb/proc/printout_points() return techweb_point_display_generic(research_points) @@ -311,10 +332,20 @@ return FALSE var/log_message = "[id]/[organization] researched node [node.id]" if(auto_adjust_cost) - var/node_cost = node.get_price(src) + var/list/node_cost = node.get_price(src) remove_point_list(node_cost) - log_message += " at the cost of [node_cost]" - researched_nodes[node.id] = TRUE //Add to our researched list + log_message += " at the cost of [json_encode(node_cost)]" + + //Add to our researched list + researched_nodes[node.id] = TRUE + + // Track any experiments we skipped relating to this + for(var/missed_experiment in node.discount_experiments) + if(completed_experiments[missed_experiment] || skipped_experiment_types[missed_experiment]) + continue + skipped_experiment_types[missed_experiment] = node.discount_experiments[missed_experiment] * skipped_experiment_refund_ratio + + // Gain the experiments from the new node for(var/id in node.unlock_ids) visible_nodes[id] = TRUE var/datum/techweb_node/unlocked_node = SSresearch.techweb_node_by_id(id) @@ -323,6 +354,8 @@ if (unlocked_node.discount_experiments.len > 0) add_experiments(unlocked_node.discount_experiments) update_node_status(unlocked_node) + + // Unlock what the research actually unlocks for(var/id in node.design_ids) add_design_by_id(id) update_node_status(node) @@ -477,9 +510,9 @@ continue experiment.completed = TRUE - complete_experiment(experiment) + var/announcetext = complete_experiment(experiment) if(length(GLOB.experiment_handlers)) var/datum/component/experiment_handler/handler = GLOB.experiment_handlers[1] - handler.announce_message_to_all("The [experiment.name] has been completed!") + handler.announce_message_to_all(announcetext) return TRUE