From 375d778f1f871005ffc79a57bb3ba5c1c667c55e Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Tue, 9 Jan 2024 10:37:15 -0600 Subject: [PATCH] makes them actually random --- code/__HELPERS/text.dm | 26 +++++--- code/modules/autowiki/pages/ships.dm | 8 +-- .../living/carbon/human/consistent_human.dm | 66 ++++++++++--------- 3 files changed, 54 insertions(+), 46 deletions(-) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index f89cfea14edb..1c605758a2cd 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -350,22 +350,32 @@ GLOBAL_LIST_INIT(binary, list("0","1")) /proc/random_short_color() return num2text(rand(0, 4095), 3, 16) -/proc/short_color_from_seed(seed) - return num2text(seed % 4095, 3, 16) +/proc/color_from_seed(seed) + seed = md5(seed) + + var/red = num2text(hex2num(copytext(seed, 1, 3)), 2, 16) + var/green = num2text(hex2num(copytext(seed, 3, 5)), 2, 16) + var/blue = num2text(hex2num(copytext(seed, 5, 7)), 2, 16) + + return red + green + blue /proc/random_color() return num2text(rand(0, 16777215), 6, 16) /proc/random_color_natural() //For use in natural haircolors. - var red = num2text(rand(0,255), 2, 16) - var green = num2text(rand(0,128), 2, 16) //Conversion to hex - var blue = "00" + var/red = num2text(rand(0,255), 2, 16) + var/green = num2text(rand(0,128), 2, 16) //Conversion to hex + var/blue = "00" + return red + green + blue /proc/color_natural_from_seed(seed) - var red = num2text(seed % 255, 2, 16) - var green = num2text(seed % 128, 2, 16) //Conversion to hex - var blue = "00" + seed = md5(seed) + + var/red = num2text(hex2num(copytext(seed, 1, 3)), 2, 16) + var/green = num2text(hex2num(copytext(seed, 3, 5)) / 2, 2, 16) + var/blue = "00" + return red + green + blue //merges non-null characters (3rd argument) from "from" into "into". Returns result diff --git a/code/modules/autowiki/pages/ships.dm b/code/modules/autowiki/pages/ships.dm index 372e9d14a9cb..ecbdf8c65e2d 100644 --- a/code/modules/autowiki/pages/ships.dm +++ b/code/modules/autowiki/pages/ships.dm @@ -74,14 +74,8 @@ return output /datum/autowiki/ship/proc/get_dummy_image(datum/job/to_equip, filename) - //Limited to just the humanoid-compliant roundstart species, but at least it's not just human. - var/static/list/species = list(/datum/species/ethereal, /datum/species/human, /datum/species/ipc, /datum/species/lizard, /datum/species/moth, /datum/species/spider) - //Length times ascii char of the last letter, good enough(?) #entropy - var/seed = length(filename) * text2ascii(filename, length(filename)) //Controlled randomisation - wiki_dummy.seeded_randomization(seed) - //Each outfit will always have the same species - wiki_dummy.set_species(species[seed % length(species) + 1]) + wiki_dummy.seeded_randomization(filename) //Delete all the old stuff they had wiki_dummy.wipe_state() diff --git a/code/modules/mob/living/carbon/human/consistent_human.dm b/code/modules/mob/living/carbon/human/consistent_human.dm index c35d8a71759e..cecfe74b7cc8 100644 --- a/code/modules/mob/living/carbon/human/consistent_human.dm +++ b/code/modules/mob/living/carbon/human/consistent_human.dm @@ -3,36 +3,40 @@ return //No randomisation /mob/living/carbon/human/dummy/consistent/proc/seeded_randomization(seed = 0) - gender = list(MALE, FEMALE)[seed % 2 + 1] - skin_tone = GLOB.skin_tones[seed % length(GLOB.skin_tones) + 1] - hairstyle = GLOB.hairstyles_list[seed % length(GLOB.hairstyles_list) + 1] - hair_color = color_natural_from_seed(seed) - eye_color = short_color_from_seed(seed) + seed = md5(seed) - // Mutant randomizing, doesn't affect the mob appearance unless it's the specific mutant. - dna.features["mcolor"] = short_color_from_seed(seed * 2) - dna.features["mcolor2"] = short_color_from_seed(seed * 3) - //AAAAAAAAAAAAAAAAAAAAAAAAAA - dna.features["ethcolor"] = GLOB.color_list_ethereal[GLOB.color_list_ethereal[seed % length(GLOB.color_list_ethereal) + 1]] - dna.features["tail_lizard"] = GLOB.tails_list_lizard[seed % length(GLOB.tails_list_lizard) + 1] - dna.features["face_markings"] = GLOB.face_markings_list[seed % length(GLOB.face_markings_list) + 1] - dna.features["horns"] = GLOB.horns_list[seed % length(GLOB.horns_list) + 1] - dna.features["frills"] = GLOB.frills_list[seed % length(GLOB.frills_list) + 1] - dna.features["spines"] = GLOB.spines_list[seed % length(GLOB.spines_list) + 1] - dna.features["body_markings"] = GLOB.body_markings_list[seed % length(GLOB.body_markings_list) + 1] - dna.features["moth_wings"] = GLOB.moth_wings_list[seed % length(GLOB.moth_wings_list) + 1] - dna.features["moth_fluff"] = GLOB.moth_fluff_list[seed % length(GLOB.moth_fluff_list) + 1] - dna.features["spider_legs"] = GLOB.spider_legs_list[seed % length(GLOB.spider_legs_list) + 1] - dna.features["spider_spinneret"] = GLOB.spider_spinneret_list[seed % length(GLOB.spider_spinneret_list) + 1] - dna.features["squid_face"] = GLOB.squid_face_list[seed % length(GLOB.squid_face_list) + 1] - dna.features["kepori_feathers"] = GLOB.kepori_feathers_list[seed % length(GLOB.kepori_feathers_list) + 1] - dna.features["kepori_body_feathers"] = GLOB.kepori_body_feathers_list[seed % length(GLOB.kepori_body_feathers_list) + 1] - dna.features["vox_head_quills"] = GLOB.vox_head_quills_list[seed % length(GLOB.vox_head_quills_list) + 1] - dna.features["vox_neck_quills"] = GLOB.vox_neck_quills_list[seed % length(GLOB.vox_neck_quills_list) + 1] - dna.features["elzu_horns"] = GLOB.elzu_horns_list[seed % length(GLOB.elzu_horns_list) + 1] - dna.features["tail_elzu"] = GLOB.tails_list_elzu[seed % length(GLOB.tails_list_elzu) + 1] - dna.features["ipc_chassis"] = GLOB.ipc_chassis_list[seed % length(GLOB.ipc_chassis_list) + 1] - dna.features["ipc_screen"] = GLOB.ipc_screens_list[seed % length(GLOB.ipc_screens_list) + 1] + gender = list(MALE, FEMALE)[hex2num(copytext(seed, 1, 2)) % 2 + 1] + skin_tone = GLOB.skin_tones[hex2num(copytext(seed, 2, 3)) % length(GLOB.skin_tones) + 1] - update_body() - update_hair() + hairstyle = GLOB.hairstyles_list[hex2num(copytext(seed, 1, 3)) % length(GLOB.hairstyles_list) + 1] + facial_hairstyle = GLOB.facial_hairstyles_list[hex2num(copytext(seed, 3, 6)) % length(GLOB.facial_hairstyles_list) + 1] + + hair_color = color_natural_from_seed(copytext(seed, 1, 6)) + facial_hair_color = hair_color + eye_color = color_from_seed(copytext(seed, 3, 9)) + + dna.features["mcolor"] = color_from_seed(copytext(seed, 1, 9)) + dna.features["mcolor2"] = color_from_seed(copytext(seed, 2, 10)) + dna.features["ethcolor"] = color_from_seed(copytext(seed, 3, 11)) + + dna.features["tail_lizard"] = GLOB.tails_list_lizard[hex2num(copytext(seed, 2, 3)) % length(GLOB.tails_list_lizard) + 1] + dna.features["face_markings"] = GLOB.face_markings_list[hex2num(copytext(seed, 3, 4)) % length(GLOB.face_markings_list) + 1] + dna.features["horns"] = GLOB.horns_list[hex2num(copytext(seed, 4, 5)) % length(GLOB.horns_list) + 1] + dna.features["frills"] = GLOB.frills_list[hex2num(copytext(seed, 5, 6)) % length(GLOB.frills_list) + 1] + dna.features["spines"] = GLOB.spines_list[hex2num(copytext(seed, 6, 7)) % length(GLOB.spines_list) + 1] + dna.features["body_markings"] = GLOB.body_markings_list[hex2num(copytext(seed, 7, 8)) % length(GLOB.body_markings_list) + 1] + dna.features["moth_wings"] = GLOB.moth_wings_list[hex2num(copytext(seed, 8, 9)) % length(GLOB.moth_wings_list) + 1] + dna.features["moth_fluff"] = GLOB.moth_fluff_list[hex2num(copytext(seed, 9, 10)) % length(GLOB.moth_fluff_list) + 1] + dna.features["spider_legs"] = GLOB.spider_legs_list[hex2num(copytext(seed, 10, 11)) % length(GLOB.spider_legs_list) + 1] + dna.features["spider_spinneret"] = GLOB.spider_spinneret_list[hex2num(copytext(seed, 11, 12)) % length(GLOB.spider_spinneret_list) + 1] + dna.features["kepori_feathers"] = GLOB.kepori_feathers_list[hex2num(copytext(seed, 12, 13)) % length(GLOB.kepori_feathers_list) + 1] + dna.features["kepori_body_feathers"] = GLOB.kepori_body_feathers_list[hex2num(copytext(seed, 13, 14)) % length(GLOB.kepori_body_feathers_list) + 1] + dna.features["vox_head_quills"] = GLOB.vox_head_quills_list[hex2num(copytext(seed, 14, 15)) % length(GLOB.vox_head_quills_list) + 1] + dna.features["vox_neck_quills"] = GLOB.vox_neck_quills_list[hex2num(copytext(seed, 15, 16)) % length(GLOB.vox_neck_quills_list) + 1] + dna.features["elzu_horns"] = GLOB.elzu_horns_list[hex2num(copytext(seed, 16, 17)) % length(GLOB.elzu_horns_list) + 1] + dna.features["tail_elzu"] = GLOB.tails_list_elzu[hex2num(copytext(seed, 17, 18)) % length(GLOB.tails_list_elzu) + 1] + dna.features["ipc_chassis"] = GLOB.ipc_chassis_list[hex2num(copytext(seed, 18, 19)) % length(GLOB.ipc_chassis_list) + 1] + dna.features["ipc_screen"] = GLOB.ipc_screens_list[hex2num(copytext(seed, 19, 20)) % length(GLOB.ipc_screens_list) + 1] + + var/species_id = GLOB.roundstart_races[hex2num(copytext(seed, 3, 4)) % length(GLOB.roundstart_races) + 1] + set_species(GLOB.species_list[species_id])