diff --git a/code/__DEFINES/jobs.dm b/code/__DEFINES/jobs.dm index f411b0867bf..cca828c3f1c 100644 --- a/code/__DEFINES/jobs.dm +++ b/code/__DEFINES/jobs.dm @@ -6,6 +6,8 @@ #define JOB_UNAVAILABLE_SLOTFULL 5 /// Job unavailable due to incompatibility with an antag role. #define JOB_UNAVAILABLE_ANTAG_INCOMPAT 6 +/// Checks for character age. +#define JOB_UNAVAILABLE_AGE 7 /// Used when the `get_job_unavailable_error_message` proc can't make sense of a given code. #define GENERIC_JOB_UNAVAILABLE_ERROR "Error: Unknown job availability." diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm index 5494d36c08b..493a64ebfd5 100644 --- a/code/controllers/subsystem/job.dm +++ b/code/controllers/subsystem/job.dm @@ -69,9 +69,10 @@ SUBSYSTEM_DEF(job) /// This is just the message we prepen and put into all of the config files to ensure documentation. We use this in more than one place, so let's put it in the SS to make life a bit easier. var/config_documentation = "## This is the configuration file for the job system.\n## This will only be enabled when the config flag LOAD_JOBS_FROM_TXT is enabled.\n\ - ## We use a system of keys here that directly correlate to the job, just to ensure they don't desync if we choose to change the name of a job.\n## You are able to change (as of now) four different variables in this file.\n\ + ## We use a system of keys here that directly correlate to the job, just to ensure they don't desync if we choose to change the name of a job.\n## You are able to change (as of now) five different variables in this file.\n\ ## Total Positions are how many job slots you get in a shift, Spawn Positions are how many you get that load in at spawn. If you set this to -1, it is unrestricted.\n## Playtime Requirements is in minutes, and the job will unlock when a player reaches that amount of time.\n\ - ## However, that can be superseded by Required Account Age, which is a time in days that you need to have had an account on the server for.\n## As time goes on, more config options may be added to this file.\n\ + ## However, that can be superseded by Required Account Age, which is a time in days that you need to have had an account on the server for.\n\ + ## Also there is a required character age in years. It prevents player from joining as this job, if their character's age as is lower than required. Zero = turned off for this job.\n## As time goes on, more config options may be added to this file.\n\ ## You can use the admin verb 'Generate Job Configuration' in-game to auto-regenerate this config as a downloadable file without having to manually edit this file if we add more jobs or more things you can edit here.\n\ ## It will always respect prior-existing values in the config, but will appropriately add more fields when they generate.\n## It's strongly advised you create your own version of this file rather than use the one provisioned on the codebase.\n\n\ ## The game will not read any line that is commented out with a '#', as to allow you to defer to codebase defaults.\n## If you want to override the codebase values, add the value and then uncomment that line by removing the # from the job key's name.\n\ @@ -641,6 +642,7 @@ SUBSYSTEM_DEF(job) #define SPAWN_POSITIONS "Spawn Positions" #define PLAYTIME_REQUIREMENTS "Playtime Requirements" #define REQUIRED_ACCOUNT_AGE "Required Account Age" +#define REQUIRED_CHARACTER_AGE "Required Character Age" /// Called in jobs subsystem initialize if LOAD_JOBS_FROM_TXT config flag is set: reads jobconfig.toml (or if in legacy mode, jobs.txt) to set all of the datum's values to what the server operator wants. /datum/controller/subsystem/job/proc/load_jobs_from_config() @@ -661,6 +663,7 @@ SUBSYSTEM_DEF(job) var/starting_positions = job_config[job_key][SPAWN_POSITIONS] var/playtime_requirements = job_config[job_key][PLAYTIME_REQUIREMENTS] var/required_account_age = job_config[job_key][REQUIRED_ACCOUNT_AGE] + var/required_character_age = job_config[job_key][REQUIRED_CHARACTER_AGE] if(default_positions || default_positions == 0) // We need to account for jobs that were intentionally turned off via config too. occupation.total_positions = default_positions @@ -670,6 +673,8 @@ SUBSYSTEM_DEF(job) occupation.exp_requirements = playtime_requirements if(required_account_age || required_account_age == 0) occupation.minimal_player_age = required_account_age + if(required_character_age || required_character_age == 0) + occupation.required_character_age = required_character_age return @@ -735,6 +740,7 @@ SUBSYSTEM_DEF(job) "# [SPAWN_POSITIONS]" = -1, "# [PLAYTIME_REQUIREMENTS]" = occupation.exp_requirements, "# [REQUIRED_ACCOUNT_AGE]" = occupation.minimal_player_age, + "# [REQUIRED_CHARACTER_AGE]" = occupation.required_character_age, ) continue // Generate new config from codebase defaults. @@ -743,6 +749,7 @@ SUBSYSTEM_DEF(job) "# [SPAWN_POSITIONS]" = occupation.spawn_positions, "# [PLAYTIME_REQUIREMENTS]" = occupation.exp_requirements, "# [REQUIRED_ACCOUNT_AGE]" = occupation.minimal_player_age, + "# [REQUIRED_CHARACTER_AGE]" = occupation.required_character_age, ) if(!export_toml(user, file_data)) return FALSE @@ -768,6 +775,7 @@ SUBSYSTEM_DEF(job) var/starting_positions = job_config[job_key][SPAWN_POSITIONS] var/playtime_requirements = job_config[job_key][PLAYTIME_REQUIREMENTS] var/required_account_age = job_config[job_key][REQUIRED_ACCOUNT_AGE] + var/required_character_age = job_config[job_key][REQUIRED_CHARACTER_AGE] if(file_data["[job_key]"]) // Sanity, let's just make sure we don't overwrite anything or add any dupe keys. We also unit test for this, but eh, you never know sometimes. stack_trace("We were about to over-write a job key that already exists in file_data while generating a new jobconfig.toml! This should not happen! Verify you do not have any duplicate job keys in your codebase!") @@ -807,6 +815,14 @@ SUBSYSTEM_DEF(job) file_data["[job_key]"] += list( "# [REQUIRED_ACCOUNT_AGE]" = occupation.minimal_player_age, ) + if(required_character_age) // Same pattern as above. + file_data["[job_key]"] += list( + REQUIRED_CHARACTER_AGE = required_character_age, + ) + else + file_data["[job_key]"] += list( + "# [REQUIRED_CHARACTER_AGE]" = occupation.required_character_age, + ) continue else to_chat(user, span_notice("New job [job_name] (using key [job_key]) detected! Adding to jobconfig.toml using default codebase values...")) @@ -816,6 +832,7 @@ SUBSYSTEM_DEF(job) "# [SPAWN_POSITIONS]" = occupation.spawn_positions, "# [PLAYTIME_REQUIREMENTS]" = occupation.exp_requirements, "# [REQUIRED_ACCOUNT_AGE]" = occupation.minimal_player_age, + "# [REQUIRED_CHARACTER_AGE]" = occupation.required_character_age, ) if(!export_toml(user, file_data)) @@ -834,6 +851,7 @@ SUBSYSTEM_DEF(job) #undef SPAWN_POSITIONS #undef PLAYTIME_REQUIREMENTS #undef REQUIRED_ACCOUNT_AGE +#undef REQUIRED_CHARACTER_AGE /datum/controller/subsystem/job/proc/HandleFeedbackGathering() for(var/datum/job/job as anything in joinable_occupations) @@ -1122,6 +1140,11 @@ SUBSYSTEM_DEF(job) if(is_banned_from(player.ckey, possible_job.title)) JobDebug("[debug_prefix] Error: [get_job_unavailable_error_message(JOB_UNAVAILABLE_BANNED, possible_job.title)], Player: [player][add_job_to_log ? ", Job: [possible_job]" : ""]") return JOB_UNAVAILABLE_BANNED + + // Check for character age + if(possible_job.required_character_age > player.client.prefs.read_preference(/datum/preference/numeric/age) && possible_job.required_character_age != null) + JobDebug("[debug_prefix] Error: [get_job_unavailable_error_message(JOB_UNAVAILABLE_AGE)], Player: [player][add_job_to_log ? ", Job: [possible_job]" : ""]") + return JOB_UNAVAILABLE_AGE //SKYRAT EDIT ADDITION BEGIN - CUSTOMIZATION if(possible_job.veteran_only && !is_veteran_player(player.client)) diff --git a/code/modules/jobs/job_types/_job.dm b/code/modules/jobs/job_types/_job.dm index 35ab9c9e216..b0983947bc7 100644 --- a/code/modules/jobs/job_types/_job.dm +++ b/code/modules/jobs/job_types/_job.dm @@ -131,6 +131,9 @@ /// custom ringtone for this job var/job_tone + + /// Minimal character age for this job + var/required_character_age /datum/job/New() diff --git a/config/jobconfig.toml b/config/jobconfig.toml index 0fa4a9a99a0..257ad59e913 100644 --- a/config/jobconfig.toml +++ b/config/jobconfig.toml @@ -1,10 +1,11 @@ ## This is the configuration file for the job system. ## This will only be enabled when the config flag LOAD_JOBS_FROM_TXT is enabled. ## We use a system of keys here that directly correlate to the job, just to ensure they don't desync if we choose to change the name of a job. -## You are able to change (as of now) four different variables in this file. +## You are able to change (as of now) five different variables in this file. ## Total Positions are how many job slots you get in a shift, Spawn Positions are how many you get that load in at spawn. If you set this to -1, it is unrestricted. ## Playtime Requirements is in minutes, and the job will unlock when a player reaches that amount of time. ## However, that can be superseded by Required Account Age, which is a time in days that you need to have had an account on the server for. +## Required Character Age checks if your character is sutable for this job. 0 = disabled. ## As time goes on, more config options may be added to this file. ## You can use the admin verb 'Generate Job Configuration' in-game to auto-regenerate this config as a downloadable file without having to manually edit this file if we add more jobs or more things you can edit here. ## It will always respect prior-existing values in the config, but will appropriately add more fields when they generate. @@ -19,281 +20,328 @@ [AI] "Playtime Requirements" = 2400 "Required Account Age" = 30 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [ASSISTANT] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = -1 "Total Positions" = -1 [ATMOSPHERIC_TECHNICIAN] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 3 [BARBER] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [BARTENDER] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [BLUESHIELD] "Playtime Requirements" = 2400 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [BOTANIST] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 3 [BOUNCER] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [CAPTAIN] "Playtime Requirements" = 2400 "Required Account Age" = 14 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [CARGO_TECHNICIAN] "# Playtime Requirements" = 0 "# Required Account Age" = 0 +"# Required Character Age" = 0 "# Spawn Positions" = 3 "# Total Positions" = 5 [CHAPLAIN] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [CHEMIST] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [CHIEF_ENGINEER] "Playtime Requirements" = 2400 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [CHIEF_MEDICAL_OFFICER] "Playtime Requirements" = 2400 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [CLOWN] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [COOK] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 2 [CORRECTIONS_OFFICER] "Playtime Requirements" = 150 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [CORONER] "# Playtime Requirements" = 0 "# Required Account Age" = 0 +"# Required Character Age" = 0 "# Spawn Positions" = 1 "# Total Positions" = 1 [CURATOR] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [CUSTOMS_AGENT] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [CYBORG] "Playtime Requirements" = 120 "Required Account Age" = 21 +"# Required Character Age" = 0 "Spawn Positions" = 3 "Total Positions" = 3 [DETECTIVE] "Playtime Requirements" = 300 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [ENGINEERING_GUARD] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [GENETICIST] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [HEAD_OF_PERSONNEL] "Playtime Requirements" = 2400 "Required Account Age" = 10 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [HEAD_OF_SECURITY] "Playtime Requirements" = 2400 "Required Account Age" = 14 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [JANITOR] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 5 "Total Positions" = 5 [LAWYER] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [MEDICAL_DOCTOR] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 3 "Total Positions" = 5 [MIME] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [NANOTRASEN_CONSULTANT] "Playtime Requirements" = 2400 "Required Account Age" = 14 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [ORDERLY] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [PARAMEDIC] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 3 [PRISONER] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 12 "Total Positions" = 12 [PSYCHOLOGIST] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [QUARTERMASTER] "Playtime Requirements" = 2400 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [RESEARCH_DIRECTOR] "Playtime Requirements" = 2400 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [ROBOTICIST] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 3 [SCIENCE_GUARD] "Playtime Requirements" = 180 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 2 "Total Positions" = 2 [SCIENTIST] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 5 "Total Positions" = 5 [SECURITY_MEDIC] "Playtime Requirements" = 180 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [SECURITY_OFFICER] "Playtime Requirements" = 300 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 6 "Total Positions" = 6 [SHAFT_MINER] "Playtime Requirements" = 0 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 4 "Total Positions" = 4 [STATION_ENGINEER] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 5 "Total Positions" = 5 [VANGUARD_OPERATIVE] "Playtime Requirements" = 400 "Required Account Age" = 40 +"# Required Character Age" = 0 "Spawn Positions" = 0 "Total Positions" = 0 [VIROLOGIST] "Playtime Requirements" = 60 "Required Account Age" = 0 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1 [WARDEN] "Playtime Requirements" = 300 "Required Account Age" = 7 +"# Required Character Age" = 0 "Spawn Positions" = 1 "Total Positions" = 1