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

add: species age restrictions #6101

Open
wants to merge 5 commits into
base: master220
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 0 additions & 3 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#define TOXIN_TO_INTERNAL_DAMAGE_MULTIPLIER 2 // coefficient wich defines ratio of toxin into internal organs damage transfer

#define AGE_MIN 17 //youngest a character can be
#define AGE_MAX 85 //oldest a character can be


#define LEFT 1
#define RIGHT 2
Expand Down
10 changes: 10 additions & 0 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@

#define EXP_DEPT_TYPE_LIST list(EXP_TYPE_SERVICE, EXP_TYPE_MEDICAL, EXP_TYPE_ENGINEERING, EXP_TYPE_SCIENCE, EXP_TYPE_SECURITY, EXP_TYPE_COMMAND, EXP_TYPE_SILICON, EXP_TYPE_SPECIAL)


/// Tags for 'age needed for this job' list.
#define SPECIES_AGE_MIN "Min"
#define SPECIES_AGE_MAX "Max"
#define JOB_MIN_AGE_HIGH_ED "Higher Education"
#define JOB_MIN_AGE_COMMAND "Command"

#define AGE_SHEET list(SPECIES_AGE_MIN = 18, SPECIES_AGE_MAX = 85, JOB_MIN_AGE_HIGH_ED = 30, JOB_MIN_AGE_COMMAND = 30)


// Defines just for parallax because its levels make storing it in the regular prefs a pain in the ass
// These dont need to be bitflags because there isnt going to be more than one at a time of these active
// But its gonna piss off my OCD if it isnt bitflags, so deal with it, -affected
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/engineering.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ACCESS_HEADS, ACCESS_CONSTRUCTION, ACCESS_SEC_DOORS,
ACCESS_CE, ACCESS_RC_ANNOUNCE, ACCESS_KEYCARD_AUTH, ACCESS_TCOMSAT, ACCESS_MINISAT, ACCESS_MECHANIC, ACCESS_MINERAL_STOREROOM)
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
exp_requirements = 3000
exp_type = EXP_TYPE_ENGINEERING
outfit = /datum/outfit/job/chief_engineer
Expand Down
16 changes: 10 additions & 6 deletions code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
var/exp_max = 0 //Max EXP, then hide
var/exp_type_max = ""

var/min_age_allowed = 0
var/min_age_type = SPECIES_AGE_MIN
var/disabilities_allowed = 1
var/transfer_allowed = TRUE // If false, ID computer will always discourage transfers to this job, even if player is eligible
var/hidden_from_job_prefs = FALSE // if true, job preferences screen never shows this job.
Expand All @@ -69,7 +69,7 @@
var/salary = 0
var/min_start_money = 0
var/max_start_money = 0

var/outfit = null

/////////////////////////////////
Expand Down Expand Up @@ -141,11 +141,15 @@
return 0

/datum/job/proc/character_old_enough(client/C)
. = FALSE

if(!C)
return FALSE
if(C.prefs.age >= min_age_allowed)
return TRUE
return FALSE
return

var/datum/species/species = GLOB.all_species[C.prefs.species]
if(C.prefs.age >= get_age_limits(species, min_age_type))
. = TRUE


/datum/job/proc/species_in_blacklist(client/C)
if(!C)
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ACCESS_CHEMISTRY, ACCESS_VIROLOGY, ACCESS_CMO, ACCESS_SURGERY, ACCESS_RC_ANNOUNCE,
ACCESS_KEYCARD_AUTH, ACCESS_SEC_DOORS, ACCESS_PSYCHIATRIST, ACCESS_MAINT_TUNNELS, ACCESS_PARAMEDIC, ACCESS_MINERAL_STOREROOM)
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
exp_requirements = 3000
exp_type = EXP_TYPE_MEDICAL
outfit = /datum/outfit/job/cmo
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/science.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ACCESS_RESEARCH, ACCESS_ROBOTICS, ACCESS_XENOBIOLOGY, ACCESS_AI_UPLOAD,
ACCESS_RC_ANNOUNCE, ACCESS_KEYCARD_AUTH, ACCESS_TCOMSAT, ACCESS_GATEWAY, ACCESS_XENOARCH, ACCESS_MINISAT, ACCESS_MAINT_TUNNELS, ACCESS_MINERAL_STOREROOM, ACCESS_NETWORK)
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
exp_requirements = 3000
exp_type = EXP_TYPE_SCIENCE
// All science-y guys get bonuses for maxing out their tech.
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/security.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ACCESS_RESEARCH, ACCESS_ENGINE, ACCESS_MINING, ACCESS_MEDICAL, ACCESS_CONSTRUCTION, ACCESS_MAILSORTING,
ACCESS_HEADS, ACCESS_HOS, ACCESS_RC_ANNOUNCE, ACCESS_KEYCARD_AUTH, ACCESS_GATEWAY, ACCESS_PILOT, ACCESS_WEAPONS)
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 3000
exp_type = EXP_TYPE_SECURITY
Expand Down
12 changes: 6 additions & 6 deletions code/game/jobs/job/supervisor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GLOBAL_DATUM_INIT(captain_announcement, /datum/announcement/minor, new(do_newsca
access = list() //See get_access()
minimal_access = list() //See get_access()
minimal_player_age = 30
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 3000
exp_type = EXP_TYPE_COMMAND
Expand Down Expand Up @@ -73,7 +73,7 @@ GLOBAL_DATUM_INIT(captain_announcement, /datum/announcement/minor, new(do_newsca
req_admin_notify = 1
is_command = 1
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 1200
exp_type = EXP_TYPE_COMMAND
Expand Down Expand Up @@ -130,7 +130,7 @@ GLOBAL_DATUM_INIT(captain_announcement, /datum/announcement/minor, new(do_newsca
is_command = 1
transfer_allowed = FALSE
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 1200
exp_type = EXP_TYPE_COMMAND
Expand Down Expand Up @@ -183,7 +183,7 @@ GLOBAL_DATUM_INIT(captain_announcement, /datum/announcement/minor, new(do_newsca
is_command = 1
transfer_allowed = FALSE
minimal_player_age = 21
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_HIGH_ED
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 3000
exp_type = EXP_TYPE_SECURITY
Expand Down Expand Up @@ -242,7 +242,7 @@ GLOBAL_DATUM_INIT(captain_announcement, /datum/announcement/minor, new(do_newsca
is_legal = 1
transfer_allowed = FALSE
minimal_player_age = 30
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 1200
exp_type = EXP_TYPE_COMMAND
Expand Down Expand Up @@ -300,7 +300,7 @@ GLOBAL_DATUM_INIT(captain_announcement, /datum/announcement/minor, new(do_newsca
minimal_access = list(ACCESS_LAWYER, ACCESS_COURT, ACCESS_SEC_DOORS, ACCESS_MAINT_TUNNELS, ACCESS_RESEARCH, ACCESS_MEDICAL, ACCESS_CONSTRUCTION, ACCESS_MAILSORTING)
alt_titles = list("Human Resources Agent","Lawyer","Attorney")
minimal_player_age = 30
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_HIGH_ED
blocked_race_for_job = list(SPECIES_VOX)
exp_requirements = 3000
exp_type = EXP_TYPE_CREW
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/support.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
selection_color = "#9f8545"
access = list(ACCESS_RC_ANNOUNCE, ACCESS_KEYCARD_AUTH, ACCESS_HEADS_VAULT, ACCESS_ALL_PERSONAL_LOCKERS, ACCESS_HEADS, ACCESS_SEC_DOORS, ACCESS_EVA, ACCESS_MAINT_TUNNELS, ACCESS_MAILSORTING, ACCESS_CARGO, ACCESS_CARGO_BOT, ACCESS_QM, ACCESS_MINT, ACCESS_MINING, ACCESS_MINING_STATION, ACCESS_MINERAL_STOREROOM)
minimal_access = list(ACCESS_RC_ANNOUNCE, ACCESS_KEYCARD_AUTH, ACCESS_HEADS_VAULT, ACCESS_ALL_PERSONAL_LOCKERS, ACCESS_HEADS, ACCESS_SECURITY, ACCESS_EVA, ACCESS_MAINT_TUNNELS, ACCESS_MAILSORTING, ACCESS_CARGO, ACCESS_CARGO_BOT, ACCESS_QM, ACCESS_MINT, ACCESS_MINING, ACCESS_MINING_STATION, ACCESS_MINERAL_STOREROOM)
min_age_allowed = 30
min_age_type = JOB_MIN_AGE_COMMAND
exp_requirements = 3000
exp_type = EXP_TYPE_CREW
alt_titles = list("Chief Supply Manager")
Expand Down
10 changes: 8 additions & 2 deletions code/game/machinery/computer/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,16 @@
return

if(field == "age")
if(!active1)
return

var/datum/species/species = active1.fields["species"]
var/new_age = text2num(answer)
if(new_age < AGE_MIN || new_age > AGE_MAX)
set_temp("Invalid age. It must be between [AGE_MIN] and [AGE_MAX].", "danger")
var/age_limits = get_age_limits(species, list(SPECIES_AGE_MIN, SPECIES_AGE_MAX))
if(new_age < age_limits[SPECIES_AGE_MIN] || new_age > age_limits[SPECIES_AGE_MAX])
set_temp("Invalid age. It must be between [age_limits[SPECIES_AGE_MIN]] and [age_limits[SPECIES_AGE_MAX]].", "danger")
return

answer = new_age

if(istype(active2) && (field in active2.fields))
Expand Down
13 changes: 10 additions & 3 deletions code/game/machinery/computer/security.dm
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,19 @@
return

if(field == "age")
if(!record_general)
return

var/datum/species/species = record_general.fields["species"]
var/new_age = text2num(answer)
if(new_age < AGE_MIN || new_age > AGE_MAX)
set_temp("Invalid age. It must be between [AGE_MIN] and [AGE_MAX].", "danger")
var/age_limits = get_age_limits(species, list(SPECIES_AGE_MIN, SPECIES_AGE_MAX))
if(new_age < age_limits[SPECIES_AGE_MIN] || new_age > age_limits[SPECIES_AGE_MAX])
set_temp("Invalid age. It must be between [age_limits[SPECIES_AGE_MIN]] and [age_limits[SPECIES_AGE_MAX]].", "danger")
return

answer = new_age
else if(field == "criminal")

if(field == "criminal")
var/text = "Please enter a reason for the status change to [answer]:"
if(answer == SEC_RECORD_STATUS_EXECUTE)
text = "Please explain why they are being executed. Include a list of their crimes, and victims."
Expand Down
11 changes: 7 additions & 4 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
html += "<del class='[color]'>[rank]</del></td><td><span class='btn btn-sm btn-danger text-light border border-secondary disabled' style='padding: 0px 4px;'><b> \[ЧЕРЕЗ [(available_in_days)] ДНЕЙ]</b></span></td></tr>"
continue
if(!job.character_old_enough(user.client))
html += "<del class='[color]'>[rank]</del></td><td><span class='btn btn-sm btn-danger text-light border border-secondary disabled' style='padding: 0px 4px;'><b> \[ВОЗРАСТ ОТ [(job.min_age_allowed)]]</b></span></td></tr>"
var/datum/species/current_species = GLOB.all_species[species]
html += "<del class='[color]'>[rank]</del></td><td><span class='btn btn-sm btn-danger text-light border border-secondary disabled' style='padding: 0px 4px;'><b> \[ВОЗРАСТ ОТ [current_species.age_sheet[job.min_age_type]]]</b></span></td></tr>"
Samirakis marked this conversation as resolved.
Show resolved Hide resolved
continue
if(job.species_in_blacklist(user.client))
html += "<del class='[color]'>[rank]</del></td><td><span class='btn btn-sm btn-danger text-light border border-secondary disabled' style='padding: 0px 4px;'><b> \[НЕДОСТУПНО ДЛЯ ДАННОЙ РАСЫ]</b></span></td></tr>"
Expand Down Expand Up @@ -1542,7 +1543,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
real_name = random_name(gender,species)
user.client << output(real_name, "title_browser:update_current_character")
if("age")
age = rand(AGE_MIN, AGE_MAX)
age = get_rand_age(S)
if("hair")
if(species in list(SPECIES_HUMAN, SPECIES_UNATHI, SPECIES_TAJARAN, SPECIES_SKRELL, SPECIES_MACNINEPERSON, SPECIES_WRYN, SPECIES_VULPKANIN, SPECIES_VOX))
h_colour = rand_hex_color()
Expand Down Expand Up @@ -1619,10 +1620,11 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
to_chat(user, "<font color='red'>Invalid name. Your name should be at least 2 and at most [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and .</font>")

if("age")
var/new_age = tgui_input_number(user, "Choose your character's age:\n([AGE_MIN]-[AGE_MAX])", "Character Preference", age, AGE_MAX, AGE_MIN)
var/list/age_list = get_age_limits(S, list(SPECIES_AGE_MIN, SPECIES_AGE_MAX))
var/new_age = tgui_input_number(user, "Choose your character's age:\n([age_list[SPECIES_AGE_MIN]]-[age_list[SPECIES_AGE_MAX]])", "Character Preference", age, age_list[SPECIES_AGE_MAX], age_list[SPECIES_AGE_MIN])
if(!new_age)
return
age = max(min(round(text2num(new_age)), AGE_MAX), AGE_MIN)
age = clamp(round(text2num(new_age)), age_list[SPECIES_AGE_MIN], age_list[SPECIES_AGE_MAX])
if("species")
var/list/new_species = list(SPECIES_HUMAN)
var/prev_species = species
Expand Down Expand Up @@ -1696,6 +1698,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
if(!(NS.bodyflags & HAS_SKIN_COLOR))
s_colour = "#000000"

age = get_rand_age(NS)
alt_head = "None" //No alt heads on species that don't have them.
speciesprefs = 0 //My Vox tank shouldn't change how my future Grey talks.
language = LANGUAGE_NONE
Expand Down
3 changes: 2 additions & 1 deletion code/modules/client/preference/preferences_mysql.dm
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@
if(!real_name) real_name = random_name(gender,species)
be_random_name = sanitize_integer(be_random_name, 0, 1, initial(be_random_name))
gender = sanitize_gender(gender, FALSE, !SP.has_gender)
age = sanitize_integer(age, AGE_MIN, AGE_MAX, initial(age))
var/age_limits = get_age_limits(SP, list(SPECIES_AGE_MIN, SPECIES_AGE_MAX, JOB_MIN_AGE_COMMAND))
age = sanitize_integer(age, age_limits[SPECIES_AGE_MIN], age_limits[SPECIES_AGE_MAX], age_limits[JOB_MIN_AGE_COMMAND])
h_colour = sanitize_hexcolor(h_colour)
h_sec_colour = sanitize_hexcolor(h_sec_colour)
f_colour = sanitize_hexcolor(f_colour)
Expand Down
6 changes: 4 additions & 2 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1590,8 +1590,10 @@ Eyes need to have significantly high darksight to shine unless the mob has the X

return ..()

/mob/living/carbon/human/proc/get_age_pitch(var/tolerance = 5)
return 1.0 + 0.5*(30 - age)/80 + (0.01*rand(-tolerance,tolerance))

/mob/living/carbon/human/proc/get_age_pitch(tolerance = 5)
return dna?.species.get_emote_pitch(src, tolerance) || 1.0 + 0.5 * (30 - age) / 80 + (0.01 * rand(-tolerance, tolerance))


/mob/living/carbon/human/get_access_locations()
. = ..()
Expand Down
27 changes: 27 additions & 0 deletions code/modules/mob/living/carbon/human/species/_species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@
var/list/autohiss_extra_map = null
var/list/autohiss_exempt = null

/// Contains info for all age related preferences.
var/list/age_sheet


/datum/species/New()
unarmed = new unarmed_type()

Expand All @@ -269,6 +273,26 @@
return species_language.get_random_name(gender)


/proc/get_age_limits(datum/species/species, list/tags)
if(!islist(tags))
tags = list(tags)

var/list/result = list()
for(var/tag in tags)
if(species)
result[tag] = LAZYACCESS(species.age_sheet, tag)

if(!isnum(result[tag]))
result[tag] = AGE_SHEET[tag]

return length(result) > 1 ? result : result[tags[1]]


/proc/get_rand_age(datum/species/species)
var/age_limits = get_age_limits(species, list(SPECIES_AGE_MIN, SPECIES_AGE_MAX))
return rand(age_limits[SPECIES_AGE_MIN], age_limits[SPECIES_AGE_MAX])


/**
* Handles creation of mob organs.
*
Expand Down Expand Up @@ -1188,3 +1212,6 @@ It'll return null if the organ doesn't correspond, so include null checks when u
var/obj/item/organ/external/head/HD = H.get_organ(BODY_ZONE_HEAD)
return HD.hair_colour

/datum/species/proc/get_emote_pitch(mob/living/carbon/human/H, tolerance)
var/age_limits = get_age_limits(src, list(SPECIES_AGE_MIN, SPECIES_AGE_MAX))
return 1 + 0.5 * (age_limits[SPECIES_AGE_MIN] + 10 - H.age) / age_limits[SPECIES_AGE_MAX] + (0.01 * rand(-tolerance, tolerance))
7 changes: 7 additions & 0 deletions code/modules/mob/living/carbon/human/species/diona.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
disliked_food = MEAT | RAW | EGG
liked_food = VEGETABLES | FRUIT

age_sheet = list(
SPECIES_AGE_MIN = 1,
SPECIES_AGE_MAX = 90,
JOB_MIN_AGE_HIGH_ED = 26,
JOB_MIN_AGE_COMMAND = 26,
)

/datum/species/diona/can_understand(mob/other)
if(istype(other, /mob/living/simple_animal/diona))
return 1
Expand Down
14 changes: 14 additions & 0 deletions code/modules/mob/living/carbon/human/species/drask.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define DRASK_COOLINGSTARTTEMP 280
#define ENVIRONMENT_COOLINGSTOPTEMP 400
#define DRASK_PITCH_SHIFT -0.1 // a bit lower emotes

/datum/species/drask
name = SPECIES_DRASK
Expand Down Expand Up @@ -83,6 +84,13 @@
liked_food = DAIRY
special_diet = MATERIAL_CLASS_SOAP

age_sheet = list(
SPECIES_AGE_MIN = 30,
SPECIES_AGE_MAX = 999,
JOB_MIN_AGE_HIGH_ED = 50,
JOB_MIN_AGE_COMMAND = 50,
)

/datum/species/drask/get_species_runechat_color(mob/living/carbon/human/H)
var/obj/item/organ/internal/eyes/E = H.get_int_organ(/obj/item/organ/internal/eyes)
return E.eye_colour
Expand Down Expand Up @@ -123,5 +131,11 @@
return FALSE
return ..()

/datum/species/drask/get_emote_pitch(mob/living/carbon/human/H, tolerance)
. = ..()
. += DRASK_PITCH_SHIFT


#undef DRASK_COOLINGSTARTTEMP
#undef ENVIRONMENT_COOLINGSTOPTEMP
#undef DRASK_PITCH_SHIFT
7 changes: 7 additions & 0 deletions code/modules/mob/living/carbon/human/species/grey.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
disliked_food = SUGAR | FRIED
liked_food = VEGETABLES | GRAIN | MEAT

age_sheet = list(
SPECIES_AGE_MIN = 3,
SPECIES_AGE_MAX = 150,
JOB_MIN_AGE_HIGH_ED = 13,
JOB_MIN_AGE_COMMAND = 13,
)


/datum/species/grey/on_species_gain(mob/living/carbon/human/H)
. = ..()
Expand Down
7 changes: 7 additions & 0 deletions code/modules/mob/living/carbon/human/species/kidan.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@
disliked_food = FRIED | DAIRY
liked_food = SUGAR | ALCOHOL | GROSS | FRUIT

age_sheet = list(
SPECIES_AGE_MIN = 12,
SPECIES_AGE_MAX = 45,
JOB_MIN_AGE_HIGH_ED = 20,
JOB_MIN_AGE_COMMAND = 20,
)

/datum/species/kidan/get_species_runechat_color(mob/living/carbon/human/H)
var/obj/item/organ/internal/eyes/E = H.get_int_organ(/obj/item/organ/internal/eyes)
return E.eye_colour
Expand Down
Loading