mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-24 00:51:26 +00:00
* 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
389 lines
12 KiB
Plaintext
389 lines
12 KiB
Plaintext
/obj/machinery/power/am_control_unit
|
|
name = "antimatter control unit"
|
|
desc = "The control unit for an antimatter reactor. Probably safe."
|
|
description_info = "Use a wrench to attach the control unit to the ground, then arrange the reactor sections nearby. Reactor sections can only be activated if they are near the control unit, but otherwise are not restricted in how they must be placed."
|
|
description_antag = "The antimatter engine will quickly destabilize if the fuel injection rate is set too high, causing a large explosion."
|
|
icon = 'icons/obj/machines/new_ame.dmi'
|
|
icon_state = "control"
|
|
var/icon_mod = "on" // on, critical, or fuck
|
|
var/old_icon_mod = "on"
|
|
anchored = 0
|
|
density = 1
|
|
use_power = 1
|
|
idle_power_usage = 100
|
|
active_power_usage = 1000
|
|
|
|
var/list/obj/machinery/am_shielding/linked_shielding
|
|
var/list/obj/machinery/am_shielding/linked_cores
|
|
var/obj/item/weapon/am_containment/fueljar
|
|
var/update_shield_icons = 0
|
|
var/stability = 100
|
|
var/exploding = 0
|
|
var/exploded = 0
|
|
|
|
var/active = 0 //On or not
|
|
var/fuel_injection = 2 //How much fuel to inject
|
|
var/shield_icon_delay = 0 //delays resetting for a short time
|
|
var/reported_core_efficiency = 0
|
|
|
|
var/power_cycle = 0
|
|
var/power_cycle_delay = 4 //How many ticks till produce_power is called
|
|
var/stored_core_stability = 0
|
|
var/stored_core_stability_delay = 0
|
|
|
|
var/stored_power = 0 //Power to deploy per tick
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/New()
|
|
..()
|
|
linked_shielding = list()
|
|
linked_cores = list()
|
|
|
|
/obj/machinery/power/am_control_unit/Destroy()//Perhaps damage and run stability checks rather than just del on the others
|
|
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
|
AMS.control_unit = null
|
|
qdel(AMS)
|
|
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
|
AMS.control_unit = null
|
|
qdel(AMS)
|
|
|
|
qdel(fueljar)
|
|
fueljar = null
|
|
return ..()
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/process()
|
|
if(exploding && !exploded)
|
|
message_admins("AME explosion at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>) - Last touched by [fingerprintslast]",0,1)
|
|
exploded=1
|
|
explosion(get_turf(src),8,10,12,15)
|
|
if(src)
|
|
qdel(src)
|
|
|
|
if(update_shield_icons && !shield_icon_delay)
|
|
check_shield_icons()
|
|
update_shield_icons = 0
|
|
|
|
if(stat & (NOPOWER|BROKEN) || !active)//can update the icons even without power
|
|
return
|
|
|
|
if(!fueljar)//No fuel but we are on, shutdown
|
|
toggle_power()
|
|
//Angry buzz or such here
|
|
return
|
|
|
|
check_core_stability()
|
|
|
|
add_avail(stored_power)
|
|
|
|
power_cycle++
|
|
if(power_cycle >= power_cycle_delay)
|
|
produce_power()
|
|
power_cycle = 0
|
|
|
|
/obj/machinery/power/am_control_unit/proc/produce_power()
|
|
playsound(get_turf(src), 'sound/effects/bang.ogg', 25, 1)
|
|
for (var/thing in linked_cores)
|
|
flick("core2", thing)
|
|
var/core_power = reported_core_efficiency //Effectively how much fuel we can safely deal with
|
|
if(core_power <= 0)
|
|
return 0//Something is wrong
|
|
var/core_damage = 0
|
|
var/fuel = fueljar.usefuel(fuel_injection)
|
|
|
|
stored_power = (fuel / core_power) * fuel * AM_POWER_FACTOR // Was 200000, was too much. New value run past Aurx. - N3X
|
|
//Now check if the cores could deal with it safely, this is done after so you can overload for more power if needed, still a bad idea
|
|
if(fuel > (2*core_power)) //More fuel has been put in than the current cores can deal with
|
|
if(prob(50))
|
|
core_damage = 1 //Small chance of damage
|
|
if((fuel-core_power) > 5)
|
|
core_damage = 5 //Now its really starting to overload the cores
|
|
if((fuel-core_power) > 10)
|
|
core_damage = 20 //Welp now you did it, they wont stand much of this
|
|
if(core_damage == 0)
|
|
return
|
|
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
|
AMS.stability -= core_damage
|
|
AMS.check_stability(1)
|
|
playsound(get_turf(src), 'sound/effects/bang.ogg', 50, 1)
|
|
|
|
/obj/machinery/power/am_control_unit/emp_act(severity)
|
|
switch(severity)
|
|
if(1)
|
|
if(active)
|
|
toggle_power()
|
|
stability -= rand(15,30)
|
|
if(2)
|
|
if(active)
|
|
toggle_power()
|
|
stability -= rand(10,20)
|
|
..()
|
|
|
|
/obj/machinery/power/am_control_unit/ex_act(severity)
|
|
switch(severity)
|
|
if(1.0)
|
|
stability -= 60
|
|
if(2.0)
|
|
stability -= 40
|
|
if(3.0)
|
|
stability -= 20
|
|
check_stability()
|
|
return
|
|
|
|
/obj/machinery/power/am_control_unit/power_change()
|
|
..()
|
|
if(stat & NOPOWER && active)
|
|
toggle_power()
|
|
return
|
|
|
|
/obj/machinery/power/am_control_unit/update_icon()
|
|
if(active)
|
|
icon_state = "control_[icon_mod]"
|
|
else
|
|
icon_state = "control"
|
|
//No other icons for it atm
|
|
|
|
/obj/machinery/power/am_control_unit/attackby(obj/item/W, mob/user)
|
|
if(!istype(W) || !user)
|
|
return
|
|
if(iswrench(W))
|
|
if(!anchored)
|
|
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 75, 1)
|
|
user.visible_message("[user.name] secures the [src.name] to the floor.", \
|
|
"You secure the anchor bolts to the floor.", \
|
|
"You hear a ratchet")
|
|
src.anchored = 1
|
|
update_shield_icons = 2
|
|
check_shield_icons()
|
|
connect_to_network()
|
|
else if(!linked_shielding.len > 0)
|
|
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 75, 1)
|
|
user.visible_message("[user.name] unsecures the [src.name].", \
|
|
"You remove the anchor bolts.", \
|
|
"You hear a ratchet")
|
|
src.anchored = 0
|
|
disconnect_from_network()
|
|
else
|
|
to_chat(user, "<span class='warning'>Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!</span>")
|
|
return
|
|
|
|
if(istype(W, /obj/item/weapon/am_containment))
|
|
if(fueljar)
|
|
to_chat(user, "<span class='warning'>There is already a [fueljar] inside!</span>")
|
|
return
|
|
fueljar = W
|
|
user.drop_from_inventory(W, src)
|
|
message_admins("AME loaded with fuel by [user.real_name] ([user.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
|
user.visible_message("[user.name] loads an [W.name] into the [src.name].", \
|
|
"You load an [W.name].", \
|
|
"You hear a thunk.")
|
|
return
|
|
|
|
if(W.force >= 20)
|
|
stability -= W.force/2
|
|
check_stability()
|
|
..()
|
|
return
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/attack_hand(mob/user as mob)
|
|
if(anchored)
|
|
interact(user)
|
|
return
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/proc/add_shielding(var/obj/machinery/am_shielding/AMS, var/AMS_linking = 0)
|
|
if(!istype(AMS))
|
|
return 0
|
|
if(!anchored)
|
|
return 0
|
|
if(!AMS_linking && !AMS.link_control(src))
|
|
return 0
|
|
if(!(AMS in linked_shielding))
|
|
linked_shielding.Add(AMS)
|
|
update_shield_icons = 1
|
|
return 1
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/proc/remove_shielding(var/obj/machinery/am_shielding/AMS)
|
|
if(!istype(AMS))
|
|
return 0
|
|
linked_shielding.Remove(AMS)
|
|
update_shield_icons = 2
|
|
if(active)
|
|
toggle_power()
|
|
return 1
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/proc/check_stability()//TODO: make it break when low also might want to add a way to fix it like a part or such that can be replaced
|
|
if(stability <= 0)
|
|
qdel(src)
|
|
return
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/proc/toggle_power()
|
|
active = !active
|
|
if(active)
|
|
use_power = 2
|
|
visible_message("The [src.name] starts up.")
|
|
else
|
|
use_power = 1
|
|
visible_message("The [src.name] shuts down.")
|
|
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
|
AMS.update_icon()
|
|
update_icon()
|
|
return
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/proc/check_shield_icons()//Forces icon_update for all shields
|
|
if(shield_icon_delay)
|
|
return
|
|
shield_icon_delay = 1
|
|
if(update_shield_icons == 2)//2 means to clear everything and rebuild
|
|
for(var/obj/machinery/am_shielding/neighbor in cardinalrange(loc))
|
|
if(!neighbor.control_unit)
|
|
linked_shielding += neighbor
|
|
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
|
if(AMS.processing)
|
|
AMS.shutdown_core()
|
|
AMS.control_unit = null
|
|
spawn(10)
|
|
AMS.controllerscan()
|
|
AMS.assimilate()
|
|
linked_shielding = list()
|
|
|
|
else
|
|
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
|
AMS.update_icon()
|
|
sleep(20)
|
|
shield_icon_delay = 0
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/proc/check_core_stability()
|
|
//if(stored_core_stability_delay || linked_cores.len <= 0) return
|
|
if(linked_cores.len <= 0)
|
|
return
|
|
//stored_core_stability_delay = 1
|
|
stored_core_stability = 0
|
|
for(var/thing in linked_cores)
|
|
var/obj/machinery/am_shielding/AMS = thing
|
|
if (QDELETED(AMS))
|
|
continue
|
|
|
|
stored_core_stability += AMS.stability
|
|
stored_core_stability /= linked_cores.len
|
|
switch(stored_core_stability)
|
|
if(0 to 24)
|
|
icon_mod = "fuck"
|
|
if(25 to 49)
|
|
icon_mod = "critical"
|
|
if(50 to INFINITY)
|
|
icon_mod = "on"
|
|
|
|
if(icon_mod != old_icon_mod)
|
|
old_icon_mod = icon_mod
|
|
update_icon()
|
|
|
|
//spawn(40)
|
|
// stored_core_stability_delay = 0
|
|
|
|
/obj/machinery/power/am_control_unit/interact(mob/user)
|
|
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
|
|
if(!istype(user, /mob/living/silicon/ai))
|
|
user.unset_machine()
|
|
user << browse(null, "window=AMcontrol")
|
|
return
|
|
return ui_interact(user)
|
|
|
|
/obj/machinery/power/am_control_unit/ui_interact(mob/user, ui_key = "main")
|
|
if(!user)
|
|
return
|
|
|
|
var/list/fueljar_data=null
|
|
if(fueljar)
|
|
fueljar_data=list(
|
|
"fuel"=fueljar.fuel,
|
|
"fuel_max"=fueljar.fuel_max,
|
|
"injecting"=fuel_injection
|
|
)
|
|
|
|
var/list/data = list(
|
|
"active" = active,
|
|
//"stability" = stability,
|
|
"linked_shields" = linked_shielding.len,
|
|
"linked_cores" = linked_cores.len,
|
|
"efficiency" = reported_core_efficiency,
|
|
"stability" = stored_core_stability,
|
|
"stored_power" = stored_power,
|
|
"fueljar" = fueljar_data,
|
|
"siliconUser" = istype(user, /mob/living/silicon)
|
|
)
|
|
|
|
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
|
|
if (!ui)
|
|
// the ui does not exist, so we'll create a new one
|
|
ui = new(user, src, ui_key, "ame.tmpl", "Antimatter Control Unit", 500, data["siliconUser"] ? 465 : 390)
|
|
// When the UI is first opened this is the data it will use
|
|
ui.set_initial_data(data)
|
|
ui.open()
|
|
// Auto update every Master Controller tick
|
|
ui.set_auto_update(1)
|
|
else
|
|
// The UI is already open so push the new data to it
|
|
ui.push_data(data)
|
|
return
|
|
|
|
|
|
/obj/machinery/power/am_control_unit/Topic(href, href_list)
|
|
if(..())
|
|
return 1
|
|
if(href_list["close"])
|
|
if(usr.machine == src)
|
|
usr.unset_machine()
|
|
return 1
|
|
//Ignore input if we are broken or guy is not touching us, AI can control from a ways away
|
|
if(stat & (BROKEN|NOPOWER))
|
|
usr.unset_machine()
|
|
usr << browse(null, "window=AMcontrol")
|
|
return
|
|
|
|
if(href_list["close"])
|
|
usr << browse(null, "window=AMcontrol")
|
|
usr.unset_machine()
|
|
return
|
|
|
|
if(href_list["togglestatus"])
|
|
toggle_power()
|
|
message_admins("AME toggled [active?"on":"off"] by [usr.real_name] ([usr.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
|
return 1
|
|
|
|
if(href_list["refreshicons"])
|
|
update_shield_icons = 2 // Fuck it
|
|
return 1
|
|
|
|
if(href_list["ejectjar"])
|
|
if(fueljar)
|
|
message_admins("AME fuel jar ejected by [usr.real_name] ([usr.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
|
fueljar.forceMove(src.loc)
|
|
fueljar = null
|
|
//fueljar.control_unit = null currently it does not care where it is
|
|
//update_icon() when we have the icon for it
|
|
return 1
|
|
|
|
if(href_list["set_strength"])
|
|
var/newval = input("Enter new injection strength") as num|null
|
|
if(isnull(newval))
|
|
return
|
|
fuel_injection=newval
|
|
fuel_injection=max(1,fuel_injection)
|
|
message_admins("AME injection strength set to [fuel_injection] by [usr.real_name] ([usr.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
|
return 1
|
|
|
|
if(href_list["refreshstability"])
|
|
check_core_stability()
|
|
return 1
|
|
|
|
updateDialog()
|
|
return 1
|
|
|