From 6545b28cdc5145d8793fc0d146aabcede5dcdc47 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 29 Dec 2024 00:41:03 -0800 Subject: [PATCH] use xp formula instead of limited range of enum values --- changelog.txt | 1 + internal/unit-info-viewer/skills-progress.lua | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index f4082534b..6e4009555 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ Template for new versions: ## Fixes - `fix/dry-buckets`: don't empty buckets for wells that are actively in use +- `gui/unit-info-viewer`: skill progress bars now show correct XP thresholds for skills past Legendary+5 ## Misc Improvements - `immortal-cravings`: goblins and other naturally non-eating/non-drinking races will now also satisfy their needs for eating and drinking diff --git a/internal/unit-info-viewer/skills-progress.lua b/internal/unit-info-viewer/skills-progress.lua index 7e7dd1714..fdf9cb5bd 100644 --- a/internal/unit-info-viewer/skills-progress.lua +++ b/internal/unit-info-viewer/skills-progress.lua @@ -27,7 +27,6 @@ SkillProgressOverlay.ATTRS { 'dwarfmode/ViewSheets/UNIT/Skills/Combat', 'dwarfmode/ViewSheets/UNIT/Skills/Social', 'dwarfmode/ViewSheets/UNIT/Skills/Other', - 'dungeonmode/ViewSheets/UNIT/Skills/Labor', 'dungeonmode/ViewSheets/UNIT/Skills/Combat', 'dungeonmode/ViewSheets/UNIT/Skills/Social', @@ -79,6 +78,10 @@ function SkillProgressOverlay:preUpdateLayout(parent_rect) self.frame.h = parent_rect.height - 21 end +local function get_threshold(lvl) + return 500 + lvl * 100 +end + function SkillProgressOverlay:onRenderFrame(dc, rect) local annotations = {} local current_unit = df.unit.find(view_sheets.active_id) @@ -104,7 +107,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect) table.insert(annotations, "\n\n\n\n") goto continue end - local rating = df.skill_rating.attrs[math.max(df.skill_rating.Dabbling, math.min(skill.rating, df.skill_rating.Legendary5))] + local xp_threshold = get_threshold(skill.rating) if experience then if not progress_bar then table.insert(annotations, NEWLINE) @@ -122,7 +125,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect) pen=level_color, }) table.insert(annotations, { - text=('%4d/%4d'):format(skill.experience, rating.xp_threshold), + text=('%4d/%4d'):format(skill.experience, xp_threshold), pen=level_color, width=9, rjustify=true, @@ -134,7 +137,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect) -- Progress Bar if progress_bar then table.insert(annotations, NEWLINE) - local percentage = skill.experience / rating.xp_threshold + local percentage = skill.experience / xp_threshold local barstop = math.floor((margin * percentage) + 0.5) for i = 0, margin-1 do local color = COLOR_LIGHTCYAN