mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 03:55:11 +01:00
[MIRROR] Cleans up signal use in bitrunning [NO GBP] [MDB IGNORE] (#24738)
* Cleans up signal use in bitrunning [NO GBP] * Update avatar_connection.dm --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
This commit is contained in:
@@ -1,37 +1,50 @@
|
||||
/// from /obj/machinery/netpod/default_pry_open() : (mob/living/intruder)
|
||||
#define COMSIG_BITRUNNER_CROWBAR_ALERT "bitrunner_crowbar"
|
||||
/// from /atom/movable/screen/alert/bitrunning/qserver_domain_complete
|
||||
#define COMSIG_BITRUNNER_ALERT_SEVER "bitrunner_alert_sever"
|
||||
|
||||
/// from /obj/effect/bitrunning/loot_signal: (points)
|
||||
#define COMSIG_BITRUNNER_GOAL_POINT "bitrunner_goal_point"
|
||||
|
||||
// Netpods
|
||||
|
||||
/// from /obj/machinery/netpod/sever_connection()
|
||||
#define COMSIG_BITRUNNER_NETPOD_SEVER "bitrunner_netpod_sever"
|
||||
|
||||
/// from /obj/machinery/netpod/default_pry_open() : (mob/living/intruder)
|
||||
#define COMSIG_BITRUNNER_CROWBAR_ALERT "bitrunner_crowbar"
|
||||
|
||||
/// from /obj/machinery/netpod/on_damage_taken()
|
||||
#define COMSIG_BITRUNNER_NETPOD_INTEGRITY "bitrunner_netpod_damage"
|
||||
|
||||
/// from /obj/machinery/netpod/open_machine()
|
||||
#define COMSIG_BITRUNNER_NETPOD_OPENED "bitrunner_netpod_opened"
|
||||
|
||||
// Server
|
||||
|
||||
/// from /obj/machinery/quantum_server/on_goal_turf_entered(): (atom/entered, reward_points)
|
||||
#define COMSIG_BITRUNNER_DOMAIN_COMPLETE "bitrunner_complete"
|
||||
|
||||
/// from /obj/machinery/netpod/on_take_damage()
|
||||
#define COMSIG_BITRUNNER_NETPOD_INTEGRITY "bitrunner_netpod_damage"
|
||||
/// from /obj/machinery/quantum_server/generate_loot()
|
||||
#define COMSIG_BITRUNNER_CACHE_SEVER "bitrunner_cache_sever"
|
||||
|
||||
/// from /obj/structure/hololadder and complete alert
|
||||
#define COMSIG_BITRUNNER_SAFE_DISCONNECT "bitrunner_disconnect"
|
||||
|
||||
/// from /obj/machinery/netpod/open_machine(), /obj/machinery/quantum_server, etc (obj/machinery/netpod)
|
||||
#define COMSIG_BITRUNNER_SEVER_AVATAR "bitrunner_sever"
|
||||
/// from /obj/machinery/quantum_server/sever_connection()
|
||||
#define COMSIG_BITRUNNER_QSRV_SEVER "bitrunner_qserver_sever"
|
||||
|
||||
/// from /obj/machinery/quantum_server/shutdown() : (mob/living)
|
||||
#define COMSIG_BITRUNNER_SHUTDOWN_ALERT "bitrunner_shutdown"
|
||||
|
||||
// Notifies the bitrunners
|
||||
/// from /datum/antagonist/cyber_police/proc/notify() :
|
||||
/// from /obj/machinery/quantum_server/notify_threat()
|
||||
#define COMSIG_BITRUNNER_THREAT_CREATED "bitrunner_threat"
|
||||
|
||||
// Informs the server to up the threat count
|
||||
/// from event spawns: (mob/living)
|
||||
#define COMSIG_BITRUNNER_SPAWN_GLITCH "bitrunner_spawn_glitch"
|
||||
|
||||
/// from /obj/machinery/quantum_server/refreshParts(): (servo rating)
|
||||
#define COMSIG_BITRUNNER_SERVER_UPGRADED "bitrunner_server_upgraded"
|
||||
|
||||
/// from /obj/machinery/quantum_server/scrub_vdom()
|
||||
#define COMSIG_BITRUNNER_DOMAIN_SCRUBBED "bitrunner_domain_scrubbed"
|
||||
|
||||
/// from /obj/machinery/netpod/open_machine()
|
||||
#define COMSIG_BITRUNNER_NETPOD_OPENED "bitrunner_netpod_opened"
|
||||
/// from /obj/machienry/quantum_server/station_spawn()
|
||||
#define COMSIG_BITRUNNER_STATION_SPAWN "bitrunner_station_spawn"
|
||||
|
||||
// Ladder
|
||||
/// from /obj/structure/hololadder/disconnect()
|
||||
#define COMSIG_BITRUNNER_LADDER_SEVER "bitrunner_ladder_sever"
|
||||
|
||||
|
||||
/// deprecated
|
||||
#define COMSIG_BITRUNNER_SPAWN_GLITCH "bitrunner_spawn_glitch"
|
||||
|
||||
@@ -3,26 +3,6 @@
|
||||
icon_state = "template"
|
||||
timeout = 10 SECONDS
|
||||
|
||||
/atom/movable/screen/alert/bitrunning/netpod_crowbar
|
||||
name = "Forced Entry"
|
||||
desc = "Someone is prying open the netpod door. Find an exit."
|
||||
|
||||
/atom/movable/screen/alert/bitrunning/netpod_damaged
|
||||
name = "Integrity Compromised"
|
||||
desc = "The netpod is damaged. Find an exit."
|
||||
|
||||
/atom/movable/screen/alert/bitrunning/qserver_shutting_down
|
||||
name = "Domain Rebooting"
|
||||
desc = "The domain is rebooting. Find an exit."
|
||||
|
||||
/atom/movable/screen/alert/bitrunning/qserver_threat_deletion
|
||||
name = "Queue Deletion"
|
||||
desc = "The server is resetting. Oblivion awaits."
|
||||
|
||||
/atom/movable/screen/alert/bitrunning/qserver_threat_spawned
|
||||
name = "Threat Detected"
|
||||
desc = "Data stream abnormalities present."
|
||||
|
||||
/atom/movable/screen/alert/bitrunning/qserver_domain_complete
|
||||
name = "Domain Completed"
|
||||
desc = "The domain is completed. Activate to exit."
|
||||
@@ -37,4 +17,5 @@
|
||||
return
|
||||
|
||||
if(tgui_alert(living_owner, "Disconnect safely?", "Server Message", list("Exit", "Remain"), 10 SECONDS) == "Exit")
|
||||
SEND_SIGNAL(living_owner, COMSIG_BITRUNNER_SAFE_DISCONNECT)
|
||||
SEND_SIGNAL(living_owner, COMSIG_BITRUNNER_ALERT_SEVER)
|
||||
|
||||
|
||||
@@ -36,12 +36,18 @@
|
||||
ADD_TRAIT(avatar, TRAIT_NO_MINDSWAP, REF(src)) // do not remove this one
|
||||
ADD_TRAIT(old_body, TRAIT_MIND_TEMPORARILY_GONE, REF(src))
|
||||
|
||||
/**
|
||||
* Things that will disconnect forcefully:
|
||||
* - Server shutdown / broken
|
||||
* - Netpod power loss / broken
|
||||
* - Pilot dies/ is moved / falls unconscious
|
||||
*/
|
||||
RegisterSignals(old_body, list(COMSIG_LIVING_DEATH, COMSIG_MOVABLE_MOVED, COMSIG_LIVING_STATUS_UNCONSCIOUS), PROC_REF(on_sever_connection))
|
||||
RegisterSignal(pod, COMSIG_BITRUNNER_CROWBAR_ALERT, PROC_REF(on_netpod_crowbar))
|
||||
RegisterSignal(pod, COMSIG_BITRUNNER_NETPOD_INTEGRITY, PROC_REF(on_netpod_damaged))
|
||||
RegisterSignal(pod, COMSIG_BITRUNNER_SEVER_AVATAR, PROC_REF(on_sever_connection))
|
||||
RegisterSignal(pod, COMSIG_BITRUNNER_NETPOD_SEVER, PROC_REF(on_sever_connection))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_DOMAIN_COMPLETE, PROC_REF(on_domain_completed))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_SEVER_AVATAR, PROC_REF(on_sever_connection))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_QSRV_SEVER, PROC_REF(on_sever_connection))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_SHUTDOWN_ALERT, PROC_REF(on_shutting_down))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_THREAT_CREATED, PROC_REF(on_threat_created))
|
||||
#ifndef UNIT_TESTS
|
||||
@@ -69,18 +75,26 @@
|
||||
|
||||
/datum/component/avatar_connection/RegisterWithParent()
|
||||
ADD_TRAIT(parent, TRAIT_TEMPORARY_BODY, REF(src))
|
||||
RegisterSignal(parent, COMSIG_BITRUNNER_SAFE_DISCONNECT, PROC_REF(on_safe_disconnect))
|
||||
/**
|
||||
* Things that cause safe disconnection:
|
||||
* - Click the alert
|
||||
* - Mailed in a cache
|
||||
* - Click / Stand on the ladder
|
||||
*/
|
||||
RegisterSignals(parent, list(COMSIG_BITRUNNER_ALERT_SEVER, COMSIG_BITRUNNER_CACHE_SEVER, COMSIG_BITRUNNER_LADDER_SEVER), PROC_REF(on_safe_disconnect))
|
||||
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_sever_connection))
|
||||
RegisterSignal(parent, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(on_linked_damage))
|
||||
|
||||
/datum/component/avatar_connection/UnregisterFromParent()
|
||||
REMOVE_TRAIT(parent, TRAIT_TEMPORARY_BODY, REF(src))
|
||||
UnregisterSignal(parent, COMSIG_BITRUNNER_SAFE_DISCONNECT)
|
||||
UnregisterSignal(parent, COMSIG_BITRUNNER_ALERT_SEVER)
|
||||
UnregisterSignal(parent, COMSIG_BITRUNNER_CACHE_SEVER)
|
||||
UnregisterSignal(parent, COMSIG_BITRUNNER_LADDER_SEVER)
|
||||
UnregisterSignal(parent, COMSIG_LIVING_DEATH)
|
||||
UnregisterSignal(parent, COMSIG_MOB_APPLY_DAMAGE)
|
||||
|
||||
/// Disconnects the avatar and returns the mind to the old_body.
|
||||
/datum/component/avatar_connection/proc/full_avatar_disconnect(forced = FALSE, datum/source)
|
||||
/datum/component/avatar_connection/proc/full_avatar_disconnect(cause_damage = FALSE, datum/source)
|
||||
#ifndef UNIT_TESTS
|
||||
return_to_old_body()
|
||||
#endif
|
||||
@@ -89,7 +103,7 @@
|
||||
if(isnull(hosting_netpod) && istype(source, /obj/machinery/netpod))
|
||||
hosting_netpod = source
|
||||
|
||||
hosting_netpod?.disconnect_occupant(forced)
|
||||
hosting_netpod?.disconnect_occupant(cause_damage)
|
||||
|
||||
var/obj/machinery/quantum_server/server = server_ref?.resolve()
|
||||
server?.avatar_connection_refs.Remove(WEAKREF(src))
|
||||
@@ -101,7 +115,7 @@
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/mob/living/avatar = parent
|
||||
avatar.playsound_local(avatar, 'sound/machines/terminal_success.ogg', 50, TRUE)
|
||||
avatar.playsound_local(avatar, 'sound/machines/terminal_success.ogg', 50, vary = TRUE)
|
||||
avatar.throw_alert(
|
||||
ALERT_BITRUNNER_COMPLETED,
|
||||
/atom/movable/screen/alert/bitrunning/qserver_domain_complete,
|
||||
@@ -113,12 +127,11 @@
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/mob/living/carbon/old_body = old_body_ref?.resolve()
|
||||
|
||||
if(isnull(old_body) || damage_type == STAMINA || damage_type == OXYLOSS)
|
||||
return
|
||||
|
||||
if(damage >= (old_body.health + (ishuman(old_body) ? HUMAN_MAXHEALTH : MAX_LIVING_HEALTH))) // SKYRAT EDIT CHANGE - ORIGINAL: if(damage >= (old_body.health + MAX_LIVING_HEALTH))
|
||||
full_avatar_disconnect(forced = TRUE)
|
||||
full_avatar_disconnect(cause_damage = TRUE)
|
||||
return
|
||||
|
||||
if(damage > 30 && prob(30))
|
||||
@@ -127,7 +140,7 @@
|
||||
old_body.apply_damage(damage, damage_type, def_zone, blocked, wound_bonus = CANT_WOUND)
|
||||
|
||||
if(old_body.stat > SOFT_CRIT) // KO!
|
||||
full_avatar_disconnect(forced = TRUE)
|
||||
full_avatar_disconnect(cause_damage = TRUE)
|
||||
|
||||
/// Handles minds being swapped around in subsequent avatars
|
||||
/datum/component/avatar_connection/proc/on_mind_transfer(datum/mind/source, mob/living/previous_body)
|
||||
@@ -144,58 +157,66 @@
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/mob/living/avatar = parent
|
||||
avatar.playsound_local(avatar, 'sound/machines/terminal_alert.ogg', 50, TRUE)
|
||||
avatar.throw_alert(
|
||||
avatar.playsound_local(avatar, 'sound/machines/terminal_alert.ogg', 50, vary = TRUE)
|
||||
var/atom/movable/screen/alert/bitrunning/alert = avatar.throw_alert(
|
||||
ALERT_BITRUNNER_CROWBAR,
|
||||
/atom/movable/screen/alert/bitrunning/netpod_crowbar,
|
||||
/atom/movable/screen/alert/bitrunning,
|
||||
new_master = intruder
|
||||
)
|
||||
alert.name = "Netpod Breached"
|
||||
alert.desc = "Someone is prying open the netpod. Find an exit."
|
||||
|
||||
/// Triggers when the netpod is taking damage and is under 50%
|
||||
/datum/component/avatar_connection/proc/on_netpod_damaged(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/mob/living/avatar = parent
|
||||
avatar.throw_alert(
|
||||
var/atom/movable/screen/alert/bitrunning/alert = avatar.throw_alert(
|
||||
ALERT_BITRUNNER_INTEGRITY,
|
||||
/atom/movable/screen/alert/bitrunning/netpod_damaged,
|
||||
/atom/movable/screen/alert/bitrunning,
|
||||
new_master = source
|
||||
)
|
||||
alert.name = "Integrity Compromised"
|
||||
alert.desc = "The netpod is damaged. Find an exit."
|
||||
|
||||
/// Safely exits without forced variables, etc
|
||||
/// Triggers when a safe disconnect is called
|
||||
/datum/component/avatar_connection/proc/on_safe_disconnect(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
full_avatar_disconnect()
|
||||
|
||||
/// Helper for calling sever with forced variables
|
||||
/// Received message to sever connection
|
||||
/datum/component/avatar_connection/proc/on_sever_connection(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
full_avatar_disconnect(forced = TRUE, source = source)
|
||||
full_avatar_disconnect(cause_damage = TRUE, source = source)
|
||||
|
||||
/// Triggers when the server is shutting down
|
||||
/datum/component/avatar_connection/proc/on_shutting_down(datum/source, mob/living/hackerman)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/mob/living/avatar = parent
|
||||
avatar.playsound_local(avatar, 'sound/machines/terminal_alert.ogg', 50, TRUE)
|
||||
avatar.throw_alert(
|
||||
avatar.playsound_local(avatar, 'sound/machines/terminal_alert.ogg', 50, vary = TRUE)
|
||||
var/atom/movable/screen/alert/bitrunning/alert = avatar.throw_alert(
|
||||
ALERT_BITRUNNER_SHUTDOWN,
|
||||
/atom/movable/screen/alert/bitrunning/qserver_shutting_down,
|
||||
/atom/movable/screen/alert/bitrunning,
|
||||
new_master = hackerman,
|
||||
)
|
||||
alert.name = "Domain Rebooting"
|
||||
alert.desc = "The domain is rebooting. Find an exit."
|
||||
|
||||
/// Server has spawned a ghost role threat
|
||||
/datum/component/avatar_connection/proc/on_threat_created(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/mob/living/avatar = parent
|
||||
avatar.throw_alert(
|
||||
var/atom/movable/screen/alert/bitrunning/alert = avatar.throw_alert(
|
||||
ALERT_BITRUNNER_THREAT,
|
||||
/atom/movable/screen/alert/bitrunning/qserver_threat_spawned,
|
||||
/atom/movable/screen/alert/bitrunning,
|
||||
new_master = source,
|
||||
)
|
||||
alert.name = "Threat Detected"
|
||||
alert.desc = "Data stream abnormalities present."
|
||||
|
||||
/// Returns the mind to the old body
|
||||
/datum/component/avatar_connection/proc/return_to_old_body()
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
balloon_alert(user, "disconnecting...")
|
||||
if(do_after(user, travel_time, src))
|
||||
SEND_SIGNAL(user, COMSIG_BITRUNNER_SAFE_DISCONNECT)
|
||||
SEND_SIGNAL(user, COMSIG_BITRUNNER_LADDER_SEVER)
|
||||
|
||||
/// Helper for times when you dont have hands (gondola??)
|
||||
/obj/structure/hololadder/proc/on_enter(datum/source, atom/movable/arrived, turf/old_loc)
|
||||
|
||||
@@ -121,11 +121,6 @@
|
||||
if(!state_open && gone == occupant)
|
||||
container_resist_act(gone)
|
||||
|
||||
/obj/machinery/netpod/Exited(atom/movable/gone, direction)
|
||||
. = ..()
|
||||
if(!state_open && gone == occupant)
|
||||
container_resist_act(gone)
|
||||
|
||||
/obj/machinery/netpod/relaymove(mob/living/user, direction)
|
||||
if(!state_open)
|
||||
container_resist_act(user)
|
||||
@@ -176,7 +171,7 @@
|
||||
|
||||
if(do_after(pryer, 15 SECONDS, src))
|
||||
if(!state_open)
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
|
||||
sever_connection()
|
||||
open_machine()
|
||||
|
||||
return TRUE
|
||||
@@ -246,7 +241,7 @@
|
||||
open_machine()
|
||||
|
||||
/// Handles occupant post-disconnection effects like damage, sounds, etc
|
||||
/obj/machinery/netpod/proc/disconnect_occupant(forced = FALSE)
|
||||
/obj/machinery/netpod/proc/disconnect_occupant(cause_damage = FALSE)
|
||||
connected = FALSE
|
||||
|
||||
var/mob/living/mob_occupant = occupant
|
||||
@@ -268,7 +263,7 @@
|
||||
heal_time = (mob_occupant.stat + 2) * 5
|
||||
addtimer(CALLBACK(src, PROC_REF(auto_disconnect)), heal_time SECONDS, TIMER_UNIQUE|TIMER_STOPPABLE|TIMER_DELETE_ME)
|
||||
|
||||
if(!forced)
|
||||
if(!cause_damage)
|
||||
return
|
||||
|
||||
mob_occupant.flash_act(override_blindness_check = TRUE, visual = TRUE)
|
||||
@@ -339,7 +334,7 @@
|
||||
return
|
||||
|
||||
server_ref = WEAKREF(server)
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_SERVER_UPGRADED, PROC_REF(on_server_upgraded))
|
||||
RegisterSignal(server, COMSIG_MACHINERY_REFRESH_PARTS, PROC_REF(on_server_upgraded))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_DOMAIN_COMPLETE, PROC_REF(on_domain_complete))
|
||||
RegisterSignal(server, COMSIG_BITRUNNER_DOMAIN_SCRUBBED, PROC_REF(on_domain_scrubbed))
|
||||
|
||||
@@ -352,14 +347,12 @@
|
||||
"outfits" = list()
|
||||
)
|
||||
|
||||
for(var/path as anything in outfit_list)
|
||||
var/datum/outfit/outfit = path
|
||||
|
||||
for(var/datum/outfit/outfit as anything in outfit_list)
|
||||
var/outfit_name = initial(outfit.name)
|
||||
if(findtext(outfit_name, "(") != 0 || findtext(outfit_name, "-") != 0) // No special variants please
|
||||
continue
|
||||
|
||||
collection["outfits"] += list(list("path" = path, "name" = outfit_name))
|
||||
collection["outfits"] += list(list("path" = outfit, "name" = outfit_name))
|
||||
|
||||
return list(collection)
|
||||
|
||||
@@ -367,10 +360,7 @@
|
||||
/obj/machinery/netpod/proc/on_broken(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(isnull(occupant) || !connected)
|
||||
return
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
|
||||
sever_connection()
|
||||
|
||||
/// Checks the integrity, alerts occupants
|
||||
/obj/machinery/netpod/proc/on_damage_taken(datum/source, damage_amount)
|
||||
@@ -415,6 +405,11 @@
|
||||
/obj/machinery/netpod/proc/on_examine(datum/source, mob/examiner, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(isnull(server_ref?.resolve()))
|
||||
examine_text += span_infoplain("It's not connected to anything.")
|
||||
examine_text += span_infoplain("Netpods must be built within 4 tiles of a server.")
|
||||
return
|
||||
|
||||
examine_text += span_infoplain("Drag yourself into the pod to engage the link.")
|
||||
examine_text += span_infoplain("It has limited resuscitation capabilities. Remaining in the pod can heal some injuries.")
|
||||
examine_text += span_infoplain("It has a security system that will alert the occupant if it is tampered with.")
|
||||
@@ -438,13 +433,13 @@
|
||||
open_machine()
|
||||
return
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
|
||||
sever_connection()
|
||||
|
||||
/// When the server is upgraded, drops brain damage a little
|
||||
/obj/machinery/netpod/proc/on_server_upgraded(datum/source, servo_rating)
|
||||
/obj/machinery/netpod/proc/on_server_upgraded(obj/machinery/quantum_server/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
disconnect_damage = BASE_DISCONNECT_DAMAGE * (1 - servo_rating)
|
||||
disconnect_damage = BASE_DISCONNECT_DAMAGE * (1 - source.servo_bonus)
|
||||
|
||||
/// Resolves a path to an outfit.
|
||||
/obj/machinery/netpod/proc/resolve_outfit(text)
|
||||
@@ -452,6 +447,13 @@
|
||||
if(ispath(path, /datum/outfit))
|
||||
return path
|
||||
|
||||
/// Severs the connection with the current avatar
|
||||
/obj/machinery/netpod/proc/sever_connection()
|
||||
if(isnull(occupant) || !connected)
|
||||
return
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_NETPOD_SEVER)
|
||||
|
||||
/// Closes the machine without shoving in an occupant
|
||||
/obj/machinery/netpod/proc/shut_pod()
|
||||
state_open = FALSE
|
||||
|
||||
@@ -104,5 +104,4 @@
|
||||
var/obj/machinery/quantum_server/nearby_server = locate(/obj/machinery/quantum_server, get_step(src, direction))
|
||||
if(nearby_server)
|
||||
server_ref = WEAKREF(nearby_server)
|
||||
nearby_server.console_ref = WEAKREF(src)
|
||||
return nearby_server
|
||||
|
||||
@@ -7,27 +7,24 @@
|
||||
|
||||
rewards_base += servo_bonus
|
||||
|
||||
rewards_base += (domain_threats * 2)
|
||||
rewards_base += (length(spawned_threat_refs) * 2)
|
||||
|
||||
for(var/index in 2 to length(avatar_connection_refs))
|
||||
rewards_base += multiplayer_bonus
|
||||
|
||||
return rewards_base
|
||||
|
||||
/// Generates a reward based on the given domain
|
||||
/obj/machinery/quantum_server/proc/generate_loot()
|
||||
var/list/obj/machinery/byteforge/nearby_forges = get_nearby_forges()
|
||||
if(isnull(nearby_forges))
|
||||
say(src, "No nearby byteforges detected.")
|
||||
return FALSE
|
||||
/// Handles spawning the (new) crate and deleting the former
|
||||
/obj/machinery/quantum_server/proc/generate_loot(obj/cache, obj/machinery/byteforge/chosen_forge)
|
||||
for(var/mob/person in cache.contents)
|
||||
SEND_SIGNAL(person, COMSIG_BITRUNNER_CACHE_SEVER)
|
||||
|
||||
spark_at_location(cache) // abracadabra!
|
||||
qdel(cache) // and it's gone!
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_DOMAIN_COMPLETE, cache, generated_domain.reward_points)
|
||||
|
||||
points += generated_domain.reward_points
|
||||
playsound(src, 'sound/machines/terminal_success.ogg', 30, 2)
|
||||
|
||||
var/obj/machinery/byteforge/chosen_forge = pick(nearby_forges)
|
||||
if(isnull(chosen_forge))
|
||||
stack_trace("Failed to find a turf to spawn loot crate on.")
|
||||
return FALSE
|
||||
playsound(src, 'sound/machines/terminal_success.ogg', 30, vary = TRUE)
|
||||
|
||||
var/bonus = calculate_rewards()
|
||||
|
||||
@@ -36,11 +33,11 @@
|
||||
certificate.name = "certificate of domain completion"
|
||||
certificate.update_appearance()
|
||||
|
||||
var/obj/structure/closet/crate/secure/bitrunning/decrypted/reward_crate = new(src, generated_domain, bonus)
|
||||
reward_crate.manifest = certificate
|
||||
reward_crate.update_appearance()
|
||||
var/obj/structure/closet/crate/secure/bitrunning/decrypted/reward_cache = new(src, generated_domain, bonus)
|
||||
reward_cache.manifest = certificate
|
||||
reward_cache.update_appearance()
|
||||
|
||||
chosen_forge.start_to_spawn(reward_crate)
|
||||
chosen_forge.start_to_spawn(reward_cache)
|
||||
return TRUE
|
||||
|
||||
/// Returns the markdown text containing domain completion information
|
||||
@@ -51,18 +48,20 @@
|
||||
|
||||
var/bonuses = calculate_rewards()
|
||||
|
||||
var/domain_threats = length(spawned_threat_refs)
|
||||
|
||||
var/time_difference = world.time - generated_domain.start_time
|
||||
|
||||
var/completion_time = "### Completion Time: [DisplayTimeText(time_difference)]\n"
|
||||
|
||||
var/grade = "\n---\n\n# Rating: [grade_completion(generated_domain.difficulty, domain_threats, base_points, domain_randomized, time_difference)]"
|
||||
var/grade = "\n---\n\n# Rating: [grade_completion(time_difference)]"
|
||||
|
||||
var/text = "# Certificate of Domain Completion\n\n---\n\n"
|
||||
|
||||
text += "### [generated_domain.name][domain_randomized ? " (Randomized)" : ""]\n"
|
||||
text += "- **Difficulty:** [generated_domain.difficulty]\n"
|
||||
text += "- **Threats:** [domain_threats]\n"
|
||||
text += "- **Base Points:** [base_points][domain_randomized ? " +1" : ""]\n\n"
|
||||
text += "- **Base Reward:** [base_points][domain_randomized ? " +1" : ""]\n\n"
|
||||
text += "- **Total Bonus:** [bonuses]x\n\n"
|
||||
|
||||
if(bonuses <= 1)
|
||||
@@ -91,12 +90,11 @@
|
||||
return text
|
||||
|
||||
/// Grades the player's run based on several factors
|
||||
/obj/machinery/quantum_server/proc/grade_completion(difficulty, threats, points, randomized, completion_time)
|
||||
var/score = threats * 5
|
||||
score += points
|
||||
score += randomized ? 1 : 0
|
||||
/obj/machinery/quantum_server/proc/grade_completion(completion_time)
|
||||
var/score = length(spawned_threat_refs) * 5
|
||||
score += generated_domain.reward_points
|
||||
|
||||
var/base = difficulty + 1
|
||||
var/base = generated_domain.difficulty + 1
|
||||
var/time_score = 1
|
||||
|
||||
if(completion_time <= 1 MINUTES)
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
/obj/machinery/quantum_server/proc/reset(fast = FALSE)
|
||||
is_ready = FALSE
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
|
||||
sever_connections()
|
||||
|
||||
if(!fast)
|
||||
notify_spawned_threats()
|
||||
@@ -155,12 +155,11 @@
|
||||
|
||||
update_use_power(IDLE_POWER_USE)
|
||||
domain_randomized = FALSE
|
||||
domain_threats = 0
|
||||
retries_spent = 0
|
||||
|
||||
/// Deletes all the tile contents
|
||||
/obj/machinery/quantum_server/proc/scrub_vdom()
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR) /// just in case someone's connected
|
||||
sever_connections() /// just in case someone's connected
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_DOMAIN_SCRUBBED) // avatar cleanup just in case
|
||||
|
||||
if(length(generated_domain.reservations))
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
var/datum/lazy_template/virtual_domain/generated_domain
|
||||
/// The loaded safehouse, map_template/safehouse
|
||||
var/datum/map_template/safehouse/generated_safehouse
|
||||
/// The connected console
|
||||
var/datum/weakref/console_ref
|
||||
/// If the current domain was a random selection
|
||||
var/domain_randomized = FALSE
|
||||
/// If any threats were spawned, adds to rewards
|
||||
var/domain_threats = 0
|
||||
/// Prevents multiple user actions. Handled by loading domains and cooldowns
|
||||
var/is_ready = TRUE
|
||||
/// List of available domains
|
||||
@@ -57,9 +53,6 @@
|
||||
/obj/machinery/quantum_server/LateInitialize()
|
||||
. = ..()
|
||||
|
||||
if(isnull(console_ref))
|
||||
find_console()
|
||||
|
||||
radio = new(src)
|
||||
radio.set_frequency(FREQ_SUPPLY)
|
||||
radio.subspace_transmission = TRUE
|
||||
@@ -146,4 +139,3 @@
|
||||
|
||||
servo_bonus = servo_rating
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SERVER_UPGRADED, servo_rating)
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
/obj/machinery/quantum_server/proc/on_broken(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(isnull(generated_domain))
|
||||
return
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
|
||||
sever_connections()
|
||||
|
||||
/// Whenever a corpse spawner makes a new corpse, add it to the list of potential mutations
|
||||
/obj/machinery/quantum_server/proc/on_corpse_spawned(datum/source, mob/living/corpse)
|
||||
@@ -18,7 +15,7 @@
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(generated_domain)
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_SEVER_AVATAR)
|
||||
sever_connections()
|
||||
scrub_vdom()
|
||||
|
||||
if(is_ready)
|
||||
@@ -49,25 +46,14 @@
|
||||
/obj/machinery/quantum_server/proc/on_goal_turf_entered(datum/source, atom/movable/arrived, atom/old_loc, list/atom/old_locs)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(!istype(arrived, /obj/structure/closet/crate/secure/bitrunning/encrypted))
|
||||
var/obj/machinery/byteforge/chosen_forge = get_random_nearby_forge()
|
||||
if(isnull(chosen_forge))
|
||||
return
|
||||
|
||||
var/obj/structure/closet/crate/secure/bitrunning/encrypted/loot_crate = arrived
|
||||
if(!istype(loot_crate))
|
||||
if(istype(arrived, /obj/structure/closet/crate/secure/bitrunning/encrypted))
|
||||
generate_loot(arrived, chosen_forge)
|
||||
return
|
||||
|
||||
for(var/mob/person in loot_crate.contents)
|
||||
if(isnull(person.mind))
|
||||
person.forceMove(get_turf(loot_crate))
|
||||
|
||||
var/datum/component/avatar_connection/connection = person.GetComponent(/datum/component/avatar_connection)
|
||||
connection?.full_avatar_disconnect()
|
||||
|
||||
spark_at_location(loot_crate)
|
||||
qdel(loot_crate)
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_DOMAIN_COMPLETE, arrived, generated_domain.reward_points)
|
||||
generate_loot()
|
||||
|
||||
/// Handles examining the server. Shows cooldown time and efficiency.
|
||||
/obj/machinery/quantum_server/proc/on_goal_turf_examined(datum/source, mob/examiner, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
@@ -105,6 +91,4 @@
|
||||
/obj/machinery/quantum_server/proc/on_threat_created(datum/source, mob/living/threat)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
domain_threats += 1
|
||||
spawned_threat_refs.Add(WEAKREF(threat))
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_THREAT_CREATED) // notify players
|
||||
add_threats(threat)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/// Adds threats to the list and notifies players
|
||||
/obj/machinery/quantum_server/proc/add_threats(mob/living/threat)
|
||||
spawned_threat_refs.Add(WEAKREF(threat))
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_THREAT_CREATED)
|
||||
|
||||
/// Finds any mobs with minds in the zones and gives them the bad news
|
||||
/obj/machinery/quantum_server/proc/notify_spawned_threats()
|
||||
for(var/datum/weakref/baddie_ref as anything in spawned_threat_refs)
|
||||
var/mob/living/baddie = baddie_ref.resolve()
|
||||
if(isnull(baddie?.mind) || baddie.stat >= UNCONSCIOUS)
|
||||
continue
|
||||
|
||||
var/atom/movable/screen/alert/bitrunning/alert = baddie.throw_alert(
|
||||
ALERT_BITRUNNER_RESET,
|
||||
/atom/movable/screen/alert/bitrunning,
|
||||
new_master = src,
|
||||
)
|
||||
alert.name = "Queue Deletion"
|
||||
alert.desc = "The server is resetting. Oblivion awaits."
|
||||
|
||||
to_chat(baddie, span_userdanger("You have been flagged for deletion! Thank you for your service."))
|
||||
@@ -7,19 +7,6 @@
|
||||
update_appearance()
|
||||
radio.talk_into(src, "Thermal systems within operational parameters. Proceeding to domain configuration.", RADIO_CHANNEL_SUPPLY)
|
||||
|
||||
/// Attempts to connect to a quantum console
|
||||
/obj/machinery/quantum_server/proc/find_console()
|
||||
var/obj/machinery/computer/quantum_console/console = console_ref?.resolve()
|
||||
if(console)
|
||||
return console
|
||||
|
||||
for(var/direction in GLOB.cardinals)
|
||||
var/obj/machinery/computer/quantum_console/nearby_console = locate(/obj/machinery/computer/quantum_console, get_step(src, direction))
|
||||
if(nearby_console)
|
||||
console_ref = WEAKREF(nearby_console)
|
||||
nearby_console.server_ref = WEAKREF(src)
|
||||
return nearby_console
|
||||
|
||||
/// Compiles a list of available domains.
|
||||
/obj/machinery/quantum_server/proc/get_available_domains()
|
||||
var/list/levels = list()
|
||||
@@ -91,6 +78,15 @@
|
||||
domain_randomized = TRUE
|
||||
return available["id"]
|
||||
|
||||
/// Locates any turfs with forges on them, returns a random one
|
||||
/obj/machinery/quantum_server/proc/get_random_nearby_forge()
|
||||
var/list/nearby_forges = list()
|
||||
|
||||
for(var/obj/machinery/byteforge/forge in oview(MAX_DISTANCE, src))
|
||||
nearby_forges += forge
|
||||
|
||||
return pick(nearby_forges)
|
||||
|
||||
/// Gets all mobs originally generated by the loaded domain and returns a list that are capable of being antagged
|
||||
/obj/machinery/quantum_server/proc/get_valid_domain_targets()
|
||||
// A: No one is playing
|
||||
@@ -116,20 +112,12 @@
|
||||
|
||||
return nearby_forges
|
||||
|
||||
/// Finds any mobs with minds in the zones and gives them the bad news
|
||||
/obj/machinery/quantum_server/proc/notify_spawned_threats()
|
||||
for(var/datum/weakref/baddie_ref as anything in spawned_threat_refs)
|
||||
var/mob/living/baddie = baddie_ref.resolve()
|
||||
if(isnull(baddie) || baddie.stat >= UNCONSCIOUS || isnull(baddie.mind))
|
||||
continue
|
||||
/// Severs any connected users
|
||||
/obj/machinery/quantum_server/proc/sever_connections()
|
||||
if(isnull(generated_domain) || !length(avatar_connection_refs))
|
||||
return
|
||||
|
||||
baddie.throw_alert(
|
||||
ALERT_BITRUNNER_RESET,
|
||||
/atom/movable/screen/alert/bitrunning/qserver_threat_deletion,
|
||||
new_master = src,
|
||||
)
|
||||
|
||||
to_chat(baddie, span_userdanger("You have been flagged for deletion! Thank you for your service."))
|
||||
SEND_SIGNAL(src, COMSIG_BITRUNNER_QSRV_SEVER)
|
||||
|
||||
/// Do some magic teleport sparks
|
||||
/obj/machinery/quantum_server/proc/spark_at_location(obj/cache)
|
||||
|
||||
@@ -3403,6 +3403,7 @@
|
||||
#include "code\modules\bitrunning\server\obj_generation.dm"
|
||||
#include "code\modules\bitrunning\server\quantum_server.dm"
|
||||
#include "code\modules\bitrunning\server\signal_handlers.dm"
|
||||
#include "code\modules\bitrunning\server\threats.dm"
|
||||
#include "code\modules\bitrunning\server\util.dm"
|
||||
#include "code\modules\bitrunning\virtual_domain\safehouses.dm"
|
||||
#include "code\modules\bitrunning\virtual_domain\virtual_domain.dm"
|
||||
|
||||
Reference in New Issue
Block a user