mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
Ties research servers to Techwebs and de-hardcodes research point gen (#72513)
## About The Pull Request Research point generation is now done on all techwebs that have ``should_generate_points`` set to TRUE, which by default is only the Science techweb. I also entirely replaced the old 'servers' and 'master_servers' lists on SSresearch with the individual 'techweb_servers' (that already existed prior to this PR, the title is a little misleading) which are all stored on the individual techwebs, so we no longer store these in 2-3 different lists. Funnily enough, master server's list was unused as their behavior was refactored a good while ago. Sabotaging a master server now only affects the techweb the master server is connected to, rather than cut everyone's by half I also removed ``calculate_server_coefficient`` instead of reworked it to work with techweb servers, because it was entirely unused. ## Why It's Good For The Game Better consistency for several techwebs, as sabotaging one techweb won't sabotage all of them. This was also at the request of one of our contributors who wanted to make use of this system but didn't know that non-science techwebs didn't generate points, so here you go. ## Changelog 🆑 fix: If there are several techwebs, sabotaging the master server of one of them will no longer cut research point generation of the rest. /🆑
This commit is contained in:
@@ -7,15 +7,17 @@ SUBSYSTEM_DEF(research)
|
||||
//TECHWEB STATIC
|
||||
var/list/techweb_nodes = list() //associative id = node datum
|
||||
var/list/techweb_designs = list() //associative id = node datum
|
||||
|
||||
///List of all techwebs.
|
||||
var/list/datum/techweb/techwebs = list()
|
||||
///The default Science Techweb.
|
||||
var/datum/techweb/science/science_tech
|
||||
///The default Admin Techweb.
|
||||
var/datum/techweb/admin/admin_tech
|
||||
|
||||
var/datum/techweb_node/error_node/error_node //These two are what you get if a node/design is deleted and somehow still stored in a console.
|
||||
var/datum/design/error_design/error_design
|
||||
|
||||
///List of all research servers.
|
||||
var/list/obj/machinery/rnd/server/servers = list()
|
||||
|
||||
//ERROR LOGGING
|
||||
///associative id = number of times
|
||||
var/list/invalid_design_ids = list()
|
||||
@@ -42,14 +44,8 @@ SUBSYSTEM_DEF(research)
|
||||
var/list/point_types = list() //typecache style type = TRUE list
|
||||
//----------------------------------------------
|
||||
var/list/single_server_income = list(TECHWEB_POINT_TYPE_GENERIC = TECHWEB_SINGLE_SERVER_INCOME)
|
||||
var/last_income
|
||||
//^^^^^^^^ ALL OF THESE ARE PER SECOND! ^^^^^^^^
|
||||
|
||||
/// A list of all master servers. If none of these have a source code HDD, research point generation is lowered.
|
||||
var/list/obj/machinery/rnd/server/master/master_servers = list()
|
||||
/// A multiplier applied to all research gain.
|
||||
var/income_modifier = 1
|
||||
|
||||
//Aiming for 1.5 hours to max R&D
|
||||
//[88nodes * 5000points/node] / [1.5hr * 90min/hr * 60s/min]
|
||||
//Around 450000 points max???
|
||||
@@ -86,28 +82,23 @@ SUBSYSTEM_DEF(research)
|
||||
return SS_INIT_SUCCESS
|
||||
|
||||
/datum/controller/subsystem/research/fire()
|
||||
var/list/bitcoins = list()
|
||||
for(var/obj/machinery/rnd/server/miner as anything in servers)
|
||||
if(miner.working)
|
||||
bitcoins = single_server_income.Copy()
|
||||
break //Just need one to work.
|
||||
for(var/datum/techweb/techweb_list as anything in techwebs)
|
||||
if(!techweb_list.should_generate_points)
|
||||
continue
|
||||
var/list/bitcoins = list()
|
||||
for(var/obj/machinery/rnd/server/miner as anything in techweb_list.techweb_servers)
|
||||
if(miner.working)
|
||||
bitcoins = single_server_income.Copy()
|
||||
break //Just need one to work.
|
||||
|
||||
if (!isnull(last_income))
|
||||
var/income_time_difference = world.time - last_income
|
||||
science_tech.last_bitcoins = bitcoins // Doesn't take tick drift into account
|
||||
for(var/i in bitcoins)
|
||||
bitcoins[i] *= (income_time_difference / 10) * income_modifier
|
||||
science_tech.add_point_list(bitcoins)
|
||||
if(!isnull(techweb_list.last_income))
|
||||
var/income_time_difference = world.time - techweb_list.last_income
|
||||
techweb_list.last_bitcoins = bitcoins // Doesn't take tick drift into account
|
||||
for(var/i in bitcoins)
|
||||
bitcoins[i] *= (income_time_difference / 10) * techweb_list.income_modifier
|
||||
techweb_list.add_point_list(bitcoins)
|
||||
|
||||
last_income = world.time
|
||||
|
||||
/datum/controller/subsystem/research/proc/calculate_server_coefficient() //Diminishing returns.
|
||||
var/amt = servers.len
|
||||
if(!amt)
|
||||
return 0
|
||||
var/coeff = 100
|
||||
coeff = sqrt(coeff / amt)
|
||||
return coeff
|
||||
techweb_list.last_income = world.time
|
||||
|
||||
/datum/controller/subsystem/research/proc/autosort_categories()
|
||||
for(var/i in techweb_nodes)
|
||||
|
||||
@@ -144,11 +144,9 @@
|
||||
|
||||
//interrupt_research
|
||||
/obj/machinery/shuttle_scrambler/proc/interrupt_research()
|
||||
for(var/obj/machinery/rnd/server/S as anything in SSresearch.servers)
|
||||
for(var/obj/machinery/rnd/server/S as anything in SSresearch.science_tech.techweb_servers)
|
||||
if(S.machine_stat & (NOPOWER|BROKEN))
|
||||
continue
|
||||
if(S.stored_research != SSresearch.science_tech) //only target the station
|
||||
continue
|
||||
S.emp_act()
|
||||
new /obj/effect/temp_visual/emp(get_turf(S))
|
||||
|
||||
|
||||
@@ -301,12 +301,13 @@
|
||||
if (!turf_source)
|
||||
turf_source = get_turf(parent)
|
||||
var/list/local_servers = list()
|
||||
for (var/obj/machinery/rnd/server/server as anything in SSresearch.servers)
|
||||
var/turf/turf_server = get_turf(server)
|
||||
if (!turf_source || !turf_server)
|
||||
break
|
||||
if(is_valid_z_level(turf_source, turf_server))
|
||||
local_servers += server
|
||||
for (var/datum/techweb/techwebs as anything in SSresearch.techwebs)
|
||||
for (var/obj/machinery/rnd/server/server as anything in techwebs.techweb_servers)
|
||||
var/turf/turf_server = get_turf(server)
|
||||
if (!turf_source || !turf_server)
|
||||
break
|
||||
if(is_valid_z_level(turf_source, turf_server))
|
||||
local_servers += server
|
||||
return local_servers
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
. = ..()
|
||||
if(CONFIG_GET(flag/no_default_techweb_link))
|
||||
stored_research = new /datum/techweb
|
||||
SSresearch.servers |= src
|
||||
stored_research.techweb_servers |= src
|
||||
name += " [num2hex(rand(1,65535), -1)]" //gives us a random four-digit hex number as part of the name. Y'know, for fluff.
|
||||
|
||||
@@ -38,7 +37,6 @@
|
||||
stored_research.techweb_servers -= src
|
||||
if(CONFIG_GET(flag/no_default_techweb_link))
|
||||
QDEL_NULL(stored_research)
|
||||
SSresearch.servers -= src
|
||||
return ..()
|
||||
|
||||
/obj/machinery/rnd/server/update_icon_state()
|
||||
@@ -131,7 +129,7 @@
|
||||
add_fingerprint(usr)
|
||||
if (href_list["toggle"])
|
||||
if(allowed(usr) || obj_flags & EMAGGED)
|
||||
var/obj/machinery/rnd/server/S = locate(href_list["toggle"]) in SSresearch.servers
|
||||
var/obj/machinery/rnd/server/S = locate(href_list["toggle"]) in stored_research.techweb_servers
|
||||
S.toggle_disable(usr)
|
||||
else
|
||||
to_chat(usr, span_danger("Access Denied."))
|
||||
@@ -145,9 +143,7 @@
|
||||
|
||||
dat += "<b>Connected Servers:</b>"
|
||||
dat += "<table><tr><td style='width:25%'><b>Server</b></td><td style='width:25%'><b>Status</b></td><td style='width:25%'><b>Control</b></td>"
|
||||
for(var/obj/machinery/rnd/server/server as anything in SSresearch.servers)
|
||||
if(server.stored_research != stored_research) //not on our servers
|
||||
continue
|
||||
for(var/obj/machinery/rnd/server/server as anything in stored_research.techweb_servers)
|
||||
var/server_info = ""
|
||||
|
||||
var/status_text = server.get_status_text()
|
||||
@@ -204,7 +200,6 @@
|
||||
name = "\improper Master " + name
|
||||
desc += "\nIt looks incredibly resistant to damage!"
|
||||
source_code_hdd = new(src)
|
||||
SSresearch.master_servers += src
|
||||
|
||||
add_overlay("RD-server-objective-stripes")
|
||||
|
||||
@@ -212,8 +207,6 @@
|
||||
if (source_code_hdd && (deconstruction_state == HDD_OVERLOADED))
|
||||
QDEL_NULL(source_code_hdd)
|
||||
|
||||
SSresearch.master_servers -= src
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/rnd/server/master/get_status_text()
|
||||
@@ -307,7 +300,7 @@
|
||||
to_chat(user, span_notice("You cut the final wire and remove [source_code_hdd]."))
|
||||
try_put_in_hand(source_code_hdd, user)
|
||||
source_code_hdd = null
|
||||
SSresearch.income_modifier *= 0.5
|
||||
stored_research.income_modifier *= 0.5
|
||||
return TRUE
|
||||
to_chat(user, span_notice("You delicately cut the wire. [hdd_wires] wire\s left..."))
|
||||
return TRUE
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
///All research servers connected to this individual techweb.
|
||||
var/list/obj/machinery/rnd/server/techweb_servers = list()
|
||||
|
||||
///Boolean on whether the techweb should generate research points overtime.
|
||||
var/should_generate_points = FALSE
|
||||
///A multiplier applied to all research gain, cut in half if the Master server was sabotaged.
|
||||
var/income_modifier = 1
|
||||
///The amount of research points generated the techweb generated the latest time it generated.
|
||||
var/last_income
|
||||
|
||||
/**
|
||||
* Assoc list of relationships with various partners
|
||||
* scientific_cooperation[partner_typepath] = relationship
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
/datum/techweb/science
|
||||
id = "SCIENCE"
|
||||
organization = "Nanotrasen"
|
||||
should_generate_points = TRUE
|
||||
|
||||
//When something is researched, triggers the proc for this techweb only
|
||||
/datum/techweb/science/research_node(datum/techweb_node/node, force = FALSE, auto_adjust_cost = TRUE, get_that_dosh = TRUE)
|
||||
|
||||
Reference in New Issue
Block a user