Commit 96d591f7430fe07690fa50415fdeac2584e15fe0

Authored by liuzujun
1 parent 50bcef87

天赋升级修改,增加英雄信赖

src/actions/AdvAction.lua
... ... @@ -266,6 +266,16 @@ function _M.startHangRpc(agent, data)
266 266 return true
267 267 end
268 268  
  269 +local function addHeroFaith(role, heroId, exp)
  270 + local hero = role.heros[heroId]
  271 + if not hero then
  272 + return
  273 + end
  274 +
  275 + hero:addHeroFaith(exp)
  276 + return hero:getProperty("faith")
  277 +end
  278 +
269 279 function _M.quickHangRpc(agent, data)
270 280 local role = agent.role
271 281 local msg = MsgPack.unpack(data)
... ... @@ -333,7 +343,7 @@ function _M.endHangRpc(agent, data)
333 343 end
334 344 adv_idle_time = adv_idle_time * 60
335 345  
336   - local reward, isFull, change
  346 + local reward, isFull, change, heroFaithMap
337 347 if skynet.timex() >= info.time then
338 348 -- 最新需求加成取消
339 349 --[[
... ... @@ -362,6 +372,14 @@ function _M.endHangRpc(agent, data)
362 372  
363 373 if not maxCampsite then return end
364 374 ]]
  375 + -- 增加英雄信赖
  376 + local exp = info.duration / 60
  377 + heroFaithMap = {}
  378 + for _, heroId in pairs(info.format.heros) do
  379 + local curFaith = addHeroFaith(role, heroId, exp)
  380 + heroFaithMap[heroId] = curFaith
  381 + end
  382 +
365 383 local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
366 384  
367 385 local idleReward = totalReward:toNumMap()
... ... @@ -389,7 +407,7 @@ function _M.endHangRpc(agent, data)
389 407  
390 408 role:checkTaskEnter("AdvHang", {})
391 409  
392   - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull}))
  410 + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap}))
393 411 return true
394 412 end
395 413  
... ...
src/actions/HeroAction.lua
... ... @@ -143,74 +143,45 @@ function _M.talentRpc(agent, data)
143 143 local hero = role.heros[msg.id]
144 144 if not hero then return 1 end
145 145  
146   - local index = msg.index -- 第几个天赋
147   - local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1}
148   - if not need[index] then return 2 end
149   -
150 146 local talent = hero:getProperty("talent")
  147 + local heroCfgId = hero:getProperty("type")
151 148 local curStage = talent:getv(0, 1)
152   - local curData = csvdb["unit_talentCsv"][curStage]
153   - if not curData then return 4 end
  149 + local curLevel = talent:getv(1, 1)
  150 + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage]
  151 + if not curData then return 1 end
154 152 local oldSkillLv = hero:getSkillLevel(1)
155 153  
156 154  
157 155 local cost = {}
158   - if index == 0 then
159   - --是否进阶
160   - local max = true
161   - for i = 1, 4 do
162   - if talent:getv(i, 0) < #curData then
163   - max = false
164   - break
165   - end
166   - end
167   - if max then
168   - talent = talent:setv(0, curStage + 1)
169   - for i = 1, 4 do
170   - talent = talent:setv(i, 0)
171   - end
172   - else
173   - return 12
174   - end
  156 + if curLevel == #curData then
  157 + talent = talent:setv(0, curStage + 1)
  158 + talent = talent:setv(1, 1)
175 159 else
176   -
177   - local level = talent:getv(index, 0)
178   - if level >= #curData then return 5 end
  160 + if curLevel > #curData then return 2 end
179 161  
180   - local talentData = curData[level]
181   - if not talentData then return end
  162 + local talentData = curData[curLevel]
  163 + if not talentData then return 3 end
182 164  
183   - if talentData.lvRequire > hero:getProperty("level") then return 6 end
  165 + if talentData.lvRequire > hero:getProperty("level") then return 4 end
184 166  
185 167 cost = talentData.money:toNumMap()
186   - local cost2 = talentData.cost:toNumMap()
187   - for k,v in pairs(cost2) do
188   - cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v
189   - end
190   - if not role:checkItemEnough(cost) then return 6 end
  168 + if not role:checkItemEnough(cost) then return 5 end
191 169 role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}})
192   - talent = talent:incrv(index, 1)
193   -
194   -
195   - local aheadLevel = 0
196   - for i = 1, talent:getv(0, 1) - 1 do
197   - aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i]
198   - end
199   - aheadLevel = aheadLevel + talent:getv(index, 0)
200   -
201   - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel})
  170 + talent = talent:setv(1, curLevel + 1)
202 171 end
  172 + curStage = talent:getv(0, 1)
  173 + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage})
203 174  
204 175 hero:updateProperty({field = "talent", value = talent})
205 176  
206 177 role:log("hero_talent", {
207 178 hero_id = hero:getProperty("type"), --英雄ID
208   - hero_talent_id = index, --天赋ID
  179 + hero_talent_id = curStage, --天赋ID
209 180 hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
210 181 hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级
211 182 hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级
212 183 })
213   - hero:mylog({desc = "talent", int1 = index, int2 = talent:getv(index, 0)})
  184 + hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)})
214 185  
215 186 SendPacket(actionCodes.Hero_talentRpc, '')
216 187 return true
... ... @@ -641,6 +612,7 @@ function _M.getResetRewardRpc(agent, data)
641 612 local level = hero:getProperty("level")
642 613 local breakL = hero:getProperty("breakL")
643 614 local talent = hero:getProperty("talent")
  615 + local heroCfgId = hero:getProperty("type")
644 616  
645 617 local tmpLevel = level
646 618 if level <= 1 and talent == "" then return end
... ... @@ -669,32 +641,18 @@ function _M.getResetRewardRpc(agent, data)
669 641 end
670 642  
671 643 local stage = talent:getv(0, 1)
672   - local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
  644 + local curTalentLvl = talent:getv(1, 1)
  645 + --local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
673 646  
674   - local talentCostIds = globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp]
675 647 while stage > 0 do
676   - local curData = csvdb["unit_talentCsv"][stage]
677   - for level = math.max(table.unpack(tlevel)), 1, -1 do
678   - local add = 0
679   - for i = 1, 4 do
680   - if tlevel[i] == level then
681   - add = add + 1
682   - tlevel[i] = tlevel[i] - 1
683   - end
684   - end
685   - local talentData = curData[level - 1]
  648 + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage]
  649 + for lvl = 1, curTalentLvl - 1 do
  650 + local talentData = curData[lvl]
686 651 for itemId, count in pairs(talentData.money:toNumMap()) do
687   - reward[itemId] = (reward[itemId] or 0) + count * add
688   - end
689   - for idx , count in pairs(talentData.cost:toNumMap()) do
690   - reward[talentCostIds[idx]] = (reward[talentCostIds[idx]] or 0) + count * add
  652 + reward[itemId] = (reward[itemId] or 0) + count
691 653 end
692 654 end
693 655 stage = stage - 1
694   - curData = csvdb["unit_talentCsv"][stage]
695   - if curData then
696   - tlevel = {#curData, #curData, #curData, #curData}
697   - end
698 656 end
699 657  
700 658 local equip = hero:getProperty("equip")
... ...
1   -Subproject commit 02a9bbbb10bb99a91cc5d67f62dc7e5b49d8cb46
  1 +Subproject commit 0f60ee4ca695995942574454c696747a4390ee5d
... ...
src/models/Hero.lua
... ... @@ -15,6 +15,7 @@ Hero.schema = {
15 15 -- loveL = {"number", 0}, --好感度等级
16 16 equip = {"string",""}, --装备 type=level
17 17 rune = {"string",""}, --零件 type=id
  18 + faith = {"number", 0}, -- 信赖
18 19 }
19 20  
20 21 function Hero:ctor( properties )
... ... @@ -102,6 +103,7 @@ function Hero:data()
102 103 -- loveL = self:getProperty("loveL"),
103 104 equip = self:getProperty("equip"),
104 105 rune = self:getProperty("rune"),
  106 + faith = self:getProperty("faith")
105 107 }
106 108 end
107 109  
... ...
src/models/HeroPlugin.lua
... ... @@ -48,34 +48,44 @@ function HeroPlugin.bind(Hero)
48 48 local breakL = params.breakL or self:getProperty("breakL")
49 49 local wakeL = params.wakeL or self:getProperty("wakeL")
50 50 local talent = params.talent or self:getProperty("talent")
51   -
  51 + local heroCfgId = self:getProperty("type")
52 52 --天赋
53 53 local talentAttrS = {}
54 54  
55 55 -- 四个基础属性
56 56 local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)]
  57 + local curTalentLvl = 0
57 58 if not curData then -- 已经满阶段了
58   - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]]
59   - local strength = curData[#curData].strength
60   - for i = 1, 4 do
61   - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + strength
62   - end
  59 + local cfgName = "unit_talent_"..heroCfgId.."Csv"
  60 + curData = csvdb[cfgName][#csvdb[cfgName]]
63 61 else
64   - for i = 1, 4 do --4个天赋
65   - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + curData[talent:getv(i, 0)].strength
66   - end
  62 + curTalentLvl = talent:getv(1, 1)
67 63 end
68   - --阶段属性
69   - for i = 1, (talent:getv(0, 1) - 1) do
70   - local curData = csvdb["unit_talentCsv"][i]
71   - local effect = curData[#curData].effect:toArray(true, "=")
72   - talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2]
  64 + for lvl, cfg in pairs(curData) do
  65 + if lvl < curTalentLvl or curTalentLvl == 0 then
  66 + if cfg.effect ~= 99 then
  67 + local curVal = talentAttrS[cfg.effect] or 0
  68 + if curVal < cfg.strength then
  69 + talentAttrS[cfg.effect] = cfg.strength
  70 + end
  71 + end
  72 + end
73 73 end
74   -
75 74  
76 75 for _, attrName in pairs(AttsEnumEx) do
77 76 if talentAttrS[attrName] then
78   - talentAttrS[attrName] = addAttr(unitData[attrName], talentAttrS[attrName], 1, attrName)
  77 + talentAttrS[attrName] = addAttr(unitData[attrName], talentAttrS[attrName], 0, attrName)
  78 + end
  79 + end
  80 +
  81 + -- 信赖属性
  82 + local faithAttr = {}
  83 + local faith = self:getProperty("faith")
  84 + local faithConfig = csvdb["unit_trustCsv"]
  85 + for lvl = 1, #faithConfig do
  86 + if faith >= faithConfig[lvl].exp then
  87 + local add = faithConfig[lvl]["position_"..unitData.position]:toArray(true, "=")
  88 + faithAttr[add[1]] = (faithAttr[add[1]] or 0) + add[2]
79 89 end
80 90 end
81 91  
... ... @@ -90,7 +100,7 @@ function HeroPlugin.bind(Hero)
90 100 for attr, value in pairs(attrs) do
91 101 attrs[attr] = attrs[attr] + addAttr(attrs[attr], lData[attr .. "Level"], 1, attr)
92 102 attrs[attr] = attrs[attr] + addAttr(attrs[attr], blData[attr .. "Level"], 1, attr)
93   - attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0)
  103 + attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0) + (faithAttr[attr] or 0)
94 104 end
95 105  
96 106 return attrs
... ... @@ -296,6 +306,27 @@ function HeroPlugin.bind(Hero)
296 306 end
297 307 return
298 308 end
  309 +
  310 + -- 添加英雄信赖
  311 + function Hero:addHeroFaith(exp)
  312 + local faith = self:getProperty("faith")
  313 + local config = csvdb["unit_trustCsv"]
  314 + local star = self:getProperty("wakeL")
  315 + local tmpExp = faith + exp
  316 + for lvl = 1, #config do
  317 + if star < config[lvl].star then
  318 + break
  319 + end
  320 + if tmpExp < config[lvl].exp then
  321 + faith = tmpExp
  322 + break
  323 + else
  324 + faith = config[lvl].exp
  325 + end
  326 + end
  327 + self:setProperty("faith", faith)
  328 + end
  329 +
299 330 end
300 331  
301 332  
... ...