it works better when you're actually using a delta

This commit is contained in:
Putnam3145
2021-12-11 17:04:05 -08:00
parent f21be027d0
commit 13834847e0
2 changed files with 32 additions and 13 deletions
+6 -5
View File
@@ -346,12 +346,13 @@ SUBSYSTEM_DEF(research)
for(var/i in bitcoins)
bitcoins[i] *= income_time_difference / 10
science_tech.add_point_list(bitcoins)
if(!length(science_tech.last_bitcoins))
science_tech.last_bitcoins = science_tech.research_points
for(var/i in science_tech.last_bitcoins)
var/list/income = science_tech.commit_income()
for(var/i in income)
var/old_weighted = science_tech.last_bitcoins[i] * (1 MINUTES - income_time_difference)
var/new_weighted = science_tech.research_points[i] * income_time_difference
science_tech.last_bitcoins[i] = round((old_weighted + new_weighted) / (1 MINUTES))
var/new_weighted = income[i] * income_time_difference
science_tech.last_bitcoins[i] = (old_weighted + new_weighted) / (1 MINUTES)
else
science_tech.last_bitcoins = bitcoins.Copy()
last_income = world.time
/datum/controller/subsystem/research/proc/calculate_server_coefficient() //Diminishing returns.
+26 -8
View File
@@ -19,6 +19,7 @@
var/list/research_logs = list() //IC logs.
var/largest_bomb_value = 0
var/organization = "Third-Party" //Organization name, used for display.
var/list/next_income = list() //To be applied on the next passive techweb income
var/list/last_bitcoins = list() //Current per-second production, used for display only.
var/list/discovered_mutations = list() //Mutations discovered by genetics, this way they are shared and cant be destroyed by destroying a single console
var/list/tiers = list() //Assoc list, id = number, 1 is available, 2 is all reqs are 1, so on
@@ -105,10 +106,15 @@
V.rescan_views()
V.updateUsrDialog()
/datum/techweb/proc/add_point_list(list/pointlist)
for(var/i in pointlist)
if(SSresearch.point_types[i] && pointlist[i] > 0)
research_points[i] += pointlist[i]
/datum/techweb/proc/add_point_list(list/pointlist, income = TRUE)
if(income) // i DO NOT TRUST byond to optimize this way properly
for(var/i in pointlist)
if(SSresearch.point_types[i] && pointlist[i] > 0)
next_income[i] += pointlist[i]
else
for(var/i in pointlist)
if(SSresearch.point_types[i] && pointlist[i] > 0)
research_points[i] += pointlist[i]
/datum/techweb/proc/add_points_all(amount)
var/list/l = SSresearch.point_types.Copy()
@@ -116,6 +122,12 @@
l[i] = amount
add_point_list(l)
/datum/techweb/proc/commit_income()
. = next_income.Copy()
add_point_list(next_income, income = FALSE)
for(var/i in next_income)
next_income[i] = 0
/datum/techweb/proc/remove_point_list(list/pointlist)
for(var/i in pointlist)
if(SSresearch.point_types[i] && pointlist[i] > 0)
@@ -170,16 +182,22 @@
/datum/techweb/proc/get_researched_nodes()
return researched_nodes - hidden_nodes
/datum/techweb/proc/add_point_type(type, amount)
/datum/techweb/proc/add_point_type(type, amount, income = TRUE)
if(!SSresearch.point_types[type] || (amount <= 0))
return FALSE
research_points[type] += amount
if(income)
next_income[type] += amount
else
research_points[type] += amount
return TRUE
/datum/techweb/proc/modify_point_type(type, amount)
/datum/techweb/proc/modify_point_type(type, amount, income = TRUE)
if(!SSresearch.point_types[type])
return FALSE
research_points[type] = max(0, research_points[type] + amount)
if(income && amount > 0)
next_income[type] += amount
else
research_points[type] = max(0, research_points[type] + amount)
return TRUE
/datum/techweb/proc/remove_point_type(type, amount)