Commit 6dc482bb38240b1978e1693f64999702694a51f8
1 parent
1bb3abca
中继层完成, 新增两个冒险物品使用效果
Showing
6 changed files
with
98 additions
and
23 deletions
Show diff stats
src/GlobalVar.lua
... | ... | @@ -106,6 +106,9 @@ AdvSpecialStage = { |
106 | 106 | [6] = "InOut", |
107 | 107 | [7] = "Diner" |
108 | 108 | } |
109 | + | |
110 | +AdvCodeRandomStage = 10 -- 一些功能需要代码强行随机事件 随机到这个地块类型上面 | |
111 | + | |
109 | 112 | --客户端需要知道这个 |
110 | 113 | AdvEventType = { |
111 | 114 | -- 特殊事件(地块决定) |
... | ... | @@ -117,7 +120,6 @@ AdvEventType = { |
117 | 120 | InOut = -6, -- 出入口集合体 |
118 | 121 | Diner = -7, -- 料理台 |
119 | 122 | |
120 | - | |
121 | 123 | -- 普通事件(随机) |
122 | 124 | Choose = 1, --选择点 |
123 | 125 | Drop = 2, --物品掉落点 | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -315,15 +315,6 @@ function _M.useItemRpc(agent, data) |
315 | 315 | if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end |
316 | 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 | 319 | if itemData["function"] == 0 or itemData["function"] == 1 then |
329 | 320 | adv:cost({[itemId] = count}, {}) |
... | ... | @@ -331,6 +322,11 @@ function _M.useItemRpc(agent, data) |
331 | 322 | end |
332 | 323 | |
333 | 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 | 330 | adv:afterRound() |
335 | 331 | adv:saveDB() |
336 | 332 | ... | ... |
src/adv/Adv.lua
... | ... | @@ -150,6 +150,13 @@ function Adv:forceOver(notNotify) |
150 | 150 | self:clear() |
151 | 151 | local advTeam = self.owner:getProperty("advTeam") |
152 | 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 | 160 | self.owner:updateProperties({ |
154 | 161 | advInfo = {}, |
155 | 162 | advTeam = advTeam, |
... | ... | @@ -389,11 +396,20 @@ function Adv:haveComboAF(id) |
389 | 396 | return false |
390 | 397 | end |
391 | 398 | |
392 | -function Adv:artifactLevelUp(id) | |
399 | +function Adv:artifactLevelUp(id, level) | |
400 | + level = level or 1 | |
393 | 401 | local advAFGet = self.owner:getProperty("advAFGet") |
402 | + if not advAFGet[id] then return end | |
394 | 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 | 412 | local status = 0 |
396 | - local newLv = advAFGet[id] + 1 | |
397 | 413 | if advAFWear[id] then -- 穿着呢 |
398 | 414 | local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] |
399 | 415 | local newData = csvdb["adv_artifactCsv"][id][newLv] |
... | ... | @@ -450,16 +466,29 @@ function Adv:getCurFloorData() |
450 | 466 | return (csvdb["adv_chapter_floorCsv"][chapter] or {})[self.level] |
451 | 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 | 476 | local score = self:getScore() |
456 | 477 | local scoreInfo = self.score |
457 | - local reward | |
478 | + | |
458 | 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 | 488 | if success then |
460 | - reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap()) | |
461 | 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 | 492 | self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId}) |
464 | 493 | end |
465 | 494 | |
... | ... | @@ -630,10 +659,9 @@ local function clickOut(self, room, block, params) |
630 | 659 | |
631 | 660 | self:checkAchievement(Adv.AchievType.OverWin, 1, self.level) |
632 | 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 | 665 | else |
638 | 666 | self.battle.player:triggerPassive(Passive.DOWN_LAYER) |
639 | 667 | local curFloorData = self:getCurFloorData() |
... | ... | @@ -656,8 +684,7 @@ local function clickOut(self, room, block, params) |
656 | 684 | end |
657 | 685 | |
658 | 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 | 688 | return true |
662 | 689 | end |
663 | 690 | |
... | ... | @@ -1222,7 +1249,27 @@ function Adv:doActive(activeId, target) |
1222 | 1249 | return true |
1223 | 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 | 1274 | for _, effect in ipairs(activeData.effect:toArray()) do |
1228 | 1275 | local cur = effect:toArray(true, "=") | ... | ... |
src/adv/AdvBattle.lua
... | ... | @@ -91,7 +91,7 @@ function Battle:initPlayer() |
91 | 91 | for _, hero in pairs(attrs) do |
92 | 92 | player[attrName] = (player[attrName] or 0) + hero[attrName] |
93 | 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 | 95 | player.growth[attrName] = player[attrName] * 0.025 |
96 | 96 | player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1) |
97 | 97 | end | ... | ... |
src/adv/AdvMap.lua
... | ... | @@ -336,6 +336,11 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
336 | 336 | end |
337 | 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 | 345 | local stagePool = {["global"] = {}} |
341 | 346 | for roomId, roomName in pairs(mapData["rooms"]) do |
... | ... | @@ -360,6 +365,27 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
360 | 365 | end |
361 | 366 | end |
362 | 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 | 390 | for stageType, events in pairs(mapData["events"]) do |
365 | 391 | for _, event in ipairs(events) do | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -797,11 +797,15 @@ function RolePlugin.bind(Role) |
797 | 797 | advOverTime = self.advOverTime, |
798 | 798 | })) |
799 | 799 | end |
800 | + -- 路过的中继层重置掉 | |
801 | + local advRelay = self:getProperty("advRelay") | |
802 | + advRelay[-1] = nil | |
800 | 803 | -- 清掉冒险手册 |
801 | 804 | self:updateProperties({ |
802 | 805 | advEAchiev = {}, |
803 | 806 | advElM = 0, |
804 | 807 | advElS = nowSeason, |
808 | + advRelay = advRelay, | |
805 | 809 | }, notNotify) |
806 | 810 | end |
807 | 811 | end | ... | ... |