diff --git a/code/game/gamemodes/cult/cult_mode.dm b/code/game/gamemodes/cult/cult_mode.dm
index 86e8d4a82ff..f2abcc0aced 100644
--- a/code/game/gamemodes/cult/cult_mode.dm
+++ b/code/game/gamemodes/cult/cult_mode.dm
@@ -164,6 +164,7 @@
check_cult_size()
cult_objs.study(cult_mind.current)
to_chat(cult_mind.current, "For more information, check the wiki page: ([GLOB.configuration.url.wiki_url]/index.php/Cultist)")
+ RegisterSignal(cult_mind.current, COMSIG_MOB_STATCHANGE, PROC_REF(cultist_stat_change))
return TRUE
/datum/game_mode/proc/remove_cultist(datum/mind/cult_mind, show_message = TRUE, remove_gear = FALSE, mob/target_mob)
@@ -203,6 +204,7 @@
if(show_message)
cultist.visible_message("[cultist] looks like [cultist.p_they()] just reverted to [cultist.p_their()] old faith!",
"An unfamiliar white light flashes through your mind, cleansing the taint of [SSticker.cultdat ? SSticker.cultdat.entity_title1 : "Nar'Sie"] and the memories of your time as their servant with it.")
+ UnregisterSignal(cult_mind.current, COMSIG_MOB_STATCHANGE)
/datum/game_mode/proc/add_cult_immunity(mob/living/target)
ADD_TRAIT(target, TRAIT_CULT_IMMUNITY, CULT_TRAIT)
@@ -246,23 +248,32 @@
/datum/game_mode/proc/get_cultists(separate = FALSE)
var/cultists = 0
var/constructs = 0
- for(var/I in cult)
- var/datum/mind/M = I
+ for(var/datum/mind/M as anything in cult)
+ if(QDELETED(M) || M.current?.stat == DEAD)
+ continue
if(ishuman(M.current) && !M.current.has_status_effect(STATUS_EFFECT_SUMMONEDGHOST))
cultists++
else if(isconstruct(M.current))
constructs++
if(separate)
return list(cultists, constructs)
- else
- return cultists + constructs
+ return cultists + constructs
+
+/datum/game_mode/proc/cultist_stat_change(mob/target_cultist, new_stat, old_stat)
+ SIGNAL_HANDLER // COMSIG_MOB_STATCHANGE from cultists
+ if(new_stat == old_stat) // huh, how? whatever, we ignore it
+ return
+ if(new_stat != DEAD && old_stat != DEAD)
+ return // switching between alive and unconcious
+ // switching between dead and alive/unconcious
+ check_cult_size()
/datum/game_mode/proc/check_cult_size()
var/cult_players = get_cultists()
if(cult_ascendant)
// The cult only falls if below 1/2 of the rising, usually pretty low. e.g. 5% on highpop, 10% on lowpop
- if(cult_players < rise_number / 2)
+ if(cult_players < (rise_number / 2))
cult_fall()
return