找回密码
 立即注册
搜索
查看: 189|回复: 4

发下自己学习着重新写的炼体体质模块核心代码,也算完整跑通啦

[复制链接]
发表于 2026-6-15 16:52:16 | 显示全部楼层 |阅读模式

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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

发表于 2026-6-15 17:28:26 | 显示全部楼层
不错 加油啊
回复

使用道具 举报

发表于 2026-6-15 18:04:22 | 显示全部楼层
强, 感谢分享,学习学习
回复

使用道具 举报

发表于 2026-6-19 09:06:41 | 显示全部楼层
牛P..................................................
回复

使用道具 举报

 楼主| 发表于 2026-6-22 16:12:11 | 显示全部楼层
aaa肥兔 发表于 2026-6-19 09:06
牛P..................................................

框架可以AI给思路,但是具体的实现和实际情况还是要自己根据逻辑来,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|HGEM2论坛

GMT+8, 2026-7-13 17:55 , Processed in 0.214973 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表