Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors species gender code, allows IPCs to be referred to as objects #21910

Merged
merged 4 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions code/__DEFINES/DNA.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,20 @@
#define NOFLASH 17
/// Use this if you want to change the race's color without the player being able to pick their own color. AKA special color shifting
#define DYNCOLORS 18
/// Forced genders
#define AGENDER 19
#define FGENDER 20
#define MGENDER 21
/// Do not draw eyes or eyeless overlay
#define NOEYESPRITES 22
#define NOEYESPRITES 19
/// Used for determining which wounds are applicable to this species.
/// if we have flesh (can suffer slash/piercing/burn wounds, requires they don't have NOBLOOD)
#define HAS_FLESH 23
#define HAS_FLESH 20
/// if we have bones (can suffer bone wounds)
#define HAS_BONE 24
#define HAS_BONE 21
/// Can't be husked.
#define NOHUSK 25
#define NOHUSK 22
/// have no mouth to ingest/eat with
#define NOMOUTH 26
#define NOMOUTH 23
/// has a tail
#define HAS_TAIL 27
#define NONANITES 28
#define HAS_TAIL 24
#define NONANITES 25

//organ slots
#define ORGAN_SLOT_BRAIN "brain"
Expand Down Expand Up @@ -228,9 +224,11 @@
#define CHROMOSOME_NONE 1
#define CHROMOSOME_USED 2

#define GENDERS 4
#define G_MALE 1
#define G_FEMALE 2
#define G_PLURAL 3
#define G_NEUTER 4

// Defines for used in creating "perks" for the species preference pages.
/// A key that designates UI icon displayed on the perk.
Expand Down
20 changes: 13 additions & 7 deletions code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())

switch(holder.gender)
if(MALE)
L[DNA_GENDER_BLOCK] = construct_block(G_MALE, 3)
L[DNA_GENDER_BLOCK] = construct_block(G_MALE, GENDERS)
if(FEMALE)
L[DNA_GENDER_BLOCK] = construct_block(G_FEMALE, 3)
L[DNA_GENDER_BLOCK] = construct_block(G_FEMALE, GENDERS)
if(NEUTER)
L[DNA_GENDER_BLOCK] = construct_block(G_NEUTER, GENDERS)
else
L[DNA_GENDER_BLOCK] = construct_block(G_PLURAL, 3)
L[DNA_GENDER_BLOCK] = construct_block(G_PLURAL, GENDERS)
if(ishuman(holder))
var/mob/living/carbon/human/H = holder
if(!GLOB.hair_styles_list.len)
Expand Down Expand Up @@ -326,11 +328,13 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())
if(DNA_GENDER_BLOCK)
switch(H.gender)
if(MALE)
set_uni_identity_block(blocknumber, construct_block(G_MALE, 3))
set_uni_identity_block(blocknumber, construct_block(G_MALE, GENDERS))
if(FEMALE)
set_uni_identity_block(blocknumber, construct_block(G_FEMALE, 3))
set_uni_identity_block(blocknumber, construct_block(G_FEMALE, GENDERS))
if(NEUTER)
set_uni_identity_block(blocknumber, construct_block(G_NEUTER, GENDERS))
else
set_uni_identity_block(blocknumber, construct_block(G_PLURAL, 3))
set_uni_identity_block(blocknumber, construct_block(G_PLURAL, GENDERS))
if(DNA_FACIAL_HAIR_STYLE_BLOCK)
set_uni_identity_block(blocknumber, construct_block(GLOB.facial_hair_styles_list.Find(H.facial_hair_style), GLOB.facial_hair_styles_list.len))
if(DNA_HAIR_STYLE_BLOCK)
Expand Down Expand Up @@ -573,11 +577,13 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())
if(!has_dna())
return

switch(deconstruct_block(get_uni_identity_block(dna.unique_identity, DNA_GENDER_BLOCK), 3))
switch(deconstruct_block(get_uni_identity_block(dna.unique_identity, DNA_GENDER_BLOCK), GENDERS))
if(G_MALE)
gender = MALE
if(G_FEMALE)
gender = FEMALE
if(G_NEUTER)
gender = NEUTER
else
gender = PLURAL

Expand Down
15 changes: 8 additions & 7 deletions code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,14 @@ GLOBAL_VAR_INIT(clones, 0)
var/mob/M = H.easy_random_mutate(NEGATIVE+MINOR_NEGATIVE)
if(ismob(M))
H = M
if((AGENDER || MGENDER || FGENDER) in H.dna.species.species_traits)
if((FGENDER in H.dna.species.species_traits) && (H.gender != FEMALE))
H.gender = FEMALE
if((MGENDER in H.dna.species.species_traits) && (H.gender != MALE))
H.gender = MALE
if((AGENDER in H.dna.species.species_traits) && (H.gender != PLURAL))
H.gender = PLURAL

var/list/possible_genders = H.dna.species.possible_genders
if(!possible_genders || possible_genders.len < 1)
stack_trace("[H.dna.species.type] has no possible genders!")
H.gender = PLURAL // uh oh
else if(possible_genders.len == 1)
H.gender = possible_genders[1] // some species only have one gender

if(!H.GetComponent(/datum/component/mood) && mood)
H.AddComponent(/datum/component/mood)

Expand Down
12 changes: 4 additions & 8 deletions code/game/objects/structures/mirror.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@
. += list(RACE = list("select a new race", choosable_races))
. += list(GENDER = list("Select a new gender", list()))
var/datum/species/S = H.dna.species
if(!(AGENDER in S.species_traits) || !(FGENDER in S.species_traits) || !(MGENDER in S.species_traits))
.[GENDER][2] = list(MALE, FEMALE)
if(S.possible_genders.len > 1)
.[GENDER][2] = S.possible_genders
if(!(NOEYESPRITES in S.species_traits))
. += list(EYE_COLOR)
if(S.use_skintones)
Expand Down Expand Up @@ -249,12 +249,8 @@
if(RACE)
var/newrace = GLOB.species_list[selection]
H.set_species(newrace, icon_update=0)
if(FGENDER in S.species_traits)
H.gender = FEMALE
if(MGENDER in S.species_traits)
H.gender = MALE
if(AGENDER in S.species_traits)
H.gender = PLURAL
if(S.possible_genders.len < 2)
H.gender = S.possible_genders[1]
return TRUE
if(SKIN_COLOR)
H.skin_tone = selection
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/create_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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)
human.gender = human.dna ? pick(human.dna.species.possible_genders) : pick(MALE, FEMALE, PLURAL, NEUTER)
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)
Expand Down
30 changes: 11 additions & 19 deletions code/modules/client/preferences/gender.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,23 @@
priority = PREFERENCE_PRIORITY_GENDER

/datum/preference/choiced/gender/init_possible_values()
return list(MALE, FEMALE, PLURAL)
return list(MALE, FEMALE, PLURAL, NEUTER)

/datum/preference/choiced/gender/create_informed_default_value(datum/preferences/preferences)

var/datum/species/species_type = preferences.read_preference(/datum/preference/choiced/species)

if(!initial(species_type.sexes) || (AGENDER in initial(species_type.species_traits)))
return PLURAL
else if(FGENDER in initial(species_type.species_traits))
return FEMALE
else if(MGENDER in initial(species_type.species_traits))
return MALE

return pick(list(MALE, FEMALE, PLURAL))
var/list/possible_genders = initial(species_type.possible_genders)
if(possible_genders.len < 1)
stack_trace("[species_type.type] has no possible genders!")
return list(PLURAL)

return pick(possible_genders)

/datum/preference/choiced/gender/apply_to_human(mob/living/carbon/human/target, value)
var/datum/species/S = target.dna.species

if(!S.sexes || (AGENDER in S.species_traits))
value = PLURAL //disregard gender preferences on this species

if(S)
if(FGENDER in S.species_traits)
value = FEMALE
else if(MGENDER in S.species_traits)
value = MALE

target.gender = value
if(!(value in S.possible_genders))
target.gender = pick(S.possible_genders)
else
target.gender = value
2 changes: 1 addition & 1 deletion code/modules/client/preferences/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
data[species_id]["lore"] = species.get_species_lore()
data[species_id]["icon"] = sanitize_css_class_name(species.name)
data[species_id]["use_skintones"] = species.use_skintones
data[species_id]["sexes"] = species.sexes && !((FGENDER in species.species_traits) || (MGENDER in species.species_traits) || (AGENDER in species.species_traits))
data[species_id]["possible_genders"] = species.possible_genders
data[species_id]["enabled_features"] = species.get_features()
data[species_id]["perks"] = species.get_species_perks()
data[species_id]["diet"] = species.get_species_diet()
Expand Down
20 changes: 11 additions & 9 deletions code/modules/mob/living/carbon/human/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ GLOBAL_LIST_EMPTY(features_by_species)
var/plural_form
/// if alien colors are disabled, this is the color that will be used by that race
var/default_color = "#FFF"
/// whether or not the race has sexual characteristics. at the moment this is only FALSE for skeletons and shadows
var/sexes = TRUE

///A list that contains pixel offsets for various clothing features, if your species is a different shape
var/list/offset_features = list(OFFSET_UNIFORM = list(0,0), OFFSET_ID = list(0,0), OFFSET_GLOVES = list(0,0), OFFSET_GLASSES = list(0,0), OFFSET_EARS = list(0,0), OFFSET_SHOES = list(0,0), OFFSET_S_STORE = list(0,0), OFFSET_FACEMASK = list(0,0), OFFSET_HEAD = list(0,0), OFFSET_FACE = list(0,0), OFFSET_BELT = list(0,0), OFFSET_BACK = list(0,0), OFFSET_SUIT = list(0,0), OFFSET_NECK = list(0,0))
Expand All @@ -38,6 +36,8 @@ GLOBAL_LIST_EMPTY(features_by_species)

var/forced_skintone

/// What genders can this race be?
var/list/possible_genders = list(MALE, PLURAL, FEMALE)
/// If your race wants to bleed something other than bog standard blood, change this to reagent id.
var/datum/reagent/exotic_blood
///If your race uses a non standard bloodtype (A+, O-, AB-, etc)
Expand Down Expand Up @@ -432,13 +432,15 @@ GLOBAL_LIST_EMPTY(features_by_species)
replacement.Insert(C, TRUE, FALSE)

/datum/species/proc/on_species_gain(mob/living/carbon/C, datum/species/old_species, pref_load)
// Change the gender to fit with the new species
if(!possible_genders || possible_genders.len < 1)
stack_trace("[type] has no possible genders!")
C.gender = PLURAL // uh oh
else if(possible_genders.len == 1)
C.gender = possible_genders[1] // some species only have one gender
else if(!(C.gender in possible_genders))
C.gender = pick(possible_genders) // randomized gender
// Drop the items the new species can't wear
if((AGENDER in species_traits))
C.gender = PLURAL
if((FGENDER in species_traits))
C.gender = FEMALE
if((MGENDER in species_traits))
C.gender = MALE
extra_no_equip = old_species.extra_no_equip.Copy()
for(var/slot_id in no_equip)
var/obj/item/thing = C.get_item_by_slot(slot_id)
Expand Down Expand Up @@ -801,7 +803,7 @@ GLOBAL_LIST_EMPTY(features_by_species)
if(undershirt)
if(HAS_TRAIT(H, TRAIT_SKINNY)) //Check for skinny first
standing += wear_skinny_version(undershirt.icon_state, undershirt.icon, BODY_LAYER)
else if(H.dna.species.sexes && H.gender == FEMALE)
else if(H.gender == FEMALE && (FEMALE in possible_genders))
standing += wear_female_version(undershirt.icon_state, undershirt.icon, BODY_LAYER)
else
standing += mutable_appearance(undershirt.icon, undershirt.icon_state, -BODY_LAYER)
Expand Down
15 changes: 11 additions & 4 deletions code/modules/mob/living/carbon/human/species_types/IPC.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
id = "ipc"
say_mod = "states" //inherited from a user's real species
bubble_icon = BUBBLE_ROBOT // beep boop
sexes = FALSE
species_traits = list(NOTRANSSTING,NOEYESPRITES,NO_DNA_COPY,NOZOMBIE,MUTCOLORS,NOHUSK,AGENDER,NOBLOOD,NO_UNDERWEAR)
possible_genders = list(PLURAL, NEUTER) // A MERE OBJECT
species_traits = list(NOTRANSSTING,NOEYESPRITES,NO_DNA_COPY,NOZOMBIE,MUTCOLORS,NOHUSK,NOBLOOD,NO_UNDERWEAR)
inherent_traits = list(TRAIT_RESISTCOLD,TRAIT_RADIMMUNE,TRAIT_NOBREATH,TRAIT_LIMBATTACHMENT,TRAIT_EASYDISMEMBER,TRAIT_NOCRITDAMAGE,TRAIT_GENELESS,TRAIT_MEDICALIGNORE,TRAIT_NOCLONE,TRAIT_TOXIMMUNE,TRAIT_EASILY_WOUNDED,TRAIT_NODEFIB,TRAIT_POWERHUNGRY)
inherent_biotypes = MOB_ROBOTIC|MOB_HUMANOID
mutantbrain = /obj/item/organ/brain/positron
Expand Down Expand Up @@ -390,8 +390,10 @@ ipc martial arts stuff
var/list/initial_mutant_bodyparts
var/list/initial_step_sounds
var/list/initial_walk_sounds
var/list/initial_genders
var/list/blacklisted_species = list(/datum/species/ethereal, /datum/species/moth)//species that really don't work with this system (lizards aren't quite right either, but whatever)
var/list/old_features
var/old_gender
var/ipc_color
var/disguised = FALSE

Expand All @@ -401,6 +403,7 @@ ipc martial arts stuff
initial_mutant_bodyparts = LAZYCOPY(mutant_bodyparts)
initial_step_sounds = LAZYCOPY(special_step_sounds)
initial_walk_sounds = LAZYCOPY(special_walk_sounds)
initial_genders = LAZYCOPY(possible_genders)
ipc_color = sanitize_hexcolor("[pick("7F", "FF")][pick("7F", "FF")][pick("7F", "FF")]")

fake_species = new /datum/species/human() //default is human
Expand Down Expand Up @@ -430,7 +433,10 @@ ipc martial arts stuff
disguised = TRUE
name = fake_species.name
say_mod = fake_species.say_mod
sexes = fake_species.sexes
old_gender = H.gender
possible_genders = fake_species.possible_genders
if(!(H.gender in fake_species.possible_genders))
H.gender = pick(fake_species.possible_genders)
species_traits = LAZYCOPY(initial_species_traits)
inherent_traits = LAZYCOPY(initial_inherent_traits)
mutant_bodyparts = LAZYCOPY(fake_species.mutant_bodyparts)
Expand Down Expand Up @@ -461,7 +467,8 @@ ipc martial arts stuff
disguised = FALSE
name = initial(name)
say_mod = initial(say_mod)
sexes = initial(sexes)
H.gender = old_gender
possible_genders = LAZYCOPY(initial_genders)
species_traits = LAZYCOPY(initial_species_traits)
inherent_traits = LAZYCOPY(initial_inherent_traits)
mutant_bodyparts = LAZYCOPY(initial_mutant_bodyparts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "Abductor"
id = "abductor"
say_mod = "gibbers"
sexes = FALSE
possible_genders = list(PLURAL)
species_traits = list(NOBLOOD,NOEYESPRITES)
inherent_traits = list(TRAIT_VIRUSIMMUNE,TRAIT_NOGUNS,TRAIT_NOHUNGER,TRAIT_NOBREATH,TRAIT_RADIMMUNE,TRAIT_GENELESS)
mutanttongue = /obj/item/organ/tongue/abductor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
id = "android"
say_mod = "states"
bubble_icon = BUBBLE_ROBOT
sexes = FALSE
possible_genders = list(PLURAL, NEUTER)
species_traits = list(NOBLOOD, NOZOMBIE, NOHUSK, NO_DNA_COPY, NOTRANSSTING)
inherent_traits = list(TRAIT_RESISTHEAT,TRAIT_COLDBLOODED,TRAIT_NOBREATH,TRAIT_RESISTCOLD,TRAIT_RESISTHIGHPRESSURE,TRAIT_RESISTLOWPRESSURE,TRAIT_RADIMMUNE,TRAIT_NOCLONE,TRAIT_TOXIMMUNE,TRAIT_GENELESS,TRAIT_NOFIRE,TRAIT_PIERCEIMMUNE,TRAIT_NOHUNGER,TRAIT_LIMBATTACHMENT,TRAIT_MEDICALIGNORE)
inherent_biotypes = MOB_ROBOTIC|MOB_HUMANOID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
punchstunthreshold = 11 //Still stuns on max hit, but subsequently lower chance to stun overall
attack_type = BURN //burn bish
damage_overlay_type = "" //We are too cool for regular damage overlays
species_traits = list(NOEYESPRITES, EYECOLOR, MUTCOLORS, AGENDER, HAIR, FACEHAIR, HAS_FLESH) // i mean i guess they have blood so they can have wounds too
species_traits = list(NOEYESPRITES, EYECOLOR, MUTCOLORS, HAIR, FACEHAIR, HAS_FLESH) // i mean i guess they have blood so they can have wounds too
changesource_flags = MIRROR_BADMIN | WABBAJACK | MIRROR_PRIDE | MIRROR_MAGIC | RACE_SWAP | ERT_SPAWN | SLIME_EXTRACT
inherent_traits = list(TRAIT_POWERHUNGRY, TRAIT_RADIMMUNE)
mutant_bodyparts = list("ethereal_mark")
default_features = list("ethereal_mark" = "Eyes", "mcolor" = "#ffffff")
species_language_holder = /datum/language_holder/ethereal
deathsound = 'yogstation/sound/voice/ethereal/deathsound.ogg'
screamsound = list('sound/voice/ethereal/ethereal_scream_1.ogg', 'sound/voice/ethereal/ethereal_scream_2.ogg', 'sound/voice/ethereal/ethereal_scream_3.ogg')
sexes = FALSE //no fetish content allowed
possible_genders = list(PLURAL) //no fetish content allowed
toxic_food = NONE
inert_mutation = RADIANTBURST
hair_color = "fixedmutcolor"
Expand Down
Loading
Loading