Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions code/__DEFINES/DNA.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

#define UI_CHANGED "ui changed"
#define UE_CHANGED "ue changed"
#define UF_CHANGED "uf changed"

#define CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY 204

Expand All @@ -78,6 +79,11 @@
//DNA - Because fuck you and your magic numbers being all over the codebase.
#define DNA_BLOCK_SIZE 3

//this should be in a colors.dm define but we don't use that like tg does
#define DEFAULT_HEX_COLOR_LEN 6

#define DNA_BLOCK_SIZE_COLOR DEFAULT_HEX_COLOR_LEN

#define DNA_UNI_IDENTITY_BLOCKS 7
#define DNA_HAIR_COLOR_BLOCK 1
#define DNA_FACIAL_HAIR_COLOR_BLOCK 2
Expand All @@ -87,6 +93,27 @@
#define DNA_FACIAL_HAIR_STYLE_BLOCK 6
#define DNA_HAIR_STYLE_BLOCK 7

#define DNA_FEATURE_BLOCKS 19
#define DNA_MUTANT_COLOR_BLOCK 1
#define DNA_ETHEREAL_COLOR_BLOCK 2
#define DNA_LIZARD_MARKINGS_BLOCK 3
#define DNA_LIZARD_TAIL_BLOCK 4
#define DNA_SNOUT_BLOCK 5
#define DNA_HORNS_BLOCK 6
#define DNA_FRILLS_BLOCK 7
#define DNA_SPINES_BLOCK 8
#define DNA_HUMAN_TAIL_BLOCK 9
#define DNA_EARS_BLOCK 10
#define DNA_MOTH_WINGS_BLOCK 11
#define DNA_MUSHROOM_CAPS_BLOCK 12
#define DNA_POLY_TAIL_BLOCK 13
#define DNA_POLY_TEETH_BLOCK 14
#define DNA_POLY_DOME_BLOCK 15
#define DNA_POLY_DORSAL_BLOCK 16
#define DNA_ETHEREAL_MARK_BLOCK 17
#define DNA_PLANT_HAIR_BLOCK 18
#define DNA_PLANT_FLOWER_BLOCK 19

#define DNA_SEQUENCE_LENGTH 4
#define DNA_MUTATION_BLOCKS 8
#define DNA_UNIQUE_ENZYMES_LEN 32
Expand Down
7 changes: 6 additions & 1 deletion code/__HELPERS/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
#define GET_MUTATION_STABILIZER(A) ((A.stabilizer_coeff < 0) ? 1 : A.stabilizer_coeff)
#define GET_MUTATION_SYNCHRONIZER(A) ((A.synchronizer_coeff < 0) ? 1 : A.synchronizer_coeff)
#define GET_MUTATION_POWER(A) ((A.power_coeff < 0) ? 1 : A.power_coeff)
#define GET_MUTATION_ENERGY(A) ((A.energy_coeff < 0) ? 1 : A.energy_coeff)
#define GET_MUTATION_ENERGY(A) ((A.energy_coeff < 0) ? 1 : A.energy_coeff)

///Getter macro used to get the length of a identity block
#define GET_UI_BLOCK_LEN(blocknum) (GLOB.identity_block_lengths["[blocknum]"] || DNA_BLOCK_SIZE)
///Ditto, but for a feature.
#define GET_UF_BLOCK_LEN(blocknum) (GLOB.features_block_lengths["[blocknum]"] || DNA_BLOCK_SIZE)
22 changes: 11 additions & 11 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
/proc/random_eye_color()
switch(pick(20;"brown",20;"hazel",20;"grey",15;"blue",15;"green",1;"amber",1;"albino"))
if("brown")
return "630"
return "#663300"
if("hazel")
return "542"
return "#554422"
if("grey")
return pick("666","777","888","999","aaa","bbb","ccc")
return pick("#666666","#777777","#888888","#999999","#aaaaaa","#bbbbbb","#cccccc")
if("blue")
return "36c"
return "#3366cc"
if("green")
return "060"
return "#006600"
if("amber")
return "fc0"
return "#ffcc00"
if("albino")
return pick("c","d","e","f") + pick("0","1","2","3","4","5","6","7","8","9") + pick("0","1","2","3","4","5","6","7","8","9")
return "#" + pick("cc","dd","ee","ff") + pick("00","11","22","33","44","55","66","77","88","99") + pick("00","11","22","33","44","55","66","77","88","99")
else
return "000"
return "#000000"

/proc/random_underwear(gender)
if(!GLOB.underwear_list.len)
Expand Down Expand Up @@ -93,9 +93,9 @@

//For now we will always return none for tail_human and ears. this shit was unreadable if you do somethign like this make it at least readable
return(list(
"mcolor" = pick("FFFFFF","7F7F7F", "7FFF7F", "7F7FFF", "FF7F7F", "7FFFFF", "FF7FFF", "FFFF7F"),
"mcolor" = "#[pick("7F","FF")][pick("7F","FF")][pick("7F","FF")]",
"gradientstyle" = random_hair_gradient_style(10),
"gradientcolor" = pick("FFFFFF","7F7F7F", "7FFF7F", "7F7FFF", "FF7F7F", "7FFFFF", "FF7FFF", "FFFF7F"),
"gradientcolor" = "#[pick("FFFFFF","7F7F7F", "7FFF7F", "7F7FFF", "FF7F7F", "7FFFFF", "FF7FFF", "FFFF7F")]",
"ethcolor" = GLOB.color_list_ethereal[pick(GLOB.color_list_ethereal)],
"tail_lizard" = pick(GLOB.tails_list_lizard),
"tail_human" = "None",
Expand All @@ -109,7 +109,7 @@
"legs" = "Normal Legs",
"caps" = pick(GLOB.caps_list),
"moth_wings" = pick(GLOB.moth_wings_list),
"tail_polysmorph" = "Polys",
"tail_polysmorph" = pick(GLOB.tails_list_polysmorph),
"teeth" = pick(GLOB.teeth_list),
"dome" = pick(GLOB.dome_list),
"dorsal_tubes" = pick(GLOB.dorsal_tubes_list),
Expand Down
71 changes: 54 additions & 17 deletions code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,30 @@
return number
return default

/proc/sanitize_float(number, min=0, max=1, accuracy=1, default=0)
if(isnum(number))
number = round(number, accuracy)
if(min <= number && number <= max)
return number
return default

/proc/sanitize_text(text, default="")
if(istext(text))
return text
return default

/proc/sanitize_islist(value, default)
if(islist(value) && length(value))
return value
if(default)
return default

/proc/sanitize_inlist(value, list/List, default)
if(value in List)
return value
if(default)
return default
if(List && List.len)
if(List?.len)
return pick(List)


Expand All @@ -38,40 +51,64 @@
return default
return default

/proc/sanitize_hexcolor(color, desired_format=3, include_crunch=0, default)
/**
* Sanitize_Hexcolor takes in a color in hexcode as a string, be it shorthand hex as 3 characters, or full-sized 6 digit hex, with or without a leading #
* you can pass it a full hexcode with leading #, such as "#FFFFFF", and with the default arguments you will get exactly that color back, because it accounts for
* leading # signs and ignores them, then later in the function will either readd one, or won't depending on what you want.
*
* Full hexcolors will just be validated, shorthand hex of 3 characters can be cleanly converted up to full hex with a leading # no problem.
*
* With default arguments:
* * "FFF" -> "#FFFFFF"
* * "#FFFFFF" -> "#FFFFFF"
*
* converting down to short, with or without the # is doable by setting the desired format to the length you want and specifying the crunch to true for adding a # or false to not
*/
/proc/sanitize_hexcolor(color, desired_format = DEFAULT_HEX_COLOR_LEN, include_crunch = TRUE, default)
var/crunch = include_crunch ? "#" : ""
if(!istext(color))
color = ""

//start checks for a leading "#", and if there is it skips past it before doing the color logic.
//this means you can pass something like "#FFFFFF" into sanitize_hexcolor without arguments, and it will automatically cut the leading #, and readd it at the end
//there is no risk of accidentally creating a malformed color like ##FFFFFF
var/start = 1 + (text2ascii(color, 1) == 35)
var/len = length(color)
var/char = ""
// RRGGBB -> RGB but awful
var/convert_to_shorthand = desired_format == 3 && length_char(color) > 3
// Used for conversion between RGBA hex formats.
var/format_input_ratio = "[desired_format]:[length_char(color)-(start-1)]"

. = ""
var/i = start
while(i <= len)
char = color[i]
i += length(char)
switch(text2ascii(char))
if(48 to 57) //numbers 0 to 9
if(48 to 57) //numbers 0 to 9
. += char
if(97 to 102) //letters a to f
. += char
if(97 to 102) //letters a to f
if(65 to 70) //letters A to F
char = lowertext(char)
. += char
if(65 to 70) //letters A to F
. += lowertext(char)
else
break
i += length(char)
if(convert_to_shorthand && i <= len) //skip next one
i += length(color[i])

if(length_char(.) != desired_format)
if(default)
return default
return crunch + repeat_string(desired_format, "0")
switch(format_input_ratio)
//if you're trying to convert up from short hex (3 characters) to a full hex 6, that's what these switch statements are doing, adding and removing to meet the desired format
if("3:8", "4:8", "3:6", "4:6") //skip next one. RRGGBB(AA) -> RGB(A)
i += length(color[i])
if("6:4", "6:3", "8:4", "8:3") //add current char again. RGB(A) -> RRGGBB(AA)
. += char

return crunch + .
if(length_char(.) == desired_format)
return crunch + .
switch(format_input_ratio) //add or remove alpha channel depending on desired format.
if("3:8", "3:4", "6:4")
return crunch + copytext(., 1, desired_format+1)
if("4:6", "4:3", "8:3")
return crunch + . + ((desired_format == 4) ? "f" : "ff")
else //not a supported hex color format.
return default ? default : crunch + repeat_string(desired_format, "0")

/proc/sanitize_ooccolor(color)
if(length(color) != length_char(color))
Expand Down
21 changes: 20 additions & 1 deletion code/_globalvars/lists/flavor_misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,26 @@ GLOBAL_LIST_EMPTY(ipc_antennas_list)
GLOBAL_LIST_EMPTY(ipc_chassis_list)

GLOBAL_LIST_EMPTY(ethereal_mark_list) //ethereal face marks
GLOBAL_LIST_INIT(color_list_ethereal, list("F Class(Green)" = "97ee63", "F2 Class (Light Green)" = "00fa9a", "F3 Class (Dark Green)" = "37835b", "M Class (Red)" = "9c3030", "M1 Class (Purple)" = "ee82ee", "G Class (Yellow)" = "fbdf56", "O Class (Blue)" = "3399ff", "A Class (Cyan)" = "00ffff"))
GLOBAL_LIST_INIT(color_list_ethereal, list(
"F Class (Green)" = "#97ee63",
"F2 Class (Light Green)" = "#00fa9a",
"F3 Class (Dark Green)" = "#37835b",
"F4 Class (Faint Green)" = "#ddff99",
"M Class (Red)" = "#9c3030",
"M1 Class (Purple)" = "#ee82ee",
"M2 Class (Faint Red)" = "#ff4d4d",
"M3 Class (Light Pink)" = "#ffb3b3",
"M4 Class (Pink)" = "#ff99cc",
"G Class (Yellow)" = "#fbdf56",
"G1 Class (Bright Yellow)" = "#ffff99",
"O Class (Blue)" = "#3399ff",
"O1 Class (Dark Blue)" = "#6666ff",
"O2 Class (Faint Blue)" = "#b3d9ff",
"O3 Class (Dark Fuschia)" = "#cc0066",
"A Class (Cyan)" = "#00ffff",
"K Class (Orange)" = "#ffa64d",
"K1 Class (Burnt Orange)" = "#cc4400",
"White Dwarf" = "#f2f2f2",))

GLOBAL_LIST_EMPTY(pod_hair_list) //ethereal face marks
GLOBAL_LIST_EMPTY(pod_flower_list) //ethereal face marks
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/regexes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ GLOBAL_DATUM_INIT(is_website, /regex, regex("http|www.|\[a-z0-9_-]+.(com|org|net
GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-]+", "i"))
GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex("\[a-z0-9]+", "i"))
GLOBAL_DATUM_INIT(is_punctuation, /regex, regex("\[.!?]+", "i"))
GLOBAL_DATUM_INIT(is_color, /regex, regex("^#\[0-9a-fA-F]{6}$"))
2 changes: 1 addition & 1 deletion code/datums/components/forensics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
if(!ignoregloves)
H.gloves.add_fingerprint(H, TRUE) //ignoregloves = 1 to avoid infinite loop.
return
var/full_print = md5(H.dna.uni_identity)
var/full_print = md5(H.dna.unique_identity)
LAZYSET(fingerprints, full_print, full_print)
return TRUE

Expand Down
4 changes: 2 additions & 2 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
G.fields["rank"] = assignment
G.fields["age"] = H.age
G.fields["species"] = H.dna.species.name
G.fields["fingerprint"] = md5(H.dna.uni_identity)
G.fields["fingerprint"] = md5(H.dna.unique_identity)
G.fields["p_stat"] = "Active"
G.fields["m_stat"] = "Stable"
G.fields["gender"] = H.gender
Expand Down Expand Up @@ -383,7 +383,7 @@
G.fields["gender"] = "Other"
L.fields["blood_type"] = H.dna.blood_type
L.fields["b_dna"] = H.dna.unique_enzymes
L.fields["identity"] = H.dna.uni_identity
L.fields["identity"] = H.dna.unique_identity
L.fields["species"] = H.dna.species.type
L.fields["features"] = H.dna.features
L.fields["image"] = image
Expand Down
22 changes: 14 additions & 8 deletions code/datums/diseases/retrovirus.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@
to_chat(affected_mob, span_danger("Your entire body vibrates."))

if (prob(35))
if(prob(50))
scramble_dna(affected_mob, 1, 0, rand(15,45))
else
scramble_dna(affected_mob, 0, 1, rand(15,45))
switch(rand(1,3))
if(1)
scramble_dna(affected_mob, 1, 0, 0, rand(15,45))
if(2)
scramble_dna(affected_mob, 0, 1, 0, rand(15,45))
if(3)
scramble_dna(affected_mob, 0, 0, 1, rand(15,45))

if(4)
if(restcure)
Expand All @@ -78,7 +81,10 @@
cure()
return
if (prob(60))
if(prob(50))
scramble_dna(affected_mob, 1, 0, rand(50,75))
else
scramble_dna(affected_mob, 0, 1, rand(50,75))
switch(rand(1,3))
if(1)
scramble_dna(affected_mob, 1, 0, 0, rand(50,75))
if(2)
scramble_dna(affected_mob, 0, 1, 0, rand(50,75))
if(3)
scramble_dna(affected_mob, 0, 0, 1, rand(50,75))
Loading