Large patch to Slime/IPC PR - Character Creator + General Imitation Fixes (#28348)

* add: slimify icon proc, clamps L in HSL.
fix: skin tones, corrupted character slots, species subtype accessories, and spawning without the proper DNA set.
character creator fixes.
reduces the eye strain from super bright slime people :pain:

* fix
This commit is contained in:
Spaghetti-bit
2025-02-12 00:08:39 +00:00
committed by GitHub
parent 2793a1c7f4
commit 3fe1cd3521
8 changed files with 87 additions and 61 deletions
+9
View File
@@ -528,3 +528,12 @@ GLOBAL_LIST_EMPTY(bicon_cache)
var/icon/I = getFlatIcon(thing)
return icon2asset(I, target)
/// Slimifies an icon by painting a color onto the icon, then changing the alpha.
/icon/proc/slimify(color = "#FFFFFF", alpha = "FF")
GrayScale()
var/list/hsl = rgb2hsl(hex2num(copytext(color, 2, 4)), hex2num(copytext(color, 4, 6)), hex2num(copytext(color, 6, 8)))
hsl[3] = clamp(hsl[3], 0, 0.4) // Clamps luminance.
var/rgb = hsl2rgb(arglist(hsl))
var/new_color = "#[num2hex(rgb[1], 2)][num2hex(rgb[2], 2)][num2hex(rgb[3], 2)]"
Blend("[new_color][alpha]", ICON_ADD)
+19 -5
View File
@@ -833,6 +833,7 @@
var/icon/icobase
var/datum/species/current_species = GLOB.all_species[species]
var/will_slimify = FALSE
//Icon-based species colour.
var/coloured_tail
@@ -844,12 +845,17 @@
if(subtype_species) // Take certain attributes from our subtype to apply to our current species.
H.dna.species.updatespeciessubtype(H, subtype_species)
current_species = H.dna.species
icobase = current_species.icobase
else if(current_species.bodyflags & HAS_ICON_SKIN_TONE) //Handling species-specific icon-based skin tones by flagged race.
H.s_tone = s_tone
H.dna.species.updatespeciescolor(H, 0) //The mob's species wasn't set, so it's almost certainly different than the character's species at the moment. Thus, we need to be owner-insensitive.
var/obj/item/organ/external/chest/C = H.get_organ("chest")
icobase = C.icobase ? C.icobase : C.dna.species.icobase
if(H.dna.species.bodyflags & HAS_TAIL)
coloured_tail = H.tail ? H.tail : H.dna.species.tail
icobase = current_species.icobase
else
icobase = current_species.icobase
will_slimify = (istype(current_species, /datum/species/slime) && current_species.species_subtype != "None")
qdel(H)
else
icobase = 'icons/mob/human_races/r_human.dmi'
@@ -882,9 +888,8 @@
bodypart.Blend(new /icon(R.icon, "[name]"), ICON_OVERLAY)
preview_icon.Blend(bodypart, ICON_OVERLAY)
continue
if(istype(current_species, /datum/species/slime) && current_species.species_subtype != "None") // Applies to limbs that are not robotic.
bodypart.GrayScale()
bodypart.Blend("[s_colour]DC", ICON_AND) //DC = 220 alpha.
if(will_slimify) // Applies to limbs that are not robotic.
bodypart.slimify(s_colour, "A0")
else
// Skin color
if(current_species && (current_species.bodyflags & HAS_SKIN_COLOR))
@@ -936,6 +941,10 @@
t_marking_s.Blend(m_colours["tail"], ICON_ADD)
temp.Blend(t_marking_s, ICON_OVERLAY)
if(will_slimify)
temp.slimify(s_colour, "A0")
if(underlay)
underlay.slimify(s_colour, "A0")
// Body accessory has an underlay, add it too.
if(underlay)
ICON_SHIFT_XY(underlay, offset_x, offset_y)
@@ -952,6 +961,8 @@
if(body_marking_style && body_marking_style.species_allowed)
var/icon/b_marking_s = new/icon("icon" = body_marking_style.icon, "icon_state" = "[body_marking_style.icon_state]_s")
b_marking_s.Blend(m_colours["body"], ICON_ADD)
if(will_slimify)
b_marking_s.slimify(s_colour, "A0")
preview_icon.Blend(b_marking_s, ICON_OVERLAY)
if(current_species.bodyflags & HAS_HEAD_MARKINGS) //Head markings.
var/head_marking = m_styles["head"]
@@ -959,6 +970,8 @@
if(head_marking_style && head_marking_style.species_allowed)
var/icon/h_marking_s = new/icon("icon" = head_marking_style.icon, "icon_state" = "[head_marking_style.icon_state]_s")
h_marking_s.Blend(m_colours["head"], ICON_ADD)
if(will_slimify)
h_marking_s.slimify(s_colour, "A0")
preview_icon.Blend(h_marking_s, ICON_OVERLAY)
var/icon/hands_icon = icon(preview_icon)
@@ -1005,6 +1018,8 @@
if(head_accessory_style && head_accessory_style.species_allowed)
var/icon/head_accessory_s = new/icon("icon" = head_accessory_style.icon, "icon_state" = "[head_accessory_style.icon_state]_s")
head_accessory_s.Blend(hacc_colour, ICON_ADD)
if(will_slimify)
head_accessory_s.slimify(s_colour, "A0")
face_s.Blend(head_accessory_s, ICON_OVERLAY)
var/datum/sprite_accessory/facial_hair_style = GLOB.facial_hair_styles_list[f_style]
@@ -1857,7 +1872,6 @@
character.species_subtype = "None"
if(be_random_name)
real_name = random_name(gender, species)
character.add_language(language)
@@ -8,7 +8,8 @@
subtype = S
else
S = new S.type()
S.bodyflags |= subtype.bodyflags
S.bodyflags |= subtype.bodyflags // Used for finding valid styles.
S.species_subtype = subtype.name // Used for finding valid styles.
if(href_list["preference"] == "job")
switch(href_list["task"])
if("close")
@@ -203,13 +204,15 @@
to_chat(user, "<span class='warning'>Invalid species, please pick something else.</span>")
return
if(prev_species != active_character.species)
if(isnull(NS))
NS = GLOB.all_species[active_character.species]
S = new NS.type()
active_character.species_subtype = "None"
active_character.age = clamp(active_character.age, S.min_age, S.max_age)
NS = GLOB.all_species[active_character.species_subtype] // Changing species resets subtype.
if(isnull(NS))
NS = GLOB.all_species[active_character.species]
subtype = new NS.type()
subtype = GLOB.all_species[active_character.species_subtype] // Changing species resets subtype.
if(isnull(subtype))
subtype = GLOB.all_species[active_character.species]
subtype = new subtype.type()
reset_styles(S)
if("species_subtype")
if(S.bodyflags & HAS_SPECIES_SUBTYPE)
@@ -217,11 +220,17 @@
if(isnull(new_subtype) || active_character.species_subtype == new_subtype)
return
active_character.species_subtype = new_subtype
var/datum/species/NS = GLOB.all_species[active_character.species_subtype]
if(isnull(NS))
NS = GLOB.all_species[active_character.species]
subtype = new NS.type()
reset_styles(subtype, S)
subtype = GLOB.all_species[active_character.species_subtype]
if(isnull(subtype))
subtype = GLOB.all_species[active_character.species]
subtype = new subtype.type()
S = new S.type() // Always make a new species before editing it, as datums get messy.
if(S.name != subtype.name)
S.bodyflags |= subtype.bodyflags // Add our body flags of the new subtype.
S.species_subtype = subtype.name
reset_styles(subtype, S)
else
reset_styles(S)
if("speciesprefs")
active_character.speciesprefs = !active_character.speciesprefs //Starts 0, so if someone clicks the button up top there, this won't be 0 anymore. If they click it again, it'll go back to 0.
if("language")
@@ -1275,51 +1284,51 @@
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, NS, robohead)
active_character.h_style = random_hair_style(active_character.gender, NS.name, 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, NS, robohead)
active_character.f_style = random_facial_hair_style(active_character.gender, NS.name, robohead)
if(NS.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories.
active_character.ha_style = random_head_accessory(NS)
active_character.ha_style = random_head_accessory(NS.name)
else
active_character.ha_style = "None" // No Vulp ears on Unathi
active_character.hacc_colour = rand_hex_color()
if(NS.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings.
active_character.m_styles["head"] = random_marking_style("head", NS, robohead, null, active_character.alt_head)
active_character.m_styles["head"] = random_marking_style("head", NS.name, robohead, null, active_character.alt_head)
else
active_character.m_styles["head"] = "None"
active_character.m_colours["head"] = "#000000"
if(NS.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos.
active_character.m_styles["body"] = random_marking_style("body", NS)
active_character.m_styles["body"] = random_marking_style("body", NS.name)
else
active_character.m_styles["body"] = "None"
active_character.m_colours["body"] = "#000000"
if(NS.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings.
active_character.m_styles["tail"] = random_marking_style("tail", NS, null, active_character.body_accessory)
active_character.m_styles["tail"] = random_marking_style("tail", NS.name, null, active_character.body_accessory)
else
active_character.m_styles["tail"] = "None"
active_character.m_colours["tail"] = "#000000"
// Don't wear another species' underwear!
var/datum/sprite_accessory/SA = GLOB.underwear_list[active_character.underwear]
if(!SA || !(NS in SA.species_allowed))
active_character.underwear = random_underwear(active_character.body_type, NS)
if(!SA || !(NS.name in SA.species_allowed))
active_character.underwear = random_underwear(active_character.body_type, NS.name)
SA = GLOB.undershirt_list[active_character.undershirt]
if(!SA || !(NS in SA.species_allowed))
active_character.undershirt = random_undershirt(active_character.body_type, NS)
if(!SA || !(NS.name in SA.species_allowed))
active_character.undershirt = random_undershirt(active_character.body_type, NS.name)
SA = GLOB.socks_list[active_character.socks]
if(!SA || !(NS in SA.species_allowed))
active_character.socks = random_socks(active_character.body_type, NS)
if(!SA || !(NS.name in SA.species_allowed))
active_character.socks = random_socks(active_character.body_type, NS.name)
//reset skin tone and colour
if(NS.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE))
random_skin_tone(NS)
random_skin_tone(NS.name)
else
active_character.s_tone = 0
@@ -182,6 +182,11 @@ GLOBAL_LIST_INIT(special_role_times, list(
switch(current_tab)
if(TAB_CHAR) // Character Settings
var/datum/species/S = GLOB.all_species[active_character.species]
var/datum/species/subtype = GLOB.all_species[active_character.species_subtype]
if(istype(S) && istype(subtype))
subtype = new subtype.type()
S = new S.type()
S.bodyflags |= subtype.bodyflags
if(!istype(S)) //The species was invalid. Set the species to the default, fetch the datum for that species and generate a random character.
active_character.species = initial(active_character.species)
S = GLOB.all_species[active_character.species]
@@ -311,8 +311,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
if(body_marking_style.do_colouration)
b_marking_s.Blend(m_colours["body"], ICON_ADD)
if(istype(src.dna.species, /datum/species/slime))
b_marking_s.GrayScale()
b_marking_s.Blend("[skin_colour]A0", ICON_AND)
b_marking_s.slimify(skin_colour, "A0")
markings_standing.Blend(b_marking_s, ICON_OVERLAY)
//Head markings.
var/obj/item/organ/external/head/head_organ = get_organ("head")
@@ -324,8 +323,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
if(head_marking_style.do_colouration)
h_marking_s.Blend(m_colours["head"], ICON_ADD)
if(istype(src.dna.species, /datum/species/slime))
h_marking_s.GrayScale()
h_marking_s.Blend("[skin_colour]A0", ICON_AND)
h_marking_s.slimify(skin_colour, "A0")
markings_standing.Blend(h_marking_s, ICON_OVERLAY)
overlays_standing[MARKINGS_LAYER] = mutable_appearance(markings_standing, layer = -MARKINGS_LAYER)
@@ -355,8 +353,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
if(head_accessory_style.do_colouration)
head_accessory_s.Blend(head_organ.headacc_colour, ICON_ADD)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies head acc
head_accessory_s.GrayScale()
head_accessory_s.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha.
head_accessory_s.slimify(skin_colour, "A0")
if(HAS_TRAIT(src, TRAIT_I_WANT_BRAINS))
head_accessory_s.ColorTone(COLORTONE_DEAD_EXT_ORGAN)
head_accessory_s.SetIntensity(0.7)
@@ -483,7 +480,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
if((head_organ.dna.species.sprite_sheet_name in facial_hair_style.species_allowed) || (head_organ.dna.species.bodyflags & ALL_RPARTS)) //If the head's species is in the list of allowed species for the hairstyle, or the head's species is one flagged to have bodies comprised wholly of cybernetics...
var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
if(istype(head_organ.dna.species, /datum/species/slime)) // I am el worstos
facial_s.Blend("[skin_colour]A0", ICON_AND)
facial_s.slimify(skin_colour, "A0")
else if(facial_hair_style.do_colouration)
facial_s.Blend(head_organ.facial_colour, ICON_ADD)
@@ -1308,8 +1305,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
wings_icon.ColorTone(COLORTONE_DEAD_EXT_ORGAN)
wings_icon.SetIntensity(0.7)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies the wings
wings_icon.GrayScale()
wings_icon.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha.
wings_icon.slimify(skin_colour, "A0")
var/mutable_appearance/wings = mutable_appearance(wings_icon, layer = -WING_LAYER)
wings.pixel_x = body_accessory.pixel_x_offset
wings.pixel_y = body_accessory.pixel_y_offset
@@ -1321,8 +1317,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
under_wing_icon.ColorTone(COLORTONE_DEAD_EXT_ORGAN)
under_wing_icon.SetIntensity(0.7)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies the wings
under_wing_icon.GrayScale()
under_wing_icon.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha.
under_wing_icon.slimify(skin_colour, "A0")
var/mutable_appearance/under_wing = mutable_appearance(under_wing_icon, layer = -WING_UNDERLIMBS_LAYER)
under_wing.pixel_x = body_accessory.pixel_x_offset
under_wing.pixel_y = body_accessory.pixel_y_offset
@@ -1359,8 +1354,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
accessory_s.Blend(tail_marking_icon, ICON_OVERLAY)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies the body acc
accessory_s.GrayScale()
accessory_s.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha. Less alpha here because the tail is generally stubborn...
accessory_s.slimify(skin_colour, "A0")
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && dna.species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
// Gives the underlimbs layer SEW direction icons since it's overlayed by limbs and just about everything else anyway.
@@ -1402,8 +1396,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
tail_s.Blend(tail_marking_icon, ICON_OVERLAY)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies the tail
tail_s.GrayScale()
tail_s.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha.
tail_s.slimify(skin_colour, "A0")
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && dna.species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
// Gives the underlimbs layer SEW direction icons since it's overlayed by limbs and just about everything else anyway.
@@ -1445,8 +1438,8 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
if(dna.species.bodyflags & HAS_SKIN_COLOR)
accessory_s.Blend(skin_colour, body_accessory.blend_mode)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies the wings
accessory_s.GrayScale()
accessory_s.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha.
accessory_s.slimify(skin_colour, "A0")
if(tail_marking_icon && (body_accessory.name in tail_marking_style.tails_allowed))
accessory_s.Blend(tail_marking_icon, ICON_OVERLAY)
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && dna.species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
@@ -1485,8 +1478,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
if(dna.species.bodyflags & HAS_SKIN_COLOR)
tailw_s.Blend(skin_colour, ICON_ADD)
if(istype(src.dna.species, /datum/species/slime)) // Slimifies the tail
tailw_s.GrayScale()
tailw_s.Blend("[skin_colour]A0", ICON_AND) //DC = 160 alpha.
tailw_s.slimify(skin_colour, "A0")
if(tail_marking_icon && !tail_marking_style.tails_allowed)
tailw_s.Blend(tail_marking_icon, ICON_OVERLAY)
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && dna.species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
@@ -1601,6 +1593,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
/mob/living/carbon/human/proc/force_update_limbs()
for(var/obj/item/organ/external/O in bodyparts)
O.dna.species = dna.species
O.sync_colour_to_human(src)
update_body()
@@ -1657,9 +1650,8 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
. = "[.][!!husk][!!hulk][!!skeleton]"
/// Slimifies a limb by painting a color onto the icon, then changing the alpha
/mob/living/carbon/human/proc/slimify_limb(obj/item/organ/external/L, icon/I, slimify)
if(slimify) // Used for a when slime morphs into another species. Makes them slightly transparent.
if(!L.is_robotic())
I.GrayScale()
var/color = sanitize_hexcolor(skin_colour)
I.Blend("[color]C8", ICON_AND) //DC = 220 alpha. C8 = 200
I.slimify(skin_colour)
@@ -416,9 +416,10 @@
* - new_subtype: Our imitate species, by datum reference.
* - owner_sensitive: Always leave at TRUE, this is for updating our icon. (change_icobase)
* - reset_styles: If true, resets styles, hair, and other appearance styles.
* - forced: If true, will set the subspecies type even if it is the same as the current species.
*/
///
/datum/species/proc/updatespeciessubtype(mob/living/carbon/human/H, datum/species/new_subtype, owner_sensitive = TRUE, reset_styles = TRUE)
/datum/species/proc/updatespeciessubtype(mob/living/carbon/human/H, datum/species/new_subtype, owner_sensitive = TRUE, reset_styles = TRUE, forced = FALSE)
return
// Do species-specific reagent handling here
@@ -89,10 +89,10 @@
var/static_bodyflags = HAS_SKIN_COLOR | HAS_HEAD_MARKINGS | HAS_HEAD_ACCESSORY | ALL_RPARTS | SHAVED | HAS_SPECIES_SUBTYPE
/datum/species/machine/updatespeciessubtype(mob/living/carbon/human/H, datum/species/new_subtype, owner_sensitive = TRUE, reset_styles = TRUE) //Handling species-subtype and imitation
/datum/species/machine/updatespeciessubtype(mob/living/carbon/human/H, datum/species/new_subtype, owner_sensitive = TRUE, reset_styles = TRUE, forced = FALSE) //Handling species-subtype and imitation
if(H.dna.species.bodyflags & HAS_SPECIES_SUBTYPE)
var/datum/species/temp_species = new type()
if(isnull(new_subtype) || temp_species.name == new_subtype.name) // Back to our original species.
if(isnull(new_subtype) || (temp_species.name == new_subtype.name && !forced)) // Back to our original species.
H.species_subtype = "None"
temp_species.species_subtype = "None" // Update our species subtype to match the Mob's subtype.
var/datum/species/S = GLOB.all_species[temp_species.name]
@@ -99,10 +99,10 @@
i.Remove(H)
UnregisterSignal(H, COMSIG_HUMAN_UPDATE_DNA)
/datum/species/slime/updatespeciessubtype(mob/living/carbon/human/H, datum/species/new_subtype, owner_sensitive = TRUE, reset_styles = TRUE) //Handling species-subtype and imitation
/datum/species/slime/updatespeciessubtype(mob/living/carbon/human/H, datum/species/new_subtype, owner_sensitive = TRUE, reset_styles = TRUE, forced = FALSE) //Handling species-subtype and imitation
if(H.dna.species.bodyflags & HAS_SPECIES_SUBTYPE)
var/datum/species/temp_species = new type()
if(isnull(new_subtype) || temp_species.name == new_subtype.name) // Back to our original species.
if(isnull(new_subtype) || (temp_species.name == new_subtype.name && !forced)) // Back to our original species.
H.species_subtype = "None"
temp_species.species_subtype = "None" // Update our species subtype to match the Mob's subtype.
var/datum/species/S = GLOB.all_species[temp_species.name]
@@ -121,10 +121,6 @@
temp_species.female_scream_sound = new_subtype.female_scream_sound
temp_species.default_headacc = new_subtype.default_headacc
temp_species.default_bodyacc = new_subtype.default_bodyacc
temp_species.male_cough_sounds = new_subtype.male_cough_sounds
temp_species.female_cough_sounds = new_subtype.female_cough_sounds
temp_species.male_sneeze_sound = new_subtype.male_sneeze_sound
temp_species.female_sneeze_sound = new_subtype.female_sneeze_sound
temp_species.bodyflags = new_subtype.bodyflags
temp_species.bodyflags |= static_bodyflags // Add our static bodyflags that slime must always have.
temp_species.sprite_sheet_name = new_subtype.sprite_sheet_name
@@ -139,7 +135,7 @@
// Update misc parts that are stored as reference in species and used on the mob. Also resets stylings to none to prevent anything wacky...
if(reset_styles)
H.body_accessory = GLOB.body_accessory_by_name[default_bodyacc]
H.body_accessory = GLOB.body_accessory_by_name[temp_species.default_bodyacc]
H.tail = temp_species.tail
H.wing = temp_species.wing
var/obj/item/organ/external/head/head = H.get_organ("head")
@@ -149,7 +145,7 @@
H.s_tone = 0
H.m_styles = DEFAULT_MARKING_STYLES //Wipes out markings, setting them all to "None".
H.m_colours = DEFAULT_MARKING_COLOURS //Defaults colour to #00000 for all markings.
H.change_head_accessory(GLOB.head_accessory_styles_list[default_headacc])
H.change_head_accessory(GLOB.head_accessory_styles_list[temp_species.default_headacc])
H.change_icobase(temp_species.icobase, owner_sensitive) //Update the icobase of all our organs, but make sure we don't mess with frankenstein limbs in doing so.
/datum/species/slime/proc/blend(mob/living/carbon/human/H)