Skip to content

Commit

Permalink
makes them actually random
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Jan 9, 2024
1 parent 1a13a01 commit 375d778
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 46 deletions.
26 changes: 18 additions & 8 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions code/modules/autowiki/pages/ships.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
66 changes: 35 additions & 31 deletions code/modules/mob/living/carbon/human/consistent_human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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])

0 comments on commit 375d778

Please sign in to comment.