mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-20 19:44:46 +01:00
Minor SM Tweaks
Moves the SM files into the power folder. Makes the SM have a radiation floor of 50, instead of being completely inert when uncharged.
This commit is contained in:
@@ -0,0 +1,271 @@
|
||||
#define SETUP_OK 1 // All good
|
||||
#define SETUP_WARNING 2 // Something that shouldn't happen happened, but it's not critical so we will continue
|
||||
#define SETUP_ERROR 3 // Something bad happened, and it's important so we won't continue setup.
|
||||
#define SETUP_DELAYED 4 // Wait for other things first.
|
||||
|
||||
|
||||
#define ENERGY_NITROGEN 115 // Roughly 8 emitter shots.
|
||||
#define ENERGY_CARBONDIOXIDE 150 // Roughly 10 emitter shots.
|
||||
#define ENERGY_PHORON 300 // Roughly 20 emitter shots. Phoron can take more but this is enough to max out both SMESs anyway.
|
||||
|
||||
|
||||
/datum/admins/proc/setup_supermatter()
|
||||
set category = "Debug"
|
||||
set name = "Setup Supermatter"
|
||||
set desc = "Allows you to start the Supermatter engine."
|
||||
|
||||
if (!istype(src,/datum/admins))
|
||||
src = usr.client.holder
|
||||
if (!istype(src,/datum/admins))
|
||||
to_chat(usr, "Error: you are not an admin!")
|
||||
return
|
||||
|
||||
var/response = input(usr, "Are you sure? This will start up the engine with selected gas as coolant.", "Engine setup") as null|anything in list("N2", "CO2", "PH", "Abort")
|
||||
if(!response || response == "Abort")
|
||||
return
|
||||
|
||||
var/errors = 0
|
||||
var/warnings = 0
|
||||
var/success = 0
|
||||
|
||||
log_and_message_admins("## SUPERMATTER SETUP - Setup initiated by [usr] using coolant type [response].")
|
||||
|
||||
// CONFIGURATION PHASE
|
||||
// Coolant canisters, set types according to response.
|
||||
for(var/obj/effect/engine_setup/coolant_canister/C in world)
|
||||
switch(response)
|
||||
if("N2")
|
||||
C.canister_type = /obj/machinery/portable_atmospherics/canister/nitrogen/engine_setup/
|
||||
continue
|
||||
if("CO2")
|
||||
C.canister_type = /obj/machinery/portable_atmospherics/canister/carbon_dioxide/engine_setup/
|
||||
continue
|
||||
if("PH")
|
||||
C.canister_type = /obj/machinery/portable_atmospherics/canister/phoron/engine_setup/
|
||||
continue
|
||||
|
||||
for(var/obj/effect/engine_setup/core/C in world)
|
||||
switch(response)
|
||||
if("N2")
|
||||
C.energy_setting = ENERGY_NITROGEN
|
||||
continue
|
||||
if("CO2")
|
||||
C.energy_setting = ENERGY_CARBONDIOXIDE
|
||||
continue
|
||||
if("PH")
|
||||
C.energy_setting = ENERGY_PHORON
|
||||
continue
|
||||
|
||||
for(var/obj/effect/engine_setup/filter/F in world)
|
||||
F.coolant = response
|
||||
|
||||
var/list/delayed_objects = list()
|
||||
// SETUP PHASE
|
||||
for(var/obj/effect/engine_setup/S in world)
|
||||
var/result = S.activate(0)
|
||||
switch(result)
|
||||
if(SETUP_OK)
|
||||
success++
|
||||
continue
|
||||
if(SETUP_WARNING)
|
||||
warnings++
|
||||
continue
|
||||
if(SETUP_ERROR)
|
||||
errors++
|
||||
log_and_message_admins("## SUPERMATTER SETUP - Error encountered! Aborting.")
|
||||
break
|
||||
if(SETUP_DELAYED)
|
||||
delayed_objects.Add(S)
|
||||
continue
|
||||
|
||||
if(!errors)
|
||||
for(var/obj/effect/engine_setup/S in delayed_objects)
|
||||
var/result = S.activate(1)
|
||||
switch(result)
|
||||
if(SETUP_OK)
|
||||
success++
|
||||
continue
|
||||
if(SETUP_WARNING)
|
||||
warnings++
|
||||
continue
|
||||
if(SETUP_ERROR)
|
||||
errors++
|
||||
log_and_message_admins("## SUPERMATTER SETUP - Error encountered! Aborting.")
|
||||
break
|
||||
|
||||
log_and_message_admins("## SUPERMATTER SETUP - Setup completed with [errors] errors, [warnings] warnings and [success] successful steps.")
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
/obj/effect/engine_setup/
|
||||
name = "Engine Setup Marker"
|
||||
desc = "You shouldn't see this."
|
||||
invisibility = 101
|
||||
anchored = 1
|
||||
density = 0
|
||||
icon = 'icons/mob/screen1.dmi'
|
||||
icon_state = "x3"
|
||||
|
||||
/obj/effect/engine_setup/proc/activate(var/last = 0)
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
// Tries to locate a pump, enables it, and sets it to MAX. Triggers warning if unable to locate a pump.
|
||||
/obj/effect/engine_setup/pump_max/
|
||||
name = "Pump Setup Marker"
|
||||
|
||||
/obj/effect/engine_setup/pump_max/activate()
|
||||
..()
|
||||
var/obj/machinery/atmospherics/binary/pump/P = locate() in get_turf(src)
|
||||
if(!P)
|
||||
log_and_message_admins("## WARNING: Unable to locate pump at [x] [y] [z]!")
|
||||
return SETUP_WARNING
|
||||
P.target_pressure = P.max_pressure_setting
|
||||
P.use_power = 1
|
||||
P.update_icon()
|
||||
return SETUP_OK
|
||||
|
||||
|
||||
|
||||
// Spawns an empty canister on this turf, if it has a connector port. Triggers warning if unable to find a connector port
|
||||
/obj/effect/engine_setup/empty_canister/
|
||||
name = "Empty Canister Marker"
|
||||
|
||||
/obj/effect/engine_setup/empty_canister/activate()
|
||||
..()
|
||||
var/obj/machinery/atmospherics/portables_connector/P = locate() in get_turf(src)
|
||||
if(!P)
|
||||
log_and_message_admins("## WARNING: Unable to locate connector port at [x] [y] [z]!")
|
||||
return SETUP_WARNING
|
||||
new/obj/machinery/portable_atmospherics/canister(get_turf(src)) // Canisters automatically connect to connectors in New()
|
||||
return SETUP_OK
|
||||
|
||||
|
||||
|
||||
|
||||
// Spawns a coolant canister on this turf, if it has a connector port.
|
||||
// Triggers error when unable to locate connector port or when coolant canister type is unset.
|
||||
/obj/effect/engine_setup/coolant_canister/
|
||||
name = "Coolant Canister Marker"
|
||||
var/canister_type = null
|
||||
|
||||
/obj/effect/engine_setup/coolant_canister/activate()
|
||||
..()
|
||||
var/obj/machinery/atmospherics/portables_connector/P = locate() in get_turf(src)
|
||||
if(!P)
|
||||
log_and_message_admins("## ERROR: Unable to locate coolant connector port at [x] [y] [z]!")
|
||||
return SETUP_ERROR
|
||||
if(!canister_type)
|
||||
log_and_message_admins("## ERROR: Canister type unset at [x] [y] [z]!")
|
||||
return SETUP_ERROR
|
||||
new canister_type(get_turf(src))
|
||||
return SETUP_OK
|
||||
|
||||
|
||||
|
||||
// Energises the supermatter. Errors when unable to locate supermatter.
|
||||
/obj/effect/engine_setup/core/
|
||||
name = "Supermatter Core Marker"
|
||||
var/energy_setting = 0
|
||||
|
||||
/obj/effect/engine_setup/core/activate(var/last = 0)
|
||||
if(!last)
|
||||
return SETUP_DELAYED
|
||||
..()
|
||||
var/obj/machinery/power/supermatter/SM = locate() in get_turf(src)
|
||||
if(!SM)
|
||||
log_and_message_admins("## ERROR: Unable to locate supermatter core at [x] [y] [z]!")
|
||||
return SETUP_ERROR
|
||||
if(!energy_setting)
|
||||
log_and_message_admins("## ERROR: Energy setting unset at [x] [y] [z]!")
|
||||
return SETUP_ERROR
|
||||
SM.power = energy_setting
|
||||
return SETUP_OK
|
||||
|
||||
|
||||
|
||||
// Tries to enable the SMES on max input/output settings, unless the vars are changed. THIS SHOULD NOT BE PLACED ON THE MAIN SMES OR THE ENGINE WILL OVERHEAT
|
||||
/obj/effect/engine_setup/smes/
|
||||
name = "SMES Marker"
|
||||
var/target_input_level //These are in watts, the display is in kilowatts. Add three zeros to the value you want.
|
||||
var/target_output_level //These are in watts, the display is in kilowatts. Add three zeros to the value you want.
|
||||
|
||||
/obj/effect/engine_setup/smes/main
|
||||
target_input_level = 750000
|
||||
target_output_level = 750000
|
||||
|
||||
/obj/effect/engine_setup/smes/activate()
|
||||
..()
|
||||
var/obj/machinery/power/smes/S = locate() in get_turf(src)
|
||||
if(!S)
|
||||
log_and_message_admins("## WARNING: Unable to locate SMES unit at [x] [y] [z]!")
|
||||
return SETUP_WARNING
|
||||
S.input_attempt = 1
|
||||
S.output_attempt = 1
|
||||
if(target_input_level)
|
||||
if(target_input_level > S.input_level_max)
|
||||
S.input_level = S.input_level_max
|
||||
else
|
||||
S.input_level = target_input_level
|
||||
else
|
||||
S.input_level = S.input_level_max
|
||||
|
||||
if(target_output_level)
|
||||
if(target_output_level > S.input_level_max)
|
||||
S.output_level = S.output_level_max
|
||||
else
|
||||
S.output_level = target_output_level
|
||||
else
|
||||
S.output_level = S.output_level_max
|
||||
|
||||
S.update_icon()
|
||||
return SETUP_OK
|
||||
|
||||
|
||||
|
||||
// Sets up filters. This assumes filters are set to filter out N2 back to the core loop by default!
|
||||
/obj/effect/engine_setup/filter/
|
||||
name = "Omni Filter Marker"
|
||||
var/coolant = null
|
||||
|
||||
/obj/effect/engine_setup/filter/activate()
|
||||
..()
|
||||
var/obj/machinery/atmospherics/omni/filter/F = locate() in get_turf(src)
|
||||
if(!F)
|
||||
log_and_message_admins("## WARNING: Unable to locate omni filter at [x] [y] [z]!")
|
||||
return SETUP_WARNING
|
||||
if(!coolant)
|
||||
log_and_message_admins("## WARNING: No coolant type set at [x] [y] [z]!")
|
||||
return SETUP_WARNING
|
||||
|
||||
// Non-nitrogen coolant, adjust the filter's config first.
|
||||
if(coolant != "N2")
|
||||
for(var/datum/omni_port/P in F.ports)
|
||||
if(P.mode != ATM_N2)
|
||||
continue
|
||||
if(coolant == "PH")
|
||||
P.mode = ATM_P
|
||||
break
|
||||
else if(coolant == "CO2")
|
||||
P.mode = ATM_CO2
|
||||
break
|
||||
else
|
||||
log_and_message_admins("## WARNING: Inapropriate filter coolant type set at [x] [y] [z]!")
|
||||
return SETUP_WARNING
|
||||
F.rebuild_filtering_list()
|
||||
|
||||
F.use_power = 1
|
||||
F.update_icon()
|
||||
return SETUP_OK
|
||||
|
||||
|
||||
#undef SETUP_OK
|
||||
#undef SETUP_WARNING
|
||||
#undef SETUP_ERROR
|
||||
#undef SETUP_DELAYED
|
||||
#undef ENERGY_NITROGEN
|
||||
#undef ENERGY_CARBONDIOXIDE
|
||||
#undef ENERGY_PHORON
|
||||
@@ -0,0 +1,410 @@
|
||||
|
||||
#define NITROGEN_RETARDATION_FACTOR 0.15 //Higher == N2 slows reaction more
|
||||
#define THERMAL_RELEASE_MODIFIER 10000 //Higher == more heat released during reaction
|
||||
#define PHORON_RELEASE_MODIFIER 1500 //Higher == less phoron released by reaction
|
||||
#define OXYGEN_RELEASE_MODIFIER 15000 //Higher == less oxygen released at high temperature/power
|
||||
#define REACTION_POWER_MODIFIER 1.1 //Higher == more overall power
|
||||
|
||||
/*
|
||||
How to tweak the SM
|
||||
|
||||
POWER_FACTOR directly controls how much power the SM puts out at a given level of excitation (power var). Making this lower means you have to work the SM harder to get the same amount of power.
|
||||
CRITICAL_TEMPERATURE The temperature at which the SM starts taking damage.
|
||||
|
||||
CHARGING_FACTOR Controls how much emitter shots excite the SM.
|
||||
DAMAGE_RATE_LIMIT Controls the maximum rate at which the SM will take damage due to high temperatures.
|
||||
*/
|
||||
|
||||
//Controls how much power is produced by each collector in range - this is the main parameter for tweaking SM balance, as it basically controls how the power variable relates to the rest of the game.
|
||||
#define POWER_FACTOR 1.0
|
||||
#define DECAY_FACTOR 700 //Affects how fast the supermatter power decays
|
||||
#define CRITICAL_TEMPERATURE 5000 //K
|
||||
#define CHARGING_FACTOR 0.05
|
||||
#define DAMAGE_RATE_LIMIT 3 //damage rate cap at power = 300, scales linearly with power
|
||||
|
||||
|
||||
// Base variants are applied to everyone on the same Z level
|
||||
// Range variants are applied on per-range basis: numbers here are on point blank, it scales with the map size (assumes square shaped Z levels)
|
||||
#define DETONATION_RADS 20
|
||||
#define DETONATION_HALLUCINATION_BASE 300
|
||||
#define DETONATION_HALLUCINATION_RANGE 300
|
||||
#define DETONATION_HALLUCINATION 600
|
||||
|
||||
|
||||
#define WARNING_DELAY 20 //seconds between warnings.
|
||||
|
||||
/obj/machinery/power/supermatter
|
||||
name = "Supermatter"
|
||||
desc = "A strangely translucent and iridescent crystal. <font color='red'>You get headaches just from looking at it.</font>"
|
||||
icon = 'icons/obj/engine.dmi'
|
||||
icon_state = "darkmatter"
|
||||
density = 1
|
||||
anchored = 0
|
||||
light_range = 4
|
||||
|
||||
var/gasefficency = 0.25
|
||||
|
||||
var/base_icon_state = "darkmatter"
|
||||
|
||||
var/damage = 0
|
||||
var/damage_archived = 0
|
||||
var/safe_alert = "Crystaline hyperstructure returning to safe operating levels."
|
||||
var/safe_warned = 0
|
||||
var/public_alert = 0 //Stick to Engineering frequency except for big warnings when integrity bad
|
||||
var/warning_point = 100
|
||||
var/warning_alert = "Danger! Crystal hyperstructure instability!"
|
||||
var/emergency_point = 500
|
||||
var/emergency_alert = "CRYSTAL DELAMINATION IMMINENT."
|
||||
var/explosion_point = 1000
|
||||
|
||||
light_color = "#8A8A00"
|
||||
var/warning_color = "#B8B800"
|
||||
var/emergency_color = "#D9D900"
|
||||
|
||||
var/grav_pulling = 0
|
||||
var/pull_radius = 14
|
||||
// Time in ticks between delamination ('exploding') and exploding (as in the actual boom)
|
||||
var/pull_time = 100
|
||||
var/explosion_power = 8
|
||||
|
||||
var/emergency_issued = 0
|
||||
|
||||
// Time in 1/10th of seconds since the last sent warning
|
||||
var/lastwarning = 0
|
||||
|
||||
// This stops spawning redundand explosions. Also incidentally makes supermatter unexplodable if set to 1.
|
||||
var/exploded = 0
|
||||
|
||||
var/power = 0
|
||||
var/oxygen = 0
|
||||
|
||||
//Temporary values so that we can optimize this
|
||||
//How much the bullets damage should be multiplied by when it is added to the internal variables
|
||||
var/config_bullet_energy = 2
|
||||
//How much of the power is left after processing is finished?
|
||||
// var/config_power_reduction_per_tick = 0.5
|
||||
//How much hallucination should it produce per unit of power?
|
||||
var/config_hallucination_power = 0.1
|
||||
|
||||
var/debug = 0
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/Destroy()
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/power/supermatter/proc/explode()
|
||||
message_admins("Supermatter exploded at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("Supermatter exploded at ([x],[y],[z])")
|
||||
anchored = 1
|
||||
grav_pulling = 1
|
||||
exploded = 1
|
||||
var/turf/TS = get_turf(src) // The turf supermatter is on. SM being in a locker, mecha, or other container shouldn't block it's effects that way.
|
||||
if(!TS)
|
||||
return
|
||||
for(var/z in GetConnectedZlevels(TS.z))
|
||||
radiation_repository.z_radiate(locate(1, 1, z), DETONATION_RADS, 1)
|
||||
for(var/mob/living/mob in living_mob_list)
|
||||
var/turf/T = get_turf(mob)
|
||||
if(T && (loc.z == T.z))
|
||||
if(istype(mob, /mob/living/carbon/human))
|
||||
//Hilariously enough, running into a closet should make you get hit the hardest.
|
||||
var/mob/living/carbon/human/H = mob
|
||||
H.hallucination += max(50, min(300, DETONATION_HALLUCINATION * sqrt(1 / (get_dist(mob, src) + 1)) ) )
|
||||
spawn(pull_time)
|
||||
explosion(get_turf(src), explosion_power, explosion_power * 2, explosion_power * 3, explosion_power * 4, 1)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
//Changes color and luminosity of the light to these values if they were not already set
|
||||
/obj/machinery/power/supermatter/proc/shift_light(var/lum, var/clr)
|
||||
if(lum != light_range || clr != light_color)
|
||||
set_light(lum, l_color = clr)
|
||||
|
||||
/obj/machinery/power/supermatter/proc/get_integrity()
|
||||
var/integrity = damage / explosion_point
|
||||
integrity = round(100 - integrity * 100)
|
||||
integrity = integrity < 0 ? 0 : integrity
|
||||
return integrity
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/proc/announce_warning()
|
||||
var/integrity = get_integrity()
|
||||
var/alert_msg = " Integrity at [integrity]%"
|
||||
|
||||
if(damage > emergency_point)
|
||||
alert_msg = emergency_alert + alert_msg
|
||||
lastwarning = world.timeofday - WARNING_DELAY * 4
|
||||
else if(damage >= damage_archived) // The damage is still going up
|
||||
safe_warned = 0
|
||||
alert_msg = warning_alert + alert_msg
|
||||
lastwarning = world.timeofday
|
||||
else if(!safe_warned)
|
||||
safe_warned = 1 // We are safe, warn only once
|
||||
alert_msg = safe_alert
|
||||
lastwarning = world.timeofday
|
||||
else
|
||||
alert_msg = null
|
||||
if(alert_msg)
|
||||
global_announcer.autosay(alert_msg, "Supermatter Monitor", "Engineering")
|
||||
//Public alerts
|
||||
if((damage > emergency_point) && !public_alert)
|
||||
global_announcer.autosay("WARNING: SUPERMATTER CRYSTAL DELAMINATION IMMINENT!", "Supermatter Monitor")
|
||||
public_alert = 1
|
||||
else if(safe_warned && public_alert)
|
||||
global_announcer.autosay(alert_msg, "Supermatter Monitor")
|
||||
public_alert = 0
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/get_transit_zlevel()
|
||||
//don't send it back to the station -- most of the time
|
||||
if(prob(99))
|
||||
var/list/candidates = using_map.accessible_z_levels.Copy()
|
||||
for(var/zlevel in using_map.station_levels)
|
||||
candidates.Remove("[zlevel]")
|
||||
candidates.Remove("[src.z]")
|
||||
|
||||
if(candidates.len)
|
||||
return text2num(pickweight(candidates))
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/supermatter/process()
|
||||
|
||||
var/turf/L = loc
|
||||
|
||||
if(isnull(L)) // We have a null turf...something is wrong, stop processing this entity.
|
||||
return PROCESS_KILL
|
||||
|
||||
if(!istype(L)) //We are in a crate or somewhere that isn't turf, if we return to turf resume processing but for now.
|
||||
return //Yeah just stop.
|
||||
|
||||
if(damage > explosion_point)
|
||||
if(!exploded)
|
||||
if(!istype(L, /turf/space))
|
||||
announce_warning()
|
||||
explode()
|
||||
else if(damage > warning_point) // while the core is still damaged and it's still worth noting its status
|
||||
shift_light(5, warning_color)
|
||||
if(damage > emergency_point)
|
||||
shift_light(7, emergency_color)
|
||||
if(!istype(L, /turf/space) && (world.timeofday - lastwarning) >= WARNING_DELAY * 10)
|
||||
announce_warning()
|
||||
else
|
||||
shift_light(4,initial(light_color))
|
||||
if(grav_pulling)
|
||||
supermatter_pull()
|
||||
|
||||
//Ok, get the air from the turf
|
||||
var/datum/gas_mixture/removed = null
|
||||
var/datum/gas_mixture/env = null
|
||||
|
||||
//ensure that damage doesn't increase too quickly due to super high temperatures resulting from no coolant, for example. We dont want the SM exploding before anyone can react.
|
||||
//We want the cap to scale linearly with power (and explosion_point). Let's aim for a cap of 5 at power = 300 (based on testing, equals roughly 5% per SM alert announcement).
|
||||
var/damage_inc_limit = (power/300)*(explosion_point/1000)*DAMAGE_RATE_LIMIT
|
||||
|
||||
if(!istype(L, /turf/space))
|
||||
env = L.return_air()
|
||||
removed = env.remove(gasefficency * env.total_moles) //Remove gas from surrounding area
|
||||
|
||||
if(!env || !removed || !removed.total_moles)
|
||||
damage += max((power - 15*POWER_FACTOR)/10, 0)
|
||||
else if (grav_pulling) //If supermatter is detonating, remove all air from the zone
|
||||
env.remove(env.total_moles)
|
||||
else
|
||||
damage_archived = damage
|
||||
|
||||
damage = max( damage + min( ( (removed.temperature - CRITICAL_TEMPERATURE) / 150 ), damage_inc_limit ) , 0 )
|
||||
//Ok, 100% oxygen atmosphere = best reaction
|
||||
//Maxes out at 100% oxygen pressure
|
||||
oxygen = max(min((removed.gas["oxygen"] - (removed.gas["nitrogen"] * NITROGEN_RETARDATION_FACTOR)) / removed.total_moles, 1), 0)
|
||||
|
||||
//calculate power gain for oxygen reaction
|
||||
var/temp_factor
|
||||
var/equilibrium_power
|
||||
if (oxygen > 0.8)
|
||||
//If chain reacting at oxygen == 1, we want the power at 800 K to stabilize at a power level of 400
|
||||
equilibrium_power = 400
|
||||
icon_state = "[base_icon_state]_glow"
|
||||
else
|
||||
//If chain reacting at oxygen == 1, we want the power at 800 K to stabilize at a power level of 250
|
||||
equilibrium_power = 250
|
||||
icon_state = base_icon_state
|
||||
|
||||
temp_factor = ( (equilibrium_power/DECAY_FACTOR)**3 )/800
|
||||
power = max( (removed.temperature * temp_factor) * oxygen + power, 0)
|
||||
|
||||
//We've generated power, now let's transfer it to the collectors for storing/usage
|
||||
//transfer_energy()
|
||||
|
||||
var/device_energy = power * REACTION_POWER_MODIFIER
|
||||
|
||||
//Release reaction gasses
|
||||
var/heat_capacity = removed.heat_capacity()
|
||||
removed.adjust_multi("phoron", max(device_energy / PHORON_RELEASE_MODIFIER, 0), \
|
||||
"oxygen", max((device_energy + removed.temperature - T0C) / OXYGEN_RELEASE_MODIFIER, 0))
|
||||
|
||||
var/thermal_power = THERMAL_RELEASE_MODIFIER * device_energy
|
||||
if (debug)
|
||||
var/heat_capacity_new = removed.heat_capacity()
|
||||
visible_message("[src]: Releasing [round(thermal_power)] W.")
|
||||
visible_message("[src]: Releasing additional [round((heat_capacity_new - heat_capacity)*removed.temperature)] W with exhaust gasses.")
|
||||
|
||||
removed.add_thermal_energy(thermal_power)
|
||||
removed.temperature = between(0, removed.temperature, 10000)
|
||||
|
||||
env.merge(removed)
|
||||
|
||||
for(var/mob/living/carbon/human/l in view(src, min(7, round(sqrt(power/6))))) // If they can see it without mesons on. Bad on them.
|
||||
var/eye_shield = 0 //How protected they are
|
||||
if(istype(l.glasses, /obj/item/clothing/glasses/meson))
|
||||
eye_shield += 1
|
||||
if(istype(l.head, /obj/item/clothing/head/helmet/space))
|
||||
if(l.run_armor_check(BP_HEAD, "rad") >= 60)
|
||||
eye_shield += 1
|
||||
if(eye_shield < 1)
|
||||
l.hallucination = max(0, min(200, l.hallucination + power * config_hallucination_power * sqrt( 1 / max(1,get_dist(l, src)) ) ) )
|
||||
|
||||
radiation_repository.radiate(src, max(power * 1.5, 50) ) //Better close those shutters!
|
||||
|
||||
power -= (power/DECAY_FACTOR)**3 //energy losses due to radiation
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/bullet_act(var/obj/item/projectile/Proj)
|
||||
var/turf/L = loc
|
||||
if(!istype(L)) // We don't run process() when we are in space
|
||||
return 0 // This stops people from being able to really power up the supermatter
|
||||
// Then bring it inside to explode instantly upon landing on a valid turf.
|
||||
|
||||
|
||||
var/proj_damage = Proj.get_structure_damage()
|
||||
if(istype(Proj, /obj/item/projectile/beam))
|
||||
power += proj_damage * config_bullet_energy * CHARGING_FACTOR / POWER_FACTOR
|
||||
else
|
||||
damage += proj_damage * config_bullet_energy
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/supermatter/attack_robot(mob/user as mob)
|
||||
if(Adjacent(user))
|
||||
return attack_hand(user)
|
||||
else
|
||||
ui_interact(user)
|
||||
return
|
||||
|
||||
/obj/machinery/power/supermatter/attack_ai(mob/user as mob)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/supermatter/attack_hand(mob/user as mob)
|
||||
user.visible_message("<span class=\"warning\">\The [user] reaches out and touches \the [src], inducing a resonance... \his body starts to glow and bursts into flames before flashing into ash.</span>",\
|
||||
"<span class=\"danger\">You reach out and touch \the [src]. Everything starts burning and all you can hear is ringing. Your last thought is \"That was not a wise decision.\"</span>",\
|
||||
"<span class=\"warning\">You hear an uneartly ringing, then what sounds like a shrilling kettle as you are washed with a wave of heat.</span>")
|
||||
|
||||
Consume(user)
|
||||
|
||||
// This is purely informational UI that may be accessed by AIs or robots
|
||||
/obj/machinery/power/supermatter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/data[0]
|
||||
|
||||
data["integrity_percentage"] = round(get_integrity())
|
||||
var/datum/gas_mixture/env = null
|
||||
if(!istype(src.loc, /turf/space))
|
||||
env = src.loc.return_air()
|
||||
|
||||
if(!env)
|
||||
data["ambient_temp"] = 0
|
||||
data["ambient_pressure"] = 0
|
||||
else
|
||||
data["ambient_temp"] = round(env.temperature)
|
||||
data["ambient_pressure"] = round(env.return_pressure())
|
||||
data["detonating"] = grav_pulling
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "supermatter_crystal.tmpl", "Supermatter Crystal", 500, 300)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/attackby(obj/item/weapon/W as obj, mob/living/user as mob)
|
||||
user.visible_message("<span class=\"warning\">\The [user] touches \a [W] to \the [src] as a silence fills the room...</span>",\
|
||||
"<span class=\"danger\">You touch \the [W] to \the [src] when everything suddenly goes silent.\"</span>\n<span class=\"notice\">\The [W] flashes into dust as you flinch away from \the [src].</span>",\
|
||||
"<span class=\"warning\">Everything suddenly goes silent.</span>")
|
||||
|
||||
user.drop_from_inventory(W)
|
||||
Consume(W)
|
||||
|
||||
user.apply_effect(150, IRRADIATE)
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/Bumped(atom/AM as mob|obj)
|
||||
if(istype(AM, /obj/effect))
|
||||
return
|
||||
if(istype(AM, /mob/living))
|
||||
AM.visible_message("<span class=\"warning\">\The [AM] slams into \the [src] inducing a resonance... \his body starts to glow and catch flame before flashing into ash.</span>",\
|
||||
"<span class=\"danger\">You slam into \the [src] as your ears are filled with unearthly ringing. Your last thought is \"Oh, fuck.\"</span>",\
|
||||
"<span class=\"warning\">You hear an uneartly ringing, then what sounds like a shrilling kettle as you are washed with a wave of heat.</span>")
|
||||
else if(!grav_pulling) //To prevent spam, detonating supermatter does not indicate non-mobs being destroyed
|
||||
AM.visible_message("<span class=\"warning\">\The [AM] smacks into \the [src] and rapidly flashes to ash.</span>",\
|
||||
"<span class=\"warning\">You hear a loud crack as you are washed with a wave of heat.</span>")
|
||||
|
||||
Consume(AM)
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/proc/Consume(var/mob/living/user)
|
||||
if(istype(user))
|
||||
user.dust()
|
||||
power += 200
|
||||
else
|
||||
qdel(user)
|
||||
|
||||
power += 200
|
||||
|
||||
//Some poor sod got eaten, go ahead and irradiate people nearby.
|
||||
for(var/mob/living/l in range(10))
|
||||
if(l in view())
|
||||
l.show_message("<span class=\"warning\">As \the [src] slowly stops resonating, you find your skin covered in new radiation burns.</span>", 1,\
|
||||
"<span class=\"warning\">The unearthly ringing subsides and you notice you have new radiation burns.</span>", 2)
|
||||
else
|
||||
l.show_message("<span class=\"warning\">You hear an uneartly ringing and notice your skin is covered in fresh radiation burns.</span>", 2)
|
||||
var/rads = 500
|
||||
radiation_repository.radiate(src, rads)
|
||||
|
||||
/obj/machinery/power/supermatter/proc/supermatter_pull()
|
||||
//following is adapted from singulo code
|
||||
if(defer_powernet_rebuild != 2)
|
||||
defer_powernet_rebuild = 1
|
||||
// Let's just make this one loop.
|
||||
for(var/atom/X in orange(pull_radius,src))
|
||||
spawn() X.singularity_pull(src, STAGE_FIVE)
|
||||
|
||||
if(defer_powernet_rebuild != 2)
|
||||
defer_powernet_rebuild = 0
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/supermatter/GotoAirflowDest(n) //Supermatter not pushed around by airflow
|
||||
return
|
||||
|
||||
/obj/machinery/power/supermatter/RepelAirflowDest(n)
|
||||
return
|
||||
|
||||
/obj/machinery/power/supermatter/shard //Small subtype, less efficient and more sensitive, but less boom.
|
||||
name = "Supermatter Shard"
|
||||
desc = "A strangely translucent and iridescent crystal that looks like it used to be part of a larger structure. <font color='red'>You get headaches just from looking at it.</font>"
|
||||
icon_state = "darkmatter_shard"
|
||||
base_icon_state = "darkmatter_shard"
|
||||
|
||||
warning_point = 50
|
||||
emergency_point = 400
|
||||
explosion_point = 600
|
||||
|
||||
gasefficency = 0.125
|
||||
|
||||
pull_radius = 5
|
||||
pull_time = 45
|
||||
explosion_power = 3
|
||||
|
||||
/obj/machinery/power/supermatter/shard/announce_warning() //Shards don't get announcements
|
||||
return
|
||||
Reference in New Issue
Block a user