diff --git a/code/__HELPERS/mob_helpers.dm b/code/__HELPERS/mob_helpers.dm index 66b81649377..fceeb6a3b25 100644 --- a/code/__HELPERS/mob_helpers.dm +++ b/code/__HELPERS/mob_helpers.dm @@ -118,7 +118,7 @@ /// Returns a purely random tint for specific color /proc/tint_color(color, range = 25) - if(!istext(color) || length(color) < 7 || copytext(color, 1, 2) != "#") // if it's not a hex color + if(!is_color_text(color)) // if it's not a hex color return color // just leave it as it is var/R = clamp(color2R(color) + rand(-range, range), 0, 255) @@ -218,55 +218,13 @@ /// Randomises skin tone, specifically for each species that has a skin tone. Otherwise keeps a default of 1 /proc/random_skin_tone(species = "Human") - switch(species) - if("Human") - return rand(1, 13) - if("Drask") - return rand(1, 220) - if("Nian") - return rand(1, 4) - if("Vox") - return rand(1, 8) + var/datum/species/species_selected = GLOB.all_species[species] + if(species_selected?.bodyflags & HAS_SKIN_TONE) + return rand(1, 220) + else if(species_selected?.bodyflags & HAS_ICON_SKIN_TONE) + return rand(1, length(species_selected.icon_skin_tones)) return 1 -/proc/skintone2racedescription(tone, species = "Human") - if(species == "Human") - switch(tone) - if(30 to INFINITY) return "albino" - if(20 to 30) return "pale" - if(5 to 15) return "light skinned" - if(-10 to 5) return "white" - if(-25 to -10) return "tan" - if(-45 to -25) return "darker skinned" - if(-65 to -45) return "brown" - if(-INFINITY to -65) return "black" - else return "unknown" - else if(species == "Vox") - switch(tone) - if(2) return "plum" - if(3) return "brown" - if(4) return "gray" - if(5) return "emerald" - if(6) return "azure" - if(7) return "crimson" - if(8) return "nebula" - else return "lime" - else - return "unknown" - -/proc/age2agedescription(age) - switch(age) - if(0 to 1) return "infant" - if(1 to 3) return "toddler" - if(3 to 13) return "child" - if(13 to 19) return "teenager" - if(19 to 30) return "young adult" - if(30 to 45) return "adult" - if(45 to 60) return "middle-aged" - if(60 to 70) return "aging" - if(70 to INFINITY) return "elderly" - else return "unknown" - /proc/set_criminal_status(mob/living/user, datum/data/record/target_records , criminal_status, comment, user_rank, list/authcard_access = list(), user_name) var/status = criminal_status var/their_name = target_records.fields["name"] diff --git a/code/modules/client/preference/character.dm b/code/modules/client/preference/character.dm index 09a828c724f..1282fc86ac4 100644 --- a/code/modules/client/preference/character.dm +++ b/code/modules/client/preference/character.dm @@ -32,7 +32,7 @@ var/f_style = "Shaved" //Facial hair type var/f_colour = "#000000" //Facial hair color var/f_sec_colour = "#000000" //Secondary facial hair color - var/s_tone = 0 //Skin tone + var/s_tone = 1 //Skin tone var/s_colour = "#000000" //Skin color var/e_colour = "#000000" //Eye color var/alt_head = "None" //Alt head style. @@ -619,7 +619,9 @@ socks = random_socks(body_type, species) if(length(GLOB.body_accessory_by_species[species])) body_accessory = random_body_accessory(species, S.optional_body_accessory) - if(S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) + if(S.bodyflags & HAS_SKIN_TONE) + 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) f_style = random_facial_hair_style(gender, species, robohead) diff --git a/code/modules/client/preference/link_processing.dm b/code/modules/client/preference/link_processing.dm index 2564fdb6843..539785d148e 100644 --- a/code/modules/client/preference/link_processing.dm +++ b/code/modules/client/preference/link_processing.dm @@ -151,8 +151,10 @@ if("eyes") active_character.e_colour = rand_hex_color() if("s_tone") - if(S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) - active_character.s_tone = random_skin_tone() + if(S.bodyflags & HAS_SKIN_TONE) + active_character.s_tone = 35 - random_skin_tone(active_character.species) + else if(S.bodyflags & HAS_ICON_SKIN_TONE) + active_character.s_tone = random_skin_tone(active_character.species) if("s_color") if(S.bodyflags & HAS_SKIN_COLOR) active_character.s_colour = rand_hex_color() @@ -246,10 +248,12 @@ active_character.socks = random_socks(active_character.body_type, active_character.species) //reset skin tone and colour - if(NS.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) - random_skin_tone(active_character.species) + if(NS.bodyflags & HAS_SKIN_TONE) + active_character.s_tone = 35 - random_skin_tone(active_character.species) + else if(NS.bodyflags & HAS_ICON_SKIN_TONE) + active_character.s_tone = random_skin_tone(active_character.species) else - active_character.s_tone = 0 + active_character.s_tone = 1 if(!(NS.bodyflags & HAS_SKIN_COLOR)) active_character.s_colour = "#000000" @@ -639,18 +643,18 @@ active_character.e_colour = new_eyes if("s_tone") + var/new_s_tone if(S.bodyflags & HAS_SKIN_TONE) - var/new_s_tone = input(user, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference") as num|null + new_s_tone = tgui_input_number(user, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference", -active_character.s_tone + 35, 220, 1) if(isnull(new_s_tone)) return - active_character.s_tone = 35 - max(min(round(new_s_tone), 220), 1) + active_character.s_tone = 35 - new_s_tone else if(S.bodyflags & HAS_ICON_SKIN_TONE) - var/const/MAX_LINE_ENTRIES = 4 var/prompt = "Choose your character's skin tone: 1-[length(S.icon_skin_tones)]\n(Light to Dark)" - var/skin_c = tgui_input_number(user, prompt, "Character Preference", active_character.s_tone, length(S.icon_skin_tones), 1) - if(isnull(skin_c)) + new_s_tone = tgui_input_number(user, prompt, "Character Preference", active_character.s_tone, length(S.icon_skin_tones), 1) + if(isnull(new_s_tone)) return - active_character.s_tone = skin_c + active_character.s_tone = new_s_tone if("skin") if((S.bodyflags & HAS_SKIN_COLOR) || GLOB.body_accessory_by_species[active_character.species] || check_rights(R_ADMIN, 0, user)) diff --git a/code/modules/customitems/item_defines.dm b/code/modules/customitems/item_defines.dm index d0e15704a1f..3813ce60123 100644 --- a/code/modules/customitems/item_defines.dm +++ b/code/modules/customitems/item_defines.dm @@ -129,8 +129,14 @@ /obj/item/fluff/bird_painter/attack_self__legacy__attackchain(mob/user) if(ishuman(user)) var/mob/living/carbon/human/H = user - H.s_tone = -115 - H.regenerate_icons() + if(H.dna.species.bodyflags & (HAS_SKIN_TONE | HAS_ICON_SKIN_TONE)) + H.change_skin_tone(-115, TRUE) + else if(H.dna.species.bodyflags & HAS_SKIN_COLOR) + var/list/hsl = rgb2hsl(hex2num(copytext(H.skin_colour, 2, 4)), hex2num(copytext(H.skin_colour, 4, 6)), hex2num(copytext(color, 6, 8))) + hsl[3] = min(hsl[3], 0.15) // makes their current skin color dark, setting its lightness to max of 15% + var/list/rgb = hsl2rgb(arglist(hsl)) + var/new_color = "#[num2hex(rgb[1], 2)][num2hex(rgb[2], 2)][num2hex(rgb[3], 2)]" + H.change_skin_color(new_color) to_chat(user, "You use [src] on yourself.") qdel(src) diff --git a/code/modules/mob/living/carbon/human/appearance.dm b/code/modules/mob/living/carbon/human/appearance.dm index 9e6056afb98..fd2e574c455 100644 --- a/code/modules/mob/living/carbon/human/appearance.dm +++ b/code/modules/mob/living/carbon/human/appearance.dm @@ -318,18 +318,18 @@ return TRUE -/mob/living/carbon/human/proc/change_skin_color(colour = "#000000") - if(colour == skin_colour || !(dna.species.bodyflags & HAS_SKIN_COLOR)) +/mob/living/carbon/human/proc/change_skin_color(color = "#000000") + if(!is_color_text(color) || color == skin_colour || !(dna.species.bodyflags & HAS_SKIN_COLOR)) return - skin_colour = colour + skin_colour = color force_update_limbs() return TRUE /// Tone must be between -185 and 220. commonly used in 1 to 220, see `random_skin_tone()` for species-specific values /mob/living/carbon/human/proc/change_skin_tone(tone, override = FALSE) - if(s_tone == tone || !((dna.species.bodyflags & HAS_SKIN_TONE) || (dna.species.bodyflags & HAS_ICON_SKIN_TONE))) + if(!isnum(tone) || !((dna.species.bodyflags & HAS_SKIN_TONE) || (dna.species.bodyflags & HAS_ICON_SKIN_TONE))) return if(tone in -185 to 220) diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 40e9f883cf3..d2b3efd8bde 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -20,7 +20,7 @@ var/list/m_colours = DEFAULT_MARKING_COLOURS //All colours set to #000000. var/list/m_styles = DEFAULT_MARKING_STYLES //All markings set to None. - var/s_tone = 0 //Skin tone + var/s_tone = 1 //Skin tone //Skin colour var/skin_colour = "#000000" diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm index 39bcd00c6f7..f1a6f746103 100644 --- a/code/modules/mob/living/carbon/human/human_mob.dm +++ b/code/modules/mob/living/carbon/human/human_mob.dm @@ -1176,8 +1176,8 @@ else skin_colour = "#000000" - if(!(dna.species.bodyflags & HAS_SKIN_TONE)) - s_tone = 0 + if(!(dna.species.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE))) + s_tone = 1 var/list/thing_to_check = list(ITEM_SLOT_MASK, ITEM_SLOT_HEAD, ITEM_SLOT_SHOES, ITEM_SLOT_GLOVES, ITEM_SLOT_LEFT_EAR, ITEM_SLOT_RIGHT_EAR, ITEM_SLOT_EYES, ITEM_SLOT_LEFT_HAND, ITEM_SLOT_RIGHT_HAND, ITEM_SLOT_NECK) var/list/kept_items[0] diff --git a/code/modules/mob/living/carbon/superheroes.dm b/code/modules/mob/living/carbon/superheroes.dm index a4c5d79aeff..2bfbb6f071e 100644 --- a/code/modules/mob/living/carbon/superheroes.dm +++ b/code/modules/mob/living/carbon/superheroes.dm @@ -218,7 +218,7 @@ if(istype(head_organ)) head_organ.h_style = "Bald" head_organ.f_style = "Shaved" - target.s_tone = 35 + target.change_skin_tone(1) // No `update_dna=0` here because the character is being over-written target.change_eye_color(1,1,1) for(var/obj/item/W in target.get_all_slots()) diff --git a/code/modules/reagents/chemistry/reagents/misc_reagents.dm b/code/modules/reagents/chemistry/reagents/misc_reagents.dm index 721b6224bbf..fe73c7a60b4 100644 --- a/code/modules/reagents/chemistry/reagents/misc_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/misc_reagents.dm @@ -803,9 +803,18 @@ /datum/reagent/spraytan/proc/set_skin_color(mob/living/carbon/human/H) if(H.dna.species.bodyflags & HAS_SKIN_TONE) - H.change_skin_tone(max(H.s_tone - 10, -195)) - - if(H.dna.species.bodyflags & HAS_SKIN_COLOR) //take current alien color and darken it slightly + H.change_skin_tone(min(-H.s_tone + 45, 220)) // adjusts our skin tone by 10 - makes it darker + else if(H.dna.species.bodyflags & HAS_ICON_SKIN_TONE) + switch(H.dna.species.name) + if("Human") + H.change_skin_tone(max(H.s_tone, 10)) // bronze - `icons/mob/human_races/human_skintones/r_human_bronzed.dmi` + if("Vox") + H.change_skin_tone(3) // brown - `icons/mob/human_races/vox/r_voxbrn.dmi` + if("Nian") + H.change_skin_tone(1) // default - `icons/mob/human_races/nian/r_moth.dmi` + if("Grey") + H.change_skin_tone(4) // red - `icons/mob/human_races/grey/r_grey_red.dmi` + else if(H.dna.species.bodyflags & HAS_SKIN_COLOR) // take current alien color and darken it slightly H.change_skin_color("#9B7653") /datum/reagent/admin_cleaner diff --git a/code/modules/tgui/modules/appearance_changer.dm b/code/modules/tgui/modules/appearance_changer.dm index 435a238e619..fc68831aada 100644 --- a/code/modules/tgui/modules/appearance_changer.dm +++ b/code/modules/tgui/modules/appearance_changer.dm @@ -47,28 +47,15 @@ if("skin_tone") if(can_change_skin_tone()) - var/new_s_tone = null + var/new_s_tone if(owner.dna.species.bodyflags & HAS_SKIN_TONE) - new_s_tone = input(usr, "Choose your character's skin tone:\n(Light 1 - 220 Dark)", "Skin Tone", owner.s_tone) as num|null - if(isnum(new_s_tone) && (!..())) - new_s_tone = max(min(round(new_s_tone), 220),1) + new_s_tone = tgui_input_number(usr, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference", owner.s_tone, 220, 1) else if(owner.dna.species.bodyflags & HAS_ICON_SKIN_TONE) - var/const/MAX_LINE_ENTRIES = 4 - var/prompt = "Choose your character's skin tone: 1-[length(owner.dna.species.icon_skin_tones)]\n(" - for(var/i in 1 to length(owner.dna.species.icon_skin_tones)) - if(i > MAX_LINE_ENTRIES && !((i - 1) % MAX_LINE_ENTRIES)) - prompt += "\n" - prompt += "[i] = [owner.dna.species.icon_skin_tones[i]]" - if(i != length(owner.dna.species.icon_skin_tones)) - prompt += ", " - prompt += ")" + var/prompt = "Choose your character's skin tone: 1-[length(owner.dna.species.icon_skin_tones)]\n(Light to Dark)" + new_s_tone = tgui_input_number(usr, prompt, "Character Preference", owner.s_tone, length(owner.dna.species.icon_skin_tones), 1) - new_s_tone = input(usr, prompt, "Skin Tone", owner.s_tone) as num|null - if(isnum(new_s_tone) && (!..())) - new_s_tone = max(min(round(new_s_tone), length(owner.dna.species.icon_skin_tones)), 1) - - if(new_s_tone) - owner.change_skin_tone(new_s_tone) + if(!isnull(new_s_tone) && (!..()) && owner.change_skin_tone(new_s_tone)) + update_dna() if("skin_color") if(can_change_skin_color())