Compare commits
4 commits
ed1e696eb5
...
6a44458443
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a44458443 | |||
| c27a6cd033 | |||
| 5b36bfdb1b | |||
| ab8388e27c |
6 changed files with 55 additions and 12 deletions
|
|
@ -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: 1.0
|
## Version: 1.1
|
||||||
## Dependencies: totalRP3, totalRP3_Extended
|
## Dependencies: totalRP3, totalRP3_Extended
|
||||||
## SavedVariables: AltSystemDB
|
## SavedVariables: AltSystemDB
|
||||||
|
|
||||||
|
|
|
||||||
20
Core.lua
20
Core.lua
|
|
@ -4,6 +4,7 @@
|
||||||
AltSystem = AltSystem or {}
|
AltSystem = AltSystem or {}
|
||||||
AltSystem.State = {
|
AltSystem.State = {
|
||||||
selectedSkillIndex = 1,
|
selectedSkillIndex = 1,
|
||||||
|
selectedSkillName = nil, -- skill name used to restore selection across sessions
|
||||||
selectedItemIndex = 1, -- 1 = No item
|
selectedItemIndex = 1, -- 1 = No item
|
||||||
selectedDefenseIndex = 1, -- 1 = Base armor
|
selectedDefenseIndex = 1, -- 1 = Base armor
|
||||||
shieldEnabled = false,
|
shieldEnabled = false,
|
||||||
|
|
@ -43,6 +44,18 @@ function AltSystem:Init()
|
||||||
if AltSystemDB.petSummonEnabled ~= nil then
|
if AltSystemDB.petSummonEnabled ~= nil then
|
||||||
AltSystem.State.petSummonEnabled = AltSystemDB.petSummonEnabled
|
AltSystem.State.petSummonEnabled = AltSystemDB.petSummonEnabled
|
||||||
end
|
end
|
||||||
|
if AltSystemDB.shieldEnabled ~= nil then
|
||||||
|
AltSystem.State.shieldEnabled = AltSystemDB.shieldEnabled
|
||||||
|
end
|
||||||
|
if AltSystemDB.selectedItemIndex then
|
||||||
|
AltSystem.State.selectedItemIndex = AltSystemDB.selectedItemIndex
|
||||||
|
end
|
||||||
|
if AltSystemDB.selectedDefenseIndex then
|
||||||
|
AltSystem.State.selectedDefenseIndex = AltSystemDB.selectedDefenseIndex
|
||||||
|
end
|
||||||
|
if AltSystemDB.selectedSkillName then
|
||||||
|
AltSystem.State.selectedSkillName = AltSystemDB.selectedSkillName
|
||||||
|
end
|
||||||
|
|
||||||
-- Register slash command /altsystem
|
-- Register slash command /altsystem
|
||||||
SLASH_ALTSYSTEM1 = "/altsystem"
|
SLASH_ALTSYSTEM1 = "/altsystem"
|
||||||
|
|
@ -58,8 +71,15 @@ function AltSystem:Init()
|
||||||
AltSystemDB.announceEnabled = AltSystem.State.announceEnabled
|
AltSystemDB.announceEnabled = AltSystem.State.announceEnabled
|
||||||
AltSystemDB.announceChannelIndex = AltSystem.State.announceChannelIndex
|
AltSystemDB.announceChannelIndex = AltSystem.State.announceChannelIndex
|
||||||
AltSystemDB.petSummonEnabled = AltSystem.State.petSummonEnabled
|
AltSystemDB.petSummonEnabled = AltSystem.State.petSummonEnabled
|
||||||
|
AltSystemDB.shieldEnabled = AltSystem.State.shieldEnabled
|
||||||
|
AltSystemDB.selectedItemIndex = AltSystem.State.selectedItemIndex
|
||||||
|
AltSystemDB.selectedDefenseIndex = AltSystem.State.selectedDefenseIndex
|
||||||
|
AltSystemDB.selectedSkillName = AltSystem.State.selectedSkillName
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Build the main frame now that saved variables are loaded
|
||||||
|
AltSystem:CreateMainFrame()
|
||||||
|
|
||||||
print("|cff00ccffAltSystem|r loaded. Type /altsystem to open.")
|
print("|cff00ccffAltSystem|r loaded. Type /altsystem to open.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
12
Data.lua
12
Data.lua
|
|
@ -14,15 +14,18 @@ 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 "Unskilled" entry is always the last skill
|
||||||
|
local UNSKILLED_ENTRY = { name = "Unskilled", level = "Unskilled", 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 = "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 },
|
||||||
{ name = "Master Skill", level = "Master", modifier = 4 },
|
{ name = "Master Skill", level = "Master", modifier = 4 },
|
||||||
|
{ name = "Unskilled", level = "Unskilled", modifier = -4 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 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)
|
||||||
|
|
@ -124,6 +127,9 @@ function AltSystem.Data:RefreshSkills()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Always add Unskilled as the last entry
|
||||||
|
table.insert(skills, { name = UNSKILLED_ENTRY.name, level = UNSKILLED_ENTRY.level, modifier = UNSKILLED_ENTRY.modifier })
|
||||||
|
|
||||||
AltSystem.Data.Skills = skills
|
AltSystem.Data.Skills = skills
|
||||||
return skills
|
return skills
|
||||||
end
|
end
|
||||||
|
|
|
||||||
6
Roll.lua
6
Roll.lua
|
|
@ -78,8 +78,9 @@ rollListener:RegisterEvent("CHAT_MSG_SYSTEM")
|
||||||
rollListener:SetScript("OnEvent", function(self, event, message)
|
rollListener:SetScript("OnEvent", function(self, event, message)
|
||||||
-- Phase 2: waiting for pet/summon roll result (1-5)
|
-- Phase 2: waiting for pet/summon roll result (1-5)
|
||||||
if pendingPetRoll then
|
if pendingPetRoll then
|
||||||
local petRoll = message:match("rolls (%d+) %(1%-5%)")
|
local petRoller, petRoll = message:match("(.+) rolls (%d+) %(1%-5%)")
|
||||||
if not petRoll then return end
|
if not petRoll then return end
|
||||||
|
if petRoller ~= UnitName("player") then return end
|
||||||
|
|
||||||
local petValue = tonumber(petRoll)
|
local petValue = tonumber(petRoll)
|
||||||
local info = pendingPetRoll
|
local info = pendingPetRoll
|
||||||
|
|
@ -93,8 +94,9 @@ rollListener:SetScript("OnEvent", function(self, event, message)
|
||||||
if not pendingRollType then return end
|
if not pendingRollType then return end
|
||||||
|
|
||||||
-- Match the roll result pattern: "PlayerName rolls X (1-20)"
|
-- Match the roll result pattern: "PlayerName rolls X (1-20)"
|
||||||
local roll = message:match("rolls (%d+) %(1%-20%)")
|
local roller, roll = message:match("(.+) rolls (%d+) %(1%-20%)")
|
||||||
if not roll then return end
|
if not roll then return end
|
||||||
|
if roller ~= UnitName("player") then return end
|
||||||
|
|
||||||
local rollValue = tonumber(roll)
|
local rollValue = tonumber(roll)
|
||||||
local rollType = pendingRollType
|
local rollType = pendingRollType
|
||||||
|
|
|
||||||
24
UI.lua
24
UI.lua
|
|
@ -90,6 +90,7 @@ function AltSystem:CreateMainFrame()
|
||||||
AltSystem.State.selectedSkillIndex,
|
AltSystem.State.selectedSkillIndex,
|
||||||
function(index)
|
function(index)
|
||||||
AltSystem.State.selectedSkillIndex = index
|
AltSystem.State.selectedSkillIndex = index
|
||||||
|
AltSystem.State.selectedSkillName = AltSystem.Data.Skills[index] and AltSystem.Data.Skills[index].name or nil
|
||||||
UpdateSkillWarning(index)
|
UpdateSkillWarning(index)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
@ -314,13 +315,24 @@ end
|
||||||
function AltSystem:RefreshSkillDropdown()
|
function AltSystem:RefreshSkillDropdown()
|
||||||
AltSystem.Data:RefreshSkills()
|
AltSystem.Data:RefreshSkills()
|
||||||
|
|
||||||
-- Reset selection to 1 (Base roll) since the skill list may have changed
|
-- Try to restore the previously selected skill by name; fall back to 1 (Base roll)
|
||||||
AltSystem.State.selectedSkillIndex = 1
|
local newIndex = 1
|
||||||
|
local savedName = AltSystem.State.selectedSkillName
|
||||||
|
if savedName then
|
||||||
|
for i, skill in ipairs(AltSystem.Data.Skills) do
|
||||||
|
if skill.name == savedName then
|
||||||
|
newIndex = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
AltSystem.State.selectedSkillIndex = newIndex
|
||||||
|
AltSystem.State.selectedSkillName = AltSystem.Data.Skills[newIndex] and AltSystem.Data.Skills[newIndex].name or nil
|
||||||
if AltSystem.SetSkillIndex then
|
if AltSystem.SetSkillIndex then
|
||||||
AltSystem.SetSkillIndex(1)
|
AltSystem.SetSkillIndex(newIndex)
|
||||||
end
|
end
|
||||||
if AltSystem.UpdateSkillWarning then
|
if AltSystem.UpdateSkillWarning then
|
||||||
AltSystem.UpdateSkillWarning(1)
|
AltSystem.UpdateSkillWarning(newIndex)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Rebuild the dropdown menu with the new skill list
|
-- Rebuild the dropdown menu with the new skill list
|
||||||
|
|
@ -333,6 +345,7 @@ function AltSystem:RefreshSkillDropdown()
|
||||||
function(data) return data == AltSystem.State.selectedSkillIndex end,
|
function(data) return data == AltSystem.State.selectedSkillIndex end,
|
||||||
function(data)
|
function(data)
|
||||||
AltSystem.State.selectedSkillIndex = data
|
AltSystem.State.selectedSkillIndex = data
|
||||||
|
AltSystem.State.selectedSkillName = AltSystem.Data.Skills[data] and AltSystem.Data.Skills[data].name or nil
|
||||||
if AltSystem.SetSkillIndex then
|
if AltSystem.SetSkillIndex then
|
||||||
AltSystem.SetSkillIndex(data)
|
AltSystem.SetSkillIndex(data)
|
||||||
end
|
end
|
||||||
|
|
@ -347,5 +360,4 @@ function AltSystem:RefreshSkillDropdown()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create the frame on file load so it's ready when Init runs
|
-- Frame is created by AltSystem:Init() in Core.lua, after saved variables are loaded
|
||||||
AltSystem:CreateMainFrame()
|
|
||||||
|
|
|
||||||
3
docs/Changelog.md
Normal file
3
docs/Changelog.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
- Adding default 'Unskilled (-4)' option
|
||||||
|
- The roll window now remembers all user selections (skill, item, armor type, shield, pet, announce and channel) across sessions
|
||||||
|
- Fixed an issue where the wrong rolls were displayed when in a large enough group
|
||||||
Loading…
Add table
Add a link
Reference in a new issue