From 6bb70297ec6e6b7eca01203eb3b60bd1ea3905fb Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 22 May 2019 06:09:18 +0200 Subject: [PATCH 1/3] Why did you check if the gamemode's type is an antagonist datum? And why did it sort of work too? I don't understand. Pooj's copypasting this black magic, smh. --- code/game/gamemodes/cult/cult.dm | 15 ++++ code/modules/antagonists/cult/cult.dm | 84 ++++++++++++------- .../code/game/machinery/cryopod.dm | 42 ++-------- 3 files changed, 73 insertions(+), 68 deletions(-) diff --git a/code/game/gamemodes/cult/cult.dm b/code/game/gamemodes/cult/cult.dm index 7b492e3a95..ce4b0014c9 100644 --- a/code/game/gamemodes/cult/cult.dm +++ b/code/game/gamemodes/cult/cult.dm @@ -97,6 +97,21 @@ main_cult = C.cult_team ..() +/datum/game_mode/cult/process() + if(finished) + return + var/datum/objective/sacrifice/sac_objective = locate() in main_cult.objectives + if(!sac_objective || sac_objective.check_completion()) + return + var/datum/mind/sacrificial = sac_objective.get_target() + var/mob/living/t_current = sacrificial.current + if(!sacrificial || !sacrificial.current) //target is gone for good but not sacced. + main_cult.sort_sacrifice(TRUE) + if(QDELETED(sac_objective.target_current) || sac_objective.target_current != t_current) //target is now a different mob (monkey, simple mob) + sac_objective.sac_image = t_current.get_sac_image() + sac_objective.target_current = t_current + sac_objective.update_explanation_text() + /datum/game_mode/proc/add_cultist(datum/mind/cult_mind, stun , equip = FALSE) //BASE if (!istype(cult_mind)) return FALSE diff --git a/code/modules/antagonists/cult/cult.dm b/code/modules/antagonists/cult/cult.dm index c8d59f54a8..c4d696ab59 100644 --- a/code/modules/antagonists/cult/cult.dm +++ b/code/modules/antagonists/cult/cult.dm @@ -13,7 +13,7 @@ var/give_equipment = FALSE var/datum/team/cult/cult_team - + /datum/antagonist/cult/get_team() return cult_team @@ -115,7 +115,7 @@ cult_team.rise(current) if(cult_team.cult_ascendent) cult_team.ascend(current) - + /datum/antagonist/cult/remove_innate_effects(mob/living/mob_override) . = ..() var/mob/living/current = owner.current @@ -220,7 +220,7 @@ throwing.Remove(current) current.update_action_buttons_icon() current.remove_status_effect(/datum/status_effect/cult_master) - + if(ishuman(current)) var/mob/living/carbon/human/H = current H.eye_color = initial(H.eye_color) @@ -241,7 +241,7 @@ var/reckoning_complete = FALSE var/cult_risen = FALSE var/cult_ascendent = FALSE - + /datum/team/cult/proc/check_size() if(cult_ascendent) return @@ -262,7 +262,7 @@ to_chat(B.current, "The veil weakens as your cult grows, your eyes begin to glow...") addtimer(CALLBACK(src, .proc/rise, B.current), 200) cult_risen = TRUE - + if(ratio > CULT_ASCENDENT && !cult_ascendent) for(var/datum/mind/B in members) if(B.current) @@ -270,8 +270,8 @@ to_chat(B.current, "Your cult is ascendent and the red harvest approaches - you cannot hide your true nature for much longer!!") addtimer(CALLBACK(src, .proc/ascend, B.current), 200) cult_ascendent = TRUE - - + + /datum/team/cult/proc/rise(cultist) if(ishuman(cultist)) var/mob/living/carbon/human/H = cultist @@ -279,7 +279,7 @@ H.dna.update_ui_block(DNA_EYE_COLOR_BLOCK) H.add_trait(CULT_EYES) H.update_body() - + /datum/team/cult/proc/ascend(cultist) if(ishuman(cultist)) var/mob/living/carbon/human/H = cultist @@ -289,48 +289,68 @@ /datum/team/cult/proc/setup_objectives() //SAC OBJECTIVE , todo: move this to objective internals + sort_sacrifice() + //SUMMON OBJECTIVE + var/datum/objective/eldergod/summon_objective = new() + summon_objective.team = src + objectives += summon_objective + +/datum/team/cult/proc/sort_sacrifice(replacement = FALSE) + var/list/target_candidates = list() - var/datum/objective/sacrifice/sac_objective = new - sac_objective.team = src + + var/datum/objective/sacrifice/sac_objective = locate() in GLOB.objectives + if(!sac_objective) + sac_objective = new + sac_objective.team = src for(var/mob/living/carbon/human/player in GLOB.player_list) if(player.mind && !player.mind.has_antag_datum(/datum/antagonist/cult) && !is_convertable_to_cult(player) && player.stat != DEAD) target_candidates += player.mind - if(target_candidates.len == 0) + if(!length(target_candidates)) message_admins("Cult Sacrifice: Could not find unconvertible target, checking for convertible target.") for(var/mob/living/carbon/human/player in GLOB.player_list) if(player.mind && !player.mind.has_antag_datum(/datum/antagonist/cult) && player.stat != DEAD) target_candidates += player.mind + listclearnulls(target_candidates) - if(LAZYLEN(target_candidates)) - sac_objective.target = pick(target_candidates) - sac_objective.update_explanation_text() + if(!LAZYLEN(target_candidates)) + message_admins("Cult Sacrifice: Could not find unconvertible or convertible target. Proceeding to next stage!") + sac_objective.sacced = TRUE + return + var/datum/mind/new_target = pick(target_candidates) + if(replacement) + for(var/datum/mind/H in members) + if(H.current) + to_chat(H.current, "Nar'Sie murmurs, [sac_objective.target] is beyond your reach. Sacrifice [new_target] instead...") + sac_objective.target = new_target + sac_objective.target_current = new_target.current + sac_objective.update_explanation_text() - var/datum/job/sacjob = SSjob.GetJob(sac_objective.target.assigned_role) - var/datum/preferences/sacface = sac_objective.target.current.client.prefs - var/icon/reshape = get_flat_human_icon(null, sacjob, sacface, list(SOUTH)) - reshape.Shift(SOUTH, 4) - reshape.Shift(EAST, 1) - reshape.Crop(7,4,26,31) - reshape.Crop(-5,-3,26,30) - sac_objective.sac_image = reshape + sac_objective.sac_image = sac_objective.target_current.get_sac_image() + objectives += sac_objective - objectives += sac_objective - else - message_admins("Cult Sacrifice: Could not find unconvertible or convertible target. WELP!") +/mob/proc/get_sac_image() + var/icon/reshape = icon(icon, icon_state, SOUTH) + reshape.Shift(SOUTH, 4) + reshape.Shift(EAST, 1) + reshape.Crop(7,4,26,31) + reshape.Crop(-5,-3,26,30) +/mob/living/carbon/human/get_sac_image() + var/datum/job/sacjob = SSjob.GetJob(mind.assigned_role) + var/datum/preferences/sacface = client.prefs + var/icon/reshape = get_flat_human_icon(null, sacjob, sacface, list(SOUTH)) + reshape.Shift(SOUTH, 4) + reshape.Shift(EAST, 1) + reshape.Crop(7,4,26,31) + reshape.Crop(-5,-3,26,30) - //SUMMON OBJECTIVE - - var/datum/objective/eldergod/summon_objective = new() - summon_objective.team = src - objectives += summon_objective - - /datum/objective/sacrifice var/sacced = FALSE var/sac_image + var/mob/living/target_current /datum/objective/sacrifice/check_completion() return sacced || completed diff --git a/modular_citadel/code/game/machinery/cryopod.dm b/modular_citadel/code/game/machinery/cryopod.dm index 1ff628bfbd..095641f1b4 100644 --- a/modular_citadel/code/game/machinery/cryopod.dm +++ b/modular_citadel/code/game/machinery/cryopod.dm @@ -245,43 +245,13 @@ // This function can not be undone; do not call this unless you are sure /obj/machinery/cryopod/proc/despawn_occupant() var/mob/living/mob_occupant = occupant - var/list/target_candidates = list() - if(istype(SSticker.mode, /datum/antagonist/cult))//thank - if("sacrifice" in SSticker.mode.cult) - for(var/mob/living/carbon/human/player in GLOB.player_list) - if(player.mind && !player.mind.has_antag_datum(/datum/antagonist/cult) && !is_convertable_to_cult(player) && player.stat != DEAD) - target_candidates += player.mind - - target_candidates -= mob_occupant.mind - - if(target_candidates.len == 0) - message_admins("Cult Sacrifice: Could not find unconvertable target, checking for convertable target.") - for(var/mob/living/carbon/human/player in GLOB.player_list) - if(player.mind && !player.mind.has_antag_datum(/datum/antagonist/cult) && player.stat != DEAD) - target_candidates += player.mind - - listclearnulls(target_candidates) - if(LAZYLEN(target_candidates)) - var/datum/objective/sacrifice/sac_objective = locate() in GLOB.objectives - sac_objective.target = pick(target_candidates) - sac_objective.update_explanation_text() - - var/datum/job/sacjob = SSjob.GetJob(sac_objective.target.assigned_role) - var/datum/preferences/sacface = sac_objective.target.current.client.prefs - var/icon/reshape = get_flat_human_icon(null, sacjob, sacface) - reshape.Shift(SOUTH, 4) - reshape.Shift(EAST, 1) - reshape.Crop(7,4,26,31) - reshape.Crop(-5,-3,26,30) - sac_objective.sac_image = reshape - - for(var/datum/mind/H in SSticker.mode.cult) - if(H.current) - to_chat(H.current, "Nar'Sie murmurs, [occupant] is beyond your reach. Sacrifice [sac_objective.target.current] instead...") - - else - message_admins("Cult Sacrifice: Could not find unconvertable or convertable target after cryopod. WELP!") + if(istype(SSticker.mode, /datum/game_mode/cult)) + var/datum/game_mode/cult/M = SSticker.mode + var/datum/team/cult/C = M.main_cult + var/datum/objective/sacrifice/S = locate() in C.objectives + if(S.target == mob_occupant.mind) + C.sort_sacrifice(TRUE) //Update any existing objectives involving this mob. for(var/datum/objective/O in GLOB.objectives) From 6f88ecb4deb32e34d55e5877780967ae72f3d566 Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 22 May 2019 06:21:37 +0200 Subject: [PATCH 2/3] return --- code/game/gamemodes/cult/cult.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/game/gamemodes/cult/cult.dm b/code/game/gamemodes/cult/cult.dm index ce4b0014c9..c0ebc1c63a 100644 --- a/code/game/gamemodes/cult/cult.dm +++ b/code/game/gamemodes/cult/cult.dm @@ -107,6 +107,7 @@ var/mob/living/t_current = sacrificial.current if(!sacrificial || !sacrificial.current) //target is gone for good but not sacced. main_cult.sort_sacrifice(TRUE) + return if(QDELETED(sac_objective.target_current) || sac_objective.target_current != t_current) //target is now a different mob (monkey, simple mob) sac_objective.sac_image = t_current.get_sac_image() sac_objective.target_current = t_current From 4998b7cfa1883cea121a2926993298bee149859c Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 22 May 2019 18:43:26 +0200 Subject: [PATCH 3/3] Actually, the cult team should process it instead. Got you covered, badmins spawning cult on other modes. --- code/game/gamemodes/cult/cult.dm | 16 ------------- code/modules/antagonists/cult/cult.dm | 24 +++++++++++++++++++ .../code/game/machinery/cryopod.dm | 7 ------ 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/code/game/gamemodes/cult/cult.dm b/code/game/gamemodes/cult/cult.dm index c0ebc1c63a..7b492e3a95 100644 --- a/code/game/gamemodes/cult/cult.dm +++ b/code/game/gamemodes/cult/cult.dm @@ -97,22 +97,6 @@ main_cult = C.cult_team ..() -/datum/game_mode/cult/process() - if(finished) - return - var/datum/objective/sacrifice/sac_objective = locate() in main_cult.objectives - if(!sac_objective || sac_objective.check_completion()) - return - var/datum/mind/sacrificial = sac_objective.get_target() - var/mob/living/t_current = sacrificial.current - if(!sacrificial || !sacrificial.current) //target is gone for good but not sacced. - main_cult.sort_sacrifice(TRUE) - return - if(QDELETED(sac_objective.target_current) || sac_objective.target_current != t_current) //target is now a different mob (monkey, simple mob) - sac_objective.sac_image = t_current.get_sac_image() - sac_objective.target_current = t_current - sac_objective.update_explanation_text() - /datum/game_mode/proc/add_cultist(datum/mind/cult_mind, stun , equip = FALSE) //BASE if (!istype(cult_mind)) return FALSE diff --git a/code/modules/antagonists/cult/cult.dm b/code/modules/antagonists/cult/cult.dm index c4d696ab59..9451012a04 100644 --- a/code/modules/antagonists/cult/cult.dm +++ b/code/modules/antagonists/cult/cult.dm @@ -242,6 +242,30 @@ var/cult_risen = FALSE var/cult_ascendent = FALSE +/datum/team/cult/New() + . = ..() + START_PROCESSING(SSprocessing, src) + +/datum/team/cult/Destroy() + STOP_PROCESSING(SSprocessing, src) + return ..() + +/datum/team/cult/process() + if(SSticker.current_state == GAME_STATE_FINISHED) + return + var/datum/objective/sacrifice/sac_objective = locate() in objectives + if(!sac_objective || sac_objective.check_completion()) + return + var/datum/mind/sacrificial = sac_objective.get_target() + var/mob/living/sac_current = sacrificial.current + if(!sacrificial || !sac_current) //target is gone for good but not sacrified. + sort_sacrifice(TRUE) + return + if(QDELETED(sac_objective.target_current) || sac_objective.target_current != sac_current) //target is now a different mob (monkey, simple mob) + sac_objective.sac_image = sac_current.get_sac_image() + sac_objective.target_current = sac_current + sac_objective.update_explanation_text() + /datum/team/cult/proc/check_size() if(cult_ascendent) return diff --git a/modular_citadel/code/game/machinery/cryopod.dm b/modular_citadel/code/game/machinery/cryopod.dm index 095641f1b4..15e7d34c65 100644 --- a/modular_citadel/code/game/machinery/cryopod.dm +++ b/modular_citadel/code/game/machinery/cryopod.dm @@ -246,13 +246,6 @@ /obj/machinery/cryopod/proc/despawn_occupant() var/mob/living/mob_occupant = occupant - if(istype(SSticker.mode, /datum/game_mode/cult)) - var/datum/game_mode/cult/M = SSticker.mode - var/datum/team/cult/C = M.main_cult - var/datum/objective/sacrifice/S = locate() in C.objectives - if(S.target == mob_occupant.mind) - C.sort_sacrifice(TRUE) - //Update any existing objectives involving this mob. for(var/datum/objective/O in GLOB.objectives) // We don't want revs to get objectives that aren't for heads of staff. Letting