function Tizhi_AutoUpgradeStep(player)
local id = player:getVal_U(120)
if not player or not id then
player:setVal_N(502, 0) -- 释放锁
return
end
-- 获取当前等级
local currentLevel = player:getVal_U(100 + id) or 0
-- 终止条件1:满级
if currentLevel >= TIZHI_MAX_LEVEL then
player:messageBox("该穴位已达满级,修炼结束")
player:setVal_N(502, 0) -- 释放锁
return
end
-- 检查依赖(防止中途依赖失效)
local cfg = GetTizhiConfig(id)
if cfg and cfg.depend then
local dependLevel = player:getVal_U(100 + cfg.depend) or 0
if dependLevel < TIZHI_MAX_LEVEL then
player:messageBox("前置穴位等级不足,请先升级前置穴位后解锁该穴位")
player:setVal_N(502, 0) -- 释放锁
return
end
end
-- 终止条件2:材料不足
local has = player:getBagCount(TIZHI_ITEM_NAME, 0)
if has < TIZHI_COST then
player:messageBox(string.format("%s不足,需要%d个", TIZHI_ITEM_NAME, TIZHI_COST))
player:setVal_N(502, 0) -- 释放锁
return
end
-- 执行一次升级
local success = Tizhi_UpgradeOnce(player, id)
if not success then
player:setVal_N(502, 0) -- 释放锁
return
end
-- 延迟继续
player:delayGotoFunc(300, "Tizhi_AutoUpgradeStep")
end
-- 体质属性变量计算值表
function Tizhi_CalcValues(player, acupointId)
acupointId = tonumber(acupointId)
-- 获取所有穴位等级
local data = Get_tizhi_Data(player)
-- 属性类型分组
local fangyuPoints = {1, 3, 9, 14, 15}
local moxuePoints = {2, 6, 7, 11, 13}
local hunliPoints = {4, 5, 8, 10, 12}
-- 计算总属性
local function calcSum(points, unit)
local sum = 0
for _, idx in ipairs(points) do
sum = sum + (data[idx] or 0)
end
return sum * unit
end
local sumFangyu = calcSum(fangyuPoints, 1200)
local sumMoxue = calcSum(moxuePoints, 1200)
local sumHunli = calcSum(hunliPoints, 25000)
-- 当前穴位属性
local currentLevel = data[acupointId] or 0
local nowValue, nextValue = "", ""
local isMaxLevel = (currentLevel >= TIZHI_MAX_LEVEL)
-- 根据穴位类型设置显示值
if TableContains(fangyuPoints, acupointId) then
nowValue = "神圣防御+" .. currentLevel * 1200
nextValue = isMaxLevel and "已满级" or "神圣防御+" .. (currentLevel + 1) * 1200
elseif TableContains(moxuePoints, acupointId) then
nowValue = "磨血值+" .. currentLevel * 1200
nextValue = isMaxLevel and "已满级" or "磨血值+" .. (currentLevel + 1) * 1200
elseif TableContains(hunliPoints, acupointId) then
nowValue = "魂力上限+" .. currentLevel * 25000
nextValue = isMaxLevel and "已满级" or "魂力上限+" .. (currentLevel + 1) * 25000
end
return {
fangyu_value = sumFangyu,
moxue_value = sumMoxue,
hunli_value = sumHunli,
now_level = currentLevel .. "级",
now_value = nowValue,
next_value = nextValue,
}
end
|