From 7dcc7d41f2fcb4970d72031e33f97cbc0399a124 Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:05:44 -0400 Subject: [PATCH] Refactors liches a bit (#25104) * totally not breaking shit * yes --- code/datums/spells/lichdom.dm | 33 ------------------- code/game/gamemodes/wizard/wizard.dm | 20 +++-------- .../antagonists/wizard/datum_wizard.dm | 8 +++++ 3 files changed, 13 insertions(+), 48 deletions(-) diff --git a/code/datums/spells/lichdom.dm b/code/datums/spells/lichdom.dm index 30c0dd39ec4..68af16b3a79 100644 --- a/code/datums/spells/lichdom.dm +++ b/code/datums/spells/lichdom.dm @@ -13,22 +13,12 @@ var/marked_item_uid var/mob/living/current_body var/resurrections = 0 - var/existence_stops_round_end = FALSE action_icon_state = "skeleton" /datum/spell/lichdom/create_new_targeting() return new /datum/spell_targeting/self -/datum/spell/lichdom/Destroy() - for(var/datum/mind/M in SSticker.mode.wizards) //Make sure no other bones are about - for(var/datum/spell/S in M.spell_list) - if(istype(S,/datum/spell/lichdom) && S != src) - return ..() - if(existence_stops_round_end) - GLOB.configuration.gamemode.disable_certain_round_early_end = FALSE - return ..() - /datum/spell/lichdom/cast(list/targets, mob/user = usr) for(var/mob/M in targets) if(stat_allowed) @@ -89,7 +79,6 @@ lich.Weaken(stun_time) user.mind.transfer_to(lich) equip_lich(lich) - RegisterSignal(lich, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_Z_CHANGED), PROC_REF(check_revivability_handler)) current_body = lich cooldown_handler.recharge_duration += 1 MINUTES @@ -134,13 +123,8 @@ H.unEquip(H.head) equip_lich(H) - RegisterSignal(target, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_Z_CHANGED), PROC_REF(check_revivability_handler)) - RegisterSignal(current_body, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_Z_CHANGED), PROC_REF(check_revivability_handler)) to_chat(user, "With a hideous feeling of emptiness you watch in horrified fascination as skin sloughs off bone! Blood boils, nerves disintegrate, eyes boil in their sockets! As your organs crumble to dust in your fleshless chest you come to terms with your choice. You're a lich!") - existence_stops_round_end = TRUE - GLOB.configuration.gamemode.disable_certain_round_early_end = TRUE - /datum/spell/lichdom/proc/is_revive_possible() var/obj/item/marked_item = locateUID(marked_item_uid) if(QDELETED(marked_item)) @@ -153,23 +137,6 @@ return FALSE return TRUE -/datum/spell/lichdom/proc/check_revivability_handler() - SIGNAL_HANDLER - - // There are other liches about, so round may still continue - for(var/datum/mind/M in SSticker.mode.wizards) - for(var/datum/spell/lichdom/S in M.spell_list) - if(S == src) - continue - // Other lich can still revive - if(S.is_revive_possible()) - return - // Other lich is still alive - if(!QDELETED(S.current_body) && S.current_body.stat != DEAD) - return - - GLOB.configuration.gamemode.disable_certain_round_early_end = is_revive_possible() - /datum/spell/lichdom/proc/equip_lich(mob/living/carbon/human/H) H.equip_to_slot_or_del(new /obj/item/clothing/suit/wizrobe/black(H), SLOT_HUD_OUTER_SUIT) H.equip_to_slot_or_del(new /obj/item/clothing/head/wizard/black(H), SLOT_HUD_HEAD) diff --git a/code/game/gamemodes/wizard/wizard.dm b/code/game/gamemodes/wizard/wizard.dm index 3bdd8468ded..30c7e40b300 100644 --- a/code/game/gamemodes/wizard/wizard.dm +++ b/code/game/gamemodes/wizard/wizard.dm @@ -45,21 +45,11 @@ if(but_wait_theres_more) return ..() - // Wizards - for(var/datum/mind/wizard in wizards) - if(!iscarbon(wizard.current) || wizard.current.stat == DEAD) // wizard is in an MMI, don't count them as alive - continue - return ..() - - // Apprentices - for(var/datum/mind/apprentice in apprentices) - if(!iscarbon(apprentice.current)) - continue - if(apprentice.current.stat == DEAD) - continue - if(istype(apprentice.current, /obj/item/mmi)) // apprentice is in an MMI, don't count them as alive - continue - return ..() + // Wizards and Apprentices + for(var/datum/mind/wizard in (wizards + apprentices)) // yes, this works so it iterates through wizards, then apprentices + var/datum/antagonist/wizard/datum_wizard = wizard.has_antag_datum(/datum/antagonist/wizard) + if(datum_wizard?.wizard_is_alive()) + return ..() finished = TRUE return TRUE diff --git a/code/modules/antagonists/wizard/datum_wizard.dm b/code/modules/antagonists/wizard/datum_wizard.dm index 90a5fb17e85..f3e1f622eb1 100644 --- a/code/modules/antagonists/wizard/datum_wizard.dm +++ b/code/modules/antagonists/wizard/datum_wizard.dm @@ -116,3 +116,11 @@ /datum/antagonist/wizard/proc/full_on_wizard() return TRUE + +/datum/antagonist/wizard/proc/wizard_is_alive() // fun fact did you know underscore make proc calls slower? + for(var/datum/spell/lichdom/S in owner.spell_list) + if(S.is_revive_possible()) // This must occur before the == DEAD check + return TRUE + if(!iscarbon(owner.current) || owner.current.stat == DEAD) + return FALSE + return TRUE