Files
Aurora.3/code/modules/power/turbine.dm
Lohikar f6dc33a465 Newmap - SMC, Openturf, Arrivals Controller, and Mine Turf Improvements (#1958)
* Replace SSingulo with SScalamity; processing cleanup
- SScalamity now handles blobs as well as singularity-types.
- Processing subtypes have been simplified to not require a stop_processing definition.

* this is probably important

* Remove cascade disabling SSgarbage

* Fixed a bug where dust() did not qdel the target mob

* Misc fixes

* Fix decals surviving break-to-plating

* Subsystem flag tweaks

* Apparently subsystems are new'd before config is.

* Fix paper icons

* Speculative fix for insane lag

* Better machinery stat

* Make organs not use SSoverlay

* Misc bugfixes & tweaks

* Nightmode fixes

* Changelog for SMC

* Port /tg/'s improved MC crash handling

* Add some more SS Recover() procs

* supply_controller -> SScargo

* More New() -> Initialize()

* pAI and robot construction overlays

* Fix cargo unit tests

* Merge the DMM Suite's atom/New() into atoms_init

* Lighting pre-baking

* Lighting initialization logging

* Fix some bad SS init orders

* Fix SSlighting logging; rename Processes to MC

* Speculative fix for insane GC lag

* Prebaked openturf/icon_smooth & fix lighting prebake

* SS init status; SSatoms LATEQDEL

* Fix bug with MC init stat panel

* Fix parallax

* Misc

* Ignore SS_NO_DISPLAY during init

* apparently this is important

* REEEEEE

* Image GC fixes; broadcaster radio-new sanity

* RCON Cleanup

* Move pAI recruiter into subsystem

* Move global solars list into sun subsystem

* Make chickens not use a global

* Demote SSdisposals to SS_BACKGROUND; garbage-debug cleanup

* Speed up space init a little

* Fix bad timer flags on floor drying

* Subsystem panic-restart verb for mins

* Explosion speedup

* Minor subsystem & MC logging tweaks

* SSopenturf improvements

* Make pipenet actually initialize (whoops)

* Minor tweaks

* Implement lighting rounding

* comments are hard okay

* Minor lattice tweaks

* Fix some timer issues & better closet init

* Timer sanity

* Request console tweaks + Storage init sanity

* Minor SSmachiner RCON improvements

* Further reduce world-start timer count

* Standardize subsystem logging

* Garbage hard delete profiling from /tg/

* Timer hang detection & recovery

* Log machines that sleep in process() and fuck up SSmachinery

* Fix an issue with external airlocks sleeping in process()

* Failsafe logging

* Minor tweaks

* Revert "Request console tweaks + Storage init sanity"

This reverts commit 98d3579e35.

* Re-implement RC changes

* Fix SQL FT saving

* Fix SSmachinery sleep in disposals

* Minor SS tweaks

* Paper fixes

* Blood drying fixes

* Merge gameticker and SSticker

* Minor global list init cleanup

* Lagcheck biogenerator & bags

* Tweak SScargo init order; RIG Initialize()

* Caching tweaks

* Remove rogue comma

* Initialize fixes

* Lighting destroy cleanup

* Fix emagging airlocks

* Initial SSicon implementation

* Tweaks & Fixes

* Fire + Air alarm queued icon updates

* Overlays + Queued icon cleanup

* Runtime & background fixes

* Kill some meaningless set statements

* Kill some image qdels

* Bump up lighting rounding val

* Fix adv. scanner destroy runtimes

* Remove unneeded icon update limiting

* Move icon smoothing into helpers

* Show a warning if DM 510 compiles without memory leak hack enabled

* Re-organize subsystems & MC defines a little

* Airlock SFX

* Log of Changes

* Make SSicon_update disable itself when not doing anything

* Fix respawn verb runtime when used early in server-init

* Add more information to MC's stat_entry()

* Replace direct refernces to gcDestroyed with QDEL* macros

* plant_controller -> SSplants

* More plant tweaks

* Add more humor to changelog

* Move parallax globals into SSparallax

* Lighting responsiveness tweaks

* Fix parallax init order & better MC init panel stat

* Make mobs GC

* More overlays + Remove intercom spawn()

* SSfast_process; make pinpointers not use spawn-recursion to process
Also made the SM Cascade beach process with SSprocessing instead of a spawn loop.

* Update changelog

* Mob GC tweaks

* Del() cleanup

* Fix insomniac ZAS connection edges

* Minor pAI cleanup

* Convert more things to SSoverlay; fix duplicated overlay in field gens

* SM Bluespace turf tweaks

* Update SSgarbage debug globals list

* Human-type qdel tweaks

* Subsystem suspension; stat_entry improvements

* SQL Statistics cleanup

* Fix runtimes with ambrosia

* More disable() -> suspend(); fix nightmode again

* Human qdel fix; minor tweaks

* Update turbolift to work with StonedMC

* Make lifts use timers instead of a subsystem

* Make SSassets start earlier

* Convert the radio controller into a subsystem

* Fix some missing CHECK_TICKs in asteroid generation

* MC stat tweaks; make shouldnt_see a typecache

* Kill some redundant debug-controller entries

* radio_controller -> SSradio

* Better SSgarbage hard-del logging from /tg/ upstream

* Logging tweaks + GELF

* Misc client caching improvements

* Slime SSoverlay

* Oven icon fixes

* Implant fixes
- Death implants will no longer spam Common on death of user.
- Death implants should handle a deleted user better.

* Holder tweaks + Welding tool Initialize()

* Fix some bad subsystem logging

* Fix suit cooling units spawning without cells

* Starlight tweaks

* Gibber infinite gib fix

* More SSoverlay stuff

* Make crates use CUT_OVERLAY_IN

* Make SSarrivals suspend instead of disable

* Make openturf use split/phased tick checks

* Speculative fix for unwet timer runtimes

* Blood overlay tweaks/fixes

* Update crusher to play nice with SMC + SSoverlay

* Openturf improvements and fixes

* Minor turbolift tweaks

* Lighting performance improvements + ChangeTurf tweaks

* this is probably important

* Fix wall weld noises on changeturf

* More ChangeTurf tweaks

* Explosion tweaks

* Pre-game lobby tweaks

* Openturf tweaks

* Prevent admins from starting the game before init finishes

* Fix Travis

* Kill an unused var

* Fix ChangeTurf runtimes on openturfs

* Fixes

* Browser datum fixes, asset caching

* Update changelog

* Changelog

* Lobby tweaks

* Ticker tweaks; kill ticker var

* Further lobby tweaks

* Cascade tweaks

* air_master -> SSair

* Reduce overhead from radio autosay

* alarm_manager -> SSalarm

* bomb_processor -> SSexplosives

* corp_regs -> SSlaw

* ZAS overlay fixes

* Small wall icon optimization

* Fix effects master

* Assembly tweaks

* Megavend fixes

* Shuttle fixes

* Camera alert performance improvements

* Fix some world.log spam from lighting overlays

* Fix some Initialize() procs

* Openspace responsiveness tweaks

* Make HE pipes animate through openturfs

* Kill a spawn
2017-05-02 14:40:40 -04:00

321 lines
8.7 KiB
Plaintext

/obj/machinery/compressor
name = "compressor"
desc = "The compressor stage of a gas turbine generator."
icon = 'icons/obj/pipes.dmi'
icon_state = "compressor"
anchored = 1
density = 1
var/obj/machinery/power/turbine/turbine
var/datum/gas_mixture/gas_contained
var/turf/simulated/inturf
var/starter = 0
var/rpm = 0
var/rpmtarget = 0
var/capacity = 1e6
var/comp_id = 0
/obj/machinery/power/turbine
name = "gas turbine generator"
desc = "A gas turbine used for backup power generation."
icon = 'icons/obj/pipes.dmi'
icon_state = "turbine"
anchored = 1
density = 1
var/obj/machinery/compressor/compressor
var/turf/simulated/outturf
var/lastgen
/obj/machinery/computer/turbine_computer
name = "Gas turbine control computer"
desc = "A computer to remotely control a gas turbine"
icon = 'icons/obj/computer.dmi'
icon_screen = "turbinecomp"
circuit = /obj/item/weapon/circuitboard/turbine_control
anchored = 1
density = 1
var/obj/machinery/compressor/compressor
var/list/obj/machinery/door/blast/doors
var/id = 0
var/door_status = 0
// the inlet stage of the gas turbine electricity generator
/obj/machinery/compressor/New()
..()
gas_contained = new
inturf = get_step(src, dir)
spawn(5)
turbine = locate() in get_step(src, get_dir(inturf, src))
if(!turbine)
stat |= BROKEN
else
turbine.stat &= !BROKEN
turbine.compressor = src
#define COMPFRICTION 5e5
#define COMPSTARTERLOAD 2800
/obj/machinery/compressor/process()
if(!starter)
return
overlays.Cut()
if(stat & BROKEN)
return
if(!turbine)
stat |= BROKEN
return
rpm = 0.9* rpm + 0.1 * rpmtarget
var/datum/gas_mixture/environment = inturf.return_air()
var/transfer_moles = environment.total_moles / 10
//var/transfer_moles = rpm/10000*capacity
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
gas_contained.merge(removed)
rpm = max(0, rpm - (rpm*rpm)/COMPFRICTION)
if(starter && !(stat & NOPOWER))
use_power(2800)
if(rpm<1000)
rpmtarget = 1000
else
if(rpm<1000)
rpmtarget = 0
if(rpm>50000)
overlays += image('icons/obj/pipes.dmi', "comp-o4", FLY_LAYER)
else if(rpm>10000)
overlays += image('icons/obj/pipes.dmi', "comp-o3", FLY_LAYER)
else if(rpm>2000)
overlays += image('icons/obj/pipes.dmi', "comp-o2", FLY_LAYER)
else if(rpm>500)
overlays += image('icons/obj/pipes.dmi', "comp-o1", FLY_LAYER)
//TODO: DEFERRED
/obj/machinery/power/turbine/New()
..()
outturf = get_step(src, dir)
spawn(5)
compressor = locate() in get_step(src, get_dir(outturf, src))
if(!compressor)
stat |= BROKEN
else
compressor.stat &= !BROKEN
compressor.turbine = src
#define TURBPRES 9000000
#define TURBGENQ 20000
#define TURBGENG 0.8
/obj/machinery/power/turbine/process()
if(!compressor.starter)
return
overlays.Cut()
if(stat & BROKEN)
return
if(!compressor)
stat |= BROKEN
return
lastgen = ((compressor.rpm / TURBGENQ)**TURBGENG) *TURBGENQ
add_avail(lastgen)
var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles)/4
newrpm = max(0, newrpm)
if(!compressor.starter || newrpm > 1000)
compressor.rpmtarget = newrpm
if(compressor.gas_contained.total_moles>0)
var/oamount = min(compressor.gas_contained.total_moles, (compressor.rpm+100)/35000*compressor.capacity)
var/datum/gas_mixture/removed = compressor.gas_contained.remove(oamount)
outturf.assume_air(removed)
if(lastgen > 100)
overlays += image('icons/obj/pipes.dmi', "turb-o", FLY_LAYER)
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.interact(M)
AutoUpdateAI(src)
/obj/machinery/power/turbine/interact(mob/user)
if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) )
user.machine = null
user << browse(null, "window=turbine")
return
user.machine = src
var/t = "<TT><B>Gas Turbine Generator</B><HR><PRE>"
t += "Generated power : [round(lastgen)] W<BR><BR>"
t += "Turbine: [round(compressor.rpm)] RPM<BR>"
t += "Starter: [ compressor.starter ? "<A href='?src=\ref[src];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=\ref[src];str=1'>On</A>"]"
t += "</PRE><HR><A href='?src=\ref[src];close=1'>Close</A>"
t += "</TT>"
user << browse(t, "window=turbine")
onclose(user, "turbine")
return
/obj/machinery/power/turbine/Topic(href, href_list)
..()
if(stat & BROKEN)
return
if (usr.stat || usr.restrained() )
return
if (usr.IsAdvancedToolUser())
if(!istype(usr, /mob/living/silicon/ai))
usr << "\red You don't have the dexterity to do this!"
return
if (( usr.machine==src && ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
if( href_list["close"] )
usr << browse(null, "window=turbine")
usr.machine = null
return
else if( href_list["str"] )
compressor.starter = !compressor.starter
spawn(0)
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.interact(M)
else
usr << browse(null, "window=turbine")
usr.machine = null
return
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/obj/machinery/computer/turbine_computer/New()
..()
spawn(5)
for(var/obj/machinery/compressor/C in machines)
if(id == C.comp_id)
compressor = C
doors = new /list()
for(var/obj/machinery/door/blast/P in machines)
if(P.id == id)
doors += P
/*
/obj/machinery/computer/turbine_computer/attackby(I as obj, user as mob)
if(istype(I, /obj/item/weapon/screwdriver))
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
if(do_after(user, 20))
if (src.stat & BROKEN)
user << "\blue The broken glass falls out."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
new /obj/item/weapon/material/shard( src.loc )
var/obj/item/weapon/circuitboard/turbine_control/M = new /obj/item/weapon/circuitboard/turbine_control( A )
for (var/obj/C in src)
C.loc = src.loc
M.id = src.id
A.circuit = M
A.state = 3
A.icon_state = "3"
A.anchored = 1
qdel(src)
else
user << "\blue You disconnect the monitor."
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
var/obj/item/weapon/circuitboard/turbine_control/M = new /obj/item/weapon/circuitboard/turbine_control( A )
for (var/obj/C in src)
C.loc = src.loc
M.id = src.id
A.circuit = M
A.state = 4
A.icon_state = "4"
A.anchored = 1
qdel(src)
else
src.attack_hand(user)
return
*/
/obj/machinery/computer/turbine_computer/attack_hand(var/mob/user as mob)
user.machine = src
var/dat
if(src.compressor)
dat += {"<BR><B>Gas turbine remote control system</B><HR>
\nTurbine status: [ src.compressor.starter ? "<A href='?src=\ref[src];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=\ref[src];str=1'>On</A>"]
\n<BR>
\nTurbine speed: [src.compressor.rpm]rpm<BR>
\nPower currently being generated: [src.compressor.turbine.lastgen]W<BR>
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K<BR>
\nVent doors: [ src.door_status ? "<A href='?src=\ref[src];doors=1'>Closed</A> <B>Open</B>" : "<B>Closed</B> <A href='?src=\ref[src];doors=1'>Open</A>"]
\n</PRE><HR><A href='?src=\ref[src];view=1'>View</A>
\n</PRE><HR><A href='?src=\ref[src];close=1'>Close</A>
\n<BR>
\n"}
else
dat += "<span class='danger'>No compatible attached compressor found.</span>"
user << browse(dat, "window=computer;size=400x500")
onclose(user, "computer")
return
/obj/machinery/computer/turbine_computer/Topic(href, href_list)
if(..())
return
if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
usr.machine = src
if( href_list["view"] )
usr.client.eye = src.compressor
else if( href_list["str"] )
src.compressor.starter = !src.compressor.starter
else if (href_list["doors"])
for(var/obj/machinery/door/blast/D in src.doors)
if (door_status == 0)
spawn( 0 )
D.open()
door_status = 1
else
spawn( 0 )
D.close()
door_status = 0
else if( href_list["close"] )
usr << browse(null, "window=computer")
usr.machine = null
return
src.add_fingerprint(usr)
src.updateUsrDialog()
return
/obj/machinery/computer/turbine_computer/process()
src.updateDialog()
return