From aa2eee2ded13465f457d29a678f3bb6f0e56558e Mon Sep 17 00:00:00 2001
From: FernandoJ8 <80640114+FernandoJ8@users.noreply.github.com>
Date: Mon, 15 Aug 2022 04:55:13 +0200
Subject: [PATCH] De-hardcodes randomize_human() and fixes some related issues
along the way (#68876)
* First draft on this branch. Should work.
* Whoopsie
* Some fixes
* And again
* Final draft, question mark?
* Please enter the commit message for your changes
* Uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
* please work
* Saving for the week offline
* Final draft
* Final final draft
* Oh and clean this up
* eah
* Okay, final for real.
* I lied.
* Sure thing boss
* clinclin
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
* That's all of em I think
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
---
code/datums/status_effects/neutral.dm | 2 +-
code/modules/admin/create_mob.dm | 30 ++++++++-----------
.../abductor/equipment/glands/transform.dm | 1 -
.../medieval_sim/medisim_game.dm | 1 -
.../ruins/icemoonruin_code/hotsprings.dm | 1 -
.../mob/living/carbon/human/species.dm | 17 ++++++++---
.../carbon/human/species_types/ethereal.dm | 2 ++
.../carbon/human/species_types/felinid.dm | 4 +++
.../carbon/human/species_types/humans.dm | 3 ++
.../human/species_types/lizardpeople.dm | 9 +++---
.../carbon/human/species_types/mothmen.dm | 11 +++----
.../carbon/human/species_types/podpeople.dm | 8 ++---
.../chemistry/reagents/other_reagents.dm | 1 -
.../crossbreeding/_status_effects.dm | 1 -
.../organs/external/_external_organs.dm | 3 ++
code/modules/surgery/organs/external/tails.dm | 6 ++++
16 files changed, 55 insertions(+), 45 deletions(-)
diff --git a/code/datums/status_effects/neutral.dm b/code/datums/status_effects/neutral.dm
index 5b5204b1eb6..fc04bb21ad3 100644
--- a/code/datums/status_effects/neutral.dm
+++ b/code/datums/status_effects/neutral.dm
@@ -423,7 +423,7 @@
monkey_tail.Insert(human_mob, drop_if_replaced = FALSE)
var/datum/species/human_species = human_mob.dna?.species
if(human_species)
- human_species.randomize_main_appearance_element(human_mob)
+ human_species.randomize_features(human_mob)
human_species.randomize_active_underwear(human_mob)
owner.remove_status_effect(/datum/status_effect/eigenstasium)
diff --git a/code/modules/admin/create_mob.dm b/code/modules/admin/create_mob.dm
index 434685bb210..fc4a4472218 100644
--- a/code/modules/admin/create_mob.dm
+++ b/code/modules/admin/create_mob.dm
@@ -11,13 +11,13 @@
user << browse(create_panel_helper(create_mob_html), "window=create_mob;size=425x475")
/proc/randomize_human(mob/living/carbon/human/human)
- human.gender = pick(MALE, FEMALE)
+ if(human.dna.species.sexes)
+ human.gender = pick(MALE, FEMALE, PLURAL)
+ else
+ human.gender = PLURAL
human.physique = human.gender
human.real_name = human.dna?.species.random_name(human.gender) || random_unique_name(human.gender)
human.name = human.real_name
- human.underwear = random_underwear(human.gender)
- human.underwear_color = "#[random_color()]"
- human.skin_tone = random_skin_tone()
human.hairstyle = random_hairstyle(human.gender)
human.facial_hairstyle = random_facial_hairstyle(human.gender)
human.hair_color = "#[random_color()]"
@@ -25,21 +25,15 @@
var/random_eye_color = random_eye_color()
human.eye_color_left = random_eye_color
human.eye_color_right = random_eye_color
+
human.dna.blood_type = random_blood_type()
-
- // Mutant randomizing, doesn't affect the mob appearance unless it's the specific mutant.
human.dna.features["mcolor"] = "#[random_color()]"
- human.dna.features["ethcolor"] = GLOB.color_list_ethereal[pick(GLOB.color_list_ethereal)]
- human.dna.features["tail_cat"] = pick(GLOB.tails_list_human)
- human.dna.features["tail_lizard"] = pick(GLOB.tails_list_lizard)
- human.dna.features["snout"] = pick(GLOB.snouts_list)
- human.dna.features["horns"] = pick(GLOB.horns_list)
- human.dna.features["frills"] = pick(GLOB.frills_list)
- human.dna.features["spines"] = pick(GLOB.spines_list)
- human.dna.features["body_markings"] = pick(GLOB.body_markings_list)
- human.dna.features["moth_wings"] = pick(GLOB.moth_wings_list)
- human.dna.features["moth_antennae"] = pick(GLOB.moth_antennae_list)
- human.dna.features["pod_hair"] = pick(GLOB.pod_hair_list)
+ human.dna.species.randomize_active_underwear(human)
- human.update_body(is_creating = TRUE)
+ for(var/datum/species/species_path as anything in subtypesof(/datum/species))
+ var/datum/species/new_species = new species_path
+ new_species.randomize_features(human)
human.dna.species.spec_updatehealth(human)
+ human.dna.update_dna_identity()
+ human.updateappearance()
+ human.update_body(is_creating = TRUE)
diff --git a/code/modules/antagonists/abductor/equipment/glands/transform.dm b/code/modules/antagonists/abductor/equipment/glands/transform.dm
index 97f437234e5..3ea10c77255 100644
--- a/code/modules/antagonists/abductor/equipment/glands/transform.dm
+++ b/code/modules/antagonists/abductor/equipment/glands/transform.dm
@@ -13,4 +13,3 @@
randomize_human(owner)
var/species = pick(list(/datum/species/human, /datum/species/lizard, /datum/species/moth, /datum/species/fly))
owner.set_species(species)
- owner.dna.update_dna_identity()
diff --git a/code/modules/capture_the_flag/medieval_sim/medisim_game.dm b/code/modules/capture_the_flag/medieval_sim/medisim_game.dm
index dce23275632..80d0b9e8c53 100644
--- a/code/modules/capture_the_flag/medieval_sim/medisim_game.dm
+++ b/code/modules/capture_the_flag/medieval_sim/medisim_game.dm
@@ -28,7 +28,6 @@
return
var/mob/living/carbon/human/human_knight = .
randomize_human(human_knight)
- human_knight.dna.update_dna_identity()
human_knight.dna.add_mutation(/datum/mutation/human/medieval, MUT_OTHER)
var/oldname = human_knight.name
var/title = "error"
diff --git a/code/modules/mapfluff/ruins/icemoonruin_code/hotsprings.dm b/code/modules/mapfluff/ruins/icemoonruin_code/hotsprings.dm
index e396f872980..cea4dcc0fd7 100644
--- a/code/modules/mapfluff/ruins/icemoonruin_code/hotsprings.dm
+++ b/code/modules/mapfluff/ruins/icemoonruin_code/hotsprings.dm
@@ -40,7 +40,6 @@
all_species += stype
var/random_race = pick(all_species)
H.set_species(random_race)
- H.dna.update_dna_identity()
L = H
var/turf/T = find_safe_turf(extended_safety_checks = TRUE, dense_atoms = FALSE)
L.forceMove(T)
diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm
index 3d9511b4941..c4351f054b8 100644
--- a/code/modules/mob/living/carbon/human/species.dm
+++ b/code/modules/mob/living/carbon/human/species.dm
@@ -786,10 +786,6 @@ GLOBAL_LIST_EMPTY(features_by_species)
if(BODY_FRONT_LAYER)
return "FRONT"
-///Proc that will randomise the hair, or primary appearance element (i.e. for moths wings) of a species' associated mob
-/datum/species/proc/randomize_main_appearance_element(mob/living/carbon/human/human_mob)
- human_mob.hairstyle = random_hairstyle(human_mob.gender)
- human_mob.update_hair(is_creating = TRUE)
///Proc that will randomise the underwear (i.e. top, pants and socks) of a species' associated mob
/datum/species/proc/randomize_active_underwear(mob/living/carbon/human/human_mob)
@@ -798,6 +794,19 @@ GLOBAL_LIST_EMPTY(features_by_species)
human_mob.socks = random_socks(human_mob.gender)
human_mob.update_body()
+///Proc that will randomize all the external organs (i.e. horns, frills, tails etc.) of a species' associated mob
+/datum/species/proc/randomize_external_organs(mob/living/carbon/human/human_mob)
+ for(var/obj/item/organ/external/organ_path as anything in external_organs)
+ var/obj/item/organ/external/randomized_organ = human_mob.getorgan(organ_path)
+ if(randomized_organ)
+ var/new_look = pick(randomized_organ.get_global_feature_list())
+ human_mob.dna.features["[randomized_organ.feature_key]"] = new_look
+ mutant_bodyparts["[randomized_organ.feature_key]"] = new_look
+
+///Proc that randomizes all the appearance elements (external organs, markings, hair etc.) of a species' associated mob. Function set by child procs
+/datum/species/proc/randomize_features(mob/living/carbon/human/human_mob)
+ return
+
/datum/species/proc/spec_life(mob/living/carbon/human/H, delta_time, times_fired)
if(HAS_TRAIT(H, TRAIT_NOBREATH))
H.setOxyLoss(0)
diff --git a/code/modules/mob/living/carbon/human/species_types/ethereal.dm b/code/modules/mob/living/carbon/human/species_types/ethereal.dm
index 5214a4f0f7e..37ac482d056 100644
--- a/code/modules/mob/living/carbon/human/species_types/ethereal.dm
+++ b/code/modules/mob/living/carbon/human/species_types/ethereal.dm
@@ -99,6 +99,8 @@
return randname
+/datum/species/ethereal/randomize_features(mob/living/carbon/human/human_mob)
+ human_mob.dna.features["ethcolor"] = GLOB.color_list_ethereal[pick(GLOB.color_list_ethereal)]
/datum/species/ethereal/spec_updatehealth(mob/living/carbon/human/ethereal)
. = ..()
diff --git a/code/modules/mob/living/carbon/human/species_types/felinid.dm b/code/modules/mob/living/carbon/human/species_types/felinid.dm
index a70d4118949..f32f06de613 100644
--- a/code/modules/mob/living/carbon/human/species_types/felinid.dm
+++ b/code/modules/mob/living/carbon/human/species_types/felinid.dm
@@ -42,6 +42,10 @@
mutantears = /obj/item/organ/internal/ears
return ..()
+/datum/species/human/felinid/randomize_features(mob/living/carbon/human/human_mob)
+ randomize_external_organs(human_mob)
+ return ..()
+
/proc/mass_purrbation()
for(var/mob in GLOB.human_list)
purrbation_apply(mob)
diff --git a/code/modules/mob/living/carbon/human/species_types/humans.dm b/code/modules/mob/living/carbon/human/species_types/humans.dm
index ac73a68eff0..156b727c362 100644
--- a/code/modules/mob/living/carbon/human/species_types/humans.dm
+++ b/code/modules/mob/living/carbon/human/species_types/humans.dm
@@ -21,6 +21,9 @@
human.hair_color = "#bb9966" // brown
human.update_hair(is_creating = TRUE)
+/datum/species/human/randomize_features(mob/living/carbon/human/human_mob)
+ human_mob.skin_tone = random_skin_tone()
+
/datum/species/human/get_scream_sound(mob/living/carbon/human/human)
if(human.gender == MALE)
if(prob(1))
diff --git a/code/modules/mob/living/carbon/human/species_types/lizardpeople.dm b/code/modules/mob/living/carbon/human/species_types/lizardpeople.dm
index 28121cdf0e4..e4b513f4757 100644
--- a/code/modules/mob/living/carbon/human/species_types/lizardpeople.dm
+++ b/code/modules/mob/living/carbon/human/species_types/lizardpeople.dm
@@ -71,11 +71,10 @@
return randname
-/datum/species/lizard/randomize_main_appearance_element(mob/living/carbon/human/human_mob)
- var/tail = pick(GLOB.tails_list_lizard)
- human_mob.dna.features["tail_lizard"] = tail
- mutant_bodyparts["tail_lizard"] = tail
- human_mob.update_body()
+
+/datum/species/lizard/randomize_features(mob/living/carbon/human/human_mob)
+ human_mob.dna.features["body_markings"] = pick(GLOB.body_markings_list)
+ randomize_external_organs(human_mob)
/datum/species/lizard/get_scream_sound(mob/living/carbon/human/lizard)
return pick(
diff --git a/code/modules/mob/living/carbon/human/species_types/mothmen.dm b/code/modules/mob/living/carbon/human/species_types/mothmen.dm
index 7ad4f9582dd..84f3e1be318 100644
--- a/code/modules/mob/living/carbon/human/species_types/mothmen.dm
+++ b/code/modules/mob/living/carbon/human/species_types/mothmen.dm
@@ -66,13 +66,10 @@
return 10 //flyswatters deal 10x damage to moths
return 1
-/datum/species/moth/randomize_main_appearance_element(mob/living/carbon/human/human_mob)
- var/wings = pick(GLOB.moth_wings_list)
- mutant_bodyparts["wings"] = wings
- mutant_bodyparts["moth_wings"] = wings
- human_mob.dna.features["wings"] = wings
- human_mob.dna.features["moth_wings"] = wings
- human_mob.update_body()
+
+/datum/species/moth/randomize_features(mob/living/carbon/human/human_mob)
+ human_mob.dna.features["moth_markings"] = pick(GLOB.moth_markings_list)
+ randomize_external_organs(human_mob)
/datum/species/moth/get_scream_sound(mob/living/carbon/human/human)
return 'sound/voice/moth/scream_moth.ogg'
diff --git a/code/modules/mob/living/carbon/human/species_types/podpeople.dm b/code/modules/mob/living/carbon/human/species_types/podpeople.dm
index 603958f9367..9bb35b86d80 100644
--- a/code/modules/mob/living/carbon/human/species_types/podpeople.dm
+++ b/code/modules/mob/living/carbon/human/species_types/podpeople.dm
@@ -67,11 +67,9 @@
H.reagents.remove_reagent(chem.type, REAGENTS_METABOLISM * delta_time)
return TRUE
-/datum/species/pod/randomize_main_appearance_element(mob/living/carbon/human/human_mob)
- var/hairstyle = pick(GLOB.pod_hair_list)
- human_mob.dna.features["pod_hair"] = hairstyle
- mutant_bodyparts["pod_hair"] = hairstyle
- human_mob.update_body()
+
+/datum/species/pod/randomize_features(mob/living/carbon/human_mob)
+ randomize_external_organs(human_mob)
/datum/species/pod/proc/change_hairstyle(mob/living/carbon/human/human_mob, new_style)
var/obj/item/organ/external/organ = human_mob.getorganslot(ORGAN_SLOT_EXTERNAL_POD_HAIR)
diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm
index 61145f7f852..f4e89ccceb9 100644
--- a/code/modules/reagents/chemistry/reagents/other_reagents.dm
+++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm
@@ -742,7 +742,6 @@
to_chat(H, span_warning("You grit your teeth in pain as your body rapidly mutates!"))
H.visible_message("[H] suddenly transforms!")
randomize_human(H)
- H.dna.update_dna_identity()
/datum/reagent/aslimetoxin
name = "Advanced Mutation Toxin"
diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm
index ad1002148bb..92d01592230 100644
--- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm
+++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm
@@ -810,7 +810,6 @@
originalname = H.real_name
H.dna.copy_dna(originalDNA)
randomize_human(H)
- H.dna.update_dna_identity()
return ..()
// Only occasionally give examiners a warning.
diff --git a/code/modules/surgery/organs/external/_external_organs.dm b/code/modules/surgery/organs/external/_external_organs.dm
index 3a08d6249f7..5d682a44abd 100644
--- a/code/modules/surgery/organs/external/_external_organs.dm
+++ b/code/modules/surgery/organs/external/_external_organs.dm
@@ -381,6 +381,9 @@
color_source = ORGAN_COLOR_OVERRIDE
+/obj/item/organ/external/pod_hair/get_global_feature_list()
+ return GLOB.pod_hair_list
+
/obj/item/organ/external/pod_hair/can_draw_on_bodypart(mob/living/carbon/human/human)
if(!(human.head?.flags_inv & HIDEHAIR) || (human.wear_mask?.flags_inv & HIDEHAIR))
return TRUE
diff --git a/code/modules/surgery/organs/external/tails.dm b/code/modules/surgery/organs/external/tails.dm
index 8dd955e685c..2a49a02ac8f 100644
--- a/code/modules/surgery/organs/external/tails.dm
+++ b/code/modules/surgery/organs/external/tails.dm
@@ -77,6 +77,9 @@
color_source = ORGAN_COLOR_HAIR
wag_flags = WAG_ABLE
+/obj/item/organ/external/tail/cat/get_global_feature_list()
+ return GLOB.tails_list_human
+
/obj/item/organ/external/tail/monkey
color_source = NONE
@@ -89,6 +92,9 @@
///A reference to the paired_spines, since for some fucking reason tail spines are tied to the spines themselves.
var/obj/item/organ/external/spines/paired_spines
+/obj/item/organ/external/tail/lizard/get_global_feature_list()
+ return GLOB.tails_list_lizard
+
/obj/item/organ/external/tail/lizard/Insert(mob/living/carbon/reciever, special, drop_if_replaced)
. = ..()
if(.)