525 lines
28 KiB
Lua
525 lines
28 KiB
Lua
local skillConfigPath = ""
|
|
local subSkillConfigPath = ""
|
|
local buffConfigPath = ""
|
|
|
|
if isDeveloper then
|
|
skillConfigPath = 'Developer/lua/app/config/skill.lua'
|
|
subSkillConfigPath = 'Developer/lua/app/config/skillSub.lua'
|
|
buffConfigPath = 'Developer/lua/app/config/buff.lua'
|
|
else
|
|
skillConfigPath = 'Lua/app/config/skill.lua.bytes'
|
|
subSkillConfigPath = 'Lua/app/config/skillSub.lua.bytes'
|
|
buffConfigPath = 'Lua/app/config/buff.lua.bytes'
|
|
end
|
|
|
|
local pairsName = {
|
|
[1] = 'skillName',
|
|
[2] = 'desc',
|
|
[3] = 'desc2'
|
|
}
|
|
|
|
local skillConfig = require(skillConfigPath).data
|
|
local subSkillConfig = require(subSkillConfigPath).data
|
|
local buffConfig = require(buffConfigPath)
|
|
|
|
function getBuffIsPercent(type)
|
|
local data = buffConfig.keys.name[type]
|
|
if not data then
|
|
CS.UnityEngine.Debug.LogError("buff表中不存在类型" .. tostring(type))
|
|
return false
|
|
end
|
|
|
|
return data.isPercent and data.isPercent == 2 or false
|
|
end
|
|
|
|
function reWrite(languageStr, str)
|
|
--配置表无序 只能按匹配
|
|
|
|
local skillDescConfigPath = ""
|
|
if isDeveloper then
|
|
skillDescConfigPath = 'Developer/lua/app/config/strings/' .. languageStr .. '/skill.lua'
|
|
else
|
|
skillDescConfigPath = 'Lua/app/config/strings/' .. languageStr .. '/skill.lua.bytes'
|
|
end
|
|
|
|
local skillDescConfig = require(skillDescConfigPath).data
|
|
local caCheTable = {}
|
|
local caCheRatioTable = {}
|
|
|
|
for skillid, data in pairs(skillDescConfig) do
|
|
for _, field in ipairs(pairsName) do
|
|
if data[field] then
|
|
--匹配规则并计算出数值记录下来
|
|
local matchResult = string.match(data[field], "{(.+)_(.)}")
|
|
if matchResult then
|
|
--计算并排序
|
|
local mainSkill = skillConfig[skillid]
|
|
if not mainSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(skillid))
|
|
return "Error"
|
|
end
|
|
|
|
local skillCacheData = {}
|
|
local skillRatioCacheData = {}
|
|
|
|
----------主技能技能效果 整体概率
|
|
local mainSkillEffects = mainSkill.effect
|
|
local mainSkillHasChange = false
|
|
local subSkillHasChange = false
|
|
|
|
if not mainSkillEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("主技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, mainSkillEffect in ipairs(mainSkillEffects) do
|
|
if mainSkillEffect.type ~= 'changeAtk' and mainSkillEffect.type ~= 'changeSkill' then
|
|
--CS.UnityEngine.Debug.Log("insert main SkillEffect")
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = mainSkillEffect.type,
|
|
v = mainSkillEffect.num,
|
|
p = mainSkillEffect.ratio,
|
|
r = mainSkillEffect.round,
|
|
},
|
|
})
|
|
else
|
|
mainSkillHasChange = true
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
table.insert(skillRatioCacheData, mainSkill.skillRatio or 0)
|
|
|
|
-----------子技能技能效果 整体概率
|
|
local subSkills = nil
|
|
if mainSkill.skillSub then
|
|
subSkills = mainSkill.skillSub
|
|
for _, subSkillId in ipairs(subSkills) do
|
|
local subSkill = subSkillConfig[subSkillId]
|
|
if not subSkill then
|
|
-- CS.UnityEngine.Debug.LogError("subskill表中不存在技能" .. tostring(subSkillId))
|
|
return "Error"
|
|
end
|
|
--子技能技能效果 整体概率
|
|
local subSkillEffects = subSkill.effect
|
|
|
|
if not subSkillEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("子技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, subSkillEffect in ipairs(subSkillEffects) do
|
|
if subSkillEffect.type ~= 'changeAtk' and subSkillEffect.type ~= 'changeSkill' then
|
|
--CS.UnityEngine.Debug.Log("insert sub SkillEffect")
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = subSkillEffect.type,
|
|
v = subSkillEffect.num,
|
|
p = subSkillEffect.ratio,
|
|
r = subSkillEffect.round,
|
|
},
|
|
})
|
|
|
|
else
|
|
subSkillHasChange = true
|
|
end
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, subSkill.skillRatio or 0)
|
|
|
|
end
|
|
end
|
|
|
|
local mainChangeAtkSkill = nil
|
|
local mainChangeSkillSkill = nil
|
|
local changeId = nil
|
|
local cacheChange = nil
|
|
|
|
if mainSkillHasChange then
|
|
---------主技能change技能
|
|
for _, mainSkillEffect in ipairs(mainSkillEffects) do
|
|
changeId = nil
|
|
if mainSkillEffect.type == 'changeAtk' then
|
|
changeId = mainSkillEffect.num
|
|
mainChangeAtkSkill = skillConfig[changeId]
|
|
cacheChange = mainChangeAtkSkill
|
|
if not mainChangeAtkSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(changeId))
|
|
return "Error"
|
|
end
|
|
end
|
|
|
|
if mainSkillEffect.type == 'changeSkill' then
|
|
changeId = mainSkillEffect.num
|
|
mainChangeSkillSkill = skillConfig[changeId]
|
|
cacheChange = mainChangeSkillSkill
|
|
if not mainChangeSkillSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(changeId))
|
|
return "Error"
|
|
end
|
|
end
|
|
|
|
if changeId then
|
|
local changeEffects = cacheChange.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("主机能chanage技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, cacheChange.skillRatio or 0)
|
|
|
|
---------主技能change技能的子技能
|
|
local changeFirstSubIds = cacheChange.skillSub
|
|
if changeFirstSubIds then
|
|
for _, changeFirstSubId in ipairs(changeFirstSubIds) do
|
|
local changeFirstSub = subSkillConfig[changeFirstSubId]
|
|
if not changeFirstSub then
|
|
-- CS.UnityEngine.Debug.LogError("subSkill表中不存在技能" .. tostring(changeFirstSubId))
|
|
return "Error"
|
|
end
|
|
|
|
local changeEffects = changeFirstSub.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("主机能chanage子技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, changeFirstSub.skillRatio or 0)
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
else
|
|
------------主技能isAct技能
|
|
if mainSkill.isAct then
|
|
local mainIsActSkill = skillConfig[mainSkill.isAct]
|
|
if not mainIsActSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(mainSkill.isAct))
|
|
return "Error"
|
|
end
|
|
|
|
local changeEffects = mainIsActSkill.effect
|
|
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("主技能isAct技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, mainIsActSkill.skillRatio or 0)
|
|
|
|
-------主技能isAct技能的子技能
|
|
local mainIsActSkillSubSkillIds = mainIsActSkill.skillSub
|
|
if mainIsActSkillSubSkillIds then
|
|
for _, mainIsActSkillSubSkillId in ipairs(mainIsActSkillSubSkillIds) do
|
|
local mainIsActSkillSubSkill = subSkillConfig[mainIsActSkillSubSkillId]
|
|
if not mainIsActSkillSubSkill then
|
|
-- CS.UnityEngine.Debug.LogError("subskill表中不存在技能" .. tostring(mainIsActSkillSubSkillId))
|
|
return "Error"
|
|
end
|
|
|
|
local changeEffects = mainIsActSkillSubSkill.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("主技能isAct技能的子技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, mainIsActSkillSubSkill.skillRatio)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
----------------子技能相关
|
|
local subSkillChangeAtkSkill = nil
|
|
local subSkillChangeSkillSkill = nil
|
|
local changeId = nil
|
|
local cacheChange = nil
|
|
|
|
if subSkills then
|
|
for _, subSkillId in ipairs(subSkills) do
|
|
local subSkill = subSkillConfig[subSkillId]
|
|
if not subSkill then
|
|
-- CS.UnityEngine.Debug.LogError("subskill表中不存在技能" .. tostring(subSkillId))
|
|
return "Error"
|
|
end
|
|
|
|
---------子技能isAct技能
|
|
if subSkill.isAct then
|
|
local subSkillActSkill = skillConfig[subSkill.isAct]
|
|
if not subSkillActSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(subSkillId))
|
|
return "Error"
|
|
end
|
|
|
|
local changeEffects = subSkillActSkill.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("子技能isAct技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, subSkillActSkill.skillRatio or 0)
|
|
|
|
|
|
------------子技能isAct技能的子技能
|
|
local subIsActSkillSubSkillIds = subSkillActSkill.skillsub
|
|
if subIsActSkillSubSkillIds then
|
|
for _, subIsActSkillSubSkillId in ipairs(subIsActSkillSubSkillIds) do
|
|
local subIsActSkillSubSkill = subSkillConfig[subIsActSkillSubSkillId]
|
|
if not subIsActSkillSubSkill then
|
|
-- CS.UnityEngine.Debug.LogError("subskill表中不存在技能" .. tostring(subIsActSkillSubSkillId))
|
|
return "Error"
|
|
end
|
|
|
|
local changeEffects = subIsActSkillSubSkill.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("子技能isAct技能的子技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, subIsActSkillSubSkill.skillRatio or 0)
|
|
|
|
end
|
|
end
|
|
else
|
|
local subSkillEffects = subSkill.effect
|
|
if not subSkillEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("子技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
----------子技能change技能
|
|
for _, subSkillEffect in ipairs(subSkillEffects) do
|
|
changeId = nil
|
|
if subSkillEffect.type == 'changeAtk' then
|
|
changeId = subSkillEffect.num
|
|
subSkillChangeAtkSkill = skillConfig[changeId]
|
|
cacheChange = subSkillChangeAtkSkill
|
|
if not subSkillChangeAtkSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(changeId))
|
|
return "Error"
|
|
end
|
|
end
|
|
|
|
if subSkillEffect.type == 'changeSkill' then
|
|
changeId = subSkillEffect.num
|
|
subSkillChangeSkillSkill = skillConfig[changeId]
|
|
cacheChange = subSkillChangeSkillSkill
|
|
if not subSkillChangeSkillSkill then
|
|
-- CS.UnityEngine.Debug.LogError("skill表中不存在技能" .. tostring(changeId))
|
|
return "Error"
|
|
end
|
|
end
|
|
|
|
if changeId then
|
|
local changeEffects = cacheChange.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("子技能change技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, cacheChange.skillRatio or 0)
|
|
|
|
---------子技能change技能的子技能
|
|
local subChangeFirstSubIds = cacheChange.skillSub
|
|
if subChangeFirstSubIds then
|
|
for _, subChangeFirstSubId in ipairs(subChangeFirstSubIds) do
|
|
local subChangeFirstSub = subSkillConfig[subChangeFirstSubId]
|
|
if not subChangeFirstSub then
|
|
-- CS.UnityEngine.Debug.LogError("subSkill表中不存在技能" .. tostring(subChangeFirstSubId))
|
|
return "Error"
|
|
end
|
|
|
|
local changeEffects = subChangeFirstSub.effect
|
|
if not changeEffects then
|
|
-- CS.UnityEngine.Debug.LogWarning("子技能change技能的子技能没有技能效果" .. tostring(skillid))
|
|
else
|
|
for _, changeEffect in ipairs(changeEffects) do
|
|
table.insert(skillCacheData,{
|
|
effect = {
|
|
type = changeEffect.type,
|
|
v = changeEffect.num,
|
|
p = changeEffect.ratio,
|
|
r = changeEffect.round,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
|
|
table.insert(skillRatioCacheData, subChangeFirstSub.skillRatio or 0)
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--CS.UnityEngine.Debug.Log(tostring(skillid) .. "写入数据" .. #skillCacheData)
|
|
caCheTable[skillid] = skillCacheData
|
|
caCheRatioTable[skillid] = skillRatioCacheData
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--匹配每个id然后替换内部字符串(保证原有顺序)
|
|
local result = string.gsub(str, "%[(%d+)%]=(%b{})", function (id, infoStr)
|
|
id = tonumber(id)
|
|
--CS.UnityEngine.Debug.LogError("id" .. tostring(id))
|
|
local returnStr = string.gsub(string.sub(infoStr, 2), "(%b{})",function(str)
|
|
local _flag = string.sub(str,2,-2)
|
|
local _index = string.find(_flag, '_')
|
|
local flag = string.sub(_flag,1 ,_index - 1)
|
|
local readFlag = string.sub(_flag,_index + 1)
|
|
local index = tonumber(flag)
|
|
|
|
if not caCheTable[id] then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "没有读取到数据 请对比多语言表和skill表" .. caCheTable[id])
|
|
return ""
|
|
end
|
|
|
|
--CS.UnityEngine.Debug.Log(flag .. " " .. readFlag)
|
|
|
|
if readFlag == 'v' then
|
|
if not index then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "{x_x}格式配置错误" .. " v")
|
|
return ""
|
|
end
|
|
|
|
if not caCheTable[id][index] then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "读取参数错误 或者 配置错误" .. "读取配置长度:" .. #caCheTable[id] .. "index: " .. index .. " v")
|
|
return ""
|
|
end
|
|
|
|
local isPercent = getBuffIsPercent(caCheTable[id][index].effect.type)
|
|
local num = math.abs(caCheTable[id][index].effect.v)
|
|
if isPercent then
|
|
num = math.floor(num / 10)
|
|
end
|
|
|
|
return tostring(num)
|
|
elseif readFlag == 'p' then
|
|
if string.sub(flag,1, 1) == "s" then
|
|
index = tonumber(string.sub(flag, 2))
|
|
if not index then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "{x_x}格式配置错误" .. " s")
|
|
return ""
|
|
end
|
|
|
|
if not caCheRatioTable[id][index] then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "读取参数错误 或者 配置错误" .. "读取配置长度:" .. #caCheRatioTable[id] .. "index: " .. index .. " p")
|
|
return ""
|
|
end
|
|
|
|
if not caCheRatioTable[id][index] then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "技能没有整体概率")
|
|
end
|
|
return math.floor((caCheRatioTable[id][index] or 0) / 10)
|
|
else
|
|
if not index then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "{x_x}格式配置错误" .. " s")
|
|
return ""
|
|
end
|
|
|
|
if not caCheTable[id][index] then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "读取参数错误 或者 配置错误" .. "读取配置长度:" .. #caCheTable[id] .. "index: " .. index .. " p")
|
|
return ""
|
|
end
|
|
|
|
return math.floor(caCheTable[id][index].effect.p / 10)
|
|
end
|
|
elseif readFlag == 'r' then
|
|
if not index then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "{x_x}格式配置错误" .. " r")
|
|
return ""
|
|
end
|
|
|
|
if not caCheTable[id][index] then
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "读取参数错误 或者 配置错误" .. "读取配置长度:" .. #caCheTable[id] .. "index: " .. index .. " r")
|
|
return ""
|
|
end
|
|
|
|
return caCheTable[id][index].effect.r
|
|
else
|
|
CS.UnityEngine.Debug.LogError(tostring(id) .. "{x_x}格式配置错误" .. "后缀不是vpr")
|
|
return ""
|
|
end
|
|
end)
|
|
|
|
return "[" .. tostring(id) .. "]={" .. returnStr
|
|
end)
|
|
|
|
return result
|
|
end
|