Remove cache and batch event libraries, update locales

Deleted the cache and batch event libraries from the codebase, including all related client, server, and shared files. Removed server-side particle library and associated client event handlers. Updated utility and clothing modules to remove cache dependencies. Improved utility logging and deprecated point functions with notices. Updated all locales to use a consistent 'PurchasedItem' message format and added Bulgarian (bg) translation. Bumped version to 0.13.1 in fxmanifest.
This commit is contained in:
MrNewb committed 2025-12-23 19:27:27 -05:00
1 parent 5fd0744ca5
commit 48f8122197
76 files changed
+488 -875

No files matched your search

+60 -40
View File
@@ -3,31 +3,39 @@ Skills = Skills or {}
Skills.All = Skills.All or {}
-- XP Cache for performance
local XP_CACHE = {}
local cachedXp = {}
-- Default skill object: currentXP (0 to required), level
local DEFAULT_SKILL = { currentXP = 0, level = 1 }
local defaultSkills = { currentXP = 0, level = 1 }
function Skills.GetResourceName()
return "default"
end
-- Helper function to get or create a skill object
---@param src number
---@param skillName string
---@return table
local function getOrCreateSkill(src, skillName)
if not src or not skillName then return table.clone(DEFAULT_SKILL) end
if not src or not skillName then return table.clone(defaultSkills) end
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
if not playerSkills[skillName] then
playerSkills[skillName] = table.clone(DEFAULT_SKILL)
playerSkills[skillName] = table.clone(defaultSkills)
end
return playerSkills[skillName]
end
-- Calculate XP required for a level using RuneScape algorithm (with caching)
Skills.GetXPForLevel = function(level)
---Calculate XP required for a level using RuneScape algorithm (with caching)
---@param level number
---@return number
function Skills.GetXPForLevel(level)
if not level or level < 1 then return 0 end
if level == 1 then return 0 end -- Level 1 requires 0 XP
-- Check cache first
if XP_CACHE[level] then
return XP_CACHE[level]
if cachedXp[level] then
return cachedXp[level]
end
-- Calculate and cache
@@ -36,30 +44,44 @@ Skills.GetXPForLevel = function(level)
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
end
local result = math.floor(xp / 4)
XP_CACHE[level] = result
cachedXp[level] = result
return result
end
-- Create a skill (for initialization)
Skills.Create = function(name, maxLevel, baseXP)
if not name then return end
---@param name string
---@param maxLevel number
---@param baseXP number
---@return table
function Skills.Create(name, maxLevel, baseXP)
if not name then return {} end
Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 }
return Skills.All[name]
end
-- Get player's current level
Skills.GetSkillLevel = function(src, skillName)
---@param src number
---@param skillName string
---@return number
function Skills.GetSkillLevel(src, skillName)
if not src or not skillName then return 1 end
local skill = getOrCreateSkill(src, skillName)
return skill.level or 1
end
Skills.GetScaledXP = function(baseXP, playerLevel)
-- returns scaled XP based on player level
---@param baseXP number
---@param playerLevel number
---@return integer
function Skills.GetScaledXP(baseXP, playerLevel)
return math.floor(baseXP * (1 + playerLevel * 0.05))
end
-- Get current XP (0 to required XP for current level)
Skills.GetXP = function(src, skillName)
---@param src number
---@param skillName string
---@return number
function Skills.GetXP(src, skillName)
if not src or not skillName then return 0 end
local skill = getOrCreateSkill(src, skillName)
local currentXP = skill.currentXP or 0
@@ -67,17 +89,21 @@ Skills.GetXP = function(src, skillName)
end
-- Get XP required to complete the current level
Skills.GetXPRequiredForLevel = function(level)
---@param level number
---@return number
function Skills.GetXPRequiredForLevel(level)
if not level or level < 1 then return 0 end
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
return Skills.GetXPForLevel(level)
end
-- Add XP and handle level ups
Skills.AddXP = function(src, skillName, xp)
if not src or not skillName then
return false
end
---@param src number
---@param skillName string
---@param xp number
---@return boolean, number, number
function Skills.AddXP(src, skillName, xp)
if not src or not skillName then return false, 0, 0 end
if not xp or xp <= 0 then
xp = Skills.GetScaledXP(50, Skills.GetSkillLevel(src, skillName))
@@ -86,15 +112,14 @@ Skills.AddXP = function(src, skillName, xp)
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
local skill = playerSkills[skillName]
if not skill then
skill = table.clone(DEFAULT_SKILL)
skill = table.clone(defaultSkills)
playerSkills[skillName] = skill
end
local oldLevel = skill.level or 1
local currentXP = skill.currentXP or 0
-- Add XP
currentXP = currentXP + xp
currentXP = currentXP + xp
local xpNeeded = Skills.GetXPRequiredForLevel(oldLevel + 1)
if currentXP >= xpNeeded then
@@ -112,11 +137,15 @@ Skills.AddXP = function(src, skillName, xp)
end
-- Set skill level directly (resets currentXP to 0)
Skills.SetSkillLevel = function(src, skillName, level)
---@param src number
---@param skillName string
---@param level number
---@return boolean
function Skills.SetSkillLevel(src, skillName, level)
if not src or not skillName or not level or level < 1 then return false end
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
local skill = playerSkills[skillName] or table.clone(DEFAULT_SKILL)
local skill = playerSkills[skillName] or table.clone(defaultSkills)
level = math.min(math.max(1, level), 99)
skill.level = level
@@ -128,11 +157,15 @@ Skills.SetSkillLevel = function(src, skillName, level)
end
-- Set current XP directly
Skills.SetXP = function(src, skillName, xp)
---@param src number
---@param skillName string
---@param xp number
---@return boolean
function Skills.SetXP(src, skillName, xp)
if not src or not skillName or not xp or xp < 0 then return false end
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
local skill = playerSkills[skillName] or table.clone(DEFAULT_SKILL)
local skill = playerSkills[skillName] or table.clone(defaultSkills)
skill.currentXP = xp
playerSkills[skillName] = skill
@@ -141,17 +174,4 @@ Skills.SetXP = function(src, skillName, xp)
return true
end
Skills.GetResourceName = function()
return "default"
end
-- Debug Commands
-- RegisterCommand('clearskill', function(source, args, rawCommand)
-- if not source or source == 0 then return end
-- local skillName = args[1] or "fishing"
-- Skills.SetXP(source, skillName, 0)
-- Skills.SetSkillLevel(source, skillName, 1)
-- print("Skill " .. skillName .. " cleared for player " .. source)
-- end, false)
return Skills