Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit b0c3e6f

Browse files
authored
Synth project minor rework (sponsored by DownloadMoreRAM.com) (#22242)
* i hate this code, but it works * Update synth_os.dm * Update download_ram.dm
1 parent c6702d7 commit b0c3e6f

File tree

9 files changed

+52
-11
lines changed

9 files changed

+52
-11
lines changed

code/modules/mob/living/carbon/human/species_types/wy_synths.dm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@
228228

229229
/datum/species/wy_synth/proc/transfer(mob/living/carbon/human/user, mob/living/carbon/human/target)
230230
var/datum/mind/our_mind = user.mind
231-
user.mind.transfer_to(target)
232-
our_mind.synth_os.switch_shell(user, target)
231+
our_mind.synth_os.switch_shell(user, target) //handles the mind transfer to prevent project runtimes
233232

234233
target.real_name = "[user.real_name]" //Randomizing the name so it shows up separately in the shells list
235234
target.name = target.real_name

code/modules/mob/living/silicon/ai/decentralized/management/ai_dashboard.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
else
6464
var/synth_count = owner.ai_network.synth_list.len
6565
data["current_cpu"] = owner.ai_network.local_cpu_usage[SYNTH_RESEARCH] ? (owner.ai_network.resources.cpu_sources[owner.ai_network] * owner.ai_network.local_cpu_usage[SYNTH_RESEARCH]) / synth_count : 0
66+
data["current_ram"] = 0
6667

6768
if(!isAI(owner))
6869
var/mob/living/carbon/human/H = owner
@@ -90,6 +91,7 @@
9091
data["max_ram"] = owner.ai_network.resources.total_ram()
9192
else
9293
data["max_cpu"] = owner.ai_network.resources.cpu_sources[owner.ai_network]
94+
data["max_ram"] = free_ram //synths have vastly simplified ram
9395

9496
data["human_lock"] = owner.ai_network.resources.human_lock
9597

code/modules/mob/living/silicon/ai/decentralized/projects/synths/cold_protection.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
description = "By dumping excess power into our internal motors, we should be able to produce enough heat to protect against the cold."
44
research_cost = 1500
55
research_requirements_text = "None"
6+
ram_required = 1
67
category = SYNTH_PROJECT_EMERGENCY_FUNCTIONS
7-
permanent_suspicion = 30
88

99
/datum/ai_project/synth_project/cold_protection/run_project(force_run = FALSE)
1010
. = ..()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/datum/ai_project/synth_project/download_ram
2+
name = "Download more RAM"
3+
description = "Download more RAM from the NTNet. It works just as well as you think it would."
4+
research_cost = 3000 //can be considered powergamey, so it's a longer research, if it's too slow then maybe upgrade your cpu for once
5+
research_requirements_text = "None"
6+
can_be_run = FALSE
7+
8+
/datum/ai_project/synth_project/download_ram/finish()
9+
dashboard.free_ram += 2

code/modules/mob/living/silicon/ai/decentralized/projects/synths/heat_protection.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
description = "By modifying our internal processes, we should be able to induce a cooling cycle using excess fluid."
44
research_cost = 1500
55
research_requirements_text = "None"
6+
ram_required = 1
67
category = SYNTH_PROJECT_EMERGENCY_FUNCTIONS
7-
permanent_suspicion = 30
88

99
/datum/ai_project/synth_project/heat_protection/run_project(force_run = FALSE)
1010
. = ..()

code/modules/mob/living/silicon/ai/decentralized/projects/synths/speed_buff.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
description = "By overclocking the primary actuator in our legs, we should be able to speed up movement considerably."
44
research_cost = 1500
55
research_requirements_text = "None"
6+
ram_required = 1
67
category = SYNTH_PROJECT_MOBILITY
78

89
/datum/ai_project/synth_project/speed/run_project(force_run = FALSE)

code/modules/mob/living/silicon/ai/synthetics/synth_os.dm

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727

2828
var/synth_slowed = FALSE
2929
var/synth_force_decreased = FALSE
30-
var/synth_audible_warning = FALSE
30+
var/synth_audible_warning = FALSE //reminder, change all these booleans to instead use bitflags or something
3131
var/synth_temp_freeze = FALSE
3232

3333
var/list/synth_action_log = list()
3434

3535

3636
/datum/ai_dashboard/synth_dashboard
37-
37+
//bit of free ram to muck around with
38+
free_ram = 1
3839

3940
/datum/ai_dashboard/synth_dashboard/New(mob/living/new_owner)
4041
if(!istype(new_owner))
@@ -46,7 +47,7 @@
4647
completed_projects = list()
4748
running_projects = list()
4849
cpu_usage = list()
49-
50+
ram_usage = list()
5051

5152
for(var/path in subtypesof(/datum/ai_project/synth_project))
5253
var/datum/ai_project/newProject = path
@@ -95,10 +96,16 @@
9596
ui.open()
9697

9798
/datum/ai_dashboard/synth_dashboard/proc/switch_shell(mob/living/carbon/human/old_shell, mob/living/carbon/human/new_shell)
99+
var/list/restart = list()
98100
for(var/datum/ai_project/running_project in running_projects)
99101
running_project.stop(TRUE)
100-
running_project.synth = new_shell
101-
running_project.run_project(FALSE, TRUE)
102+
restart += running_project
103+
104+
old_shell.mind.transfer_to(new_shell) //transfer the mind between the stop and restart or we can't handle mind specific things in the projects
105+
106+
for(var/datum/ai_project/to_restart as anything in restart)
107+
to_restart.synth = new_shell
108+
to_restart.run_project(FALSE, TRUE)
102109
owner = new_shell
103110
punishment_shell_switch(old_shell, new_shell)
104111

@@ -113,8 +120,17 @@
113120
suspicion_tick()
114121

115122
/datum/ai_dashboard/synth_dashboard/run_project(datum/ai_project/project)
116-
project.run_project()
117-
return TRUE
123+
var/current_ram = free_ram //they have no physical ram to upgrade, so it's entirely determined by free ram
124+
125+
var/total_ram_used = 0
126+
for(var/I in ram_usage)
127+
total_ram_used += ram_usage[I]
128+
129+
if(current_ram - total_ram_used >= project.ram_required && project.canRun())
130+
project.run_project()
131+
ram_usage[project.name] += project.ram_required
132+
return TRUE
133+
return FALSE
118134

119135
/datum/ai_dashboard/synth_dashboard/proc/suspicion_tick()
120136
var/mob/living/carbon/human/H = owner

tgui/packages/tgui/interfaces/SynthDashboard.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ export const SynthDashboard = (props, context) => {
8383
</ProgressBar>
8484
Utilized CPU Power
8585
</LabeledControls.Item>
86+
<LabeledControls.Item>
87+
<ProgressBar
88+
ranges={{
89+
good: [data.current_ram * 0.7, Infinity],
90+
average: [data.current_ram * 0.3, data.current_ram * 0.7],
91+
bad: [0, data.current_ram * 0.3],
92+
}}
93+
value={data.used_ram}
94+
maxValue={data.current_ram}>
95+
{data.used_ram ? data.used_ram : 0}/{data.current_ram} TB
96+
</ProgressBar>
97+
Utilized RAM Capacity
98+
</LabeledControls.Item>
8699
<LabeledControls.Item>
87100
<Box color={governor_color} bold>{governor_status}</Box>
88101
Governor Module Status

yogstation.dme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,7 @@
30323032
#include "code\modules\mob\living\silicon\ai\decentralized\projects\synth_control.dm"
30333033
#include "code\modules\mob\living\silicon\ai\decentralized\projects\synths\_synth_project.dm"
30343034
#include "code\modules\mob\living\silicon\ai\decentralized\projects\synths\cold_protection.dm"
3035+
#include "code\modules\mob\living\silicon\ai\decentralized\projects\synths\download_ram.dm"
30353036
#include "code\modules\mob\living\silicon\ai\decentralized\projects\synths\heat_protection.dm"
30363037
#include "code\modules\mob\living\silicon\ai\decentralized\projects\synths\speed_buff.dm"
30373038
#include "code\modules\mob\living\silicon\ai\decentralized\systech\cpu.dm"

0 commit comments

Comments
 (0)