Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Bitrunning server ghost communication and domain anchor balancing #5299

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modular_nova/modules/bitrunning/code/anchor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@

/obj/item/domain_anchor/attack_self(mob/user, modifiers)
for(var/obj/machinery/quantum_server/server in SSmachines.get_machines_by_type(/obj/machinery/quantum_server))
if(server.current_anchors >= server.max_anchors)
user.balloon_alert(user, "bandwidth limit reached!")
return FALSE
server.exit_turfs += get_turf(src)
server.retries_spent -= 1
server.threat += 1
server.current_anchors += 1
server.radio.talk_into(src, "Potential secure datastream detected. Locking on the new spawn point.", RADIO_CHANNEL_SUPPLY)
new /obj/effect/landmark/bitrunning/domain_anchor(drop_location())
user.balloon_alert(user, "connection stabilized!")
Expand Down
13 changes: 13 additions & 0 deletions modular_nova/modules/bitrunning/code/outfit.dm
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
/datum/outfit/job/bitrunner
r_pocket = /obj/item/bitrunning_disk/prefs
ears = /obj/item/radio/headset/headset_cargo/bitrunning

/obj/item/radio/headset/headset_cargo/bitrunning
name = "bitrunning radio headset"
desc = "A headset used by the Cargo's screen-smashers."
keyslot = /obj/item/encryptionkey/headset_bitrunning

/obj/item/encryptionkey/headset_bitrunning
name = "bitrunning radio encryption key"
icon_state = "cypherkey_cargo"
channels = list(RADIO_CHANNEL_SUPPLY = 1, RADIO_CHANNEL_SCIENCE = 1, RADIO_CHANNEL_FACTION = 1)
greyscale_config = /datum/greyscale_config/encryptionkey_cargo
greyscale_colors = "#49241a#a3344c"
86 changes: 86 additions & 0 deletions modular_nova/modules/bitrunning/code/server.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/obj/machinery/quantum_server
///List of ckeys containing players who have recently sent a message, players on this list are prohibited from sending a new one untill their ckey disappears.
var/list/spam_queue = list()
///Toggles whether the server accepts new messages or not.
var/message_protected = FALSE
///Maximum amount of connections that can be added via domain anchors. 1 for T1, 2 for T2, etc.
var/max_anchors = -1
///Current amount of used domain anchors.
var/current_anchors = 0

/obj/machinery/quantum_server/post_machine_initialize()
. = ..()
qdel(radio.keyslot)
radio.keyslot = new /obj/item/encryptionkey/headset_bitrunning()
radio.recalculateChannels()

/obj/machinery/quantum_server/Destroy()
spam_queue = null
return ..()

/obj/machinery/quantum_server/examine(mob/user)
. = ..()
if(max_anchors >= 1)
. += span_infoplain("- Its domain vulnerability scanners permit for up to [max_anchors] domain anchors to be used.")
. += span_notice("Any preloaded SNPC patterns, 'ghastly Resonance apparitions', or connected bitrunners can leave a custom-written message on the quantum server, \
causing a small, audible blip and sending a department message, indicating their activity to on-station bitrunners.")
. += span_notice("Its <b>messaging protection</b> is currently: <b>[message_protected ? "enabled" : "disabled"]</b>")

/obj/machinery/quantum_server/RefreshParts()
. = ..()
var/datum/stock_part/scanning_module/scanner = locate() in component_parts
if(scanner)
max_anchors = scanner.tier

/obj/machinery/quantum_server/reset(fast = FALSE)
. = ..()
current_anchors = initial(current_anchors)

/obj/machinery/quantum_server/attack_ghost(mob/user)
. = ..()
if(!is_operational)
return

if(message_protected)
balloon_alert(user, "message protected!")
return

for(var/player_key in spam_queue)
if(player_key == user.ckey)
balloon_alert(user, "spam protection active!")
return
ghost_mark(user)

/obj/machinery/quantum_server/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return

message_protected = !message_protected
balloon_alert(user, "message protection [message_protected ? "enabled" : "disabled"]!")

/// 'Marks' the server with the ghost's presence: their custom-written message, and the ckey added to the spam-prevention list.
/obj/machinery/quantum_server/proc/ghost_mark(mob/activator)
var/message = tgui_input_text(activator, "Write your message", "Holonet Gaming Network", max_length = MAX_PLAQUE_LEN)
if(!message)
return
var/messenger = tgui_input_text(activator, "Set your username", "Holonet Gaming Network", max_length = MAX_NAME_LEN)
if(!messenger)
messenger = pick(GLOB.hacker_aliases)
if(message_protected)
balloon_alert(activator, "message protected!")
return
playsound(loc, 'sound/machines/ectoscope_beep.ogg', 75)
radio.talk_into(src, "You have: a new message: from [messenger]: [message]", RADIO_CHANNEL_FACTION)
if(activator?.ckey)
spam_queue += activator.ckey
addtimer(CALLBACK(src, PROC_REF(clear_spam), activator.ckey), 30 SECONDS, TIMER_UNIQUE | TIMER_STOPPABLE | TIMER_DELETE_ME)
activator.log_message("[activator] (as '[messenger]') sent the following quantum server message: '[message]'", LOG_TELECOMMS)

///Removes the ghost from the spam_queue list and lets them know they are free to message again.
/obj/machinery/quantum_server/proc/clear_spam(ghost_ckey)
spam_queue -= ghost_ckey
var/mob/ghost = get_mob_by_ckey(ghost_ckey)
if(!ghost || isliving(ghost))
return
to_chat(ghost, "[FOLLOW_LINK(ghost, src)] <span class='nicegreen'>The spam protection of [src] has deactivated.</span>")
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -7232,6 +7232,7 @@
#include "modular_nova\modules\bitrunning\code\loot.dm"
#include "modular_nova\modules\bitrunning\code\mobs.dm"
#include "modular_nova\modules\bitrunning\code\outfit.dm"
#include "modular_nova\modules\bitrunning\code\server.dm"
#include "modular_nova\modules\bitrunning\code\spells.dm"
#include "modular_nova\modules\bitrunning\code\virtual_domains\ancient_milsim\area.dm"
#include "modular_nova\modules\bitrunning\code\virtual_domains\ancient_milsim\choice_beacon.dm"
Expand Down
Loading