From 62f455ebc8d5232b30c316e7e9f5df43f1dea854 Mon Sep 17 00:00:00 2001 From: Arokha Sieyes Date: Fri, 24 Feb 2017 18:32:49 -0500 Subject: [PATCH] More mind-centric resleeve code Only change for players is that resleeving pods can show the true name of a mind in a body when clicked, for discovering ~~traitors~~ impostors! --- code/game/machinery/cryopod.dm | 17 ++-- code/modules/resleeving/computers.dm | 6 +- .../resleeving/{general.dm => implant.dm} | 38 ++++++-- code/modules/resleeving/infocore.dm | 94 +++++++++---------- code/modules/resleeving/machines.dm | 32 +++---- vorestation.dme | 2 +- 6 files changed, 104 insertions(+), 85 deletions(-) rename code/modules/resleeving/{general.dm => implant.dm} (60%) diff --git a/code/game/machinery/cryopod.dm b/code/game/machinery/cryopod.dm index 2af07abb4b1..6f490000a7f 100644 --- a/code/game/machinery/cryopod.dm +++ b/code/game/machinery/cryopod.dm @@ -417,16 +417,6 @@ qdel(R) qdel(W) - //VOREStation Edit - Resleeving. - if(istype(W,/obj/item/weapon/implant/backup)) - for(var/record in transcore.backed_up) - var/datum/transhuman/mind_record/MR = transcore.backed_up[record] - if(MR.imp_ref == W) - MR.cryo_at = world.time - MR.imp_ref = null - transcore.stop_backup(MR) - qdel(W) - //VOREStation Edit End - Resleeving. if(!preserve) qdel(W) else @@ -445,6 +435,12 @@ O.owner.current << "You get the feeling your target is no longer within your reach..." qdel(O) + //VOREStation Edit - Resleeving. + if(occupant.mind && (occupant.mind.name in transcore.backed_up)) + var/datum/transhuman/mind_record/MR = transcore.backed_up[occupant.mind.name] + transcore.stop_backup(MR) + //VOREStation Edit End - Resleeving. + //Handle job slot/tater cleanup. var/job = occupant.mind.assigned_role @@ -453,6 +449,7 @@ if(occupant.mind.objectives.len) qdel(occupant.mind.objectives) occupant.mind.special_role = null + //else //if(ticker.mode.name == "AutoTraitor") //var/datum/game_mode/traitor/autotraitor/current_mode = ticker.mode diff --git a/code/modules/resleeving/computers.dm b/code/modules/resleeving/computers.dm index a9ec9f6346a..2b32afb3a0b 100644 --- a/code/modules/resleeving/computers.dm +++ b/code/modules/resleeving/computers.dm @@ -167,7 +167,7 @@ var/can_sleeve_current = 1 if(!sleevers.len) can_sleeve_current = 0 - data["activeMindRecord"] = list("charname" = active_mr.charname, \ + data["activeMindRecord"] = list("charname" = active_mr.mindname, \ "obviously_dead" = active_mr.dead_state == MR_DEAD ? "Past-due" : "Current", \ "cando" = can_sleeve_current) else @@ -298,8 +298,8 @@ temp = "Error: Mind incompatible with body." //Body to sleeve into, but mind is in another living body. - else if(active_mr.mind.current && active_mr.mind.current.stat != DEAD) //Mind is in a body already that's alive - var/answer = alert(active_mr.mind.current,"Someone is attempting to restore a backup of your mind into another body. Do you want to move to that body? You MAY suffer memory loss! (Same rules as CMD apply)","Resleeving","Yes","No") + else if(active_mr.mind_ref.current && active_mr.mind_ref.current.stat < DEAD) //Mind is in a body already that's alive + var/answer = alert(active_mr.mind_ref.current,"Someone is attempting to restore a backup of your mind into another body. Do you want to move to that body? You MAY suffer memory loss! (Same rules as CMD apply)","Resleeving","Yes","No") //They declined to be moved. if(answer == "No") diff --git a/code/modules/resleeving/general.dm b/code/modules/resleeving/implant.dm similarity index 60% rename from code/modules/resleeving/general.dm rename to code/modules/resleeving/implant.dm index 73a86a1a638..cb5f048d4d9 100644 --- a/code/modules/resleeving/general.dm +++ b/code/modules/resleeving/implant.dm @@ -1,13 +1,14 @@ //////////////////////////////// -//// General resleeving stuff common to -//// robotics and medical both +//// Resleeving implant +//// for both organic and synthetic crew //////////////////////////////// //The backup implant itself /obj/item/weapon/implant/backup name = "backup implant" - desc = "Do you wanna live forever?" - var/datum/transhuman/mind_record/my_record + desc = "A mindstate backup implant that occasionally stores a copy of one's mind on a central server for backup purposes." + var/last_attempt + var/attempt_delay = 5 MINUTES /obj/item/weapon/implant/backup/get_data() var/dat = {" @@ -25,9 +26,29 @@ /obj/item/weapon/implant/backup/implanted(var/mob/living/carbon/human/H) ..() if(istype(H)) - my_record = new(H,src,1) + var/obj/item/weapon/implant/backup/other_imp = locate(/obj/item/weapon/implant/backup,H) + if(other_imp && other_imp.imp_in == H) + qdel(other_imp) //implant fight + + if(H.mind) //One out here just in case they are dead + transcore.m_backup(H.mind) + last_attempt = world.time + + backup() + return 1 +/obj/item/weapon/implant/backup/proc/backup() + last_attempt = world.time + var/mob/living/carbon/human/H = loc + + //Okay we're in a human with a mind at least + if(istype(H) && H == imp_in && H.mind && H.stat < DEAD) + transcore.m_backup(H.mind) + + spawn(attempt_delay) + backup() + //The glass case for the implant /obj/item/weapon/implantcase/backup name = "glass case - 'backup'" @@ -50,4 +71,9 @@ ..() for(var/i = 1 to 7) new /obj/item/weapon/implantcase/backup(src) - new /obj/item/weapon/implanter(src) \ No newline at end of file + new /obj/item/weapon/implanter(src) + +//Purely for fluff +/obj/item/weapon/implant/backup/full + name = "khi backup implant" + desc = "A normal KHI wireless cortical stack with neutrino and QE transmission for constant-stream consciousness upload." diff --git a/code/modules/resleeving/infocore.dm b/code/modules/resleeving/infocore.dm index ced8d0289fb..a1bf07e64bb 100644 --- a/code/modules/resleeving/infocore.dm +++ b/code/modules/resleeving/infocore.dm @@ -4,12 +4,14 @@ //////////////////////////////// /mob/living/carbon/human/var/resleeve_lock +/mob/living/carbon/human/var/original_player var/datum/transhuman/infocore/transcore = new/datum/transhuman/infocore //Mind-backup database /datum/transhuman/infocore - var/ping_time = 5 MINUTES + var/overdue_time = 15 MINUTES + var/process_time = 1 MINUTE var/datum/transhuman/mind_record/list/backed_up = list() var/datum/transhuman/mind_record/list/has_left = list() @@ -19,30 +21,38 @@ var/datum/transhuman/infocore/transcore = new/datum/transhuman/infocore process() /datum/transhuman/infocore/proc/process() - for(var/N in backed_up) var/datum/transhuman/mind_record/curr_MR = backed_up[N] if(!curr_MR) log_debug("Tried to process [N] in transcore w/o a record!") continue - switch(curr_MR.dead_state) - if(MR_NORMAL) - if(!curr_MR.ping()) - curr_MR.dead_state = MR_UNSURE - if(MR_UNSURE) - if(curr_MR.ping()) - curr_MR.dead_state = MR_NORMAL - else - curr_MR.dead_state = MR_DEAD - notify(N) - if(MR_DEAD) - if(curr_MR.ping()) - curr_MR.dead_state = MR_NORMAL + var/since_backup = world.time - curr_MR.last_update + if(since_backup < overdue_time) + curr_MR.dead_state = MR_NORMAL + else + if(curr_MR.dead_state != MR_DEAD) //First time switching to dead + notify(N) + curr_MR.dead_state = MR_DEAD - spawn(ping_time) + spawn(process_time) process() +/datum/transhuman/infocore/proc/m_backup(var/datum/mind/mind) + ASSERT(mind) + if(!mind.name) //Name is critical to everything here + return 0 + + var/datum/transhuman/mind_record/MR + + if(mind.name in backed_up) + MR = backed_up[mind.name] + MR.last_update = world.time + else + MR = new(mind, mind.current, 1) + + return 1 + /datum/transhuman/infocore/proc/notify(var/name) ASSERT(name) var/obj/item/device/radio/headset/a = new /obj/item/device/radio/headset/heads/captain(null) @@ -51,14 +61,15 @@ var/datum/transhuman/infocore/transcore = new/datum/transhuman/infocore /datum/transhuman/infocore/proc/add_backup(var/datum/transhuman/mind_record/MR) ASSERT(MR) - backed_up[MR.charname] = MR - log_debug("Added [MR.charname] to transcore DB.") + backed_up[MR.mindname] = MR + log_debug("Added [MR.mindname] to transcore DB.") /datum/transhuman/infocore/proc/stop_backup(var/datum/transhuman/mind_record/MR) ASSERT(MR) - has_left[MR.charname] = MR - backed_up.Remove("[MR.charname]") - log_debug("Put [MR.charname] in transcore suspended DB.") + has_left[MR.mindname] = MR + backed_up.Remove("[MR.mindname]") + MR.cryo_at = world.time + log_debug("Put [MR.mindname] in transcore suspended DB.") /datum/transhuman/infocore/proc/add_body(var/datum/transhuman/body_record/BR) ASSERT(BR) @@ -68,56 +79,43 @@ var/datum/transhuman/infocore/transcore = new/datum/transhuman/infocore /////// Mind-backup record /////// /datum/transhuman/mind_record //User visible - var/charname = "!!ERROR!!" - var/implanted_at - var/body_type - var/id_gender + var/mindname = "!!ERROR!!" //0: Normal, 1: Might be dead, 2: Definitely dead, show on console var/dead_state = 0 + var/last_update = 0 //Backend - var/obj/item/weapon/implant/backup/imp_ref var/ckey = "" - var/mob/living/carbon/human/mob_ref - var/client/client - var/datum/mind/mind + var/id_gender + var/datum/mind/mind_ref var/cryo_at var/languages var/mind_oocnotes -/datum/transhuman/mind_record/New(var/mob/living/carbon/human/M,var/obj/item/weapon/implant/backup/imp,var/add_to_db = 1) - ASSERT(M && imp) +/datum/transhuman/mind_record/New(var/datum/mind/mind,var/mob/living/carbon/human/M,var/obj/item/weapon/implant/backup/imp,var/add_to_db = 1) + ASSERT(mind && M && imp) if(!istype(M)) return //Only works with humanoids. - //Scrape info from mob. - mob_ref = M - charname = M.real_name - implanted_at = world.time - body_type = M.isSynthetic() - id_gender = M.identifying_gender + //The mind! + mind_ref = mind + mindname = mind.name + ckey = mind.key - imp_ref = imp - ckey = M.ckey cryo_at = 0 + + //Mental stuff the game doesn't keep mentally + id_gender = M.identifying_gender languages = M.languages.Copy() mind_oocnotes = M.ooc_notes - //If these are gone then it's a problemmmm. - client = M.client - mind = M.mind + last_update = world.time if(add_to_db) transcore.add_backup(src) -/datum/transhuman/mind_record/proc/ping() - if(!imp_ref || !mob_ref || imp_ref.loc != mob_ref || mob_ref.stat >= DEAD) //Ways you can be considered past-due - return 0 - - return 1 //Ping replied - /////// Body Record /////// /datum/transhuman/body_record var/datum/dna2/record/mydna diff --git a/code/modules/resleeving/machines.dm b/code/modules/resleeving/machines.dm index 98b6118fab0..94681020155 100644 --- a/code/modules/resleeving/machines.dm +++ b/code/modules/resleeving/machines.dm @@ -67,6 +67,7 @@ //Apply DNA H.dna = R.dna.Clone() + H.original_player = current_project.ckey //Apply damage H.adjustCloneLoss(150) @@ -261,6 +262,7 @@ //Apply DNA H.dna = R.dna.Clone() + H.original_player = current_project.ckey //Apply damage H.adjustBruteLoss(20) @@ -388,10 +390,10 @@ else health_text = "[round(src.occupant.health,0.1)]" - if(src.occupant.client) - mind_text = "Mind present" + if(src.occupant.mind) + mind_text = "Mind present: [occupant.mind.name]" else - mind_text = "Mind absent" + mind_text = "Mind absent." var/dat ="Resleever Status
" dat +="Current occupant: [src.occupant ? "
Name: [src.occupant]
Health: [health_text]
" : "None"]
" @@ -428,18 +430,16 @@ //In case they already had a mind! occupant << "You feel your mind being overwritten..." - - //Try to briefly find their mind and null it out on their current mob to prevent debraining pulling them back to it. - if(MR.mind.current) - MR.mind.current.mind = null + if(occupant.mind) + log_and_message_admins("was resleeve-wiped from their body.",occupant.mind) + occupant.ghostize() //Attach as much stuff as possible to the mob. for(var/datum/language/L in MR.languages) occupant.add_language(L.name) + MR.mind_ref.active = 1 //Well, it's about to be. + MR.mind_ref.transfer_to(occupant) //Does mind+ckey+client. occupant.identifying_gender = MR.id_gender - occupant.client = MR.client - occupant.mind = MR.mind - occupant.ckey = MR.ckey occupant.ooc_notes = MR.mind_oocnotes occupant.apply_vore_prefs() //Cheap hack for now to give them SOME bellies. @@ -454,15 +454,13 @@ affected.implants += new_imp new_imp.part = affected - //Update the database record - MR.mob_ref = occupant - MR.imp_ref = new_imp - MR.dead_state = MR_NORMAL - //Inform them and make them a little dizzy. occupant << "You feel a small pain in your head as you're given a new backup implant. Oh, and a new body. It's disorienting, to say the least." - occupant.confused = max(occupant.confused, 25) - occupant.eye_blurry = max(occupant.eye_blurry, 25) + occupant.confused = max(occupant.confused, 30) + occupant.eye_blurry = max(occupant.eye_blurry, 30) + + if(occupant.original_player != occupant.ckey) + log_and_message_admins("is now a cross-sleeved character. Body originally belonged to [occupant.original_player]. Mind is now [occupant.mind.name].",occupant) return 1 diff --git a/vorestation.dme b/vorestation.dme index 258bc909b99..2a329b2b3e9 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -2105,7 +2105,7 @@ #include "code\modules\resleeving\circuitboards.dm" #include "code\modules\resleeving\computers.dm" #include "code\modules\resleeving\documents.dm" -#include "code\modules\resleeving\general.dm" +#include "code\modules\resleeving\implant.dm" #include "code\modules\resleeving\infocore.dm" #include "code\modules\resleeving\machines.dm" #include "code\modules\rogueminer_vr\asteroid.dm"