Skip to content

Commit

Permalink
Merge pull request Baystation12#35033 from Spookerton/spkrtn/cng/sing…
Browse files Browse the repository at this point in the history
…leton-species

singleton species, organs Init instead of New
  • Loading branch information
SierraKomodo authored Jan 8, 2025
2 parents 21383a4 + c0768ab commit 6bbdec4
Show file tree
Hide file tree
Showing 89 changed files with 473 additions and 502 deletions.
1 change: 0 additions & 1 deletion baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
#include "code\_helpers\names.dm"
#include "code\_helpers\sanitize_values.dm"
#include "code\_helpers\spawn_sync.dm"
#include "code\_helpers\species.dm"
#include "code\_helpers\storage.dm"
#include "code\_helpers\system.dm"
#include "code\_helpers\text.dm"
Expand Down
20 changes: 1 addition & 19 deletions code/_helpers/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ var/global/list/landmarks_list = list() //list of all landmarks created
#define all_genders_text_list list("Male","Female","Plural","Neuter")

//Languages/species/whitelist.
var/global/list/all_species[0]

var/global/list/datum/language/all_languages = list()
var/global/list/language_keys[0] // Table of say codes for all languages
var/global/list/playable_species = list(SPECIES_HUMAN) // A list of ALL playable species, whitelisted, latejoin or otherwise.


GLOBAL_LIST_EMPTY(all_particles)

Expand Down Expand Up @@ -134,22 +132,6 @@ var/global/list/string_slot_flags = list(
if(!(L.flags & NONGLOBAL))
language_keys[lowertext(L.key)] = L

var/rkey = 0
paths = typesof(/datum/species)
for(var/T in paths)

rkey++

var/datum/species/S = T
if(!initial(S.name))
continue

S = new T
S.race_key = rkey //Used in mob icon caching.
all_species[S.name] = S
if(!(S.spawn_flags & SPECIES_IS_RESTRICTED))
playable_species += S.name

//Grabs
paths = typesof(/datum/grab) - /datum/grab
for(var/T in paths)
Expand Down
17 changes: 9 additions & 8 deletions code/_helpers/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,35 @@
var/M = AM.get_mob()
if(M)
mobs += M

return mobs


/proc/random_hair_style(gender, species = SPECIES_HUMAN)
var/h_style = "Bald"

var/datum/species/mob_species = all_species[species]
var/singleton/species/mob_species = GLOB.species_by_name[species]
var/list/valid_hairstyles = mob_species.get_hair_styles()
if(length(valid_hairstyles))
h_style = pick(valid_hairstyles)

return h_style


/proc/random_facial_hair_style(gender, species = SPECIES_HUMAN)
var/f_style = "Shaved"
var/datum/species/mob_species = all_species[species]
var/singleton/species/mob_species = GLOB.species_by_name[species]
var/list/valid_facialhairstyles = mob_species.get_facial_hair_styles(gender)
if(length(valid_facialhairstyles))
f_style = pick(valid_facialhairstyles)
return f_style


/proc/random_name(gender, species = SPECIES_HUMAN)
var/datum/species/current_species = all_species[species]
var/singleton/species/current_species = GLOB.species_by_name[species]
var/singleton/cultural_info/current_culture = SSculture.get_culture(current_species.default_cultural_info[TAG_CULTURE])
return current_culture.get_random_name(gender)

/proc/random_skin_tone(datum/species/current_species)
var/species_tone = current_species ? 35 - current_species.max_skin_tone() : -185

/proc/random_skin_tone(singleton/species/species)
var/species_tone = species ? 35 - species.max_skin_tone() : -185
switch(pick(60;"caucasian", 15;"afroamerican", 10;"african", 10;"latino", 5;"albino"))
if("caucasian") . = -10
if("afroamerican") . = -115
Expand Down
14 changes: 0 additions & 14 deletions code/_helpers/species.dm

This file was deleted.

10 changes: 5 additions & 5 deletions code/datums/mil_ranks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GLOBAL_DATUM_INIT(mil_branches, /datum/mil_branches, new)
/**
* Return all spawn branches for the given input
*/
/datum/mil_branches/proc/spawn_branches(datum/species/S)
/datum/mil_branches/proc/spawn_branches(singleton/species/S)
if(!S)
return spawn_branches_.Copy()
. = LAZYACCESS(spawn_branches_by_species_, S)
Expand All @@ -67,21 +67,21 @@ GLOBAL_DATUM_INIT(mil_branches, /datum/mil_branches, new)
/**
* Return all spawn ranks for the given input
*/
/datum/mil_branches/proc/spawn_ranks(branch_name, datum/species/S)
/datum/mil_branches/proc/spawn_ranks(branch_name, singleton/species/S)
var/datum/mil_branch/branch = get_branch(branch_name)
return branch && branch.spawn_ranks(S)

/**
* Return a true value if branch_name is a valid spawn branch key
*/
/datum/mil_branches/proc/is_spawn_branch(branch_name, datum/species/S)
/datum/mil_branches/proc/is_spawn_branch(branch_name, singleton/species/S)
return (branch_name in spawn_branches(S))


/**
* Return a true value if rank_name is a valid spawn rank in branch under branch_name
*/
/datum/mil_branches/proc/is_spawn_rank(branch_name, rank_name, datum/species/S)
/datum/mil_branches/proc/is_spawn_rank(branch_name, rank_name, singleton/species/S)
var/datum/mil_branch/branch = get_branch(branch_name)
if(branch && (rank_name in branch.spawn_ranks(S)))
return TRUE
Expand Down Expand Up @@ -130,7 +130,7 @@ GLOBAL_DATUM_INIT(mil_branches, /datum/mil_branches, new)
if(rank_path in spawn_rank_types)
spawn_ranks_[rank.name] = rank

/datum/mil_branch/proc/spawn_ranks(datum/species/S)
/datum/mil_branch/proc/spawn_ranks(singleton/species/S)
if(!S)
return spawn_ranks_.Copy()
. = spawn_ranks_by_species_[S]
Expand Down
4 changes: 2 additions & 2 deletions code/datums/outfits/outfit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ var/global/list/outfits_singletons_by_type_
// If you want to add more items that has species restriction, consider follow-
// ing the same format as the gloves shown in the code below. Thanks.
/singleton/hierarchy/outfit/proc/check_and_try_equip_xeno(mob/living/carbon/human/H)
var/datum/species/S = H.species
if (!S || istype(S, /datum/species/human)) // null failcheck & get out here you damn humans
var/singleton/species/S = H.species
if (!S || istype(S, /singleton/species/human)) // null failcheck & get out here you damn humans
return

// Gloves
Expand Down
6 changes: 3 additions & 3 deletions code/datums/traits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ As a specific example: Previously water checked for either the mob type `/mob/li
## What is a Trait?


* A trait is at this time simply a `/decl` with a name, description, and potency:
* A trait is at this time simply a `/singleton` with a name, description, and potency:
* Simply has the trait, or:
* Minor/Moderate/Major (or a subset thereof)
* Traits are currently primarily checked for during various interactions between chemicals and mobs, but can potentially be used anywhere a mob type or species check is currently made.
* Trait checks can either merely check if a mob has a given trait, or have the trait potency affect the effect of the interaction.
* Can be used by both `/mob/living` and `/datum/species` subtypes. In the latter case traits are granted to all `/mob/living/carbon` instances of a given species.
* Can be used by both `/mob/living` and `/singleton/species` subtypes. In the latter case traits are granted to all `/mob/living/carbon` instances of a given species.

## What makes a good Trait?

Expand All @@ -29,7 +29,7 @@ If you plan to add your own trait, it's worthwhile to consider the following poi

## Future Potential

Traits do not necessarily have to be granted to entire `/mob/living` or `/datum/species` types, it is technically possible to grant them to individual mob instances as there are procs for doing so.
Traits do not necessarily have to be granted to entire `/mob/living` or `/singleton/species` types, it is technically possible to grant them to individual mob instances as there are procs for doing so.

Some examples for those inclined to implement practical uses:

Expand Down
6 changes: 3 additions & 3 deletions code/game/antagonist/outsider/vox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ GLOBAL_LIST_EMPTY(vox_artifact_spawners)
if (player_is_antag(player))
log_debug("[key_name(player)] is not eligible to become a [role_text]: They are already an antagonist!")
continue
if(!is_alien_whitelisted(player.current, all_species[SPECIES_VOX]))
if(!is_alien_whitelisted(player.current, GLOB.species_by_name[SPECIES_VOX]))
log_debug("[player.current.ckey] is not whitelisted")
continue
var/result = can_become_antag_detailed(player)
Expand All @@ -65,14 +65,14 @@ GLOBAL_LIST_EMPTY(vox_artifact_spawners)
else if (player in pending_antagonists)
else if(!can_become_antag(player))
else if(player_is_antag(player))
else if(!is_alien_whitelisted(player.current, all_species[SPECIES_VOX]))
else if(!is_alien_whitelisted(player.current, GLOB.species_by_name[SPECIES_VOX]))
else
candidates |= player

return candidates

/datum/antagonist/vox/can_become_antag_detailed(datum/mind/player, ignore_role)
if(!is_alien_whitelisted(player.current, all_species[SPECIES_VOX]))
if(!is_alien_whitelisted(player.current, GLOB.species_by_name[SPECIES_VOX]))
return "Player doesn't have vox whitelist"
..()

Expand Down
2 changes: 1 addition & 1 deletion code/game/antagonist/station/changeling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ GLOBAL_DATUM_INIT(changelings, /datum/antagonist/changeling, new)
return 1
else if(isnewplayer(player.current))
if(player.current.client && player.current.client.prefs)
var/datum/species/S = all_species[player.current.client.prefs.species]
var/singleton/species/S = GLOB.species_by_name[player.current.client.prefs.species]
if(S?.species_flags & SPECIES_FLAG_NO_SCAN|SPECIES_FLAG_NEED_DIRECT_ABSORB)
return 0
if(player.current.client.prefs.organ_data[BP_CHEST] == "cyborg") // Full synthetic.
Expand Down
6 changes: 3 additions & 3 deletions code/game/gamemodes/cult/manifest.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/datum/species/human/cult
/singleton/species/human/cult
name = "Cult"
spawn_flags = SPECIES_IS_RESTRICTED
brute_mod = 2
Expand All @@ -10,12 +10,12 @@
TAG_FACTION = FACTION_OTHER
)

/datum/species/human/cult/handle_death(mob/living/carbon/human/H)
/singleton/species/human/cult/handle_death(mob/living/carbon/human/H)
spawn(1)
if(H)
H.dust()

/datum/species/human/cult/handle_post_spawn(mob/living/carbon/human/H)
/singleton/species/human/cult/handle_post_spawn(mob/living/carbon/human/H)
H.skin_tone = 35
H.eye_color = "#e60707"
H.update_eyes()
12 changes: 6 additions & 6 deletions code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@
return (supplied_title == desired_title) || (H.mind && H.mind.role_alt_title == desired_title)

/datum/job/proc/is_restricted(datum/preferences/prefs, feedback)
var/datum/species/S
var/singleton/species/S

if (!is_species_whitelist_allowed(prefs.client, use_species_whitelist))
S = all_species[use_species_whitelist]
S = GLOB.species_by_name[use_species_whitelist]
to_chat(feedback, SPAN_CLASS("boldannounce", "\An [S] species whitelist is required for [title]."))
return TRUE

Expand All @@ -210,7 +210,7 @@
to_chat(feedback, SPAN_CLASS("boldannounce", "Wrong rank for [title]. Valid ranks in [prefs.branches[title]] are: [get_ranks(prefs.branches[title])]."))
return TRUE

S = all_species[prefs.species]
S = GLOB.species_by_name[prefs.species]
if(!is_species_allowed(S))
to_chat(feedback, SPAN_CLASS("boldannounce", "Restricted species, [S], for [title]."))
return TRUE
Expand Down Expand Up @@ -245,7 +245,7 @@
active++
return active

/datum/job/proc/is_species_allowed(datum/species/S)
/datum/job/proc/is_species_allowed(singleton/species/S)
if(GLOB.using_map.is_species_job_restricted(S, src))
return FALSE
// We also make sure that there is at least one valid branch-rank combo for the species.
Expand All @@ -262,7 +262,7 @@
return is_species_whitelisted(C.mob, use_species_whitelist)

// Don't use if the map doesn't use branches but jobs do.
/datum/job/proc/get_branch_rank(datum/species/S)
/datum/job/proc/get_branch_rank(singleton/species/S)
. = species_branch_rank_cache_[S]
if(.)
return
Expand Down Expand Up @@ -380,7 +380,7 @@
reasons["Your rank choice does not allow it."] = TRUE
if (!is_species_whitelist_allowed(caller))
reasons["You do not have the required [use_species_whitelist] species whitelist."] = TRUE
var/datum/species/S = all_species[caller.prefs.species]
var/singleton/species/S = GLOB.species_by_name[caller.prefs.species]
if(S)
if(!is_species_allowed(S))
reasons["Your species choice does not allow it."] = TRUE
Expand Down
6 changes: 3 additions & 3 deletions code/game/jobs/whitelist.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var/global/list/alien_whitelist = list()
return 1

/proc/is_species_whitelisted(mob/M, species_name)
var/datum/species/S = all_species[species_name]
var/singleton/species/S = GLOB.species_by_name[species_name]
return is_alien_whitelisted(M, S)

//todo: admin aliens
Expand All @@ -70,8 +70,8 @@ var/global/list/alien_whitelist = list()
return 1
return whitelist_lookup(L.name, M.ckey)

if(istype(species,/datum/species))
var/datum/species/S = species
if(istype(species,/singleton/species))
var/singleton/species/S = species
if(!(S.spawn_flags & (SPECIES_IS_WHITELISTED|SPECIES_IS_RESTRICTED)))
return 1
return whitelist_lookup(S.get_bodytype(S), M.ckey)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/bioprinter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
/obj/item/organ = null
)
var/datum/dna/loaded_dna_datum
var/datum/species/loaded_species //For quick refrencing
var/singleton/species/loaded_species //For quick refrencing

/obj/machinery/organ_printer/flesh/mapped/Initialize()
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/movietitles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ GLOBAL_LIST(end_titles)
else if(H.real_name)
corpses += H.real_name
for(var/spec in monkies)
var/datum/species/S = all_species[spec]
var/singleton/species/S = GLOB.species_by_name[spec]
corpses += "[monkies[spec]] [lowertext(monkies[spec] > 1 ? S.name_plural : S.name)]"
if(length(corpses))
titles += "<center>BASED ON REAL EVENTS<br>In memory of [english_list(corpses)].</center>"
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/robot/robot_parts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@

/obj/item/robot_parts/chest/proc/GetCyborgSpecies()
. = list()
for(var/N in playable_species)
var/datum/species/S = all_species[N]
for(var/N in GLOB.playable_species)
var/singleton/species/S = GLOB.species_by_name[N]
if(S.spawn_flags & SPECIES_NO_FBP_CONSTRUCTION)
continue
. += N
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/view_variables/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
to_chat(usr, "This can only be done to instances of type /mob/living/carbon/human")
return

var/new_species = input("Please choose a new species.","Species",null) as null|anything in all_species
var/new_species = input("Please choose a new species.","Species",null) as null | anything in GLOB.species_by_name

if(!H)
to_chat(usr, "Mob doesn't exist anymore")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define GET_ALLOWED_VALUES(write_to, check_key) \
var/datum/species/S = all_species[pref.species]; \
var/singleton/species/S = GLOB.species_by_name[pref.species]; \
if(!S) { \
write_to = list(); \
} else if(S.force_cultural_info[check_key]) { \
Expand Down
Loading

0 comments on commit 6bbdec4

Please sign in to comment.