From be2d9ffed7a1215e480f74e6a287853fb4f94333 Mon Sep 17 00:00:00 2001
From: Llywelwyn <82828093+Llywelwyn@users.noreply.github.com>
Date: Sat, 14 May 2022 02:41:50 +0100
Subject: [PATCH] Srom no longer crashes you on death (#13893)
---
code/modules/mob/death.dm | 13 +++++++------
code/modules/shareddream/brainghost.dm | 6 ++++--
code/modules/shareddream/dream_entry.dm | 7 ++++++-
html/changelogs/llywelwyn-srom-bugfix.yml | 6 ++++++
4 files changed, 23 insertions(+), 9 deletions(-)
create mode 100644 html/changelogs/llywelwyn-srom-bugfix.yml
diff --git a/code/modules/mob/death.dm b/code/modules/mob/death.dm
index 062d04737ac..50711f142d3 100644
--- a/code/modules/mob/death.dm
+++ b/code/modules/mob/death.dm
@@ -102,9 +102,10 @@
return
/mob/proc/exit_vr()
- // If we have a remotely controlled mob, we come back to our body to die properly
- if(vr_mob)
- vr_mob.body_return()
- // Alternatively, if we are the remotely controlled mob, just kick our controller out
- if(old_mob)
- body_return()
+ if(!bg) // If brainghost exists, let handle_shared_dreaming handle the wake up
+ // If we have a remotely controlled mob, we come back to our body to die properly
+ if(vr_mob)
+ vr_mob.body_return()
+ // Alternatively, if we are the remotely controlled mob, just kick our controller out
+ if(old_mob)
+ body_return()
diff --git a/code/modules/shareddream/brainghost.dm b/code/modules/shareddream/brainghost.dm
index 0852b95c608..f36271e53d8 100644
--- a/code/modules/shareddream/brainghost.dm
+++ b/code/modules/shareddream/brainghost.dm
@@ -37,11 +37,12 @@
/mob/living/brain_ghost/proc/awaken_impl(var/force_awaken = FALSE)
if(body.willfully_sleeping)
- body.sleeping = max(body.sleeping - 5, 0)
body.willfully_sleeping = FALSE
if(force_awaken)
+ body.sleeping = 0
to_chat(src, "You suddenly feel like your connection to the dream is breaking up by the outside force.")
else
+ body.sleeping = max(body.sleeping - 5, 0)
to_chat(src, "You release your concentration on sleep, allowing yourself to wake up.")
else
to_chat(src, "You've already released concentration. Wait to wake up naturally.")
@@ -56,7 +57,8 @@
return
if(body.stat == DEAD) // Body is dead, and won't get a life tick.
- body.handle_shared_dreaming()
+ awaken_impl(TRUE)
+ body.handle_shared_dreaming(TRUE)
/mob/living/brain_ghost/say(var/message, var/datum/language/speaking = null, var/verb="says", var/alt_name="", var/ghost_hearing = GHOSTS_ALL_HEAR, var/whisper = FALSE)
if(!istype(body) || body.stat!=UNCONSCIOUS)
diff --git a/code/modules/shareddream/dream_entry.dm b/code/modules/shareddream/dream_entry.dm
index 21e4f3b34c6..ae8807d1f97 100644
--- a/code/modules/shareddream/dream_entry.dm
+++ b/code/modules/shareddream/dream_entry.dm
@@ -1,7 +1,9 @@
var/list/dream_entries = list()
-/mob/living/carbon/human
+/mob
var/mob/living/brain_ghost/bg
+
+/mob/living/carbon/human
var/datum/weakref/srom_pulled_by
var/datum/weakref/srom_pulling
@@ -83,6 +85,9 @@ var/list/dream_entries = list()
return_mob = B.host_brain
return_text = "You are ripped from the Srom as you return to the captivity of your own mind."
+ if(stat == DEAD)
+ return_text = "You are ripped from the Srom." // You're dead - ensures there's no message about feeling weird or waking up.
+
return_mob.ckey = old_bg.ckey
old_bg.visible_message("[old_bg] begins to fade as they depart from the dream...")
animate(old_bg, alpha=0, time = 20)
diff --git a/html/changelogs/llywelwyn-srom-bugfix.yml b/html/changelogs/llywelwyn-srom-bugfix.yml
new file mode 100644
index 00000000000..111fb6f7df0
--- /dev/null
+++ b/html/changelogs/llywelwyn-srom-bugfix.yml
@@ -0,0 +1,6 @@
+author: Llywelwyn
+
+delete-after: True
+
+changes:
+ - bugfix: "People in Srom will no longer crash when they die."