Let's just use tgstation's.

This commit is contained in:
Ghommie
2020-06-19 19:01:05 +02:00
parent b13fcf9f2c
commit d555394290
14 changed files with 177 additions and 124 deletions
+32 -7
View File
@@ -15,14 +15,14 @@
mind.skill_holder.ui_interact(src)
/datum/skill_holder/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.always_state)
if(need_static_data_update)
update_static_data(user)
need_static_data_update = FALSE
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "skillpanel", "[owner.name]'s Skills", 620, 580, master_ui, state)
ui.set_autoupdate(FALSE) // This UI is only ever opened by one person, and never is updated outside of user input.
ui.open()
else if(need_static_data_update)
update_static_data(user)
need_static_data_update = FALSE
/datum/skill_holder/ui_static_data(mob/user)
. = list()
@@ -30,14 +30,17 @@
for(var/path in GLOB.skill_datums)
var/datum/skill/S = GLOB.skill_datums[path]
var/list/dat = S.get_skill_data(src)
if(dat["modifiers"])
if(islist(dat["modifiers"]))
dat["modifiers"] = jointext(dat["modifiers"], ", ")
dat["percent_base"] = (dat["value_base"] / dat["max_value"])
dat["percent_mod"] = (dat["value_mod"] / dat["max_value"])
.["skills"] += list(dat)
/datum/skill_holder/ui_data(mob/user)
. = list()
.["playername"] = owner.name
.["see_skill_mods"] = see_skill_mods
.["compact_mode"] = compact_mode
.["admin"] = check_rights(R_DEBUG)
/datum/skill_holder/ui_act(action, params)
. = ..()
@@ -47,5 +50,27 @@
if("toggle_mods")
see_skill_mods = !see_skill_mods
return TRUE
if("compact_toggle")
compact_mode = !compact_mode
if ("adj_exp")
if(!check_rights(R_DEBUG))
return
var/skill = text2path(params["skill"])
var/number = input("Please insert the amount of experience/progress you'd like to add/subtract:") as num|null
if (number)
owner.set_skill_value(skill, owner.get_skill_value(skill, FALSE) + number)
return TRUE
if ("set_exp")
if(!check_rights(R_DEBUG))
return
var/skill = text2path(params["skill"])
var/number = input("Please insert the number you want to set the player's exp/progress to:") as num|null
if (!isnull(number))
owner.set_skill_value(skill, number)
return TRUE
if ("set_lvl")
if(!check_rights(R_DEBUG))
return
var/datum/skill/level/S = GLOB.skill_datums[text2path(params["skill"])]
var/number = input("Please insert a whole number between 0[S.associative ? " ([S.unskilled_tier])" : ""] and [S.max_levels][S.associative ? " ([S.levels[S.max_levels]])" : ""] corresponding to the level you'd like to set the player to.") as num|null
if (number >= 0 && number <= S.max_levels)
owner.set_skill_value(S.type, S.get_skill_level_value(number))
return TRUE
+27 -26
View File
@@ -67,12 +67,11 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
. = list(
"name" = name,
"desc" = desc,
"name_color" = name_color,
"level_based" = progression_type == SKILL_PROGRESSION_LEVEL,
"path" = type,
"value_base" = skill_value,
"value_mod" = skill_value,
"base_readout" = skill_value,
"mod_readout" = skill_value
"modifiers" = "None",
"max_value" = 1 //To avoid division by zero later on.
)
var/list/mods = LAZYACCESS(H.skill_value_mods, type)
if(mods)
@@ -81,7 +80,7 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
var/datum/skill_modifier/M = GLOB.skill_modifiers[k]
mod_names |= M.name
skill_value = M.apply_modifier(skill_value, type, H, MODIFIER_TARGET_VALUE)
.["mod_readout"] = .["value_mod"] = skill_value
.["value_mod"] = skill_value
.["modifiers"] = mod_names //Will be jointext()'d later.
// Just saying, the choice to use different sub-parent-types is to force coders to resolve issues as I won't be implementing custom procs to grab skill levels in a certain context.
@@ -99,7 +98,6 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
. = ..()
.["base_readout"] = .["value_base"] ? "Learned: Yes" : "Learned: No"
.["mod_readout"] = .["value_mod"] ? "Learned: Yes" : "Learned: No"
.["max_value"] = 1
/datum/skill/numerical
abstract_type = /datum/skill/numerical
@@ -149,13 +147,7 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
var/max_assoc = ""
var/max_assoc_start = 1
for(var/lvl in 1 to max_levels)
var/value
switch(level_up_method)
if(STANDARD_LEVEL_UP)
value = XP_LEVEL(standard_xp_lvl_up, xp_lvl_multiplier, lvl)
if(DWARFY_LEVEL_UP)
value = DORF_XP_LEVEL(standard_xp_lvl_up, xp_lvl_multiplier, lvl)
value = round(value, 1)
var/value = round(get_skill_level_value(lvl), 1)
if(!associative)
levels += value
continue
@@ -197,6 +189,7 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
. = ..()
var/skill_value_base = .["value_base"]
var/skill_value_mod = .["value_mod"]
.["level_based"] = TRUE
var/level = LAZYACCESS(H.skill_levels, type) || 0
var/current_lvl_xp_sum = 0
@@ -206,22 +199,20 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
var/next_lvl_xp = associative ? levels[levels[next_index]] : levels[next_index]
if(next_lvl_xp > current_lvl_xp_sum)
next_lvl_xp -= current_lvl_xp_sum
.["lvl_base_num"] = .["lvl_mod_num"] = level
.["lvl_base"] = .["lvl_mod"] = associative ? (!level ? unskilled_tier : levels[level]) : level
.["lvl_base_color"] = .["lvl_mod_color"] = (level+1)*(350/max_levels)
.["xp_next_lvl_base"] = "XP To Next Level : \[[skill_value_base - current_lvl_xp_sum]/[next_lvl_xp]\]"
.["base_style"] = .["mod_style"] = "font-weight:bold; color:hsl([(level+1)*(350/max_levels+1)], 50%, 50%)"
.["xp_next_lvl_base"] = .["xp_next_lvl_mod"] = "\[[skill_value_base - current_lvl_xp_sum]/[next_lvl_xp]\]"
.["max_lvls"] = max_levels
var/max_value
switch(level_up_method)
if(STANDARD_LEVEL_UP)
max_value = .["max_value"] = XP_LEVEL(standard_xp_lvl_up, xp_lvl_multiplier, max_levels)
if(DWARFY_LEVEL_UP)
max_value = .["max_value"] = DORF_XP_LEVEL(standard_xp_lvl_up, xp_lvl_multiplier, max_levels)
.["max_lvl"] = max_levels
var/max_value = associative ? levels[levels[max_levels]] : levels[max_levels]
.["max_value"] = max_value
.["base_readout"] = "Overall Skill Progress: \[[skill_value_base]/[max_value]\]"
.["mod_readout"] = "Overall Skill Progress: \[[skill_value_mod]/[max_value]\]"
var/list/mods = LAZYACCESS(H.skill_level_mods, type)
if(mods) //I'm not proud of doing a similar process twice a row but here we go.
if(mods) //I'm not proud of doing the same-ish process twice a row but here we go.
var/list/mod_names = .["modifiers"]
if(!mod_names)
.["modifiers"] = mod_names = list()
@@ -238,10 +229,20 @@ GLOBAL_LIST_INIT_TYPED(skill_datums, /datum/skill, init_skill_datums())
next_lvl_xp = associative ? levels[levels[next_index]] : levels[next_index]
if(next_lvl_xp > current_lvl_xp_sum)
next_lvl_xp -= current_lvl_xp_sum
.["lvl_mod_num"] = level
.["lvl_mod"] = associative ? (!level ? unskilled_tier : levels[level]) : level
.["lvl_mod_color"] = (level+1)*(350/max_levels)
.["xp_next_lvl_mod"] = "XP To Next Level : \[[skill_value_mod - current_lvl_xp_sum]/[next_lvl_xp]\]"
.["mod_readout"] = "Overall Skill Progress: \[[skill_value_mod]/[max_value]\]"
.["mod_style"] = "font-weight:bold; color:hsl([(level+1)*(300/(max_levels+1))], 50%, 50%)"
.["xp_next_lvl_mod"] = "\[[skill_value_mod - current_lvl_xp_sum]/[next_lvl_xp]\]"
/**
* Gets the base value required to reach a level specified by the 'num' arg.
*/
/datum/skill/level/proc/get_skill_level_value(num)
switch(level_up_method)
if(STANDARD_LEVEL_UP)
. = XP_LEVEL(standard_xp_lvl_up, xp_lvl_multiplier, num)
if(DWARFY_LEVEL_UP)
. = DORF_XP_LEVEL(standard_xp_lvl_up, xp_lvl_multiplier, num)
/datum/skill/level/job
abstract_type = /datum/skill/level/job
+6 -2
View File
@@ -26,8 +26,12 @@
var/need_static_data_update = TRUE
/// Whether modifiers and final skill values or only base values are displayed.
var/see_skill_mods = TRUE
/// Whether skill descriptions are displayed or not.
var/compact_mode = FALSE
/// The current selected skill category.
var/selected_category
/datum/skill_holder/New(owner)
..()
src.owner = owner
/**
* Grabs the value of a skill.
+1 -8
View File
@@ -9,7 +9,6 @@ GLOBAL_LIST_EMPTY(potential_mods_per_skill)
/datum/skill_modifier
/// Name and description of the skill modifier, used in the UI
var/name = "???"
var/desc = ""
/// flags for this skill modifier.
var/modifier_flags = NONE
/// target skills, can be a specific skill typepath or a list of skill traits.
@@ -26,8 +25,6 @@ GLOBAL_LIST_EMPTY(potential_mods_per_skill)
var/level_mod = 1
/// Priority of this skill modifier compared to other ones.
var/priority = MODIFIER_SKILL_PRIORITY_DEF
/// Skill modifier icon, used in the UI
var/icon_name = "default_mod"
/datum/skill_modifier/New(id, register = FALSE)
identifier = GET_SKILL_MOD_ID(type, id)
@@ -172,11 +169,7 @@ GLOBAL_LIST_EMPTY(potential_mods_per_skill)
var/datum/skill/S = GLOB.skill_datums[skillpath]
if(method == MODIFIER_TARGET_VALUE && S.progression_type == SKILL_PROGRESSION_LEVEL)
var/datum/skill/level/L = S
switch(L.level_up_method)
if(STANDARD_LEVEL_UP)
mod = XP_LEVEL(L.standard_xp_lvl_up, L.xp_lvl_multiplier, S.competency_thresholds[mod])
if(DWARFY_LEVEL_UP)
mod = DORF_XP_LEVEL(L.standard_xp_lvl_up, L.xp_lvl_multiplier, S.competency_thresholds[mod])
mod = L.get_skill_level_value(L.competency_thresholds[mod])
else
mod = S.competency_thresholds[mod]
+1 -1
View File
@@ -1,6 +1,6 @@
/datum/skill/level/job/wiring
name = "Wiring"
desc = "How proficient and knowledged you are at wiring beyond laying cables on the floor."
desc = "How proficient and knowledged you are at wiring beyond making post-futuristic wire art."
name_color = COLOR_PALE_ORANGE
skill_traits = list(SKILL_SANITY, SKILL_INTELLIGENCE, SKILL_USE_TOOL, SKILL_TRAINING_TOOL)
ui_category = SKILL_UI_CAT_ENG
+1 -1
View File
@@ -1,6 +1,6 @@
/datum/skill/numerical/surgery
name = "Surgery"
desc = "How proficient you are at doing surgery."
desc = "How proficient you are at performing surgical procedures."
name_color = COLOR_PALE_BLUE_GRAY
competency_multiplier = 1.5 // 60% surgery speed up at max value of 100, considering the base multiplier.
ui_category = SKILL_UI_CAT_MED
+2 -1
View File
@@ -1,6 +1,7 @@
/// Jobbie skill modifiers.
/datum/skill_modifier/job
name = "Job Training"
modifier_flags = MODIFIER_SKILL_VALUE|MODIFIER_SKILL_VIRTUE|MODIFIER_SKILL_ORIGIN_DIFF
priority = MODIFIER_SKILL_PRIORITY_MAX
@@ -23,7 +24,7 @@
modifier_flags = MODIFIER_SKILL_VALUE|MODIFIER_SKILL_LEVEL|MODIFIER_SKILL_VIRTUE|MODIFIER_SKILL_ORIGIN_DIFF
level_mod = JOB_SKILL_TRAINED
/datum/skill_modifier/job/level/New(id)
/datum/skill_modifier/job/level/New(id, register = FALSE)
if(level_mod)
value_mod = GET_STANDARD_LVL(level_mod)
..()
+2
View File
@@ -1,8 +1,10 @@
/datum/skill_modifier/bad_mood
name = "Mood (Dejected)"
modifier_flags = MODIFIER_SKILL_VALUE|MODIFIER_SKILL_LEVEL|MODIFIER_SKILL_MULT|MODIFIER_SKILL_BODYBOUND
target_skills = list(SKILL_SANITY)
/datum/skill_modifier/great_mood
name = "Mood (Elated)"
modifier_flags = MODIFIER_SKILL_AFFINITY|MODIFIER_SKILL_MULT|MODIFIER_SKILL_BODYBOUND
target_skills = list(SKILL_SANITY)
affinity_mod = 1.2
+2
View File
@@ -1,4 +1,5 @@
/datum/skill_modifier/brain_damage
name = "Brain Damage"
target_skills = list(SKILL_INTELLIGENCE)
modifier_flags = MODIFIER_SKILL_VALUE|MODIFIER_SKILL_AFFINITY|MODIFIER_SKILL_LEVEL|MODIFIER_SKILL_MULT|MODIFIER_SKILL_BODYBOUND
value_mod = 0.85
@@ -6,6 +7,7 @@
affinity_mod = 0.85
/datum/skill_modifier/heavy_brain_damage
name = "Brain Damage (Severe)"
target_skills = list(SKILL_INTELLIGENCE)
modifier_flags = MODIFIER_SKILL_VALUE|MODIFIER_SKILL_AFFINITY|MODIFIER_SKILL_LEVEL|MODIFIER_SKILL_BODYBOUND|MODIFIER_SKILL_HANDICAP|MODIFIER_USE_THRESHOLDS
priority = MODIFIER_SKILL_PRIORITY_LOW