Unify style generators. (#31920)

* Unify hairstyle generators.

* Unify some body styling procs.

* Squash more duplicate logic.

* Change false value to define in link_processing.dm.

Co-authored-by: JimKil3 <47290811+JimKil3@users.noreply.github.com>
Signed-off-by: Alan <alfalfascout@users.noreply.github.com>

---------

Signed-off-by: Alan <alfalfascout@users.noreply.github.com>
Co-authored-by: JimKil3 <47290811+JimKil3@users.noreply.github.com>
This commit is contained in:
Alan
2026-05-07 05:02:06 +00:00
committed by GitHub
co-authored by JimKil3
parent d255626d4c
commit 0495f43b53
11 changed files with 104 additions and 259 deletions
+2 -2
View File
@@ -221,8 +221,8 @@ GLOBAL_VAR_INIT(deathsquad_sent, FALSE)
head_organ.sec_hair_colour = hair_c
new_commando.change_eye_color(eye_c)
new_commando.s_tone = skin_tone
head_organ.h_style = random_hair_style(new_commando.gender, head_organ.dna.species.name)
head_organ.f_style = random_facial_hair_style(new_commando.gender, head_organ.dna.species.name)
head_organ.h_style = random_hair_style(head_organ.dna.species.name)
head_organ.f_style = random_facial_hair_style(head_organ.dna.species.name)
new_commando.regenerate_icons()
new_commando.update_body()
+2 -2
View File
@@ -305,12 +305,12 @@
if(hair_style)
D.h_style = hair_style
else
D.h_style = random_hair_style(H.gender, D.dna.species.name)
D.h_style = random_hair_style(D.dna.species.name)
if(facial_hair_style)
D.f_style = facial_hair_style
else if(H.gender != FEMALE) // no beard for women
D.f_style = random_facial_hair_style(H.gender, D.dna.species.name)
D.f_style = random_facial_hair_style(D.dna.species.name)
if(hair_color)
D.hair_colour = hair_color
+1 -1
View File
@@ -652,7 +652,7 @@
s_tone = 35 - random_skin_tone(species)
else if(S.bodyflags & HAS_ICON_SKIN_TONE)
s_tone = random_skin_tone(species)
h_style = random_hair_style(gender, species, robohead)
h_style = random_hair_style(species, robohead)
f_style = random_facial_hair_style(gender, species, robohead)
if(!(S.bodyflags & BALD))
randomize_hair_color("hair")
+36 -120
View File
@@ -106,7 +106,7 @@
if(!(S.bodyflags & BALD))
active_character.h_sec_colour = rand_hex_color()
if("h_style")
active_character.h_style = random_hair_style(active_character.gender, active_character.species, robohead)
active_character.h_style = random_hair_style(active_character.species, robohead)
if("facial")
if(!(S.bodyflags & SHAVED))
active_character.f_colour = rand_hex_color()
@@ -114,7 +114,7 @@
if(!(S.bodyflags & SHAVED))
active_character.f_sec_colour = rand_hex_color()
if("f_style")
active_character.f_style = random_facial_hair_style(active_character.gender, active_character.species, robohead)
active_character.f_style = random_facial_hair_style(active_character.species, robohead)
if("headaccessory")
if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories.
active_character.hacc_colour = rand_hex_color()
@@ -206,10 +206,10 @@
var/head_model = "[!active_character.rlimb_data["head"] ? "Morpheus Cyberkinetics" : active_character.rlimb_data["head"]]"
robohead = GLOB.all_robolimbs[head_model]
//grab one of the valid hair styles for the newly chosen species
active_character.h_style = random_hair_style(active_character.gender, active_character.species, robohead)
active_character.h_style = random_hair_style(active_character.species, robohead)
//grab one of the valid facial hair styles for the newly chosen species
active_character.f_style = random_facial_hair_style(active_character.gender, active_character.species, robohead)
active_character.f_style = random_facial_hair_style(active_character.species, robohead)
if(NS.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories.
active_character.ha_style = random_head_accessory(active_character.species)
@@ -319,31 +319,16 @@
active_character.h_sec_colour = new_hair
if("h_style")
var/list/valid_hairstyles = list()
for(var/hairstyle in GLOB.hair_styles_public_list)
var/datum/sprite_accessory/SA = GLOB.hair_styles_public_list[hairstyle]
var/datum/robolimb/robohead
if(S.bodyflags & ALL_RPARTS) //Species that can use prosthetic heads.
var/head_model
if(!active_character.rlimb_data["head"]) //Handle situations where the head is default.
head_model = "Morpheus Cyberkinetics"
else
head_model = active_character.rlimb_data["head"]
robohead = GLOB.all_robolimbs[head_model]
if(hairstyle == "Bald") //Just in case.
valid_hairstyles += hairstyle
continue
if(S.bodyflags & ALL_RPARTS) //Species that can use prosthetic heads.
var/head_model
if(!active_character.rlimb_data["head"]) //Handle situations where the head is default.
head_model = "Morpheus Cyberkinetics"
else
head_model = active_character.rlimb_data["head"]
var/datum/robolimb/robohead = GLOB.all_robolimbs[head_model]
if((active_character.species in SA.species_allowed) && robohead.is_monitor && ((SA.models_allowed && (robohead.company in SA.models_allowed)) || !SA.models_allowed)) //If this is a hair style native to the user's species, check to see if they have a head with an ipc-style screen and that the head's company is in the screen style's allowed models list.
valid_hairstyles += hairstyle //Give them their hairstyles if they do.
else
if(!robohead.is_monitor && ("Human" in SA.species_allowed)) /*If the hairstyle is not native to the user's species and they're using a head with an ipc-style screen, don't let them access it.
But if the user has a robotic humanoid head and the hairstyle can fit humans, let them use it as a wig. */
valid_hairstyles += hairstyle
else //If the user is not a species who can have robotic heads, use the default handling.
if(active_character.species in SA.species_allowed) //If the user's head is of a species the hairstyle allows, add it to the list.
valid_hairstyles += hairstyle
sortTim(valid_hairstyles, GLOBAL_PROC_REF(cmp_text_asc)) //this alphabetizes the list
var/list/valid_hairstyles = list_valid_hairstyles(active_character.species, robohead)
var/new_h_style = tgui_input_list(user, "Choose your character's hair style:", "Character Preference", valid_hairstyles)
if(new_h_style)
active_character.h_style = new_h_style
@@ -389,15 +374,7 @@
if("ha_style")
if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories.
var/list/valid_head_accessory_styles = list()
for(var/head_accessory_style in GLOB.head_accessory_styles_list)
var/datum/sprite_accessory/H = GLOB.head_accessory_styles_list[head_accessory_style]
if(!(active_character.species in H.species_allowed))
continue
valid_head_accessory_styles += head_accessory_style
sortTim(valid_head_accessory_styles, GLOBAL_PROC_REF(cmp_text_asc))
var/list/valid_head_accessory_styles = list_valid_head_accessories(active_character.species)
var/new_head_accessory_style = tgui_input_list(user, "Choose the style of your character's head accessory", "Character Preference", valid_head_accessory_styles)
if(new_head_accessory_style)
active_character.ha_style = new_head_accessory_style
@@ -425,35 +402,15 @@
if("m_style_head")
if(S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings.
var/list/valid_markings = list()
for(var/markingstyle in GLOB.marking_styles_list)
var/datum/sprite_accessory/body_markings/head/M = GLOB.marking_styles_list[markingstyle]
if(!(active_character.species in M.species_allowed))
continue
if(M.marking_location != "head")
continue
if(active_character.alt_head && active_character.alt_head != "None")
if(!("All" in M.heads_allowed) && !(active_character.alt_head in M.heads_allowed))
continue
var/datum/robolimb/robohead
if(S.bodyflags & ALL_RPARTS) //Species that can use prosthetic heads.
var/head_model
if(!active_character.rlimb_data["head"]) //Handle situations where the head is default.
head_model = "Morpheus Cyberkinetics"
else
if(M.heads_allowed && !("All" in M.heads_allowed))
continue
if(S.bodyflags & ALL_RPARTS) //Species that can use prosthetic heads.
var/head_model
if(!active_character.rlimb_data["head"]) //Handle situations where the head is default.
head_model = "Morpheus Cyberkinetics"
else
head_model = active_character.rlimb_data["head"]
var/datum/robolimb/robohead = GLOB.all_robolimbs[head_model]
if(robohead.is_monitor && M.name != "None") //If the character can have prosthetic heads and they have the default Morpheus head (or another monitor-head), no optic markings.
continue
else if(!robohead.is_monitor && M.name != "None") //Otherwise, if they DON'T have the default head and the head's not a monitor but the head's not in the style's list of allowed models, skip.
if(!(robohead.company in M.models_allowed))
continue
valid_markings += markingstyle
sortTim(valid_markings, GLOBAL_PROC_REF(cmp_text_asc))
head_model = active_character.rlimb_data["head"]
robohead = GLOB.all_robolimbs[head_model]
var/list/valid_markings = list_valid_marking_styles("head", active_character.species, robohead, active_character.body_accessory, active_character.alt_head)
if(!length(valid_markings)) // Some IPC head models do have head markings, some don't; This is here to prevent us from attempting to open an empty TGUI list
tgui_alert(user, "No head markings available for this head!", "Character Preference")
return
@@ -470,16 +427,8 @@
if("m_style_body")
if(S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos.
var/list/valid_markings = list()
for(var/markingstyle in GLOB.marking_styles_list)
var/datum/sprite_accessory/M = GLOB.marking_styles_list[markingstyle]
if(!(active_character.species in M.species_allowed))
continue
if(M.marking_location != "body")
continue
var/list/valid_markings = list_valid_marking_styles("body", active_character.species, null, active_character.body_accessory, active_character.alt_head)
valid_markings += markingstyle
sortTim(valid_markings, GLOBAL_PROC_REF(cmp_text_asc))
var/new_marking_style = tgui_input_list(user, "Choose the style of your character's body markings:", "Character Preference", valid_markings)
if(new_marking_style)
active_character.m_styles["body"] = new_marking_style
@@ -493,22 +442,8 @@
if("m_style_tail")
if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings.
var/list/valid_markings = list()
for(var/markingstyle in GLOB.marking_styles_list)
var/datum/sprite_accessory/body_markings/tail/M = GLOB.marking_styles_list[markingstyle]
if(M.marking_location != "tail")
continue
if(!(active_character.species in M.species_allowed))
continue
if(!active_character.body_accessory)
if(M.tails_allowed)
continue
else
if(!M.tails_allowed || !(active_character.body_accessory in M.tails_allowed))
continue
var/list/valid_markings = list_valid_marking_styles("tail", active_character.species, null, active_character.body_accessory, active_character.alt_head)
valid_markings += markingstyle
sortTim(valid_markings, GLOBAL_PROC_REF(cmp_text_asc))
var/new_marking_style = tgui_input_list(user, "Choose the style of your character's tail markings:", "Character Preference", valid_markings)
if(new_marking_style)
active_character.m_styles["tail"] = new_marking_style
@@ -522,17 +457,12 @@
if("body_accessory")
var/list/possible_body_accessories = list()
if(check_rights(R_ADMIN, 1, user))
if(check_rights(R_ADMIN, FALSE, user))
possible_body_accessories = GLOB.body_accessory_by_name.Copy()
else
for(var/B in GLOB.body_accessory_by_name)
var/datum/body_accessory/accessory = GLOB.body_accessory_by_name[B]
if(isnull(accessory)) // None
continue
if(active_character.species in accessory.allowed_species)
possible_body_accessories += B
possible_body_accessories = list_valid_body_accessories(active_character.body_accessory, S.optional_body_accessory)
if(S.optional_body_accessory)
possible_body_accessories += "None" //the only null entry should be the "None" option
possible_body_accessories |= "None" //the only null entry should be the "None" option
else
possible_body_accessories -= "None" // in case an admin is viewing it
sortTim(possible_body_accessories, GLOBAL_PROC_REF(cmp_text_asc))
@@ -558,30 +488,16 @@
active_character.f_sec_colour = new_facial
if("f_style")
var/list/valid_facial_hairstyles = list()
for(var/facialhairstyle in GLOB.facial_hair_styles_list)
var/datum/sprite_accessory/SA = GLOB.facial_hair_styles_list[facialhairstyle]
var/datum/robolimb/robohead
if(S.bodyflags & ALL_RPARTS) //Species that can use prosthetic heads.
var/head_model
if(!active_character.rlimb_data["head"]) //Handle situations where the head is default.
head_model = "Morpheus Cyberkinetics"
else
head_model = active_character.rlimb_data["head"]
robohead = GLOB.all_robolimbs[head_model]
var/list/valid_facial_hairstyles = list_valid_facial_hairstyles(active_character.species, robohead)
if(facialhairstyle == "Shaved") //Just in case.
valid_facial_hairstyles += facialhairstyle
continue
if(S.bodyflags & ALL_RPARTS) //Species that can use prosthetic heads.
var/head_model
if(!active_character.rlimb_data["head"]) //Handle situations where the head is default.
head_model = "Morpheus Cyberkinetics"
else
head_model = active_character.rlimb_data["head"]
var/datum/robolimb/robohead = GLOB.all_robolimbs[head_model]
if((active_character.species in SA.species_allowed) && robohead.is_monitor && ((SA.models_allowed && (robohead.company in SA.models_allowed)) || !SA.models_allowed)) //If this is a facial hair style native to the user's species, check to see if they have a head with an ipc-style screen and that the head's company is in the screen style's allowed models list.
valid_facial_hairstyles += facialhairstyle //Give them their facial hairstyles if they do.
else
if(!robohead.is_monitor && ("Human" in SA.species_allowed)) /*If the facial hairstyle is not native to the user's species and they're using a head with an ipc-style screen, don't let them access it.
But if the user has a robotic humanoid head and the facial hairstyle can fit humans, let them use it as a wig. */
valid_facial_hairstyles += facialhairstyle
else //If the user is not a species who can have robotic heads, use the default handling.
if(active_character.species in SA.species_allowed) //If the user's head is of a species the facial hair style allows, add it to the list.
valid_facial_hairstyles += facialhairstyle
sortTim(valid_facial_hairstyles, GLOBAL_PROC_REF(cmp_text_asc))
var/new_f_style = tgui_input_list(user, "Choose your character's facial-hair style", "Character Preference", valid_facial_hairstyles)
if(new_f_style)
active_character.f_style = new_f_style
@@ -383,125 +383,46 @@
return sortTim(valid_species, GLOBAL_PROC_REF(cmp_text_asc))
/mob/living/carbon/human/proc/generate_valid_hairstyles()
var/list/valid_hairstyles = list()
var/obj/item/organ/external/head/H = get_organ("head")
var/datum/robolimb/robohead
if(!H)
return //No head, no hair.
for(var/hairstyle in GLOB.hair_styles_public_list)
var/datum/sprite_accessory/S = GLOB.hair_styles_public_list[hairstyle]
if(hairstyle == "Bald") //Just in case.
valid_hairstyles += hairstyle
continue
if(H.dna.species.bodyflags & ALL_RPARTS) //If the user is a species who can have a robotic head...
var/datum/robolimb/robohead = GLOB.all_robolimbs[H.model]
if((H.dna.species.name in S.species_allowed) && robohead.is_monitor && ((S.models_allowed && (robohead.company in S.models_allowed)) || !S.models_allowed)) //If this is a hair style native to the user's species, check to see if they have a head with an ipc-style screen and that the head's company is in the screen style's allowed models list.
valid_hairstyles += hairstyle //Give them their hairstyles if they do.
else
if(!robohead.is_monitor && ("Human" in S.species_allowed)) /*If the hairstyle is not native to the user's species and they're using a head with an ipc-style screen, don't let them access it.
But if the user has a robotic humanoid head and the hairstyle can fit humans, let them use it as a wig. */
valid_hairstyles += hairstyle
else //If the user is not a species who can have robotic heads, use the default handling.
if(H.dna.species.name in S.species_allowed) //If the user's head is of a species the hairstyle allows, add it to the list.
valid_hairstyles += hairstyle
return sortTim(valid_hairstyles, GLOBAL_PROC_REF(cmp_text_asc))
if(H.dna.species.bodyflags & ALL_RPARTS) //If the user is a species who can have a robotic head...
robohead = GLOB.all_robolimbs[H.model]
return list_valid_hairstyles(H.dna.species.name, robohead)
/mob/living/carbon/human/proc/generate_valid_facial_hairstyles()
var/list/valid_facial_hairstyles = list()
var/obj/item/organ/external/head/H = get_organ("head")
var/datum/robolimb/robohead
if(!H)
return //No head, no hair.
for(var/facialhairstyle in GLOB.facial_hair_styles_list)
var/datum/sprite_accessory/S = GLOB.facial_hair_styles_list[facialhairstyle]
if(facialhairstyle == "Shaved") //Just in case.
valid_facial_hairstyles += facialhairstyle
continue
if(H.dna.species.bodyflags & ALL_RPARTS) //If the user is a species who can have a robotic head...
var/datum/robolimb/robohead = GLOB.all_robolimbs[H.model]
if(H.dna.species.name in S.species_allowed) //If this is a facial hair style native to the user's species...
if((H.dna.species.name in S.species_allowed) && robohead.is_monitor && ((S.models_allowed && (robohead.company in S.models_allowed)) || !S.models_allowed)) //If this is a facial hair style native to the user's species, check to see if they have a head with an ipc-style screen and that the head's company is in the screen style's allowed models list.
valid_facial_hairstyles += facialhairstyle
else
if(!robohead.is_monitor && ("Human" in S.species_allowed)) /*If the facial hairstyle is not native to the user's species and they're using a head with an ipc-style screen, don't let them access it.
But if the user has a robotic humanoid head and the facial hairstyle can fit humans, let them use it as a wig. */
valid_facial_hairstyles += facialhairstyle
else //If the user is not a species who can have robotic heads, use the default handling.
if(H.dna.species.name in S.species_allowed) //If the user's head is of a species the facial hair style allows, add it to the list.
valid_facial_hairstyles += facialhairstyle
return sortTim(valid_facial_hairstyles, GLOBAL_PROC_REF(cmp_text_asc))
if(H.dna.species.bodyflags & ALL_RPARTS) //If the user is a species who can have a robotic head...
robohead = GLOB.all_robolimbs[H.model]
return list_valid_facial_hairstyles(H.dna.species.name, robohead)
/mob/living/carbon/human/proc/generate_valid_head_accessories()
var/list/valid_head_accessories = list()
var/obj/item/organ/external/head/H = get_organ("head")
if(!H)
return //No head, no head accessory.
for(var/head_accessory in GLOB.head_accessory_styles_list)
var/datum/sprite_accessory/S = GLOB.head_accessory_styles_list[head_accessory]
if(!(H.dna.species.name in S.species_allowed)) //If the user's head is not of a species the head accessory style allows, skip it. Otherwise, add it to the list.
continue
valid_head_accessories += head_accessory
return sortTim(valid_head_accessories, GLOBAL_PROC_REF(cmp_text_asc))
return list_valid_head_accessories(H.dna.species.name)
/mob/living/carbon/human/proc/generate_valid_markings(location = "body")
var/list/valid_markings = list()
var/obj/item/organ/external/head/H = get_organ("head")
var/datum/robolimb/robohead
if(!H && location == "head")
return //No head, no head markings.
if(H.dna.species.bodyflags & ALL_RPARTS) //If the user is a species who can have a robotic head...
robohead = GLOB.all_robolimbs[H.model]
for(var/marking in GLOB.marking_styles_list)
var/datum/sprite_accessory/body_markings/S = GLOB.marking_styles_list[marking]
if(S.name == "None")
valid_markings += marking
continue
if(S.marking_location != location) //If the marking isn't for the location we desire, skip.
continue
if(!(dna.species.name in S.species_allowed)) //If the user is not of a species the marking style allows, skip it. Otherwise, add it to the list.
continue
if(location == "tail")
if(!body_accessory)
if(S.tails_allowed)
continue
else
if(!S.tails_allowed || !(body_accessory.name in S.tails_allowed))
continue
if(location == "head")
var/datum/sprite_accessory/body_markings/head/M = GLOB.marking_styles_list[S.name]
if(H.dna.species.bodyflags & ALL_RPARTS) //If the user is a species that can have a robotic head...
var/datum/robolimb/robohead = GLOB.all_robolimbs[H.model]
if(!(S.models_allowed && (robohead.company in S.models_allowed))) //Make sure they don't get markings incompatible with their head.
continue
else if(H.alt_head && H.alt_head != "None") //If the user's got an alt head, validate markings for that head.
if(!M.heads_allowed || (!("All" in M.heads_allowed) && !(H.alt_head in M.heads_allowed)))
continue
else
if(M.heads_allowed && !("All" in M.heads_allowed))
continue
valid_markings += marking
return sortTim(valid_markings, GLOBAL_PROC_REF(cmp_text_asc))
return list_valid_marking_styles(location, H.dna.species.name, robohead, body_accessory, H.alt_head)
/mob/living/carbon/human/proc/generate_valid_body_accessories()
var/list/valid_body_accessories = list()
for(var/B in GLOB.body_accessory_by_name)
var/datum/body_accessory/A = GLOB.body_accessory_by_name[B]
if(isnull(A))
continue
else if(check_rights(R_ADMIN, FALSE, src))
valid_body_accessories = GLOB.body_accessory_by_name.Copy()
break
else if(dna.species.name in A.allowed_species) //If the user is not of a species the body accessory style allows, skip it. Otherwise, add it to the list.
valid_body_accessories += B
if(check_rights(R_ADMIN, FALSE, src))
return GLOB.body_accessory_by_name.Copy()
var/list/valid_body_accessories = list_valid_body_accessories(dna.species.name, FALSE)
if(dna.species.optional_body_accessory)
valid_body_accessories += "None"
return sortTim(valid_body_accessories, GLOBAL_PROC_REF(cmp_text_asc))
/mob/living/carbon/human/proc/generate_valid_alt_heads()
@@ -352,8 +352,8 @@
var/obj/item/organ/external/head/head_organ = H.get_organ("head")
if(!istype(head_organ))
return ..()
head_organ.h_style = random_hair_style(H.gender, head_organ.dna.species.name)
head_organ.f_style = random_facial_hair_style(H.gender, head_organ.dna.species.name)
head_organ.h_style = random_hair_style(head_organ.dna.species.name)
head_organ.f_style = random_facial_hair_style(head_organ.dna.species.name)
H.update_hair()
H.update_fhair()
..()
@@ -379,11 +379,11 @@
if(head_organ.dna.species.name in tmp_hair_style.species_allowed) //If 'Very Long Hair' is a style the person's species can have, give it to them.
head_organ.h_style = "Very Long Hair"
else //Otherwise, give them a random hair style.
head_organ.h_style = random_hair_style(H.gender, head_organ.dna.species.name)
head_organ.h_style = random_hair_style(head_organ.dna.species.name)
if(head_organ.dna.species.name in tmp_facial_hair_style.species_allowed) //If 'Very Long Beard' is a style the person's species can have, give it to them.
head_organ.f_style = "Very Long Beard"
else //Otherwise, give them a random facial hair style.
head_organ.f_style = random_facial_hair_style(H.gender, head_organ.dna.species.name)
head_organ.f_style = random_facial_hair_style(head_organ.dna.species.name)
H.update_hair()
H.update_fhair()
if(!H.wear_mask || H.wear_mask && !istype(H.wear_mask, /obj/item/clothing/mask/fakemoustache))
+2 -2
View File
@@ -177,9 +177,9 @@ GLOBAL_LIST_EMPTY(ert_request_messages)
M.change_eye_color(eye_c, FALSE)
M.change_skin_tone(random_skin_tone(M.dna.species.name))
head_organ.headacc_colour = pick("#1f138b", "#272525", "#07a035", "#8c00ff", "#a80c0c")
head_organ.h_style = random_hair_style(M.gender, head_organ.dna.species.name)
head_organ.h_style = random_hair_style(head_organ.dna.species.name)
if(M.gender != FEMALE) // no beard for women pls
head_organ.f_style = random_facial_hair_style(M.gender, head_organ.dna.species.name)
head_organ.f_style = random_facial_hair_style(head_organ.dna.species.name)
M.rename_character(M.real_name, "[pick("Corporal", "Sergeant", "Staff Sergeant", "Sergeant First Class", "Master Sergeant", "Sergeant Major")] [pick(GLOB.last_names)]")
M.age = rand(23,35)