Skills System Revival: The Things She Remembered Had Never Been Her Own (#21853)

This PR is a revisit to the previously derelict PR #20159 that has been
unfinished for sometime now. More details about it in general can be
found here:
https://github.com/orgs/Aurorastation/projects/2?pane=issue&itemId=53167153

For awhile I've been talking about "Things I've been doing but it would
be really nice to do them with a skills system", or "And here's how I
would put this into the skills system when it's done". The main thing
that was stopping me from building it myself was having poor real life
skills in UI code and in DB code. However, I've gotten permission to
resume this PR, which has already completed the steps I would not have
been able to do myself. The rest of the PR fits well into my skillset as
a dev.

I'm opening this PR as a draft so as to enable my dev environment to
locally track all the previously modified files. I'll take this PR out
of draft and give this a full writeup when I have more work to show for
the PR this weekend.

### TODO

- [x] Rework a decent chunk of the currently existing skills to no
longer require hardcoded inserts into other systems. EG, converting from
classical ss13 methods, to modern /tg/-style ECS coding methods that
work off of component-signal patterns.
- [x] Make sure all of the existing skills have actual game
functionality (I won't PR a 2016 Baystation12 situation where 90% of the
skills are fluff only)
- [x] Add the various skills not yet made but are necessary for
completion sake, EG: Pilot (Spacecraft), Gunnery, Pilot (Walkers).
- [x] Examine each existing job in the game and assess whether it should
have a skill made with it in mind, or if it's covered by an existing
skill.
- [x] TO DISCUSS, BUT NOT ESSENTIAL: Additional skill proposals not
currently in the pre-existing TODO list, proposing subcategories.
- [x] Ensure that the previous TODO list is completed.

### Current Skills
The current list of skills, checkmarked for if I've completed them/they
have actual game mechanics. Or if we're just relegating them to separate
PRs. Originally this list was going to be forced to visit for a bare
minimum "does at least one thing" requirement, but now that is being
forgone due to this PR ballooning out of control and in complexity, as
well as development time overruns.

- [x] Bartending
- [x] Cooking
- [x] Gardening
- [x] Entertaining
- [x] Electrical Engineering
- [x] Mechanical Engineering
- [x] Atmospherics Systems
- [x] Reactor Systems
- [x] Medicine
- [x] Surgery
- [x] Pharmacology
- [x] Anatomy
- [x] Forensics
- [x] Robotics
- [x] Pilot: Spacecraft
- [x] Pilot: Exosuits
- [x] Research
- [x] Xenobotany
- [x] Xenoarchaeology
- [x] Xenobiology
- [x] Unarmed Combat
- [x] Armed Combat
- [x] Firearms
- [x] Leadership

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: Matt Atlas <liermattia@gmail.com>
Co-authored-by: FabianK3 <21039694+FabianK3@users.noreply.github.com>
Co-authored-by: Matt Atlas <mattiathebest2000@hotmail.it>
This commit is contained in:
VMSolidus
2026-04-18 14:33:48 +00:00
committed by GitHub
co-authored by Matt Atlas FabianK3 Matt Atlas
parent 2948b1dc87
commit 260f744906
107 changed files with 2965 additions and 185 deletions
@@ -219,6 +219,26 @@
if(C.name in job.blacklisted_citizenship)
dat += "<del>[dispRank]</del></td><td><b> \[BACKGROUND RESTRICTED]</b></td></tr>"
continue
// Skill requirement handling.
var/skills_length = length(job.skill_requirements)
var/skill_index = 0
var/missing_skills = ""
for (var/key,value in job.skill_requirements)
skill_index++
if (!key || pref.skills[key] >= value)
continue
var/singleton/skill/skill = GET_SINGLETON(key)
missing_skills += "[skill.name] [value]"
if (skill_index != skills_length)
missing_skills += "\n"
if (missing_skills != "")
dat += "<del>[dispRank]</del></td><td> MISSING SKILLS: [missing_skills]</td></tr>"
continue
// End of skill requirement handling.
if(job.alt_titles && (LAZYLEN(pref.GetValidTitles(job)) > 1))
dispRank = "<span width='60%' align='center'>&nbsp<a href='byond://?src=[REF(src)];select_alt_title=[REF(job)]'>\[[pref.GetPlayerAltTitle(job)]\]</a></span>"
if((pref.job_civilian_low & ASSISTANT) && (rank != "Assistant"))
@@ -70,27 +70,32 @@
var/datum/species/S = GLOB.all_species[pref.species]
if(!istext(pref.culture) || !ispath(text2path(pref.culture), /singleton/origin_item/culture))
var/singleton/origin_item/culture/CI = S.possible_cultures[1]
pref.culture = "[CI]"
pref.culture = "[CI.type]"
var/singleton/origin_item/culture/our_culture = GET_SINGLETON(text2path(pref.culture))
if(!istext(pref.origin) || !ispath(text2path(pref.origin), /singleton/origin_item/origin))
var/singleton/origin_item/origin/OI = pick(our_culture.possible_origins)
pref.origin = "[OI]"
pref.origin = "[OI.type]"
else
var/singleton/origin_item/origin/origin_check = text2path(pref.origin)
if(!(origin_check in our_culture.possible_origins))
to_client_chat(SPAN_WARNING("Your origin has been reset due to it being incompatible with your culture!"))
var/singleton/origin_item/origin/OI = pick(our_culture.possible_origins)
pref.origin = "[OI]"
pref.origin = "[OI.type]"
var/singleton/origin_item/origin/our_origin = GET_SINGLETON(text2path(pref.origin))
if(!(pref.citizenship in our_origin.possible_citizenships))
to_client_chat(SPAN_WARNING("Your previous citizenship is invalid for this origin! Resetting."))
pref.citizenship = our_origin.possible_citizenships[1]
if(!(pref.religion in our_origin.possible_religions))
to_client_chat(SPAN_WARNING("Your previous religion is invalid for this origin! Resetting."))
pref.religion = our_origin.possible_religions[1]
if(!(pref.accent in our_origin.possible_accents))
to_client_chat(SPAN_WARNING("Your previous accent is invalid for this origin! Resetting."))
pref.accent = our_origin.possible_accents[1]
pref.economic_status = sanitize_inlist(pref.economic_status, ECONOMIC_POSITIONS, initial(pref.economic_status))
/datum/category_item/player_setup_item/origin/content(var/mob/user)
@@ -114,10 +119,11 @@
if(OR.important_information)
dat += "<br><i>- <font color=red>[OR.important_information]</font></i>"
dat += "<hr>"
dat += "<b>Economic Status:</b> <a href='byond://?src=[REF(src)];economic_status=1'>[pref.economic_status]</a><br/>"
dat += "<b>Citizenship:</b> <a href='byond://?src=[REF(src)];citizenship=1'>[pref.citizenship]</a><br/>"
dat += "<b>Religion:</b> <a href='byond://?src=[REF(src)];religion=1'>[pref.religion]</a><br/>"
dat += "<b>Accent:</b> <a href='byond://?src=[REF(src)];accent=1'>[pref.accent]</a><br/>"
dat += "<b>Economic Status:</b> <a href='?src=[REF(src)];economic_status=1'>[pref.economic_status]</a><br/>"
dat += "<b>Citizenship:</b> <a href='?src=[REF(src)];citizenship=1'>[pref.citizenship]</a><br/>"
dat += "<b>Religion:</b> <a href='?src=[REF(src)];religion=1'>[pref.religion]</a><br/>"
dat += "<b>Accent:</b> <a href='?src=[REF(src)];accent=1'>[pref.accent]</a><br/>"
. = dat.Join()
/datum/category_item/player_setup_item/origin/OnTopic(href, href_list, user)
@@ -131,7 +137,7 @@
var/result = tgui_input_list(user, "Choose your character's culture.", "Culture", options)
var/singleton/origin_item/culture/chosen_culture = options[result]
if(chosen_culture)
show_window(chosen_culture, "set_culture_data", user)
show_origin_window(chosen_culture, "set_culture_data", user)
return TOPIC_HANDLED
if(href_list["open_origin_menu"])
@@ -144,7 +150,7 @@
var/result = tgui_input_list(user, "Choose your character's origin.", "Origins", options)
var/singleton/origin_item/origin/chosen_origin = options[result]
if(chosen_origin)
show_window(chosen_origin, "set_origin_data", user)
show_origin_window(chosen_origin, "set_origin_data", user)
return TOPIC_HANDLED
if(href_list["set_culture_data"])
@@ -207,7 +213,7 @@
sanitize_character()
return TOPIC_REFRESH
/datum/category_item/player_setup_item/origin/proc/show_window(var/singleton/origin_item/OI, var/topic_data, var/mob/user)
/datum/category_item/player_setup_item/origin/proc/show_origin_window(var/singleton/origin_item/OI, var/topic_data, var/mob/user)
var/datum/browser/origin_win = new(user, topic_data, "Origins Selection")
var/dat = "<html><center><b>[OI.name]</center></b>"
dat += "<hr>[OI.desc]<br>"
@@ -28,30 +28,35 @@
sort_order = 2
category_item_type = /datum/category_item/player_setup_item/origin
/datum/category_group/player_setup_category/skill_preferences
name = "Skills"
sort_order = 3
category_item_type = /datum/category_item/player_setup_item/skills
/datum/category_group/player_setup_category/occupation_preferences
name = "Occupation"
sort_order = 3
sort_order = 4
category_item_type = /datum/category_item/player_setup_item/occupation
/datum/category_group/player_setup_category/appearance_preferences
name = "Roles"
sort_order = 4
sort_order = 5
category_item_type = /datum/category_item/player_setup_item/antagonism
/datum/category_group/player_setup_category/loadout_preferences
name = "Loadout"
sort_order = 5
sort_order = 6
category_item_type = /datum/category_item/player_setup_item/loadout
/datum/category_group/player_setup_category/global_preferences
name = "Global"
sort_order = 6
sort_order = 7
category_item_type = /datum/category_item/player_setup_item/player_global
sql_role = SQL_PREFERENCES
/datum/category_group/player_setup_category/other_preferences
name = "Other"
sort_order = 7
sort_order = 8
category_item_type = /datum/category_item/player_setup_item/other
/****************************
@@ -0,0 +1,336 @@
/datum/category_item/player_setup_item/skills
name = "Skills"
sort_order = 1
/datum/category_item/player_setup_item/skills/load_character(var/savefile/S)
S["skills"] >> pref.skills
S["education"] >> pref.education
/datum/category_item/player_setup_item/skills/save_character(var/savefile/S)
S["skills"] << pref.skills
S["education"] << pref.education
/datum/category_item/player_setup_item/skills/gather_load_query()
return list(
"ss13_characters" = list(
"vars" = list(
"education",
"skills"
),
"args" = list("id")
)
)
/datum/category_item/player_setup_item/skills/gather_load_parameters()
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/skills/gather_save_query()
return list(
"ss13_characters" = list(
"education",
"skills",
"id" = 1,
"ckey" = 1
)
)
/datum/category_item/player_setup_item/skills/gather_save_parameters()
var/list/sanitized_skills = list()
for(var/S in pref.skills)
var/singleton/skill/skill = GET_SINGLETON(S)
if(!istype(skill))
continue
var/skill_val = pref.skills[S]
if(skill_val <= SKILL_LEVEL_UNFAMILIAR)
continue
sanitized_skills["[skill.type]"] = skill_val
return list(
"education" = pref.education,
"skills" = json_encode(sanitized_skills),
"id" = pref.current_character,
"ckey" = PREF_CLIENT_CKEY
)
/datum/category_item/player_setup_item/skills/load_character_special(savefile/S)
if(!pref.skills)
pref.skills = "{}"
var/before = pref.skills
var/loaded_skills
try
if(istext(pref.skills))
loaded_skills = json_decode(pref.skills)
else
loaded_skills = pref.skills
catch (var/exception/e)
log_debug("SKILLS: Caught [e]. Initial value: [before]")
loaded_skills = list()
pref.skills = list()
for(var/key in SSskills.required_skills)
var/singleton/skill/skill = GET_SINGLETON(key)
if (istype(skill))
pref.skills[skill.type] = SKILL_LEVEL_UNFAMILIAR
for(var/key,value in loaded_skills)
if (!key)
continue
var/path = istext(key) ? text2path(key) : key
var/singleton/skill/skill = GET_SINGLETON(path)
if(istype(skill))
pref.skills[skill.type] = value
/datum/category_item/player_setup_item/skills/sanitize_character(var/sql_load = 0)
//todomatt
if(!istext(pref.education) || !ispath(text2path(pref.education), /singleton/education))
var/singleton/education/ED = find_suitable_education()
if(ED)
pref.education = "[ED.type]"
else
var/singleton/education/our_education = GET_SINGLETON(text2path(pref.education))
if(length(our_education.species_restriction))
if(pref.species in our_education.species_restriction)
var/singleton/education/ED = find_suitable_education()
if(ED)
pref.education = "[ED.type]"
if(length(our_education.minimum_character_age))
if(pref.species in our_education.minimum_character_age)
if(pref.age < our_education.minimum_character_age[pref.species])
var/singleton/education/ED = find_suitable_education()
if(ED)
pref.education = "[ED.type]"
// Skills HTML UI, along with a lot of other components here, lifted from Baystation 12. Credit goes to Afterthought12. Thank you for saving me from HTML hell!
/datum/category_item/player_setup_item/skills/content(var/mob/user)
if(!SSskills.initialized)
return "<center><large>Skills not initialized yet. Please wait a bit and reload this section.</large></center>"
var/list/dat = list()
dat += "<body>"
dat += "<style>.Selectable,.Current,.Unavailable,.Toohigh,.Forced{border: 1px solid #161616;padding: 1px 4px 1px 4px;margin: 0 2px 0 0}</style>"
dat += "<style>.Forced,a.Forced{background: #FF0000}</style>"
dat += "<style>.Selectable,a.Selectable{background: #40628a}</style>"
dat += "<style>.Current,a.Current{background: #2f943c}</style>"
dat += "<style>.Unavailable{background: #d09000}</style>"
var/singleton/education/ED = GET_SINGLETON(text2path(pref.education))
dat += "<center><b>Education:</b> <a href='?src=[REF(src)];open_education_menu=1'>[ED.name]</a></center><br/><hr>"
dat += "<table>"
var/singleton/education/education = GET_SINGLETON(text2path(pref.education))
for(var/category in SSskills.skill_tree)
var/singleton/skill_category/skill_category = category
dat += "<tr><th colspan = 4><b>[skill_category.name] ([calculate_remaining_skill_points(skill_category)] points remaining)</b>"
dat += "</th></tr>"
for(var/subcategory in SSskills.skill_tree[skill_category])
dat += "<tr><th colspan = 3><b>[subcategory]</b></th></tr>"
for(var/singleton/skill/skill in SSskills.skill_tree[skill_category][subcategory])
dat += get_skill_row(skill, education)
dat += "</table>"
. = JOINTEXT(dat)
/**
* Returns an HTML skill row.
*/
/datum/category_item/player_setup_item/skills/proc/get_skill_row(singleton/skill/skill, singleton/education/education)
var/list/dat = list()
dat += "<tr style='text-align:left;'>"
dat += "<th><a href='?src=[REF(src)];skillinfo=[skill.type]'>[skill.name]</a></th>"
var/level_from_pref = pref.skills[skill.type]
var/current_level = level_from_pref ? level_from_pref : SKILL_LEVEL_UNFAMILIAR
var/maximum_skill_level = get_maximum_skill_level(skill, education)
for(var/i = SKILL_LEVEL_UNFAMILIAR, i <= skill.maximum_level, i++)
dat += skill_to_button(skill, education, current_level, i, maximum_skill_level)
return JOINTEXT(dat)
/datum/category_item/player_setup_item/skills/proc/get_maximum_skill_level(singleton/skill/skill, singleton/education/education)
var/base_maximum_level = skill.get_maximum_level(education)
var/remaining_skill_points = calculate_remaining_skill_points(GET_SINGLETON(skill.category))
var/current_level = SKILL_LEVEL_UNFAMILIAR
if(skill.type in pref.skills)
current_level = pref.skills[skill.type]
var/current_cost = 0
if(!(skill.type in education.skills))
current_cost = skill.get_cost(current_level)
var/available_points = remaining_skill_points + current_cost
for(var/skill_level = base_maximum_level; skill_level >= SKILL_LEVEL_UNFAMILIAR; skill_level--)
if(skill.get_cost(skill_level) <= available_points)
return skill_level
return SKILL_LEVEL_UNFAMILIAR
/**
* Turns a skill into a dynamic button.
*/
/datum/category_item/player_setup_item/skills/proc/skill_to_button(singleton/skill/skill, singleton/education/education, current_level, selection_level, maximum_skill_level)
var/effective_level = selection_level
if(effective_level <= 0)
return "<th></th>"
var/level_name = skill.skill_level_map[effective_level]
var/cost = skill.get_cost(effective_level)
var/button_label = "[level_name] ([cost])"
var/given_skill = FALSE
// Prevent removal of skills given by education. These are meant to be minimum skills for jobs, after all.
if(skill.type in education.skills)
given_skill = TRUE
if((effective_level < current_level) && given_skill)
return "<th>[span("Forced", "[button_label]")]</th>"
else if((effective_level < current_level) && !given_skill)
return "<th>[add_link(skill, education, button_label, "'Current'", effective_level)]</th>"
else if(effective_level == current_level)
return "<th>[span("Current", "[button_label]")]</th>"
else if(effective_level <= maximum_skill_level)
return "<th>[add_link(skill, education, button_label, "'Selectable'", effective_level)]</th>"
else
return "<th>[span("Toohigh", "[button_label]")]</th>"
/**
* Returns a button to set a skill in the skill UI.
*/
/datum/category_item/player_setup_item/skills/proc/add_link(singleton/skill/skill, singleton/education/education, text, style, value)
if(skill.get_maximum_level(education) >= value)
return "<a class=[style] href='?src=[REF(src)];setskill=[skill.type];newvalue=[value]'>[text]</a>"
return text
/**
* Returns the currently remaining skill points in a given category.
*/
/datum/category_item/player_setup_item/skills/proc/calculate_remaining_skill_points(singleton/skill_category/skill_category)
if(!istype(skill_category))
crash_with("Invalid skill category [skill_category] fed to calculate_remaining_skill_points!")
var/skill_points_remaining = skill_category.calculate_skill_points(GLOB.all_species[pref.species], pref.age, GET_SINGLETON(text2path(pref.culture)), GET_SINGLETON(text2path(pref.origin)))
var/current_points_used = get_used_skill_points_per_category(skill_category, GET_SINGLETON(text2path(pref.education)))
return skill_points_remaining - current_points_used
/**
* Returns the amount of used skill points in a certain skill category, ignoring skills given by education.
*/
/datum/category_item/player_setup_item/skills/proc/get_used_skill_points_per_category(singleton/skill_category/skill_category, singleton/education/education)
if(!istype(skill_category))
crash_with("Invalid skill category [skill_category] fed to get_used_skill_points_per_category!")
if(!istype(education))
crash_with("Invalid education [education] fed to get_used_skill_points_per_category!")
. = 0
for(var/skill_type in pref.skills)
var/singleton/skill/skill = GET_SINGLETON(skill_type)
if(skill.category != skill_category.type)
continue
if(skill.type in education.skills)
continue
. += skill.get_cost(pref.skills[skill.type])
/datum/category_item/player_setup_item/skills/OnTopic(href, href_list, user)
if(href_list["skillinfo"])
var/singleton/skill/skill_to_show = GET_SINGLETON(text2path(href_list["skillinfo"]))
if(!skill_to_show)
log_debug("SKILLS: Invalid skill selected for [user]: [skill_to_show]")
return
var/datum/browser/skill_window = new(user, "skill_info", "Skill Information")
var/dat = "<html><center><b>[skill_to_show.name]</center></b>"
dat += "<hr>[skill_to_show.description]<br>"
if(skill_to_show.uneducated_skill_cap)
dat += "Without the relevant education, you may only reach the <b>[skill_to_show.skill_level_map[skill_to_show.uneducated_skill_cap]]</b> level.<br>"
dat += "<hr>"
var/skill_level = (skill_to_show.type in pref.skills) ? pref.skills[skill_to_show.type] : SKILL_LEVEL_UNFAMILIAR
dat += "Your current level in this skill is [SPAN_BOLD(skill_to_show.skill_level_map[skill_level])].<br>"
dat += "[skill_to_show.skill_level_descriptions[skill_level]]"
dat += "</html>"
skill_window.set_content(dat)
skill_window.open()
else if(href_list["setskill"])
var/singleton/skill/new_skill = GET_SINGLETON(text2path(href_list["setskill"]))
if(!new_skill)
log_debug("SKILLS: Invalid skill selected for [user]: [new_skill]")
return
var/new_skill_value = text2num(href_list["newvalue"])
pref.skills[new_skill.type] = text2num(new_skill_value)
return TOPIC_REFRESH
else if(href_list["open_education_menu"])
var/list/options = list()
var/list/singleton/education/education_list = GET_SINGLETON_SUBTYPE_MAP(/singleton/education)
for(var/singleton_type in education_list)
var/singleton/education/ED = education_list[singleton_type]
if(length(ED.species_restriction))
if(pref.species in ED.species_restriction)
continue
if(length(ED.minimum_character_age))
if(pref.species in ED.minimum_character_age)
if(pref.age < ED.minimum_character_age[pref.species])
continue
options[ED.name] = ED
var/result = tgui_input_list(user, "Choose your character's education.", "Education", options)
var/singleton/education/chosen_education = options[result]
if(chosen_education)
show_education_window(chosen_education, "set_education_data", user)
else if(href_list["set_education_data"])
user << browse(null, "window=set_education_data")
var/new_education = html_decode(href_list["set_education_data"])
pref.education = new_education
pref.skills = list() // reset skills because we have to give them new minimums
to_chat(user, SPAN_WARNING("Your skills have been reset as you changed your education."))
var/singleton/education/education = GET_SINGLETON(text2path(new_education))
if(istype(education))
for(var/skill in education.skills)
var/singleton/skill/new_skill = GET_SINGLETON(skill)
pref.skills[new_skill.type] = education.skills[new_skill.type]
to_chat(user, SPAN_NOTICE("Added the [new_skill.name] skill at level [new_skill.skill_level_map[education.skills[new_skill.type]]]."))
sanitize_character()
return TOPIC_REFRESH
return ..()
/**
* Opens a window showing details of an education.
*/
/datum/category_item/player_setup_item/skills/proc/show_education_window(var/singleton/education/ED, var/topic_data, var/mob/user)
var/datum/browser/education_win = new(user, topic_data, "Education Selection")
var/dat = "<html><center><b>[ED.name]</center></b>"
dat += "<hr>[ED.description]<hr>"
dat += "This education gives you the following skills: "
var/list/skills_to_show = list()
for(var/skill in ED.skills)
var/singleton/skill/S = GET_SINGLETON(skill)
skills_to_show += "[S.name] ([SPAN_DANGER(S.skill_level_map[ED.skills[S.type]])])"
dat += "<b>[english_list(skills_to_show)]</b>.<br>"
dat += "<br><center>\[<a href='?src=[REF(src)];[topic_data]=[html_encode(ED.type)]'>Select</a>\]</center>"
dat += "</html>"
education_win.set_content(dat)
education_win.open()
/**
* Finds and returns the first suitable education for the pref datum.
*/
/datum/category_item/player_setup_item/skills/proc/find_suitable_education()
var/list/singleton/education/education_list = GET_SINGLETON_SUBTYPE_MAP(/singleton/education)
for(var/singleton_type in education_list)
var/singleton/education/ED = education_list[singleton_type]
if(length(ED.species_restriction))
if(pref.species in ED.species_restriction)
continue
if(length(ED.minimum_character_age))
if(pref.species in ED.minimum_character_age)
if(pref.age < ED.minimum_character_age[pref.species])
continue
return ED