Skip to content

Commit c352a9d

Browse files
R-UST Mk.VII Mod. 1 (#37983)
* Rods now show their fullness * Open cover icon is now actually open * Fuel compression feedback * Building feedback * Proper fuel compressor sprite * Better building * Update fuel_assembly.dm * Update fuel_assembly_port.dm * Rods now always full, matter is 1 to 1 * to_chats for RUST testing, revert later * More logging stuff to revert later * Rust tokamak fixes * Stupid github interface * Revert "to_chats for RUST testing, revert later" This reverts commit 4b3157b. * Fixes RUST power drain * Github, I... * RUST fuel port adjacency rework * Change base type of gyrotron to power * Change gyro to power type pt2 * defines for gyrotrons * Defines in one file * Wire power consumption * New UI for core monitor * Forgot this * Github (or me) being dumb, defines * snake case + file rename * complete file rename * Proper power display in injector nano * injector power consumption indicator update * Fixes RUST core control computer
1 parent 3671738 commit c352a9d

27 files changed

+740
-362
lines changed

code/datums/supply_packs/engineering.dm

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
containsdesc = "Circuit boards for controlling a R-UST engine."
234234

235235
/datum/supply_packs/rust_gyrotron
236-
contains = list(/obj/machinery/rust/gyrotron)
236+
contains = list(/obj/machinery/power/gyrotron)
237237
name = "R-UST Mk. 7 gyrotron"
238238
cost = 25
239239
containertype = /obj/structure/closet/crate/secure/large
@@ -446,7 +446,7 @@
446446
group = "Engineering"
447447
access = list(access_engine_major)
448448
containsdesc = "Everything you need to build a very basic fission reactor. Comes with a pre-filled (albeit small) fuel reservoir."
449-
449+
450450
/datum/supply_packs/fissionreactor_expansion
451451
contains = list(
452452
/obj/structure/closet/crate/flatpack/configurable/fission_interior,
@@ -463,8 +463,8 @@
463463
containername = "Fission reactor expansion pak"
464464
group = "Engineering"
465465
access = list(access_engine_major)
466-
containsdesc = "Contains supplies to expand an existing fission reactor. Includes parts for 4 casings and 3 interior assemblies. Remember to turn it off and drain the coolant first!"
467-
466+
containsdesc = "Contains supplies to expand an existing fission reactor. Includes parts for 4 casings and 3 interior assemblies. Remember to turn it off and drain the coolant first!"
467+
468468
/datum/supply_packs/fissionreactor_bigrod
469469
contains = list(
470470
/obj/item/weapon/fuelrod/large
@@ -476,8 +476,8 @@
476476
group = "Engineering"
477477
access = list(access_engine_major)
478478
containsdesc = "An extra-large fuel reservoir, for extra power or for more complex fuel mixes. Use with extreme caution and control rods inserted."
479-
480-
479+
480+
481481
/datum/supply_packs/fissionreactor_randomrod
482482
contains = list(
483483
/obj/item/weapon/fuelrod/randomized
@@ -488,7 +488,6 @@
488488
containername = "Pre-filled fuel reservoir"
489489
group = "Engineering"
490490
access = list(access_engine_major)
491-
containsdesc = "A standard fuel reservoir, filled with a unique mixture selected by NanoTransen's engineering team."
492-
493-
494-
491+
containsdesc = "A standard fuel reservoir, filled with a unique mixture selected by NanoTransen's engineering team."
492+
493+

code/modules/maps/spawners/spawners.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
/obj/machinery/power/battery/smes,
200200
/obj/machinery/processor,
201201
/obj/machinery/recharge_station,
202-
/obj/machinery/rust/gyrotron,
202+
/obj/machinery/power/gyrotron,
203203
/obj/machinery/shield_gen,
204204
/obj/machinery/shieldgen,
205205
/obj/machinery/shieldwallgen,
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
#define RUST_GYROTRON_RANGE 25
1+
#define RUST_GYROTRON_RANGE 25
2+
#define MAX_FIELD_FREQ 1000
3+
#define MIN_FIELD_FREQ 1
4+
#define MAX_FIELD_STR 1000
5+
#define MIN_FIELD_STR 1
6+
#define RUST_CORE_STR_COST 500
7+
#define MIN_MEGA_ENERGY 0.001
8+
#define MAX_MEGA_ENERGY 0.01
9+
#define MAX_GYRO_FREQ 1000
10+
#define MIN_GYRO_FREQ 1
11+
#define GYRO_MEGA_COST 100000000 //Yes, original code made it that big

code/modules/power/rust/core_control.dm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
dat += {"
3232
<a href='?src=\ref[src];goto_scanlist=1'>Back to overview</a><hr>
3333
<b>Device tag:</b> [cur_viewed_device.id_tag]<br>
34-
<span style='color: [cur_viewed_device.owned_field ? "green" : "red"]'>Device [cur_viewed_device.owned_field ? "activated" : "deactivated"].</span><br>
35-
<a href='?src=\ref[src];toggle_active=1'>Bring field [cur_viewed_device.owned_field ? "offline" : "online"]</a><br>
34+
<span style='color: [cur_viewed_device.attempt_activate ? "green" : "red"]'>Device [cur_viewed_device.attempt_activate ? "activated" : "deactivated"].</span><br>
35+
<a href='?src=\ref[src];toggle_active=1'>[cur_viewed_device.attempt_activate ? "Shut down" : "Boot up"] field</a><br>
3636
<hr>
3737

3838
<b>Field encumbrance:</b> [cur_viewed_device.owned_field ? 0 : "N/A"]<br>
@@ -41,7 +41,7 @@
4141
<a href='?src=\ref[src];str=-100'>--- </a>
4242
<a href='?src=\ref[src];str=-10'>-- </a>
4343
<a href='?src=\ref[src];str=-1'>- </a>
44-
<a href='?src=\ref[src];str=0'>[cur_viewed_device.field_strength]</a>
44+
<a href='?src=\ref[src];str=0'>[cur_viewed_device.targeted_field_strength]</a>
4545
<a href='?src=\ref[src];str=1'>+ </a>
4646
<a href='?src=\ref[src];str=10'>++ </a>
4747
<a href='?src=\ref[src];str=100'>+++ </a>
@@ -80,7 +80,7 @@
8080
if(!check_core_status(C))
8181
status = "<span style='color: red'>Unresponsive</span>"
8282
can_access = 0
83-
else if(C.avail() < C.active_power_usage)
83+
else if(C.surplus() + round(C.get_satisfaction() * C.last_power_request) < C.active_power_usage)
8484
status = "<span style='color: orange'>Underpowered</span>"
8585
else
8686
status = "<span style='color: green'>Good</span>"
@@ -117,7 +117,7 @@
117117
return
118118

119119
if(href_list["access_device"])
120-
var/idx = clamp(text2num(href_list["toggle_active"]), 1, connected_devices.len)
120+
var/idx = clamp(text2num(href_list["access_device"]), 1, connected_devices.len)
121121
cur_viewed_device = connected_devices[idx]
122122
updateUsrDialog()
123123
return 1
@@ -139,9 +139,9 @@
139139
if(href_list["str"])
140140
var/val = text2num(href_list["str"])
141141
if(!val) //Value is 0, which is manual entering.
142-
cur_viewed_device.set_strength(input("Enter the new field power density (W.m^-3)", "R-UST Mk. 7 Tokamak Controls", cur_viewed_device.field_strength) as num)
142+
cur_viewed_device.set_targeted_strength(input("Enter the new field power density (W.m^-3)", "R-UST Mk. 7 Tokamak Controls", cur_viewed_device.targeted_field_strength) as num)
143143
else
144-
cur_viewed_device.set_strength(cur_viewed_device.field_strength + val)
144+
cur_viewed_device.set_targeted_strength(cur_viewed_device.targeted_field_strength + val)
145145
updateUsrDialog()
146146
return 1
147147

@@ -166,7 +166,7 @@
166166
if(C.state != 2)
167167
return
168168

169-
if(C.idle_power_usage > C.avail())
169+
if(!C.powered)
170170
return
171171

172172
. = 1

code/modules/power/rust/core_field.dm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Deuterium-tritium fusion: 4.5 x 10^7 K
2929
var/mega_energy = 0
3030
var/radiation = 0
3131
var/frequency = 1
32-
var/field_strength = 0.01 //in teslas, max is 50T
32+
var/field_strength = MIN_FIELD_STR //in teslas, max is 50T
3333

3434
var/obj/machinery/rust/rad_source/radiator
3535
var/datum/gas_mixture/held_plasma = new
@@ -261,6 +261,8 @@ Deuterium-tritium fusion: 4.5 x 10^7 K
261261
environment.merge(held_plasma)
262262

263263
/obj/effect/rust_em_field/proc/change_size(var/newsize = 1)
264+
if(newsize == size)
265+
return
264266
//
265267
var/changed = 0
266268
switch(newsize)
@@ -307,7 +309,8 @@ Deuterium-tritium fusion: 4.5 x 10^7 K
307309
var/list/reactants_reacting_pool = dormant_reactant_quantities.Copy()
308310
/*
309311
for(var/reagent in dormant_reactant_quantities)
310-
to_chat(world, " before: [reagent]: [dormant_reactant_quantities[reagent]]")
312+
to_chat(world, " before: [reagent]: [dormant_reactant_quantities[reagent]]")
313+
311314
*/
312315

313316
//cant have any reactions if there aren't any reactants present
@@ -343,7 +346,7 @@ Deuterium-tritium fusion: 4.5 x 10^7 K
343346
continue
344347
var/datum/fusion_reaction/cur_reaction = get_fusion_reaction(cur_primary_reactant, cur_secondary_reactant)
345348
if(cur_reaction)
346-
// to_chat(world, "<span class='notice'>secondary reactant: [cur_secondary_reactant], [reaction_products.len]</span>")
349+
// to_chat(world, "<span class='notice'>secondary reactant: [cur_secondary_reactant]</span>")s
347350
possible_reactions.Add(cur_reaction)
348351

349352
//if there are no possible reactions here, abandon this primary reactant and move on

code/modules/power/rust/core_gen.dm

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ max volume of plasma storeable by the field = the total volume of a number of ti
4040
4141
*/
4242

43-
#define MAX_FIELD_FREQ 1000
44-
#define MIN_FIELD_FREQ 1
45-
#define MAX_FIELD_STR 1000
46-
#define MIN_FIELD_STR 1
47-
#define RUST_CORE_STR_COST 5
48-
4943
/obj/machinery/power/rust_core
5044
name = "R-UST Mk 7 Tokamak core"
5145
desc = "An enormous solenoid for generating extremely high power electromagnetic fields."
@@ -57,12 +51,19 @@ max volume of plasma storeable by the field = the total volume of a number of ti
5751
light_color = LIGHT_COLOR_BLUE
5852

5953
var/obj/effect/rust_em_field/owned_field
60-
var/field_strength = 1//0.01
61-
var/field_frequency = 1
62-
63-
use_power = MACHINE_POWER_USE_IDLE
54+
var/field_strength = MIN_FIELD_STR
55+
var/targeted_field_strength = MIN_FIELD_STR
56+
var/field_frequency = MIN_FIELD_FREQ
57+
var/attempt_activate = FALSE
58+
var/powered = 0
59+
var/last_power_request = 0
60+
var/last_power_received = 0
61+
62+
use_power = MACHINE_POWER_USE_NONE
63+
power_priority = POWER_PRIORITY_POWER_EQUIPMENT
64+
monitoring_enabled = TRUE
6465
idle_power_usage = 50
65-
active_power_usage = 500 //multiplied by field strength
66+
active_power_usage = MIN_FIELD_FREQ * RUST_CORE_STR_COST //multiplied by field strength
6667
anchored = 0
6768
machine_flags = SCREWTOGGLE | CROWDESTROY | WRENCHMOVE | FIXED2WORK | WELD_FIXED | MULTITOOL_MENU
6869

@@ -81,14 +82,36 @@ max volume of plasma storeable by the field = the total volume of a number of ti
8182
if(ticker)
8283
initialize()
8384

85+
/obj/machinery/power/rust_core/Destroy()
86+
qdel(owned_field)
87+
..()
88+
8489
/obj/machinery/power/rust_core/initialize()
8590
if(!id_tag)
8691
assign_uid()
8792
id_tag = uid
8893

8994
/obj/machinery/power/rust_core/process()
90-
if(stat & BROKEN || !powernet)
95+
if(stat & BROKEN || state != 2 || (!powernet && active_power_usage))
96+
powered = 0
97+
Shutdown()
98+
return
99+
var/cur_satisfaction = get_satisfaction()
100+
var/power_received = last_power_request * cur_satisfaction
101+
add_load((attempt_activate || owned_field) ? active_power_usage : idle_power_usage)
102+
powered = power_received >= idle_power_usage
103+
if(!powered)
91104
Shutdown()
105+
else if(owned_field && power_received < MIN_FIELD_STR * RUST_CORE_STR_COST)
106+
Shutdown()
107+
else if(attempt_activate)
108+
if(owned_field)
109+
set_strength(round(power_received / RUST_CORE_STR_COST))
110+
else if(power_received >= MIN_FIELD_STR * RUST_CORE_STR_COST)
111+
set_strength(round(power_received / RUST_CORE_STR_COST))
112+
activate_field()
113+
last_power_request = (attempt_activate || owned_field) ? active_power_usage : idle_power_usage
114+
last_power_received = power_received
92115

93116
/obj/machinery/power/rust_core/weldToFloor(var/obj/item/tool/weldingtool/WT, mob/user)
94117
if(owned_field)
@@ -103,14 +126,14 @@ max volume of plasma storeable by the field = the total volume of a number of ti
103126
connect_to_network()
104127
return 1
105128
return -1
106-
129+
/* //was this ever needed? The core lacks a direct interface
107130
/obj/machinery/power/rust_core/Topic(href, href_list)
108131
if(..())
109132
return 1
110133
if(href_list["str"])
111134
var/dif = text2num(href_list["str"])
112135
field_strength = min(max(field_strength + dif, MIN_FIELD_STR), MAX_FIELD_STR)
113-
active_power_usage = 5 * field_strength //change to 500 later
136+
active_power_usage = RUST_CORE_STR_COST * field_strength //change to 500 later
114137
if(owned_field)
115138
owned_field.ChangeFieldStrength(field_strength)
116139
@@ -119,25 +142,28 @@ max volume of plasma storeable by the field = the total volume of a number of ti
119142
field_frequency = min(max(field_frequency + dif, MIN_FIELD_FREQ), MAX_FIELD_FREQ)
120143
if(owned_field)
121144
owned_field.ChangeFieldFrequency(field_frequency)
122-
145+
*/
123146
/obj/machinery/power/rust_core/proc/Startup()
124147
if(owned_field)
125148
return
149+
attempt_activate = TRUE
150+
. = 1
126151

152+
/obj/machinery/power/rust_core/proc/activate_field()
153+
if(owned_field)
154+
return
127155
owned_field = new(loc, src)
128156
owned_field.ChangeFieldStrength(field_strength)
129157
owned_field.ChangeFieldFrequency(field_frequency)
130158
set_light(light_range_on, light_power_on)
131159
icon_state = "core1"
132-
use_power = MACHINE_POWER_USE_ACTIVE
133160
. = 1
134161

135162
/obj/machinery/power/rust_core/proc/Shutdown()
136-
//todo: safety checks for field status
163+
attempt_activate = FALSE
137164
if(owned_field)
138165
icon_state = "core0"
139166
qdel(owned_field)
140-
use_power = MACHINE_POWER_USE_IDLE
141167
set_light(0)
142168

143169
/obj/machinery/power/rust_core/proc/AddParticles(var/name, var/quantity = 1)
@@ -156,10 +182,14 @@ max volume of plasma storeable by the field = the total volume of a number of ti
156182
</ul>
157183
"}
158184

185+
/obj/machinery/power/rust_core/proc/set_targeted_strength(var/value)
186+
value = clamp(value, MIN_FIELD_STR, MAX_FIELD_STR)
187+
targeted_field_strength = value
188+
active_power_usage = RUST_CORE_STR_COST * value
189+
159190
/obj/machinery/power/rust_core/proc/set_strength(var/value)
160191
value = clamp(value, MIN_FIELD_STR, MAX_FIELD_STR)
161192
field_strength = value
162-
active_power_usage = RUST_CORE_STR_COST * value
163193
if(owned_field)
164194
owned_field.ChangeFieldStrength(value)
165195

0 commit comments

Comments
 (0)