mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 11:05:03 +01:00
Made ZAS play nice with being mapped right on map edge, and remade supermatter to work right on this code base.
This commit is contained in:
@@ -1,164 +1,146 @@
|
||||
//ported from old bs12 by Cael
|
||||
//some modifications so that it's more stable, and it's primary purpose is producing plasma instead of power
|
||||
//frequency is 1-1e9
|
||||
|
||||
#define NITROGEN_RETARDATION_FACTOR 4 //Higher == N2 slows reaction more
|
||||
#define THERMAL_RELEASE_MODIFIER 50 //Higher == less heat released during reaction
|
||||
#define PLASMA_RELEASE_MODIFIER 750 //Higher == less plasma released by reaction
|
||||
#define OXYGEN_RELEASE_MODIFIER 1500 //Higher == less oxygen released at high temperature/power
|
||||
#define NITROGEN_RETARDATION_FACTOR 12 //Higher == N2 slows reaction more
|
||||
#define THERMAL_RELEASE_MODIFIER 20 //Higher == less heat released during reaction
|
||||
#define PLASMA_RELEASE_MODIFIER 200 //Higher == less plasma released by reaction
|
||||
#define OXYGEN_RELEASE_MODIFIER 150 //Higher == less oxygen released at high temperature/power
|
||||
#define REACTION_POWER_MODIFIER 1.1 //Higher == more overall power
|
||||
|
||||
#define WARNING_DELAY 30 //30 seconds between warnings.
|
||||
|
||||
/obj/machinery/power/supermatter
|
||||
name = "Supermatter"
|
||||
desc = "A strangely translucent and iridescent crystal. \red You get headaches just from looking at it."
|
||||
icon = 'engine.dmi'
|
||||
icon_state = "darkmatter"
|
||||
density = 1
|
||||
anchored = 1
|
||||
var/mega_energy = 0
|
||||
anchored = 0
|
||||
|
||||
LuminosityRed = 4
|
||||
LuminosityGreen = 6
|
||||
|
||||
var/gasefficency = 0.25
|
||||
|
||||
var/det = 0
|
||||
var/previousdet = 0
|
||||
var/const/explosiondet = 3500
|
||||
var/frequency = 50000
|
||||
var/damage = 0
|
||||
var/damage_archived = 0
|
||||
var/safe_alert = "Crystaline hyperstructure returning to safe operating levels."
|
||||
var/warning_point = 300
|
||||
var/warning_alert = "Danger! Crystal hyperstructure instability!"
|
||||
var/emergency_point = 3000
|
||||
var/emergency_alert = "CRYSTAL DELAMINATION IMMINENT"
|
||||
var/explosion_point = 4500
|
||||
|
||||
var/explosion_power = 8
|
||||
|
||||
var/const/warningtime = 50 // Make the CORE OVERLOAD message repeat only every aprox. ?? seconds
|
||||
var/lastwarning = 0 // Time in 1/10th of seconds since the last sent warning
|
||||
|
||||
New()
|
||||
..()
|
||||
spawn(1)
|
||||
ul_SetLuminosity(4,6,0)
|
||||
var/power = 0
|
||||
|
||||
var/halucination_range = 8
|
||||
var/rad_range = 4
|
||||
|
||||
|
||||
shard //Small subtype, less efficient and more sensitive, but less boom.
|
||||
name = "Supermatter Shard"
|
||||
desc = "A strangely translucent and iridescent crystal. Looks like it used to be part of a larger structure. \red You get headaches just from looking at it."
|
||||
warning_point = 200
|
||||
emergency_point = 2500
|
||||
explosion_point = 3500
|
||||
|
||||
gasefficency = 12.5
|
||||
halucination_range = 5
|
||||
rad_range = 2
|
||||
|
||||
explosion_power = 2 //2,4,6,8? Or is that too small?
|
||||
|
||||
|
||||
process()
|
||||
|
||||
var/turf/simulated/L = loc
|
||||
|
||||
if(!istype(L)) //If we are not on a turf, uh oh.
|
||||
del src
|
||||
|
||||
//Ok, get the air from the turf
|
||||
var/datum/gas_mixture/env = L.return_air()
|
||||
|
||||
//Remove gas from surrounding area
|
||||
var/transfer_moles = gasefficency * env.total_moles
|
||||
var/datum/gas_mixture/removed = env.remove(transfer_moles)
|
||||
|
||||
if (!removed)
|
||||
return 1
|
||||
|
||||
damage_archived = damage
|
||||
damage = max( damage + ( (removed.temperature - 1000) / 150 ) , 0 )
|
||||
|
||||
if(damage > warning_point) // while the core is still damaged and it's still worth noting its status
|
||||
if((world.timeofday - lastwarning) / 10 >= WARNING_DELAY)
|
||||
|
||||
if(damage > emergency_point)
|
||||
radioalert("states, \"[emergency_alert]\"","Supermatter Monitor")
|
||||
else if(damage >= damage_archived) // The damage is still going up
|
||||
radioalert("states, \"[warning_alert]\"","Supermatter Monitor")
|
||||
else // Phew, we're safe
|
||||
radioalert("states, \"[safe_alert]\"","Supermatter Monitor")
|
||||
|
||||
lastwarning = world.timeofday
|
||||
|
||||
if(damage > explosion_point)
|
||||
explosion(loc,explosion_power,explosion_power*2,explosion_power*3,explosion_power*4,1)
|
||||
del src
|
||||
|
||||
var/nitrogen_mod = abs((removed.nitrogen / removed.total_moles)) * NITROGEN_RETARDATION_FACTOR
|
||||
var/oxygen = max(min(removed.oxygen / removed.total_moles - nitrogen_mod, 1), 0)
|
||||
|
||||
var/temp_factor = 0
|
||||
if(oxygen > 0.8)
|
||||
// with a perfect gas mix, make the power less based on heat
|
||||
temp_factor = 100
|
||||
icon_state = "darkmatter_glow"
|
||||
else
|
||||
// in normal mode, base the produced energy around the heat
|
||||
temp_factor = 20
|
||||
icon_state = "darkmatter"
|
||||
|
||||
//Calculate power released as heat and gas, in as the sqrt of the power.
|
||||
var/power_factor = (power/100) ** 3
|
||||
var/device_energy = oxygen * power_factor
|
||||
power = max(round((removed.temperature - T0C) / temp_factor) + power - power_factor, 0) //Total laser power plus an overload factor
|
||||
|
||||
//Final energy calcs.
|
||||
device_energy *= removed.temperature / T0C
|
||||
device_energy = round(device_energy * REACTION_POWER_MODIFIER)
|
||||
|
||||
//To figure out how much temperature to add each tick, consider that at one atmosphere's worth
|
||||
//of pure oxygen, with all four lasers firing at standard energy and no N2 present, at room temperature
|
||||
//that the device energy is around 2140. At that stage, we don't want too much heat to be put out
|
||||
//Since the core is effectively "cold"
|
||||
|
||||
//Also keep in mind we are only adding this temperature to (efficiency)% of the one tile the rock
|
||||
//is on. An increase of 4*C @ 25% efficiency here results in an increase of 1*C / (#tilesincore) overall.
|
||||
removed.temperature += max((device_energy / THERMAL_RELEASE_MODIFIER), 0)
|
||||
|
||||
removed.temperature = min(removed.temperature, 1500)
|
||||
|
||||
//Calculate how much gas to release
|
||||
removed.toxins += max(device_energy / PLASMA_RELEASE_MODIFIER, 0)
|
||||
|
||||
removed.oxygen += max((device_energy + removed.temperature - T0C) / OXYGEN_RELEASE_MODIFIER, 0)
|
||||
|
||||
removed.update_values()
|
||||
|
||||
env.merge(removed)
|
||||
|
||||
for(var/mob/living/carbon/human/l in range(src, halucination_range)) // you have to be seeing the core to get hallucinations
|
||||
if(prob(10) && !istype(l.glasses, /obj/item/clothing/glasses/meson))
|
||||
l.hallucination = 50
|
||||
|
||||
for(var/mob/living/l in range(src,rad_range))
|
||||
l.apply_effect(rand(20,60)/(get_dist(src, l)+1), IRRADIATE)
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
bullet_act(var/obj/item/projectile/Proj)
|
||||
if(Proj.flag != "bullet")
|
||||
var/obj/item/projectile/beam/laserbeam = Proj
|
||||
var/energy_loss_ratio = abs(laserbeam.frequency - frequency) / 1e9
|
||||
var/energy_delta = laserbeam.damage / 600
|
||||
mega_energy += energy_delta - energy_delta * energy_loss_ratio
|
||||
return 0
|
||||
|
||||
/*
|
||||
/obj/machinery/engine/klaxon
|
||||
name = "Emergency Klaxon"
|
||||
icon = 'engine.dmi'
|
||||
icon_state = "darkmatter"
|
||||
density = 1
|
||||
anchored = 1
|
||||
var/obj/machinery/engine/supermatter/sup
|
||||
|
||||
/obj/machinery/engine/klaxon/process()
|
||||
if(!sup)
|
||||
for(var/obj/machinery/engine/supermatter/T in world)
|
||||
sup = T
|
||||
break
|
||||
if(sup.det >= 1)
|
||||
return
|
||||
*/
|
||||
|
||||
//a lot of these variables are pretty hacked, so dont rely on the comments
|
||||
/obj/machinery/power/supermatter/process()
|
||||
//core can no longer spontaneously explode
|
||||
/*
|
||||
previousdet = det
|
||||
det += (removed.temperature - 1000) / 150
|
||||
det = max(det, 0)
|
||||
|
||||
if(det > 0 && removed.temperature > 1000) // while the core is still damaged and it's still worth noting its status
|
||||
if((world.realtime - lastwarning) / 10 >= warningtime)
|
||||
lastwarning = world.realtime
|
||||
if(explosiondet - det <= 300)
|
||||
radioalert("CORE EXPLOSION IMMINENT","Core control computer")
|
||||
else if(det >= previousdet) // The damage is still going up
|
||||
radioalert("CORE OVERLOAD","Core control computer")
|
||||
else // Phew, we're safe
|
||||
radioalert("Core returning to safe operating levels.","Core control computer")
|
||||
|
||||
if(det > explosiondet)
|
||||
roundinfo.core = 1
|
||||
//proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, force = 0)
|
||||
explosion(src.loc,8,15,20,30,1)
|
||||
det = 0
|
||||
|
||||
if (!removed)
|
||||
return 1
|
||||
*/
|
||||
|
||||
//var/power = max(round((removed.temperature - T0C) / 20), 0) //Total laser power plus an overload factor
|
||||
|
||||
//Get the collective laser power
|
||||
/*
|
||||
for(var/dir in cardinal)
|
||||
var/turf/T = get_step(L, dir)
|
||||
for(var/obj/beam/e_beam/item in T)
|
||||
power += item.power
|
||||
*/
|
||||
|
||||
/*
|
||||
#define NITROGEN_RETARDATION_FACTOR 4 //Higher == N2 slows reaction more
|
||||
#define THERMAL_RELEASE_MODIFIER 50 //Higher == less heat released during reaction
|
||||
#define PLASMA_RELEASE_MODIFIER 750 //Higher == less plasma released by reaction
|
||||
#define OXYGEN_RELEASE_MODIFIER 1500 //Higher == less oxygen released at high temperature/power
|
||||
#define REACTION_POWER_MODIFIER 0.5 //Higher == more overall power
|
||||
*/
|
||||
|
||||
var/datum/gas_mixture/env = loc.return_air()
|
||||
|
||||
//nothing can happen in a vacuum
|
||||
var/datum/gas_mixture/removed = env
|
||||
var/retardation_factor = 0.5
|
||||
if(env.total_moles)
|
||||
//Remove gas from surrounding area
|
||||
var/transfer_moles = gasefficency * env.total_moles
|
||||
removed = env.remove(transfer_moles)
|
||||
|
||||
//100% oxygen atmosphere = 100% plasma production
|
||||
//100% nitrogen atmosphere = 0% plasma production
|
||||
//anything else is halfway in between; an atmosphere with no nitrogen or oxygen will still be at 50% (but steadily rise as more oxygen is made)
|
||||
var/total_moles = removed.total_moles
|
||||
if(total_moles)
|
||||
retardation_factor += removed.oxygen / (total_moles * 2) - removed.nitrogen / (total_moles * 2)
|
||||
else
|
||||
retardation_factor -= 0.25
|
||||
|
||||
var/device_energy = mega_energy * REACTION_POWER_MODIFIER //device energy is provided by the zero point lasers
|
||||
device_energy *= removed.temperature / T0C //environmental heat directly affects device energy
|
||||
device_energy = max(device_energy,0)
|
||||
|
||||
//To figure out how much temperature to add each tick, consider that at one atmosphere's worth
|
||||
//of pure oxygen, with all four lasers firing at standard energy and no N2 present, at room temperature
|
||||
//that the device energy is around 2140. At that stage, we don't want too much heat to be put out
|
||||
//Since the core is effectively "cold"
|
||||
|
||||
//Also keep in mind we are only adding this temperature to (efficiency)% of the one tile the rock
|
||||
//is on. An increase of 4*C @ 25% efficiency here results in an increase of 1*C / (#tilesincore) overall.
|
||||
removed.temperature += max((device_energy / THERMAL_RELEASE_MODIFIER), 0)
|
||||
|
||||
//Calculate how much gas to release
|
||||
var/produced = device_energy * PLASMA_RELEASE_MODIFIER * retardation_factor
|
||||
removed.toxins += produced
|
||||
//
|
||||
produced = device_energy * OXYGEN_RELEASE_MODIFIER * retardation_factor
|
||||
removed.oxygen += produced
|
||||
removed.update_values()
|
||||
//
|
||||
mega_energy = 0
|
||||
|
||||
//instead of producing oxygen, consume it to produce plasma,
|
||||
//use an amount proportional to the plasma produced
|
||||
//removed.oxygen -= produced
|
||||
//removed.oxygen += max(round((device_energy + removed.temperature - T0C) / OXYGEN_RELEASE_MODIFIER), 0)
|
||||
|
||||
env.merge(removed)
|
||||
|
||||
//talk to sky re hallucinations, because i'm lazy like that
|
||||
/*for(var/mob/living/l in view(src, 6)) // you have to be seeing the core to get hallucinations
|
||||
if(prob(10) && !(l.glasses && istype(l.glasses, /obj/item/clothing/glasses/meson)))
|
||||
l.hallucination = 50
|
||||
|
||||
for(var/mob/living/l in view(src,3))
|
||||
l.bruteloss += 50
|
||||
l.updatehealth()*/
|
||||
return 1
|
||||
power += Proj.damage
|
||||
return 0
|
||||
Reference in New Issue
Block a user