Files
vgstation13/code/modules/research/message_server.dm
jellyveggie2 0471421e9a Reworks electric power grid to have priority levels (#32613)
* Move machinery procs from power to machinery. Getting real tired of confusing them for power procs, why were they even there?

* use_power = [0-2] replaced with the proper MACHINE_POWER_USE(NONE|IDLE|ACTIVE) defines. KEEP IT CLEAN

* Creates MACHINE_POWER_USE_GRID, for machines marked as MACHINE_POWER_USE_NONE that were actually drawing power, and doing so straight from the grid

* More numbers to defines

* Power connection component: Get rid of unused parameters on New() that were being misused anyway, and more importantly make the radio broadcaster actually draw it's power through the component instead of APCs.
NEEEEXIIIIS!

* ...actually adds MACHINE_POWER_USE_GRID this time
JEEEELLLYYYYYY!

* Converts a bunch of snowflakes into using the power connection component

* RECAP: Alright, I've fixed some major peeves and made sure no one's adding load to the powernet without going through a machine/component first, now is the time to start modifying how power draw works

* Give grid loads priorities, and convert powernet.load to a list of loads. Does nothing yet

* Satisfaction

* Converts power sink and singularity beacon

* Converts wall shield generator

* Converts emitters. Emitters will turn off below 30% satisfaction, and beam power will be affected by power satisfaction; eg: at 50% satisfaction beams will only be 50% as powerful

* Converts the antique matter synth

* Converts APCs

* get_satisfaction() for cables

* Converts SMES

* Converts artifacts

* Fixes a bunch of stupid things with SMESs and APCs, turns some more use_power numbers into defines, and gets rid of MACHINE_POWER_USE_GRID cause there's really no need for it, not yet.

* Fixes for power sink and singularity beacon

* Antique synth fixes

* More SMES fixes. No more free energy shenanigans, and measured output/load should update properly now

* Converts radio broadcaster and syphoners. Also adds a way to connect to smooth cables, because syphoners.

* RECAP: I think that should be it for converting and testing priority/satisfaction stuff. Up next is reworking the power monitor to display all loads (not just APCs) grouped by area, and each load's priority, as well as controls to edit a load's priority.

* Power monitor is in a workable state. Issues so far:
- It looks like ass. The "area details" buttons are ugly, and the priority dropdowns are uglier AND  fuck up the vertical spacing between rows
- Power connection machines (eg: radio transmitter) don't show up
- Setting an SMES priority low enough it won't charge means it won't appear on the list, so can't change priority back. other machines likely affected too

Still, it's taking shape

* Couldn't get priority dropdowns to look nice, switches them for buttons. Touches up the show/hide details button to look nicer

* Ensure normal power/connection machinery does show up by default

* Give artifacts BYPASS priority so xenoarcheologists don't have to wonder whether it's working or not (assuming there's enough power on the grid)

* Make sure any SMES do show up even if not charging, so you can raise their priority if need be

* Allow players to set the SMES' (until now unused) nametag, to better identify them on the monitor

* Review 1

* Review 2
Adds TOTAL_PRIORITY_SLOTS for clarity instead of using POWER_PRIORITY_EXCESS
2022-06-04 00:03:58 -05:00

131 lines
4.1 KiB
Plaintext

var/global/list/obj/machinery/message_server/message_servers = list()
/datum/data_pda_msg
var/recipient = "Unspecified" //name of the person
var/sender = "Unspecified" //name of the sender
var/message = "Blank" //transferred message
var/icon/img_sent = null //transferred image, if any
/datum/data_pda_msg/New(var/param_rec = "",var/param_sender = "",var/param_message = "", var/icon/param_image = null)
if(param_rec)
recipient = param_rec
if(param_sender)
sender = param_sender
if(param_message)
message = param_message
if(param_image)
img_sent = param_image
/datum/data_rc_msg
var/rec_dpt = "Unspecified" //name of the person
var/send_dpt = "Unspecified" //name of the sender
var/message = "Blank" //transferred message
var/stamp = "Unstamped"
var/id_auth = "Unauthenticated"
var/priority = "Normal"
/datum/data_rc_msg/New(var/param_rec = "",var/param_sender = "",var/param_message = "",var/param_stamp = "",var/param_id_auth = "",var/param_priority)
if(param_rec)
rec_dpt = param_rec
if(param_sender)
send_dpt = param_sender
if(param_message)
message = param_message
if(param_stamp)
stamp = param_stamp
if(param_id_auth)
id_auth = param_id_auth
if(param_priority)
switch(param_priority)
if(1)
priority = "Normal"
if(2)
priority = "High"
if(3)
priority = "Extreme"
else
priority = "Undetermined"
/obj/machinery/message_server
icon = 'icons/obj/machines/telecomms.dmi'
icon_state = "pda_server"
name = "Messaging Server"
density = 1
anchored = 1.0
use_power = MACHINE_POWER_USE_IDLE
idle_power_usage = 10
active_power_usage = 100
ghost_read=0
ghost_write=0 // #430
var/list/datum/data_pda_msg/pda_msgs = list()
var/list/datum/data_rc_msg/rc_msgs = list()
var/disabled = FALSE
var/decryptkey = "password"
/obj/machinery/message_server/New()
message_servers += src
decryptkey = GenerateKey()
send_pda_message("System Administrator", "system", "This is an automated message. The messaging system is functioning correctly.")
..()
update_icon()
return
/obj/machinery/message_server/Destroy()
message_servers -= src
..()
return
/obj/machinery/message_server/proc/GenerateKey()
//Feel free to move to Helpers.
var/newKey
newKey += pick("the", "if", "of", "as", "in", "a", "you", "from", "to", "an", "too", "little", "snow", "dead", "drunk", "rosebud", "duck", "al", "le")
newKey += pick("diamond", "beer", "mushroom", "assistant", "clown", "captain", "twinkie", "security", "nuke", "small", "big", "escape", "yellow", "gloves", "monkey", "engine", "nuclear", "ai")
newKey += pick("1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
return newKey
/obj/machinery/message_server/proc/is_functioning()
return !disabled && !(stat & (BROKEN|NOPOWER|FORCEDISABLE))
/obj/machinery/message_server/proc/send_pda_message(var/recipient = "",var/sender = "",var/message = "", var/icon/img_sent = null)
pda_msgs += new/datum/data_pda_msg(recipient,sender,message,img_sent)
/obj/machinery/message_server/proc/send_rc_message(var/recipient = "",var/sender = "",var/message = "",var/stamp = "", var/id_auth = "", var/priority = 1)
rc_msgs += new/datum/data_rc_msg(recipient,sender,message,stamp,id_auth)
/obj/machinery/message_server/attack_hand(user as mob)
if(isobserver(user) && !isAdminGhost(user))
return 0
// to_chat(user, "<span class='notice'>There seem to be some parts missing from this server. They should arrive on the station in a few days, give or take a few CentCom delays.</span>")
to_chat(user, "You toggle PDA message passing from [disabled ? "Off" : "On"] to [disabled ? "On" : "Off"]")
disabled = !disabled
update_icon()
return
/obj/machinery/message_server/power_change()
. = ..()
update_icon()
/obj/machinery/message_server/update_icon()
if(stat & (BROKEN|NOPOWER|FORCEDISABLE))
icon_state = "pda_server-nopower"
else if (disabled)
icon_state = "pda_server-off"
else
icon_state = "pda_server-on"
return
/obj/machinery/blackbox_recorder
icon = 'icons/obj/machines/telecomms.dmi'
icon_state = "blackbox"
name = "Blackbox Recorder"
density = 1
anchored = 1.0
use_power = MACHINE_POWER_USE_IDLE
idle_power_usage = 10
active_power_usage = 100