/
supermatter_gas.dm
236 lines (210 loc) · 7.79 KB
/
supermatter_gas.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/proc/init_sm_gas()
var/list/gas_list = list()
for (var/sm_gas_path in subtypesof(/datum/sm_gas))
var/datum/sm_gas/sm_gas = new sm_gas_path
gas_list[sm_gas.gas_path] = sm_gas
return gas_list
/// Return a list info of the SM gases.
/// Can only run after init_sm_gas
/proc/sm_gas_data()
var/list/data = list()
for (var/gas_path in GLOB.sm_gas_behavior)
var/datum/sm_gas/sm_gas = GLOB.sm_gas_behavior[gas_path]
var/list/singular_gas_data = list()
singular_gas_data["desc"] = sm_gas.desc
// Positive is true if more of the amount is a good thing.
var/list/numeric_data = list()
if(sm_gas.power_transmission)
var/list/si_derived_data = siunit_isolated(sm_gas.power_transmission * BASE_POWER_TRANSMISSION_RATE, "W/MeV", 2)
numeric_data += list(list(
"name" = "Power Transmission Bonus",
"amount" = si_derived_data["coefficient"],
"unit" = si_derived_data["unit"],
"positive" = TRUE,
))
if(sm_gas.heat_modifier)
numeric_data += list(list(
"name" = "Waste Multiplier",
"amount" = 100 * sm_gas.heat_modifier,
"unit" = "%",
"positive" = FALSE,
))
if(sm_gas.heat_resistance)
numeric_data += list(list(
"name" = "Heat Resistance",
"amount" = 100 * sm_gas.heat_resistance,
"unit" = "%",
"positive" = TRUE,
))
if(sm_gas.heat_power_generation)
var/list/si_derived_data = siunit_isolated(sm_gas.heat_power_generation * GAS_HEAT_POWER_SCALING_COEFFICIENT MEGA SECONDS / SSair.wait, "eV/K/s", 2)
numeric_data += list(list(
"name" = "Heat Power Gain",
"amount" = si_derived_data["coefficient"],
"unit" = si_derived_data["unit"],
"positive" = TRUE,
))
if(sm_gas.powerloss_inhibition)
numeric_data += list(list(
"name" = "Power Decay Negation",
"amount" = 100 * sm_gas.powerloss_inhibition,
"unit" = "%",
"positive" = TRUE,
))
singular_gas_data["numeric_data"] = numeric_data
data[gas_path] = singular_gas_data
return data
/// Assoc of sm_gas_behavior[/datum/gas (path)] = datum/sm_gas (instance)
GLOBAL_LIST_INIT(sm_gas_behavior, init_sm_gas())
/// Contains effects of gases when absorbed by the sm.
/// If the gas has no effects you do not need to add another sm_gas subtype,
/// We already guard for nulls in [/obj/machinery/power/supermatter_crystal/proc/calculate_gases]
/datum/sm_gas
/// Path of the [/datum/gas] involved with this interaction.
var/gas_path
/// Influences zap power without interfering with the crystal's own energy. Gets scaled by [BASE_POWER_TRANSMISSION_RATE].
var/power_transmission = 0
/// How much more waste heat and gas the SM generates.
var/heat_modifier = 0
/// How extra hot the SM can run before taking damage
var/heat_resistance = 0
/// Lets the sm generate extra power from heat. Yeah...
var/heat_power_generation = 0
/// How much powerloss do we get rid of.
var/powerloss_inhibition = 0
/// Give a short description of the gas if needed. If the gas have extra effects describe it here.
var/desc
/datum/sm_gas/proc/extra_effects(obj/machinery/power/supermatter_crystal/sm)
return
/datum/sm_gas/oxygen
gas_path = /datum/gas/oxygen
power_transmission = 0.15
heat_power_generation = 1
/datum/sm_gas/nitrogen
gas_path = /datum/gas/nitrogen
heat_modifier = -2.5
heat_power_generation = -1
/datum/sm_gas/carbon_dioxide
gas_path = /datum/gas/carbon_dioxide
heat_modifier = 1
heat_power_generation = 1
powerloss_inhibition = 1
desc = "When absorbed by the Supermatter and exposed to oxygen, Pluoxium will be generated."
/// Can be on Oxygen or CO2, but better lump it here since CO2 is rarer.
/datum/sm_gas/carbon_dioxide/extra_effects(obj/machinery/power/supermatter_crystal/sm)
if(!sm.gas_percentage[/datum/gas/carbon_dioxide] || !sm.gas_percentage[/datum/gas/oxygen])
return
var/co2_pp = sm.absorbed_gasmix.return_pressure() * sm.gas_percentage[/datum/gas/carbon_dioxide]
var/co2_ratio = clamp((1/2 * (co2_pp - CO2_CONSUMPTION_PP) / (co2_pp + CO2_PRESSURE_SCALING)), 0, 1)
var/consumed_co2 = sm.absorbed_gasmix.gases[/datum/gas/carbon_dioxide][MOLES] * co2_ratio
consumed_co2 = min(
consumed_co2,
sm.absorbed_gasmix.gases[/datum/gas/carbon_dioxide][MOLES],
sm.absorbed_gasmix.gases[/datum/gas/oxygen][MOLES]
)
if(!consumed_co2)
return
sm.absorbed_gasmix.gases[/datum/gas/carbon_dioxide][MOLES] -= consumed_co2
sm.absorbed_gasmix.gases[/datum/gas/oxygen][MOLES] -= consumed_co2
ASSERT_GAS(/datum/gas/pluoxium, sm.absorbed_gasmix)
sm.absorbed_gasmix.gases[/datum/gas/pluoxium][MOLES] += consumed_co2
/datum/sm_gas/plasma
gas_path = /datum/gas/plasma
heat_modifier = 14
power_transmission = 0.4
heat_power_generation = 1
/datum/sm_gas/water_vapor
gas_path = /datum/gas/water_vapor
heat_modifier = 11
power_transmission = -0.25
heat_power_generation = 1
/datum/sm_gas/hypernoblium
gas_path = /datum/gas/hypernoblium
heat_modifier = -14
power_transmission = 0.3
heat_power_generation = -1
/datum/sm_gas/nitrous_oxide
gas_path = /datum/gas/nitrous_oxide
heat_resistance = 5
/datum/sm_gas/tritium
gas_path = /datum/gas/tritium
heat_modifier = 9
power_transmission = 3
heat_power_generation = 1
/datum/sm_gas/bz
gas_path = /datum/gas/bz
heat_modifier = 4
power_transmission = -0.2
heat_power_generation = 1
desc = "Will emit nuclear particles at compositions above 40%"
/// Start to emit radballs at a maximum of 30% chance per tick
/datum/sm_gas/bz/extra_effects(obj/machinery/power/supermatter_crystal/sm)
if(sm.gas_percentage[/datum/gas/bz] > 0.4 && prob(30 * sm.gas_percentage[/datum/gas/bz]))
sm.fire_nuclear_particle()
/datum/sm_gas/pluoxium
gas_path = /datum/gas/pluoxium
heat_modifier = -1.5
power_transmission = -0.5
heat_power_generation = -1
/datum/sm_gas/miasma
gas_path = /datum/gas/miasma
heat_power_generation = 0.5
desc = "Will be consumed by the Supermatter to generate power."
///Miasma is really just microscopic particulate. It gets consumed like anything else that touches the crystal.
/datum/sm_gas/miasma/extra_effects(obj/machinery/power/supermatter_crystal/sm)
if(!sm.gas_percentage[/datum/gas/miasma])
return
var/miasma_pp = sm.absorbed_gasmix.return_pressure() * sm.gas_percentage[/datum/gas/miasma]
var/miasma_ratio = clamp(((miasma_pp - MIASMA_CONSUMPTION_PP) / (miasma_pp + MIASMA_PRESSURE_SCALING)) * (1 + (sm.gas_heat_power_generation * MIASMA_GASMIX_SCALING)), 0, 1)
var/consumed_miasma = sm.absorbed_gasmix.gases[/datum/gas/miasma][MOLES] * miasma_ratio
if(!consumed_miasma)
return
sm.absorbed_gasmix.gases[/datum/gas/miasma][MOLES] -= consumed_miasma
sm.external_power_trickle += consumed_miasma * MIASMA_POWER_GAIN
sm.log_activation("miasma absorption")
/datum/sm_gas/freon
gas_path = /datum/gas/freon
heat_modifier = -9
power_transmission = -3
heat_power_generation = -1
/datum/sm_gas/hydrogen
gas_path = /datum/gas/hydrogen
heat_modifier = 9
power_transmission = 2.5
heat_resistance = 1
heat_power_generation = 1
/datum/sm_gas/healium
gas_path = /datum/gas/healium
heat_modifier = 3
power_transmission = 0.24
heat_power_generation = 1
/datum/sm_gas/proto_nitrate
gas_path = /datum/gas/proto_nitrate
heat_modifier = -4
power_transmission = 1.5
heat_resistance = 4
heat_power_generation = 1
/datum/sm_gas/zauker
gas_path = /datum/gas/zauker
heat_modifier = 7
power_transmission = 2
heat_power_generation = 1
desc = "Will generate electrical zaps."
/datum/sm_gas/zauker/extra_effects(obj/machinery/power/supermatter_crystal/sm)
if(!prob(sm.gas_percentage[/datum/gas/zauker]))
return
playsound(sm.loc, 'sound/weapons/emitter2.ogg', 100, TRUE, extrarange = 10)
sm.supermatter_zap(
sm,
range = 6,
zap_str = clamp(sm.internal_energy * 1.6 KILO JOULES, 3.2 MEGA JOULES, 16 MEGA JOULES),
zap_flags = ZAP_MOB_STUN,
zap_cutoff = sm.zap_cutoff,
power_level = sm.internal_energy,
zap_icon = sm.zap_icon
)
/datum/sm_gas/antinoblium
gas_path = /datum/gas/antinoblium
heat_modifier = 14
power_transmission = -0.5
heat_power_generation = 1