Files
Bubberstation/code/modules/client/preferences/names.dm
MrMelbert 0cc5cfb178 Random Name Generation refactor, generate random names based on languages (for species without name lists, like Felinids and Podpeople) (#83021)
## About The Pull Request

This PR moves random name generation for species onto their languages. 

What does this mean? 

- For species with a predefined name list, such as Lizards and Moths,
nothing.

- For species without predefined name lists, such as Felinids, their
names will now be randomly generated from their language's syllables.


![image](https://github.com/tgstation/tgstation/assets/51863163/dddce7a6-5882-4f97-b817-c8922033c8d2)


![image](https://github.com/tgstation/tgstation/assets/51863163/e34e03e9-bcca-45ff-84e4-239e606cd24f)

(In the prefs menu:) 


![image](https://github.com/tgstation/tgstation/assets/51863163/eb6ccf9b-8b1c-4637-b46e-66cab9c8aac0)

Why? 

- Well, we actually had some dead code that did this. All I did was fix
it up and re-enable it.
- Generates some pretty believable in-universe names for various
languages that are lacking name lists. Obviously defined lists would be
preferred, but until they are added, at least.
- Moves some stuff off of species, which is always nice. 
- Also hopefully makes it a tad easier to work with name generation.
There's now a standard framework for getting a random name for a mob,
and for getting a random name based on a species.

Misc: 

- Adds a generic `species_prototype` global, uses it in a lot of places
in prefs code.
- Makes `GLOB.species_list` init via the global defines
- Deletes Language SS
- Alphabetizes some instances of admin tooling using the list of all
species IDs
- Docs language stuff
- Deletes random_skin_tone, it does pretty much nothin

## Changelog

🆑 Melbert
refactor: Random Name Generation has been refactored. Report any
instances of people having weird (or "Unknown") names.
qol: Felinids, Slimepeople, Podpeople, and some other species without
defined namelists now automatically generate names based on their
primary language(s).
qol: More non-human names can be generated in codewords (and other misc.
areas) than just lizard names.
/🆑
2024-05-04 12:21:26 -06:00

177 lines
5.1 KiB
Plaintext

/// A preference for a name. Used not just for normal names, but also for clown names, etc.
/datum/preference/name
category = "names"
priority = PREFERENCE_PRIORITY_NAMES
savefile_identifier = PREFERENCE_CHARACTER
abstract_type = /datum/preference/name
/// The display name when showing on the "other names" panel
var/explanation
/// These will be grouped together on the preferences menu
var/group
/// Whether or not to allow numbers in the person's name
var/allow_numbers = FALSE
/// If the highest priority job matches this, will prioritize this name in the UI
var/relevant_job
/datum/preference/name/apply_to_human(mob/living/carbon/human/target, value)
// Only real_name applies directly, everything else is applied by something else
return
/datum/preference/name/deserialize(input, datum/preferences/preferences)
return reject_bad_name("[input]", allow_numbers)
/datum/preference/name/serialize(input)
// `is_valid` should always be run before `serialize`, so it should not
// be possible for this to return `null`.
return reject_bad_name(input, allow_numbers)
/datum/preference/name/is_valid(value)
return istext(value) && !isnull(reject_bad_name(value, allow_numbers))
/// A character's real name
/datum/preference/name/real_name
explanation = "Name"
// The `_` makes it first in ABC order.
group = "_real_name"
savefile_key = "real_name"
/datum/preference/name/real_name/apply_to_human(mob/living/carbon/human/target, value)
target.real_name = value
target.name = value
target.log_mob_tag("TAG: [target.tag] RENAMED: [key_name(target)]")
/datum/preference/name/real_name/create_informed_default_value(datum/preferences/preferences)
return generate_random_name_species_based(
preferences.read_preference(/datum/preference/choiced/gender),
TRUE,
preferences.read_preference(/datum/preference/choiced/species),
)
/datum/preference/name/real_name/deserialize(input, datum/preferences/preferences)
input = ..(input)
if (!input)
return input
if (CONFIG_GET(flag/humans_need_surnames) && preferences.read_preference(/datum/preference/choiced/species) == /datum/species/human)
var/first_space = findtext(input, " ")
if(!first_space) //we need a surname
input += " [pick(GLOB.last_names)]"
else if(first_space == length(input))
input += "[pick(GLOB.last_names)]"
return reject_bad_name(input, allow_numbers)
/// The name for a backup human, when nonhumans are made into head of staff
/datum/preference/name/backup_human
explanation = "Backup human name"
group = "backup_human"
savefile_key = "human_name"
/datum/preference/name/backup_human/create_informed_default_value(datum/preferences/preferences)
return generate_random_name(preferences.read_preference(/datum/preference/choiced/gender))
/datum/preference/name/clown
savefile_key = "clown_name"
explanation = "Clown name"
group = "fun"
relevant_job = /datum/job/clown
/datum/preference/name/clown/create_default_value()
return pick(GLOB.clown_names)
/datum/preference/name/mime
savefile_key = "mime_name"
explanation = "Mime name"
group = "fun"
relevant_job = /datum/job/mime
/datum/preference/name/mime/create_default_value()
return pick(GLOB.mime_names)
/datum/preference/name/cyborg
savefile_key = "cyborg_name"
allow_numbers = TRUE
can_randomize = FALSE
explanation = "Cyborg name"
group = "silicons"
relevant_job = /datum/job/cyborg
/datum/preference/name/cyborg/create_default_value()
return DEFAULT_CYBORG_NAME
/datum/preference/name/ai
savefile_key = "ai_name"
allow_numbers = TRUE
explanation = "AI name"
group = "silicons"
relevant_job = /datum/job/ai
/datum/preference/name/ai/create_default_value()
return pick(GLOB.ai_names)
/datum/preference/name/religion
savefile_key = "religion_name"
allow_numbers = TRUE
explanation = "Religion name"
group = "religion"
/datum/preference/name/religion/create_default_value()
return pick(GLOB.religion_names)
/datum/preference/name/deity
savefile_key = "deity_name"
allow_numbers = TRUE
can_randomize = FALSE
explanation = "Deity name"
group = "religion"
/datum/preference/name/deity/create_default_value()
return DEFAULT_DEITY
/datum/preference/name/bible
savefile_key = "bible_name"
allow_numbers = TRUE
can_randomize = FALSE
explanation = "Bible name"
group = "religion"
/datum/preference/name/bible/create_default_value()
return DEFAULT_BIBLE
/// The first name given to nuclear operative antagonists. The last name will be chosen by the team leader.
/datum/preference/name/operative_alias
savefile_key = "operative_alias"
allow_numbers = TRUE //You can get a little wacky with your alias nobody will judge you
explanation = "Operative Alias"
group = "antagonists"
/datum/preference/name/operative_alias/create_default_value()
return pick(GLOB.operative_aliases)
/datum/preference/name/operative_alias/is_accessible(datum/preferences/preferences)
. = ..()
if(!.)
return FALSE
// If one of the roles is ticked in the antag prefs menu, this option will show.
var/static/list/ops_roles = list(ROLE_OPERATIVE, ROLE_LONE_OPERATIVE, ROLE_OPERATIVE_MIDROUND, ROLE_CLOWN_OPERATIVE)
if(length(ops_roles & preferences.be_special))
return TRUE
return FALSE