From 7951d8702222ae4bc27364c756cfb0fbafe6b607 Mon Sep 17 00:00:00 2001
From: JTGSZ <46565256+JTGSZ@users.noreply.github.com>
Date: Mon, 7 Oct 2019 17:55:16 -0400
Subject: [PATCH 1/2] species clothing restrictions
species clothing restrictions
---
code/modules/clothing/clothing.dm | 42 +++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm
index ed3e9f9b89..9686174ede 100644
--- a/code/modules/clothing/clothing.dm
+++ b/code/modules/clothing/clothing.dm
@@ -41,6 +41,13 @@
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.j
+
+
/obj/item/clothing/Initialize()
. = ..()
if(CHECK_BITFIELD(clothing_flags, VOICEBOX_TOGGLABLE))
@@ -338,3 +345,38 @@ 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
From 30a41292d8c0c6f545a8ba7db4e7db5c02b8a972 Mon Sep 17 00:00:00 2001
From: JTGSZ <46565256+JTGSZ@users.noreply.github.com>
Date: Mon, 7 Oct 2019 18:02:16 -0400
Subject: [PATCH 2/2] left extra letter in comment
---
code/modules/clothing/clothing.dm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm
index 9686174ede..20a8c518f4 100644
--- a/code/modules/clothing/clothing.dm
+++ b/code/modules/clothing/clothing.dm
@@ -45,7 +45,7 @@
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.j
+ //You append this to clothing objects.
/obj/item/clothing/Initialize()
@@ -379,4 +379,4 @@ BLIND // can't see anything
to_chat(M, "Your species cannot wear [src].")
return FALSE
- return TRUE
\ No newline at end of file
+ return TRUE