Commit 6dc482bb38240b1978e1693f64999702694a51f8

Authored by zhouhaihai
1 parent 1bb3abca

中继层完成, 新增两个冒险物品使用效果

@@ -106,6 +106,9 @@ AdvSpecialStage = { @@ -106,6 +106,9 @@ AdvSpecialStage = {
106 [6] = "InOut", 106 [6] = "InOut",
107 [7] = "Diner" 107 [7] = "Diner"
108 } 108 }
  109 +
  110 +AdvCodeRandomStage = 10 -- 一些功能需要代码强行随机事件 随机到这个地块类型上面
  111 +
109 --客户端需要知道这个 112 --客户端需要知道这个
110 AdvEventType = { 113 AdvEventType = {
111 -- 特殊事件(地块决定) 114 -- 特殊事件(地块决定)
@@ -117,7 +120,6 @@ AdvEventType = { @@ -117,7 +120,6 @@ AdvEventType = {
117 InOut = -6, -- 出入口集合体 120 InOut = -6, -- 出入口集合体
118 Diner = -7, -- 料理台 121 Diner = -7, -- 料理台
119 122
120 -  
121 -- 普通事件(随机) 123 -- 普通事件(随机)
122 Choose = 1, --选择点 124 Choose = 1, --选择点
123 Drop = 2, --物品掉落点 125 Drop = 2, --物品掉落点
src/actions/AdvAction.lua
@@ -315,15 +315,6 @@ function _M.useItemRpc(agent, data) @@ -315,15 +315,6 @@ function _M.useItemRpc(agent, data)
315 if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end 315 if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end
316 if not adv:cost({[itemId] = count}, {}, true) then return true end 316 if not adv:cost({[itemId] = count}, {}, true) then return true end
317 317
318 - local status = true  
319 - for i = 1, count do  
320 - status = status and adv:doActive(itemData.effect, target) -- target  
321 - if not status then  
322 - break  
323 - end  
324 - end  
325 - if not status then return end  
326 -  
327 --消耗 318 --消耗
328 if itemData["function"] == 0 or itemData["function"] == 1 then 319 if itemData["function"] == 0 or itemData["function"] == 1 then
329 adv:cost({[itemId] = count}, {}) 320 adv:cost({[itemId] = count}, {})
@@ -331,6 +322,11 @@ function _M.useItemRpc(agent, data) @@ -331,6 +322,11 @@ function _M.useItemRpc(agent, data)
331 end 322 end
332 323
333 adv:checkAchievement(adv.AchievType.UseItem, count, itemId) 324 adv:checkAchievement(adv.AchievType.UseItem, count, itemId)
  325 +
  326 + for i = 1, count do
  327 + adv:doActive(itemData.effect, target) -- target
  328 + end
  329 +
334 adv:afterRound() 330 adv:afterRound()
335 adv:saveDB() 331 adv:saveDB()
336 332
@@ -150,6 +150,13 @@ function Adv:forceOver(notNotify) @@ -150,6 +150,13 @@ function Adv:forceOver(notNotify)
150 self:clear() 150 self:clear()
151 local advTeam = self.owner:getProperty("advTeam") 151 local advTeam = self.owner:getProperty("advTeam")
152 advTeam.player = nil 152 advTeam.player = nil
  153 +
  154 + local reward = self.owner:getProperty("advItems"):toNumMap()
  155 + for itemId, count in pairs(reward) do
  156 + reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败
  157 + end
  158 + self.owner:award(reward)
  159 +
153 self.owner:updateProperties({ 160 self.owner:updateProperties({
154 advInfo = {}, 161 advInfo = {},
155 advTeam = advTeam, 162 advTeam = advTeam,
@@ -389,11 +396,20 @@ function Adv:haveComboAF(id) @@ -389,11 +396,20 @@ function Adv:haveComboAF(id)
389 return false 396 return false
390 end 397 end
391 398
392 -function Adv:artifactLevelUp(id) 399 +function Adv:artifactLevelUp(id, level)
  400 + level = level or 1
393 local advAFGet = self.owner:getProperty("advAFGet") 401 local advAFGet = self.owner:getProperty("advAFGet")
  402 + if not advAFGet[id] then return end
394 local advAFWear = self.owner:getProperty("advAFWear") 403 local advAFWear = self.owner:getProperty("advAFWear")
  404 +
  405 + local newLv = advAFGet[id]
  406 + for i = 1, level do
  407 + if not self.owner:isArtifactOpen(id, self:isEndless(), newLv + 1) then break end
  408 + newLv = newLv + 1
  409 + end
  410 + if newLv == advAFGet[id] then return end
  411 +
395 local status = 0 412 local status = 0
396 - local newLv = advAFGet[id] + 1  
397 if advAFWear[id] then -- 穿着呢 413 if advAFWear[id] then -- 穿着呢
398 local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] 414 local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]]
399 local newData = csvdb["adv_artifactCsv"][id][newLv] 415 local newData = csvdb["adv_artifactCsv"][id][newLv]
@@ -450,16 +466,29 @@ function Adv:getCurFloorData() @@ -450,16 +466,29 @@ function Adv:getCurFloorData()
450 return (csvdb["adv_chapter_floorCsv"][chapter] or {})[self.level] 466 return (csvdb["adv_chapter_floorCsv"][chapter] or {})[self.level]
451 end 467 end
452 468
453 ---关卡通关,非层 score < 0 失败  
454 -function Adv:over(success, isAllPass) 469 +--关卡结束
  470 +function Adv:over(success, rewardRatio)
  471 + if success then
  472 + rewardRatio = rewardRatio or 100
  473 + else
  474 + rewardRatio = rewardRatio or globalCsv.adv_fail_reward_ratio
  475 + end
455 local score = self:getScore() 476 local score = self:getScore()
456 local scoreInfo = self.score 477 local scoreInfo = self.score
457 - local reward 478 +
458 self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level}) 479 self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level})
  480 +
  481 +
  482 + local reward = self.owner:getProperty("advItems"):toNumMap()
  483 + for itemId, count in pairs(reward) do
  484 + reward[itemId] = math.ceil(count * rewardRatio / 100)
  485 + end
  486 + reward = self.owner:award(reward)
  487 +
459 if success then 488 if success then
460 - reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap())  
461 self.owner:checkTaskEnter("AdvPass", {id = self.chapterId, level = self.level, score = score}) 489 self.owner:checkTaskEnter("AdvPass", {id = self.chapterId, level = self.level, score = score})
462 - if isAllPass then 490 + local chapterData = csvdb["adv_chapterCsv"][self.chapterId].limitlevel
  491 + if not self:isEndless() and self.level >= chapterData then
463 self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId}) 492 self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId})
464 end 493 end
465 494
@@ -630,10 +659,9 @@ local function clickOut(self, room, block, params) @@ -630,10 +659,9 @@ local function clickOut(self, room, block, params)
630 659
631 self:checkAchievement(Adv.AchievType.OverWin, 1, self.level) 660 self:checkAchievement(Adv.AchievType.OverWin, 1, self.level)
632 self:checkAdvUnlock(2, self.level) 661 self:checkAdvUnlock(2, self.level)
633 - local levellimit = csvdb["adv_chapterCsv"][self.chapterId].limitlevel  
634 662
635 - if not self:isEndless() and (self.level >= levellimit or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1)) then --关卡结束  
636 - self:over(true, not self:isEndless() and self.level >= levellimit) 663 + if not self:isEndless() and (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1)) then --关卡结束
  664 + self:over(true)
637 else 665 else
638 self.battle.player:triggerPassive(Passive.DOWN_LAYER) 666 self.battle.player:triggerPassive(Passive.DOWN_LAYER)
639 local curFloorData = self:getCurFloorData() 667 local curFloorData = self:getCurFloorData()
@@ -656,8 +684,7 @@ local function clickOut(self, room, block, params) @@ -656,8 +684,7 @@ local function clickOut(self, room, block, params)
656 end 684 end
657 685
658 local function clickExit(self, room, block, params) 686 local function clickExit(self, room, block, params)
659 - local levellimit = csvdb["adv_chapterCsv"][self.chapterId].limitlevel  
660 - self:over(true, not self:isEndless() and self.level >= levellimit) 687 + self:over(true)
661 return true 688 return true
662 end 689 end
663 690
@@ -1222,7 +1249,27 @@ function Adv:doActive(activeId, target) @@ -1222,7 +1249,27 @@ function Adv:doActive(activeId, target)
1222 return true 1249 return true
1223 end 1250 end
1224 1251
  1252 + --10: 立刻结算 按比例返还
  1253 + doActiveEffect[10] = function(_, rewardRatio)
  1254 + self:over(true, rewardRatio)
  1255 + return true
  1256 + end
1225 1257
  1258 + --11: 随机提升一个未满级神器等级,配置提升等级
  1259 + doActiveEffect[11] = function(_, level)
  1260 + local advAFGet = self.owner:getProperty("advAFGet")
  1261 + local pool = {}
  1262 + for id_, lv in pairs(advAFGet) do
  1263 + if self.owner:isArtifactOpen(id_, self:isEndless(), lv + 1) then
  1264 + table.insert(pool, id_)
  1265 + end
  1266 + end
  1267 + if #pool > 0 then
  1268 + local idx = math.randomInt(1, #pool)
  1269 + self:artifactLevelUp(pool[idx], level)
  1270 + end
  1271 + return true
  1272 + end
1226 1273
1227 for _, effect in ipairs(activeData.effect:toArray()) do 1274 for _, effect in ipairs(activeData.effect:toArray()) do
1228 local cur = effect:toArray(true, "=") 1275 local cur = effect:toArray(true, "=")
src/adv/AdvBattle.lua
@@ -91,7 +91,7 @@ function Battle:initPlayer() @@ -91,7 +91,7 @@ function Battle:initPlayer()
91 for _, hero in pairs(attrs) do 91 for _, hero in pairs(attrs) do
92 player[attrName] = (player[attrName] or 0) + hero[attrName] 92 player[attrName] = (player[attrName] or 0) + hero[attrName]
93 end 93 end
94 - player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) 94 + player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1)
95 player.growth[attrName] = player[attrName] * 0.025 95 player.growth[attrName] = player[attrName] * 0.025
96 player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1) 96 player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1)
97 end 97 end
src/adv/AdvMap.lua
@@ -336,6 +336,11 @@ createMap = function(self, mapId, isEnter, isNewRelay) @@ -336,6 +336,11 @@ createMap = function(self, mapId, isEnter, isNewRelay)
336 end 336 end
337 end 337 end
338 338
  339 + local function giveEvent(roomId, blockId, eventType, eventId)
  340 + local event = {etype = eventType, id = eventId}
  341 + mapInfo.rooms[roomId]["event"][blockId] = event
  342 + end
  343 +
339 344
340 local stagePool = {["global"] = {}} 345 local stagePool = {["global"] = {}}
341 for roomId, roomName in pairs(mapData["rooms"]) do 346 for roomId, roomName in pairs(mapData["rooms"]) do
@@ -360,6 +365,27 @@ createMap = function(self, mapId, isEnter, isNewRelay) @@ -360,6 +365,27 @@ createMap = function(self, mapId, isEnter, isNewRelay)
360 end 365 end
361 end 366 end
362 end 367 end
  368 +
  369 + -- 随机功能需要强制随机的东西
  370 + if self.adv.isRelay and isNewRelay then
  371 + local relayData = self.adv:isHaveRelay()
  372 + if relayData then
  373 + local choose = relayData.choose:toArray(true, "=")
  374 + local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0
  375 + if lastCount <= 0 then break end
  376 + for _, chooseId in pairs(choose) do
  377 + local idx = math.randomInt(1, lastCount)
  378 + local cur = stagePool["global"][AdvCodeRandomStage][idx]
  379 +
  380 + giveEvent(cur["room"], cur["block"], AdvEventType.Choose, chooseId)
  381 +
  382 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  383 + lastCount = lastCount - 1
  384 + stagePool[cur["room"]][stageType][cur["block"]] = nil
  385 + end
  386 + end
  387 + end
  388 +
363 -- 全地图事件 优先级高 389 -- 全地图事件 优先级高
364 for stageType, events in pairs(mapData["events"]) do 390 for stageType, events in pairs(mapData["events"]) do
365 for _, event in ipairs(events) do 391 for _, event in ipairs(events) do
src/models/RolePlugin.lua
@@ -797,11 +797,15 @@ function RolePlugin.bind(Role) @@ -797,11 +797,15 @@ function RolePlugin.bind(Role)
797 advOverTime = self.advOverTime, 797 advOverTime = self.advOverTime,
798 })) 798 }))
799 end 799 end
  800 + -- 路过的中继层重置掉
  801 + local advRelay = self:getProperty("advRelay")
  802 + advRelay[-1] = nil
800 -- 清掉冒险手册 803 -- 清掉冒险手册
801 self:updateProperties({ 804 self:updateProperties({
802 advEAchiev = {}, 805 advEAchiev = {},
803 advElM = 0, 806 advElM = 0,
804 advElS = nowSeason, 807 advElS = nowSeason,
  808 + advRelay = advRelay,
805 }, notNotify) 809 }, notNotify)
806 end 810 end
807 end 811 end