From 345b35156f4f8d91fe9b9d4a2f0caf05beca60cc Mon Sep 17 00:00:00 2001 From: Y0SH1M4S73R Date: Mon, 2 May 2022 00:01:02 -0400 Subject: [PATCH] Refactors wizard casting clothes into a clothing bitflag (#66604) * refactors wizard casting clothes into a clothing bitflag * autodocs the `CASTING_CLOTHES` bitflag --- code/__DEFINES/obj_flags.dm | 2 ++ code/_globalvars/bitfields.dm | 1 + code/modules/clothing/suits/wiz_robe.dm | 3 ++- code/modules/mod/mod_theme.dm | 4 ++-- code/modules/spells/spell.dm | 12 +++--------- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/obj_flags.dm index 159a8de9fc7..f5dad49310e 100644 --- a/code/__DEFINES/obj_flags.dm +++ b/code/__DEFINES/obj_flags.dm @@ -62,6 +62,8 @@ /// Clothes that block speech (i.e the muzzle). Can be applied to any clothing piece. #define BLOCKS_SPEECH (1<<16) #define PLASMAMAN_HELMET_EXEMPT (1<<17) //prevents from placing on plasmaman helmet +/// Usable as casting clothes by wizards (only matters for suits and headwear) +#define CASTING_CLOTHES (1<<18) /// Flags for the organ_flags var on /obj/item/organ diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 0be6e0c82ff..367c158553a 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -85,6 +85,7 @@ DEFINE_BITFIELD(clothing_flags, list( "BLOCKS_SHOVE_KNOCKDOWN" = BLOCKS_SHOVE_KNOCKDOWN, "BLOCKS_SPEECH" = BLOCKS_SPEECH, "BLOCK_GAS_SMOKE_EFFECT" = BLOCK_GAS_SMOKE_EFFECT, + "CASTING_CLOTHES" = CASTING_CLOTHES, "GAS_FILTERING" = GAS_FILTERING, "LAVAPROTECT" = LAVAPROTECT, "MASKINTERNALS" = MASKINTERNALS, diff --git a/code/modules/clothing/suits/wiz_robe.dm b/code/modules/clothing/suits/wiz_robe.dm index db919138bb4..c12fcf0288b 100644 --- a/code/modules/clothing/suits/wiz_robe.dm +++ b/code/modules/clothing/suits/wiz_robe.dm @@ -6,7 +6,7 @@ armor = list(MELEE = 30, BULLET = 20, LASER = 20, ENERGY = 30, BOMB = 20, BIO = 20, FIRE = 100, ACID = 100, WOUND = 20) strip_delay = 50 equip_delay_other = 50 - clothing_flags = SNUG_FIT + clothing_flags = SNUG_FIT | CASTING_CLOTHES resistance_flags = FIRE_PROOF | ACID_PROOF dog_fashion = /datum/dog_fashion/head/blue_wizard @@ -69,6 +69,7 @@ flags_inv = HIDEJUMPSUIT strip_delay = 50 equip_delay_other = 50 + clothing_flags = CASTING_CLOTHES resistance_flags = FIRE_PROOF | ACID_PROOF /obj/item/clothing/suit/wizrobe/red diff --git a/code/modules/mod/mod_theme.dm b/code/modules/mod/mod_theme.dm index 19f7f115995..7ab0eea82cc 100644 --- a/code/modules/mod/mod_theme.dm +++ b/code/modules/mod/mod_theme.dm @@ -993,13 +993,13 @@ "enchanted" = list( HELMET_FLAGS = list( UNSEALED_LAYER = null, - UNSEALED_CLOTHING = SNUG_FIT|THICKMATERIAL, + UNSEALED_CLOTHING = SNUG_FIT|THICKMATERIAL|CASTING_CLOTHES, SEALED_CLOTHING = STOPSPRESSUREDAMAGE, UNSEALED_INVISIBILITY = HIDEFACIALHAIR|HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDESNOUT, UNSEALED_COVER = HEADCOVERSMOUTH|HEADCOVERSEYES|PEPPERPROOF, ), CHESTPLATE_FLAGS = list( - UNSEALED_CLOTHING = THICKMATERIAL, + UNSEALED_CLOTHING = THICKMATERIAL|CASTING_CLOTHES, SEALED_CLOTHING = STOPSPRESSUREDAMAGE, SEALED_INVISIBILITY = HIDEJUMPSUIT, ), diff --git a/code/modules/spells/spell.dm b/code/modules/spells/spell.dm index 839b19c764e..370dbbdd788 100644 --- a/code/modules/spells/spell.dm +++ b/code/modules/spells/spell.dm @@ -197,17 +197,11 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th var/mob/living/carbon/human/H = user - var/static/list/casting_clothes = typecacheof(list(/obj/item/clothing/suit/wizrobe, /obj/item/clothing/head/wizard)) - if(clothes_req) //clothes check - var/passes_req = FALSE - if(istype(H.back, /obj/item/mod/control)) - var/obj/item/mod/control/mod = H.back - if(istype(mod.theme, /datum/mod_theme/enchanted)) - passes_req = TRUE - if(!passes_req && !is_type_in_typecache(H.wear_suit, casting_clothes)) + if(clothes_req) + if(!(H.wear_suit?.clothing_flags & CASTING_CLOTHES)) to_chat(H, span_warning("You don't feel strong enough without your robe!")) return FALSE - if(!passes_req && !is_type_in_typecache(H.head, casting_clothes)) + if(!(H.head?.clothing_flags & CASTING_CLOTHES)) to_chat(H, span_warning("You don't feel strong enough without your hat!")) return FALSE else