diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index fe93903..87c4b80 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -151,6 +151,10 @@ function _M.wakeRpc(agent, data) if curLevel == 3 then -- 解锁cg role:checkTaskEnter("WakeCG", {heroType = typ}) end + + if curLevel >= 4 then --自动觉醒技能 + hero:increGeniusTree() + end hero:mylog({desc = "wake", int1 = hero:getProperty("wakeL")}) role:log("hero_rise", { @@ -1292,8 +1296,6 @@ function _M.saveGeniusTreeRpc(agent, data) genius = "" end hero:updateProperty({field="genius", value=genius}) - print("genius:") - print(#genius) SendPacket(actionCodes.Hero_saveGeniusTreeRpc, MsgPack.pack({genius = genius})) return true end diff --git a/src/models/HeroPlugin.lua b/src/models/HeroPlugin.lua index 2b03deb..fe32deb 100644 --- a/src/models/HeroPlugin.lua +++ b/src/models/HeroPlugin.lua @@ -394,12 +394,10 @@ function HeroPlugin.bind(Hero) local geniusTree = genius:toNumMap() local tmpgenius = "" for wakeL, val in pairs(geniusTree) do - print("wakeL:") - print(wakeL) if wakeL < 4 then return maxWakeL end if wakeL % 2 == 0 then if geniusTree[wakeL+1] and geniusTree[wakeL+1] ~= val then - return 0 + return 0, 0, tmpgenius end end maxWakeL = math.max(maxWakeL, wakeL) @@ -409,16 +407,44 @@ function HeroPlugin.bind(Hero) tmpgenius = string.format("%s %s=%s", tmpgenius, tostring(wakeL), tostring(val)) end end - return tonumber(maxWakeL),tmpgenius + return tonumber(maxWakeL), tonumber(geniusTree[maxWakeL]), tmpgenius + end + + function Hero:increGeniusTree() + local genius = self:getProperty("genius") + local wakeL = self:getProperty("wakeL") + local maxWakeL, awake + maxWakeL, awake, genius = self:checkGeniusTree(genius) + if maxWakeL >= 4 and wakeL > maxWakeL and maxWakeL % 2 == 0 then + maxWakeL = maxWakeL + 1 + if #genius == 0 then + genius = string.format("%s=%s", tostring(maxWakeL), tostring(awake)) + else + genius = string.format("%s %s=%s", genius, tostring(maxWakeL), tostring(awake)) + end + end + return genius + end + + function Hero:resetGeniusTree() + local unit_starTalent_reset = globalCsv["unit_starTalent_reset"] + local cost = unit_starTalent_reset:toNumMap() + if not self.owner:checkItemEnough(cost) then return false end + + self.owner:costItems(cost, {log = {desc = "heroGenius", int1 = self:getProperty("id"), int2 = self:getProperty("type")}}) + return true end function Hero:saveGeniusTree(wakeL, awake) local genius = self:getProperty("genius") - local tid = self:getProperty("type") - if not wakeL and not awake then return "" end + local typ = self:getProperty("type") + local curWakeL = self:getProperty("wakeL") + if not wakeL or not awake then + if self:resetGeniusTree() == true then return "" end + return genius + end - - local heroUnit = csvdb["unitCsv"][tid] + local heroUnit = csvdb["unitCsv"][typ] if not heroUnit then return genius end if not heroUnit.awake_1 or not heroUnit.awake_2 then return genius end @@ -428,9 +454,16 @@ function HeroPlugin.bind(Hero) genius = string.format("%s %s=%s", genius, tostring(wakeL), tostring(awake)) end - local maxWakeL, genius = self:checkGeniusTree(genius) + local maxWakeL + maxWakeL, _, genius = self:checkGeniusTree(genius) if maxWakeL ~= wakeL then genius = self:getProperty("genius") + else + + if curWakeL > maxWakeL and maxWakeL % 2 == 0 then --自动升一级,举例,6星设置4星觉醒技能。自动升级到5星 + genius = string.format("%s %s=%s", genius, tostring(maxWakeL + 1), tostring(awake)) + maxWakeL, _, genius = self:checkGeniusTree(genius) + end end return genius end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 500a0e0..2aba315 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -136,6 +136,7 @@ local ItemReason = { changeSpark = 1213, -- 穿戴火花 sparkLvlUp = 1214, -- 火花强化 sparkQualityUp = 1215, -- 火花升华 + heroGenius = 1216, -- 英雄天赋点 -- pvp pvpCHead = 1301, -- pvp 跨服竞技场头像 -- libgit2 0.21.2