diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 6c99c8b4..796c93a3 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -41,6 +41,16 @@ var/dynamic_hair_suffix = ""//head > mask for head hair var/dynamic_fhair_suffix = ""//mask > head for facial hair + + //basically a restriction list. + var/list/species_restricted = null + //Basically syntax is species_restricted = list("Species Name","Species Name") + //Add a "exclude" string to do the opposite, making it only only species listed that can't wear it. + //You append this to clothing objects. + + + + /obj/item/clothing/Initialize() . = ..() if(CHECK_BITFIELD(clothing_flags, VOICEBOX_TOGGLABLE)) @@ -338,3 +348,39 @@ BLIND // can't see anything deconstruct(FALSE) else ..() + + + +//Species-restricted clothing check. - Thanks Oraclestation, BS13, /vg/station etc. +/obj/item/clothing/mob_can_equip(mob/M, slot, disable_warning = TRUE) + + //if we can't equip the item anyway, don't bother with species_restricted (also cuts down on spam) + if(!..()) + return FALSE + + // Skip species restriction checks on non-equipment slots + if(slot in list(SLOT_IN_BACKPACK, SLOT_L_STORE, SLOT_R_STORE)) + return TRUE + + if(species_restricted && ishuman(M)) + + var/wearable = null + var/exclusive = null + var/mob/living/carbon/human/H = M + + if("exclude" in species_restricted) //TURNS IT INTO A BLACKLIST - AKA ALL MINUS SPECIES LISTED. + exclusive = TRUE + + if(H.dna.species) + if(exclusive) + if(!(H.dna.species.name in species_restricted)) + wearable = TRUE + else + if(H.dna.species.name in species_restricted) + wearable = TRUE + + if(!wearable) + to_chat(M, "Your species cannot wear [src].") + return FALSE + + return TRUE \ No newline at end of file