From dc14ec45a40dae3814c6a1b560c54029f96dcdde Mon Sep 17 00:00:00 2001 From: Antoonij <42318445+Antoonij@users.noreply.github.com> Date: Mon, 9 Sep 2024 08:22:44 +0200 Subject: [PATCH] =?UTF-8?q?oaoao=20=D1=8D=D1=82=D0=B0=20=D1=88=D1=82=D0=BE?= =?UTF-8?q?=20=D0=9E=D0=9E=D0=9F=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/datums/components/ritual_object.dm | 15 ++++-- code/datums/rituals.dm | 65 +++++++++++++++---------- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/code/datums/components/ritual_object.dm b/code/datums/components/ritual_object.dm index 5e3c4eb02b3..1898a6a91ec 100644 --- a/code/datums/components/ritual_object.dm +++ b/code/datums/components/ritual_object.dm @@ -36,11 +36,18 @@ /datum/component/ritual_object/proc/open_ritual_ui(obj/obj, mob/living/carbon/human/human) var/list/rituals_list = list() for(var/datum/ritual/ritual as anything in rituals) - if(!ritual.ritual_completed && COOLDOWN_FINISHED(ritual, ritual_cooldown)) - LAZYADD(rituals_list, ritual.name) + if(ritual.ritual_completed) + continue + if(!COOLDOWN_FINISHED(ritual, ritual_cooldown)) + continue + if(ritual.allowed_species && !is_type_in_typecache(human.dna.species, ritual.allowed_species)) + continue + LAZYADD(rituals_list, ritual.name) + if(!LAZYLEN(rituals_list)) to_chat(human, "Не имеется доступных для исполнения ритуалов.") - + return + var/tgui_menu = tgui_input_list(src, "выберите ритуал", "Ритуалы", rituals_list) if(!tgui_menu) return @@ -55,8 +62,6 @@ if(!ishuman(user)) return var/mob/living/carbon/human/human = user - if(!isashwalker(human)) - return if(attacking_item_type && !istype(obj, attacking_item_type)) return if(open_ritual_ui_check(obj, human)) diff --git a/code/datums/rituals.dm b/code/datums/rituals.dm index 4c6a7cf0dd5..c09697f512d 100644 --- a/code/datums/rituals.dm +++ b/code/datums/rituals.dm @@ -3,29 +3,25 @@ #define RITUAL_SUCCESSFUL (1<<0) /// Invocation checks, should not be used in extra checks. #define RITUAL_FAILED_INVALID_SPECIES (1<<1) -#define RITUAL_FAILED_REQUIRED_SHAMAN_INVOKE (1<<2) -#define RITUAL_FAILED_REQUIRED_EXTRA_SHAMAN (1<<3) #define RITUAL_FAILED_EXTRA_INVOKERS (1<<4) /datum/ritual /// Linked object var/obj/ritual_object /// Name of our ritual - var/name = "Hello, I'm useless ritual" - /// If ritual can be invoked only by shaman - var/shaman_only = FALSE + var/name /// If ritual requires more than one ashwalker var/extra_invokers = 0 - /// If ritual requires extra shaman invokers - var/extra_shaman_invokers = 0 + /// If invoker species isn't in allowed - he won't do ritual. + var/allowed_species + /// If true - only whitelisted species will be added as invokers + var/require_allowed_species = TRUE /// We search for ashwalkers in that radius var/finding_range = DEFAULT_RITUAL_RANGE_FIND /// Single rituals. If true - it cannot be choosen. var/ritual_completed = FALSE /// Messages on failed invocation. var/invalid_species_message = "Вы не можете понять, как с этим работать." - var/shaman_required_message = "Данный ритуал должен выполнять шаман." - var/extra_shaman_required_message = "Для выполнения данного ритуала требуется больше шаманов." var/extra_invokers_message = "Для выполнения данного ритуала требуется больше участников." /// Cooldown for one ritual COOLDOWN_DECLARE(ritual_cooldown) @@ -44,12 +40,8 @@ switch(ritual_invoke_check(obj, invoker)) if(RITUAL_FAILED_INVALID_SPECIES) message = invalid_species_message - if(RITUAL_FAILED_REQUIRED_SHAMAN_INVOKE) - message = shaman_required_message if(RITUAL_FAILED_EXTRA_INVOKERS) message = extra_invokers_message - if(RITUAL_FAILED_REQUIRED_EXTRA_SHAMAN) - message = extra_shaman_required_message if(RITUAL_SUCCESSFUL) do_ritual(obj, invoker) COOLDOWN_START(src, ritual_cooldown, cooldown_after_cast) @@ -60,28 +52,47 @@ return /datum/ritual/proc/ritual_invoke_check(obj/obj, mob/living/carbon/human/invoker) - if(!isashwalker(invoker)) // double check to avoid funny situations + if(ritual_completed) + return // should not have message + if(allowed_species && !is_type_in_typecache(human.dna.species, allowed_species)) // double check to avoid funny situations return RITUAL_FAILED_INVALID_SPECIES - if(shaman_only && !isashwalkershaman(invoker)) - return RITUAL_FAILED_REQUIRED_SHAMAN_INVOKE var/list/invokers = list() - var/list/shaman_invokers = list() - if(extra_invokers || extra_shaman_invokers) - for(var/mob/living/carbon/human/human in range(finding_range, obj)) - if(isashwalker(human)) - LAZYADD(invokers, human) - if(isashwalkershaman(human)) - LAZYADD(shaman_invokers, human) + if(extra_invokers) + for(var/mob/living/carbon/human/human in range(finding_range, ritual_object)) + if(require_allowed_species && !is_type_in_typecache(human.dna.species, allowed_species)) + continue + LAZYADD(invokers, human) if(LAZYLEN(invokers) < extra_invokers) return RITUAL_FAILED_EXTRA_INVOKERS - if(LAZYLEN(shaman_invokers) < extra_shaman_invokers) - return RITUAL_FAILED_REQUIRED_EXTRA_SHAMAN - return ritual_check(obj, invoker, invokers, shaman_invokers) + return ritual_check(obj, invoker, invokers) -/datum/ritual/proc/ritual_check(obj/obj, mob/living/carbon/human/invoker, list/invokers, list/shaman_invokers) // After extra checks we should return RITUAL_SUCCESSFUL. +/datum/ritual/proc/ritual_check(obj/obj, mob/living/carbon/human/invoker, list/invokers) // After extra checks we should return RITUAL_SUCCESSFUL. return RITUAL_SUCCESSFUL /datum/ritual/proc/do_ritual(obj/obj, mob/living/carbon/human/invoker) // Do ritual stuff. return + +/datum/ritual/ashwalker + /// If ritual requires extra shaman invokers + var/extra_shaman_invokers = 0 + /// If ritual can be invoked only by shaman + var/shaman_only = FALSE + allowed_species = typecacheof(/datum/dna/species/ashwalker) + +/datum/ritual/ashwalker/ritual_check(obj/obj, mob/living/carbon/human/invoker, list/invokers) + if(shaman_only && !isashwalkershaman(invoker)) + return + + var/list/shaman_invokers = list() + if(extra_shaman_invokers) + for(var/mob/living/carbon/human/human as anything in invokers) + if(isashwalkershaman(human)) + LAZYADD(shaman_invokers, human) + + if(LAZYLEN(shaman_invokers) < extra_shaman_invokers) + return + + return RITUAL_SUCCESSFUL +