Inept skill level

This commit is contained in:
Gonçalo Correia 2026-05-08 16:14:45 +01:00
parent af5a3d2d41
commit 961d642018
4 changed files with 18 additions and 19 deletions

View file

@ -2,7 +2,7 @@
## Title: AltSystem ## Title: AltSystem
## Notes: Enhances RP gameplay with a custom rolling system ## Notes: Enhances RP gameplay with a custom rolling system
## Author: Rukira ## Author: Rukira
## Version: 0.5 ## Version: 0.6
## Dependencies: totalRP3, totalRP3_Extended ## Dependencies: totalRP3, totalRP3_Extended
## SavedVariables: AltSystemDB ## SavedVariables: AltSystemDB

View file

@ -6,6 +6,7 @@ AltSystem.Data = {}
-- Skill levels and their modifiers -- Skill levels and their modifiers
AltSystem.Data.SkillLevels = { AltSystem.Data.SkillLevels = {
["Inept"] = -4,
["Novice"] = -2, ["Novice"] = -2,
["Adept"] = 0, ["Adept"] = 0,
["Expert"] = 2, ["Expert"] = 2,
@ -15,13 +16,9 @@ AltSystem.Data.SkillLevels = {
-- The "Base roll" entry is always the first (default) skill -- The "Base roll" entry is always the first (default) skill
local BASE_ROLL_ENTRY = { name = "Base roll", level = "Base", modifier = 0 } local BASE_ROLL_ENTRY = { name = "Base roll", level = "Base", modifier = 0 }
-- The "Inept" entry is always the second skill
local UNSKILLED_ENTRY = { name = "Inept", level = "Inept", modifier = -4 }
-- Default/fallback skill list used when no TRP3 profile skills are found -- Default/fallback skill list used when no TRP3 profile skills are found
local DEFAULT_SKILLS = { local DEFAULT_SKILLS = {
{ name = "Base roll", level = "Base", modifier = 0 }, { name = "Base roll", level = "Base", modifier = 0 },
{ name = "Inept", level = "Inept", modifier = -4 },
{ name = "Novice Skill", level = "Novice", modifier = -2 }, { name = "Novice Skill", level = "Novice", modifier = -2 },
{ name = "Adept Skill", level = "Adept", modifier = 0 }, { name = "Adept Skill", level = "Adept", modifier = 0 },
{ name = "Expert Skill", level = "Expert", modifier = 2 }, { name = "Expert Skill", level = "Expert", modifier = 2 },
@ -29,7 +26,7 @@ local DEFAULT_SKILLS = {
} }
-- Valid skill level keywords that must appear in the trait's right field (RT) -- Valid skill level keywords that must appear in the trait's right field (RT)
local VALID_SKILL_KEYWORDS = { "Novice", "Adept", "Expert", "Master" } local VALID_SKILL_KEYWORDS = { "Inept", "Novice", "Adept", "Expert", "Master" }
-- Check if the trait's right text field contains a valid skill keyword. -- Check if the trait's right text field contains a valid skill keyword.
-- Returns true if any keyword is found, false otherwise. -- Returns true if any keyword is found, false otherwise.
@ -43,11 +40,14 @@ local function HasSkillKeyword(rightText)
return false return false
end end
-- Determine the skill level from the trait's numeric value (V2 field, 0-20 range). -- Determine the skill level from the trait's right text and numeric value (V2 field, 0-20 range).
-- Returns the level string and modifier, or nil if the value is 0 or absent. -- If the trait is marked as Inept, always returns "Inept" with -4 modifier regardless of numeric value.
local function ParseSkillLevel(numericValue) -- Otherwise returns the level string and modifier based on numeric value, or nil if the value is 0 or absent.
local function ParseSkillLevel(rightText, numericValue)
if rightText and rightText:find("Inept") then
return "Inept", AltSystem.Data.SkillLevels["Inept"]
end
if not numericValue or numericValue <= 0 then return nil, nil end if not numericValue or numericValue <= 0 then return nil, nil end
if numericValue >= 20 then if numericValue >= 20 then
return "Master", AltSystem.Data.SkillLevels["Master"] return "Master", AltSystem.Data.SkillLevels["Master"]
elseif numericValue >= 11 then elseif numericValue >= 11 then
@ -60,14 +60,13 @@ local function ParseSkillLevel(numericValue)
end end
-- Fetch skills from the current TRP3 profile's personality traits. -- Fetch skills from the current TRP3 profile's personality traits.
-- Returns an array of skill entries, always starting with "Base roll" and "Inept". -- Returns an array of skill entries, always starting with "Base roll".
-- Traits marked as Inept get a -4 modifier regardless of their numeric value.
-- Falls back to the default list if no profile or no valid skills are found. -- Falls back to the default list if no profile or no valid skills are found.
function AltSystem.Data:RefreshSkills() function AltSystem.Data:RefreshSkills()
local skills = {} local skills = {}
-- Always add Base roll as the first entry
-- Always add Base roll as the first entry, then Inept
table.insert(skills, { name = BASE_ROLL_ENTRY.name, level = BASE_ROLL_ENTRY.level, modifier = BASE_ROLL_ENTRY.modifier }) table.insert(skills, { name = BASE_ROLL_ENTRY.name, level = BASE_ROLL_ENTRY.level, modifier = BASE_ROLL_ENTRY.modifier })
table.insert(skills, { name = UNSKILLED_ENTRY.name, level = UNSKILLED_ENTRY.level, modifier = UNSKILLED_ENTRY.modifier })
local foundAny = false local foundAny = false
@ -80,7 +79,7 @@ function AltSystem.Data:RefreshSkills()
local numericValue = trait.V2 local numericValue = trait.V2
if skillName and skillName ~= "" and HasSkillKeyword(trait.RT) then if skillName and skillName ~= "" and HasSkillKeyword(trait.RT) then
local level, modifier = ParseSkillLevel(numericValue) local level, modifier = ParseSkillLevel(trait.RT, numericValue)
if level and modifier then if level and modifier then
foundAny = true foundAny = true
table.insert(skills, { table.insert(skills, {

2
UI.lua
View file

@ -256,7 +256,7 @@ end
function AltSystem:RefreshSkillDropdown() function AltSystem:RefreshSkillDropdown()
AltSystem.Data:RefreshSkills() AltSystem.Data:RefreshSkills()
-- Reset selection to 1 (Inept) since the skill list may have changed -- Reset selection to 1 (Base roll) since the skill list may have changed
AltSystem.State.selectedSkillIndex = 1 AltSystem.State.selectedSkillIndex = 1
if AltSystem.SetSkillIndex then if AltSystem.SetSkillIndex then
AltSystem.SetSkillIndex(1) AltSystem.SetSkillIndex(1)

View file

@ -3,13 +3,13 @@
- The skills are defined in the TRP profile as 'Personality traits' - The skills are defined in the TRP profile as 'Personality traits'
- For each trait: - For each trait:
- the left field represents the skill name - the left field represents the skill name
- the right field must contain a valid skill keyword (Novice, Adept, Expert, Master) — traits without one of these keywords are omitted - the right field must contain a valid skill keyword (Inept, Novice, Adept, Expert, Master) — traits without one of these keywords are omitted
- if the right field contains "Inept", the trait always gets a -4 modifier regardless of its numeric value
- the first numeric value (V2) determines the skill level based on these ranges: - the first numeric value (V2) determines the skill level based on these ranges:
- Novice: 1-5 - Novice: 1-5
- Adept: 6-10 - Adept: 6-10
- Expert: 11-19 - Expert: 11-19
- Master: 20 - Master: 20
- should a skill have a value of 0 or no value, it should be omitted from the list - should a skill have a value of 0 or no value, it should be omitted from the list
- The list should have a default selected value of "Inept" which corresponds to a -4 modifier
- In case no skills are found in the profile, or no profile is selected, a default list should be displayed - In case no skills are found in the profile, or no profile is selected, a default list should be displayed
- Inept, Novice Skill, Adept Skill, Expert Skill, Master Skill - Base roll, Novice Skill, Adept Skill, Expert Skill, Master Skill