Skip to content

Commit

Permalink
Merge pull request #3191 from MistakeNot4892/appearance
Browse files Browse the repository at this point in the history
Sprite accessories rewrite.
  • Loading branch information
out-of-phaze authored Feb 27, 2024
2 parents 97896ce + c3e54b2 commit 74af7d6
Show file tree
Hide file tree
Showing 82 changed files with 1,446 additions and 1,099 deletions.
2 changes: 0 additions & 2 deletions code/__defines/bodytype.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
// Bodytype appearance flags
#define HAS_SKIN_TONE_NORMAL BITFLAG(0) // Skin tone selectable in chargen for baseline humans (0-220)
#define HAS_SKIN_COLOR BITFLAG(1) // Skin colour selectable in chargen. (RGB)
#define HAS_LIPS BITFLAG(2) // Lips are drawn onto the mob icon. (lipstick)
#define HAS_UNDERWEAR BITFLAG(3) // Underwear is drawn onto the mob icon.
#define HAS_EYE_COLOR BITFLAG(4) // Eye colour selectable in chargen. (RGB)
#define HAS_HAIR_COLOR BITFLAG(5) // Hair colour selectable in chargen. (RGB)
#define RADIATION_GLOWS BITFLAG(6) // Radiation causes this character to glow.
#define HAS_SKIN_TONE_GRAV BITFLAG(7) // Skin tone selectable in chargen for grav-adapted humans (0-100)
#define HAS_SKIN_TONE_SPCR BITFLAG(8) // Skin tone selectable in chargen for spacer humans (0-165)
Expand Down
18 changes: 18 additions & 0 deletions code/__defines/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,21 @@ var/global/list/dexterity_levels = list(
// Enum for type of consumption, largely just cosmetic currently.
#define EATING_METHOD_EAT 0
#define EATING_METHOD_DRINK 1

#define SAC_HAIR /decl/sprite_accessory_category/hair
#define SAC_FACIAL_HAIR /decl/sprite_accessory_category/facial_hair
#define SAC_COSMETICS /decl/sprite_accessory_category/cosmetics
#define SAC_MARKINGS /decl/sprite_accessory_category/markings
#define SAC_HORNS /decl/sprite_accessory_category/horns
#define SAC_FRILLS /decl/sprite_accessory_category/frills

// Helpers for setting mob appearance. They are extremely ugly, hence the helpers.
#define SET_HAIR_STYLE(TARGET, STYLE, SKIP_UPDATE) (TARGET.set_organ_sprite_accessory_by_category((STYLE), SAC_HAIR, null, TRUE, FALSE, BP_HEAD, SKIP_UPDATE))
#define GET_HAIR_STYLE(TARGET) (TARGET.get_organ_sprite_accessory_by_category(SAC_HAIR, BP_HEAD))
#define SET_HAIR_COLOUR(TARGET, COLOUR, SKIP_UPDATE) (TARGET.set_organ_sprite_accessory_by_category(null, SAC_HAIR, (COLOUR), FALSE, TRUE, BP_HEAD, SKIP_UPDATE))
#define GET_HAIR_COLOUR(TARGET) (TARGET.get_organ_sprite_accessory(GET_HAIR_STYLE(TARGET), BP_HEAD))

#define SET_FACIAL_HAIR_STYLE(TARGET, STYLE, SKIP_UPDATE) (TARGET.set_organ_sprite_accessory_by_category((STYLE), SAC_FACIAL_HAIR, null, TRUE, FALSE, BP_HEAD, SKIP_UPDATE))
#define GET_FACIAL_HAIR_STYLE(TARGET) (TARGET.get_organ_sprite_accessory_by_category(SAC_FACIAL_HAIR, BP_HEAD))
#define SET_FACIAL_HAIR_COLOUR(TARGET, COLOUR, SKIP_UPDATE) (TARGET.set_organ_sprite_accessory_by_category(null, SAC_FACIAL_HAIR, (COLOUR), FALSE, TRUE, BP_HEAD, SKIP_UPDATE))
#define GET_FACIAL_HAIR_COLOUR(TARGET) (TARGET.get_organ_sprite_accessory(GET_FACIAL_HAIR_STYLE(TARGET), BP_HEAD))
9 changes: 5 additions & 4 deletions code/_helpers/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -284,19 +284,20 @@ Checks if a list has the same entries and values as an element of big.

//Returns the next element in parameter list after first appearance of parameter element. If it is the last element of the list or not present in list, returns first element.
/proc/next_in_list(element, list/L)
for(var/i=1, i<L.len, i++)
for(var/i = 1 to L.len)
if(L[i] == element)
if(i >= L.len)
return L[1]
return L[i+1]
return L[1]

//Returns the previous element in parameter list after first appearance of parameter element. If it is the first element of the list or not present in list, returns first element.
/proc/previous_in_list(element, list/L)
for(var/i=1, i<L.len, i++)
for(var/i = 1 to L.len)
if(L[i] == element)
if(i <= 1)
return L[L.len]
else
return L[i-1]
return L[i-1]
return L[L.len]

/*
Expand Down
7 changes: 7 additions & 0 deletions code/_helpers/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
if (BLEND_SUBTRACT) return ICON_SUBTRACT
else return ICON_OVERLAY

/proc/iconMode2blendMode(icon_mode)
switch (icon_mode)
if (ICON_MULTIPLY) return BLEND_MULTIPLY
if (ICON_ADD) return BLEND_ADD
if (ICON_SUBTRACT) return BLEND_SUBTRACT
else return BLEND_OVERLAY

// Converts a rights bitfield into a string
/proc/rights2text(rights,seperator="")
if (rights & R_BUILDMODE) . += "[seperator]+BUILDMODE"
Expand Down
2 changes: 1 addition & 1 deletion code/datums/supplypacks/galley.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
/obj/item/chems/drinks/bottle/goldschlager,
/obj/item/chems/drinks/bottle/agedwhiskey,
/obj/item/storage/box/fancy/cigarettes/dromedaryco,
/obj/random/lipstick,
/obj/random/lipstick = 2,
/obj/item/chems/drinks/bottle/small/ale = 2,
/obj/item/chems/drinks/bottle/small/beer = 4,
/obj/item/storage/box/glowsticks = 2)
Expand Down
67 changes: 21 additions & 46 deletions code/game/dna/dna2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,15 @@
#define DNA_HARD_BOUNDS list(1,3490,3500,4095)

// UI Indices (can change to mutblock style, if desired)
#define DNA_UI_HAIR_R 1
#define DNA_UI_HAIR_G 2
#define DNA_UI_HAIR_B 3
#define DNA_UI_BEARD_R 4
#define DNA_UI_BEARD_G 5
#define DNA_UI_BEARD_B 6
#define DNA_UI_SKIN_TONE 7
#define DNA_UI_SKIN_R 8
#define DNA_UI_SKIN_G 9
#define DNA_UI_SKIN_B 10
#define DNA_UI_EYES_R 11
#define DNA_UI_EYES_G 12
#define DNA_UI_EYES_B 13
#define DNA_UI_GENDER 14
#define DNA_UI_BEARD_STYLE 15
#define DNA_UI_HAIR_STYLE 16
#define DNA_UI_LENGTH 16 // Update this when you add something, or you WILL break shit.
#define DNA_UI_SKIN_TONE 1
#define DNA_UI_SKIN_R 2
#define DNA_UI_SKIN_G 3
#define DNA_UI_SKIN_B 4
#define DNA_UI_EYES_R 5
#define DNA_UI_EYES_G 6
#define DNA_UI_EYES_B 7
#define DNA_UI_GENDER 8
#define DNA_UI_LENGTH 8 // Update this when you add something, or you WILL break shit.

#define DNA_SE_LENGTH 27
// For later:
Expand Down Expand Up @@ -80,20 +72,20 @@ var/global/list/assigned_blocks[DNA_SE_LENGTH]

// New stuff
var/species
var/list/body_markings = list()
var/list/heritable_sprite_accessories = list()
var/lineage
//#TODO: Keep track of bodytype!!!!!

// Make a copy of this strand.
/datum/dna/PopulateClone(datum/dna/clone)
clone = ..()
clone.lineage = lineage
clone.unique_enzymes = unique_enzymes
clone.fingerprint = fingerprint
clone.b_type = b_type
clone.real_name = real_name
clone.species = species || global.using_map.default_species
clone.body_markings = deepCopyList(body_markings)
clone.lineage = lineage
clone.unique_enzymes = unique_enzymes
clone.fingerprint = fingerprint
clone.b_type = b_type
clone.real_name = real_name
clone.species = species || global.using_map.default_species
clone.heritable_sprite_accessories = deepCopyList(heritable_sprite_accessories)
for(var/b in 1 to DNA_SE_LENGTH)
clone.SE[b] = SE[b]
if(b <= DNA_UI_LENGTH)
Expand Down Expand Up @@ -121,16 +113,6 @@ var/global/list/assigned_blocks[DNA_SE_LENGTH]
// INITIALIZE!
ResetUI(1)

var/hair_colour = character.get_hair_colour()
SetUIValueRange(DNA_UI_HAIR_R, HEX_RED(hair_colour), 255, 1)
SetUIValueRange(DNA_UI_HAIR_G, HEX_GREEN(hair_colour), 255, 1)
SetUIValueRange(DNA_UI_HAIR_B, HEX_BLUE(hair_colour), 255, 1)

var/facial_hair_colour = character.get_facial_hair_colour()
SetUIValueRange(DNA_UI_BEARD_R, HEX_RED(facial_hair_colour), 255, 1)
SetUIValueRange(DNA_UI_BEARD_G, HEX_GREEN(facial_hair_colour), 255, 1)
SetUIValueRange(DNA_UI_BEARD_B, HEX_BLUE(facial_hair_colour), 255, 1)

var/eye_colour = character.get_eye_colour()
SetUIValueRange(DNA_UI_EYES_R, HEX_RED(eye_colour), 255, 1)
SetUIValueRange(DNA_UI_EYES_G, HEX_GREEN(eye_colour), 255, 1)
Expand All @@ -148,18 +130,11 @@ var/global/list/assigned_blocks[DNA_SE_LENGTH]
fingerprint = character.get_full_print(ignore_blockers = TRUE)
unique_enzymes = character.get_unique_enzymes()

// Hair
var/list/hair_types = decls_repository.get_decl_paths_of_subtype(/decl/sprite_accessory/hair)
SetUIValueRange(DNA_UI_HAIR_STYLE, hair_types.Find(character.get_hairstyle()), length(hair_types), 1)

// Facial Hair
var/list/beard_types = decls_repository.get_decl_paths_of_subtype(/decl/sprite_accessory/facial_hair)
SetUIValueRange(DNA_UI_BEARD_STYLE, beard_types.Find(character.get_facial_hairstyle()), length(beard_types), 1)

body_markings.Cut()
heritable_sprite_accessories.Cut()
for(var/obj/item/organ/external/E in character.get_external_organs())
if(LAZYLEN(E.markings))
body_markings[E.organ_tag] = E.markings.Copy()
var/list/sprite_accessories = E.get_heritable_sprite_accessories()
if(LAZYLEN(sprite_accessories))
heritable_sprite_accessories[E.organ_tag] = sprite_accessories

b_type = character.get_blood_type()

Expand Down
29 changes: 6 additions & 23 deletions code/game/dna/dna2_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,44 +137,27 @@
unique_enzymes = dna.unique_enzymes
set_skin_colour( rgb(dna.GetUIValueRange(DNA_UI_SKIN_R,255), dna.GetUIValueRange(DNA_UI_SKIN_G,255), dna.GetUIValueRange(DNA_UI_SKIN_B,255)))
set_eye_colour( rgb(dna.GetUIValueRange(DNA_UI_EYES_R,255), dna.GetUIValueRange(DNA_UI_EYES_G,255), dna.GetUIValueRange(DNA_UI_EYES_B,255)))
set_hair_colour( rgb(dna.GetUIValueRange(DNA_UI_HAIR_R,255), dna.GetUIValueRange(DNA_UI_HAIR_G,255), dna.GetUIValueRange(DNA_UI_HAIR_B,255)))
set_facial_hair_colour(rgb(dna.GetUIValueRange(DNA_UI_BEARD_R,255), dna.GetUIValueRange(DNA_UI_BEARD_G,255), dna.GetUIValueRange(DNA_UI_BEARD_B,255)))
skin_tone = 35 - dna.GetUIValueRange(DNA_UI_SKIN_TONE, 220) // Value can be negative.


// TODO: update DNA gender to not be a bool - use bodytype and pronouns
//Body markings
for(var/tag in dna.body_markings)
for(var/tag in dna.heritable_sprite_accessories)
var/obj/item/organ/external/E = GET_EXTERNAL_ORGAN(src, tag)
if(E)
var/list/marklist = dna.body_markings[tag]
var/list/marklist = dna.heritable_sprite_accessories[tag]
if(length(marklist))
E.markings = marklist.Copy()
for(var/accessory in marklist)
E.set_sprite_accessory(accessory, null, marklist[accessory], skip_update = TRUE)
else
LAZYCLEARLIST(E.markings)
E.clear_sprite_accessories(skip_update = TRUE)

//Base skin and blend
for(var/obj/item/organ/organ in get_organs())
organ.set_dna(dna)

//Hair
var/update_hair = FALSE
var/list/hair_subtypes = decls_repository.get_decl_paths_of_subtype(/decl/sprite_accessory/hair)
var/hair = dna.GetUIValueRange(DNA_UI_HAIR_STYLE, length(hair_subtypes))
if(hair > 0 && hair <= length(hair_subtypes))
set_hairstyle(hair_subtypes[hair], skip_update = TRUE)
update_hair = TRUE

//Facial Hair
var/list/beard_subtypes = decls_repository.get_decl_paths_of_subtype(/decl/sprite_accessory/facial_hair)
var/beard = dna.GetUIValueRange(DNA_UI_BEARD_STYLE, length(beard_subtypes))
if((0 < beard) && (beard <= length(beard_subtypes)))
set_facial_hairstyle(beard_subtypes[beard], skip_update = TRUE)
update_hair = TRUE

force_update_limbs()
if(update_hair)
update_hair(update_icons = FALSE)
update_hair(update_icons = FALSE)
update_eyes()
return TRUE

Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/vending/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
/obj/item/haircomb = 8,
/obj/item/clothing/glasses/eyepatch/monocle = 5,
/obj/item/clothing/glasses/sunglasses = 5,
/obj/item/lipstick = 3,
/obj/random/lipstick = 3,
/obj/random/makeup = 3,
/obj/item/storage/wallet/poly = 2
)
contraband = list(
Expand Down
Loading

0 comments on commit 74af7d6

Please sign in to comment.