-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,574 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// Used in ritual variables | ||
#define DEFAULT_RITUAL_RANGE_FIND 1 | ||
#define DEFAULT_RITUAL_COOLDOWN (100 SECONDS) | ||
#define DEFAULT_RITUAL_DISASTER_PROB 10 | ||
#define DEFAULT_RITUAL_FAIL_PROB 10 | ||
/// Ritual object bitflags | ||
#define RITUAL_STARTED (1<<0) | ||
#define RITUAL_ENDED (1<<1) | ||
#define RITUAL_FAILED (1<<2) | ||
/// Ritual datum bitflags | ||
#define RITUAL_SUCCESSFUL (1<<0) | ||
/// Invocation checks, should not be used in extra checks. | ||
#define RITUAL_FAILED_INVALID_SPECIES (1<<1) | ||
#define RITUAL_FAILED_EXTRA_INVOKERS (1<<2) | ||
#define RITUAL_FAILED_MISSED_REQUIREMENTS (1<<3) | ||
#define RITUAL_FAILED_ON_PROCEED (1<<4) | ||
#define RITUAL_FAILED_INVALID_SPECIAL_ROLE (1<<5) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/datum/component/ritual_object | ||
/// Pre-defined rituals list | ||
var/list/rituals = list() | ||
/// We define rituals from this. | ||
var/list/allowed_categories | ||
/// Required species to activate ritual object | ||
var/list/allowed_species | ||
/// Required special role to activate ritual object | ||
var/list/allowed_special_role | ||
/// Prevents from multiple uses | ||
var/active_ui = FALSE | ||
|
||
/datum/component/ritual_object/Initialize( | ||
allowed_categories = /datum/ritual, | ||
list/allowed_species, | ||
list/allowed_special_role | ||
) | ||
|
||
if(!isobj(parent)) | ||
return COMPONENT_INCOMPATIBLE | ||
|
||
src.allowed_categories = allowed_categories | ||
src.allowed_species = allowed_species | ||
src.allowed_special_role = allowed_special_role | ||
get_rituals() | ||
|
||
/datum/component/ritual_object/RegisterWithParent() | ||
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, PROC_REF(attackby)) | ||
|
||
/datum/component/ritual_object/UnregisterFromParent() | ||
UnregisterSignal(parent, COMSIG_ATOM_ATTACK_HAND) | ||
|
||
/datum/component/ritual_object/proc/get_rituals() // We'll get all rituals for flexibility. | ||
LAZYCLEARLIST(rituals) | ||
|
||
for(var/datum/ritual/ritual as anything in typecacheof(allowed_categories)) | ||
if(!ritual.name) | ||
continue | ||
|
||
rituals += new ritual | ||
|
||
for(var/datum/ritual/ritual as anything in rituals) | ||
ritual.ritual_object = parent | ||
|
||
return | ||
|
||
/datum/component/ritual_object/Destroy(force) | ||
LAZYNULL(rituals) | ||
return ..() | ||
|
||
/datum/component/ritual_object/proc/attackby(datum/source, mob/user) | ||
SIGNAL_HANDLER | ||
|
||
if(active_ui) | ||
return | ||
|
||
if(!ishuman(user)) | ||
return | ||
|
||
var/mob/living/carbon/human/human = user | ||
|
||
if(allowed_species && !is_type_in_list(human.dna.species, allowed_species)) | ||
return | ||
|
||
if(allowed_special_role && !is_type_in_list(human.mind?.special_role, allowed_special_role)) | ||
return | ||
|
||
active_ui = TRUE | ||
INVOKE_ASYNC(src, PROC_REF(open_ritual_ui), human) | ||
|
||
return COMPONENT_CANCEL_ATTACK_CHAIN | ||
|
||
/datum/component/ritual_object/proc/open_ritual_ui(mob/living/carbon/human/human) | ||
var/list/rituals_list = get_available_rituals(human) | ||
|
||
if(!LAZYLEN(rituals_list)) | ||
active_ui = FALSE | ||
to_chat(human, "Не имеется доступных для выполнения ритуалов.") | ||
return | ||
|
||
var/choosen_ritual = tgui_input_list(human, "Выберите ритуал", "Ритуалы", rituals_list) | ||
|
||
if(!choosen_ritual) | ||
active_ui = FALSE | ||
return | ||
|
||
var/ritual_status | ||
|
||
for(var/datum/ritual/ritual as anything in rituals) | ||
if(choosen_ritual != ritual.name) | ||
continue | ||
|
||
ritual_status = ritual.pre_ritual_check(human) | ||
break | ||
|
||
if(ritual_status) | ||
active_ui = FALSE | ||
|
||
return FALSE | ||
|
||
/datum/component/ritual_object/proc/get_available_rituals(mob/living/carbon/human/human) | ||
var/list/rituals_list = list() | ||
|
||
for(var/datum/ritual/ritual as anything in rituals) | ||
if(ritual.charges == 0) | ||
continue | ||
|
||
if(!COOLDOWN_FINISHED(ritual, ritual_cooldown)) | ||
continue | ||
|
||
if(ritual.allowed_species && !is_type_in_list(human.dna.species, ritual.allowed_species)) | ||
continue | ||
|
||
if(ritual.allowed_special_role && !is_type_in_list(human.mind?.special_role, ritual.allowed_special_role)) | ||
continue | ||
|
||
LAZYADD(rituals_list, ritual.name) | ||
|
||
return rituals_list |
Oops, something went wrong.