Commit 8955225bcf74ac31cb4dfa6ca0436d8d9cdae11f
1 parent
96d591f7
快速拾取。快速使用
Showing
4 changed files
with
107 additions
and
64 deletions
Show diff stats
src/actions/AdvAction.lua
@@ -527,25 +527,8 @@ function _M.useItemRpc(agent, data) | @@ -527,25 +527,8 @@ function _M.useItemRpc(agent, data) | ||
527 | adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}}) | 527 | adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}}) |
528 | adv:backUse({[itemId] = count}) | 528 | adv:backUse({[itemId] = count}) |
529 | end | 529 | end |
530 | - | ||
531 | - if itemId == 5020 then | ||
532 | - role:finishGuide(53) | ||
533 | - end | ||
534 | - adv:checkAchievement(adv.AchievType.UseItem, count, itemId) | ||
535 | - adv:mylog({desc = "useItem", int1 = itemId, int2 = count}) | ||
536 | - | ||
537 | - role:log("mission_pick_use", { | ||
538 | - mission_threadid = adv.chapterId, -- 大地图ID | ||
539 | - mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
540 | - mission_id = adv.level, -- 关卡ID | ||
541 | - item_id = itemId, -- 道具ID | ||
542 | - mission_pick_use_num = count, -- 道具使用量 | ||
543 | - mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
544 | - }) | ||
545 | - | ||
546 | - for i = 1, count do | ||
547 | - adv:doActive(itemData.effect, target) -- target | ||
548 | - end | 530 | + |
531 | + adv:useItem(itemId, count, target) | ||
549 | 532 | ||
550 | adv:afterRound() | 533 | adv:afterRound() |
551 | adv:saveDB() | 534 | adv:saveDB() |
src/adv/Adv.lua
@@ -936,7 +936,7 @@ end | @@ -936,7 +936,7 @@ end | ||
936 | 936 | ||
937 | -- log long1 字段被征用!!! | 937 | -- log long1 字段被征用!!! |
938 | -- 在冒险中获得的物品都发放在冒险背包内 | 938 | -- 在冒险中获得的物品都发放在冒险背包内 |
939 | -function Adv:award(gift, params) | 939 | +function Adv:award(gift, params, backRewardParams) |
940 | params = params or {} | 940 | params = params or {} |
941 | local tgift = {} | 941 | local tgift = {} |
942 | if type(gift) == "string" then | 942 | if type(gift) == "string" then |
@@ -948,6 +948,8 @@ function Adv:award(gift, params) | @@ -948,6 +948,8 @@ function Adv:award(gift, params) | ||
948 | end | 948 | end |
949 | local items = self.owner:getProperty("advItems") | 949 | local items = self.owner:getProperty("advItems") |
950 | local oldItems = items | 950 | local oldItems = items |
951 | + | ||
952 | + local autoUse = {} | ||
951 | for itemId, count in pairs(tgift) do | 953 | for itemId, count in pairs(tgift) do |
952 | if count > 0 then | 954 | if count > 0 then |
953 | local buffAdd = self.battle.player:getRewardChange(itemId) | 955 | local buffAdd = self.battle.player:getRewardChange(itemId) |
@@ -956,41 +958,45 @@ function Adv:award(gift, params) | @@ -956,41 +958,45 @@ function Adv:award(gift, params) | ||
956 | self:checkAchievement(Adv.AchievType.GetItem, count, itemId) | 958 | self:checkAchievement(Adv.AchievType.GetItem, count, itemId) |
957 | end | 959 | end |
958 | tgift[itemId] = count | 960 | tgift[itemId] = count |
959 | - local origin = items:getv(itemId, 0) | ||
960 | - local nums = origin + count | ||
961 | - | ||
962 | - if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 | ||
963 | - self:awardArtifact(itemId, params) | ||
964 | - if not self.owner:checkOverGuide(55) then | ||
965 | - self.owner:saveGuide(55,1,true) | ||
966 | - end | 961 | + if globalCsv.adv_auto_useItem[itemId] and count > 0 then |
962 | + autoUse[itemId] = count | ||
967 | else | 963 | else |
968 | - if nums <= 0 then | ||
969 | - items = items:delk(itemId) | ||
970 | - nums = 0 | 964 | + local origin = items:getv(itemId, 0) |
965 | + local nums = origin + count | ||
966 | + | ||
967 | + if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 | ||
968 | + self:awardArtifact(itemId, params) | ||
969 | + if not self.owner:checkOverGuide(55) then | ||
970 | + self.owner:saveGuide(55,1,true) | ||
971 | + end | ||
971 | else | 972 | else |
972 | - items = items:setv(itemId, nums) | ||
973 | - end | 973 | + if nums <= 0 then |
974 | + items = items:delk(itemId) | ||
975 | + nums = 0 | ||
976 | + else | ||
977 | + items = items:setv(itemId, nums) | ||
978 | + end | ||
974 | 979 | ||
975 | - if itemId == 16 and not self.owner:checkOverGuide(51,4) then | ||
976 | - self.owner:saveGuide(51,4) | ||
977 | - end | ||
978 | - if params.log then | ||
979 | - local log = clone(params.log) | ||
980 | - if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then | ||
981 | - print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback()) | 980 | + if itemId == 16 and not self.owner:checkOverGuide(51,4) then |
981 | + self.owner:saveGuide(51,4) | ||
982 | end | 982 | end |
983 | - log["cint1"] = itemId | ||
984 | - log["cint2"] = math.abs(count) | ||
985 | - log["cint3"] = self.chapterId | ||
986 | - log["long1"] = self.level | ||
987 | - if count >= 0 then | ||
988 | - self.owner:mylog("in_adv", log) | 983 | + if params.log then |
984 | + local log = clone(params.log) | ||
985 | + if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then | ||
986 | + print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
987 | + end | ||
988 | + log["cint1"] = itemId | ||
989 | + log["cint2"] = math.abs(count) | ||
990 | + log["cint3"] = self.chapterId | ||
991 | + log["long1"] = self.level | ||
992 | + if count >= 0 then | ||
993 | + self.owner:mylog("in_adv", log) | ||
994 | + else | ||
995 | + self.owner:mylog("out_adv", log) | ||
996 | + end | ||
989 | else | 997 | else |
990 | - self.owner:mylog("out_adv", log) | 998 | + print("addAdvItem no log ", debug.traceback()) |
991 | end | 999 | end |
992 | - else | ||
993 | - print("addAdvItem no log ", debug.traceback()) | ||
994 | end | 1000 | end |
995 | end | 1001 | end |
996 | end | 1002 | end |
@@ -1001,10 +1007,48 @@ function Adv:award(gift, params) | @@ -1001,10 +1007,48 @@ function Adv:award(gift, params) | ||
1001 | if tgift[ItemId.OldCoin] then | 1007 | if tgift[ItemId.OldCoin] then |
1002 | self.battle.player:attrChangeCondBuffCheck(0) | 1008 | self.battle.player:attrChangeCondBuffCheck(0) |
1003 | end | 1009 | end |
1010 | + | ||
1011 | + if backRewardParams then | ||
1012 | + self:backReward(tgift, backRewardParams) | ||
1013 | + end | ||
1014 | + | ||
1015 | + if next(autoUse) then | ||
1016 | + for itemId, count in pairs(autoUse) do | ||
1017 | + self:useItem(itemId, count) | ||
1018 | + end | ||
1019 | + self:backUse(autoUse, 1) | ||
1020 | + end | ||
1004 | return tgift | 1021 | return tgift |
1005 | end | 1022 | end |
1006 | 1023 | ||
1007 | 1024 | ||
1025 | +function Adv:useItem(itemId, count, target) | ||
1026 | + local itemData = csvdb["adv_itemCsv"][itemId] | ||
1027 | + if not itemData then return end | ||
1028 | + | ||
1029 | + if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end | ||
1030 | + | ||
1031 | + if itemId == 5020 then | ||
1032 | + role:finishGuide(53) | ||
1033 | + end | ||
1034 | + | ||
1035 | + self:checkAchievement(self.AchievType.UseItem, count, itemId) | ||
1036 | + self:mylog({desc = "useItem", int1 = itemId, int2 = count}) | ||
1037 | + | ||
1038 | + self.owner:log("mission_pick_use", { | ||
1039 | + mission_threadid = self.chapterId, -- 大地图ID | ||
1040 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
1041 | + mission_id = self.level, -- 关卡ID | ||
1042 | + item_id = itemId, -- 道具ID | ||
1043 | + mission_pick_use_num = count, -- 道具使用量 | ||
1044 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
1045 | + }) | ||
1046 | + | ||
1047 | + for i = 1, count do | ||
1048 | + self:doActive(itemData.effect, target) -- target | ||
1049 | + end | ||
1050 | +end | ||
1051 | + | ||
1008 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 | 1052 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 |
1009 | function Adv:cost(item, params, check) | 1053 | function Adv:cost(item, params, check) |
1010 | local items = self.owner:getProperty("advItems") | 1054 | local items = self.owner:getProperty("advItems") |
@@ -1071,7 +1115,7 @@ local function clickOut(self, room, block, params, isExit) | @@ -1071,7 +1115,7 @@ local function clickOut(self, room, block, params, isExit) | ||
1071 | self.battle.player:triggerPassive(Passive.DOWN_LAYER) | 1115 | self.battle.player:triggerPassive(Passive.DOWN_LAYER) |
1072 | 1116 | ||
1073 | if curFloorData then | 1117 | if curFloorData then |
1074 | - self:backReward(self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}})) | 1118 | + self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {}) |
1075 | end | 1119 | end |
1076 | local isHaveRelay = self:isHaveRelay(self.level) | 1120 | local isHaveRelay = self:isHaveRelay(self.level) |
1077 | 1121 | ||
@@ -1255,7 +1299,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | @@ -1255,7 +1299,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | ||
1255 | skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id)) | 1299 | skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id)) |
1256 | end | 1300 | end |
1257 | end | 1301 | end |
1258 | - self:backReward(self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}), {roomId = room.roomId, blockId = block.blockId}) | 1302 | + self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId}) |
1259 | end, | 1303 | end, |
1260 | [2] = function() --获得冒险buff | 1304 | [2] = function() --获得冒险buff |
1261 | local layer = effect[3] or 1 | 1305 | local layer = effect[3] or 1 |
@@ -1419,14 +1463,12 @@ local function clickDrop(self, room, block, params) | @@ -1419,14 +1463,12 @@ local function clickDrop(self, room, block, params) | ||
1419 | if not self.battle or not self.battle.player then return end | 1463 | if not self.battle or not self.battle.player then return end |
1420 | self.battle.player:triggerPassive(Passive.CLICK_DROP) | 1464 | self.battle.player:triggerPassive(Passive.CLICK_DROP) |
1421 | 1465 | ||
1422 | - local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}) | ||
1423 | - -- local reward = self:award({[5801] = 1}) | ||
1424 | - -- 获取绷带的引导 | 1466 | + local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}, {roomId = room.roomId, blockId = block.blockId}) |
1467 | + | ||
1425 | if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then | 1468 | if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then |
1426 | self.owner:saveGuide(53,2) | 1469 | self.owner:saveGuide(53,2) |
1427 | end | 1470 | end |
1428 | block:clear() | 1471 | block:clear() |
1429 | - self:backReward(reward, {roomId = room.roomId, blockId = block.blockId}) | ||
1430 | return true | 1472 | return true |
1431 | end | 1473 | end |
1432 | 1474 | ||
@@ -1447,7 +1489,7 @@ local function clickTrader(self, room, block, params) | @@ -1447,7 +1489,7 @@ local function clickTrader(self, room, block, params) | ||
1447 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) | 1489 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) |
1448 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 | 1490 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 |
1449 | self:backCost({[goodsData.currency] = costCount}) | 1491 | self:backCost({[goodsData.currency] = costCount}) |
1450 | - local reward = self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}) | 1492 | + self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {}) |
1451 | if goodsData.restrict == 1 then | 1493 | if goodsData.restrict == 1 then |
1452 | self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1 | 1494 | self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1 |
1453 | elseif goodsData.restrict == 2 then | 1495 | elseif goodsData.restrict == 2 then |
@@ -1459,7 +1501,6 @@ local function clickTrader(self, room, block, params) | @@ -1459,7 +1501,6 @@ local function clickTrader(self, room, block, params) | ||
1459 | buyCount = buyCount + 1 | 1501 | buyCount = buyCount + 1 |
1460 | self:checkTask(Adv.TaskType.Shop, 1, block.event.id) | 1502 | self:checkTask(Adv.TaskType.Shop, 1, block.event.id) |
1461 | self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id) | 1503 | self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id) |
1462 | - self:backReward(reward) | ||
1463 | 1504 | ||
1464 | if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then | 1505 | if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then |
1465 | block:clear() | 1506 | block:clear() |
@@ -1501,7 +1542,7 @@ local function clickClick(self, room, block, params) | @@ -1501,7 +1542,7 @@ local function clickClick(self, room, block, params) | ||
1501 | local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true) | 1542 | local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true) |
1502 | reward[item[1]] = (reward[item[1]] or 0) + item[2] | 1543 | reward[item[1]] = (reward[item[1]] or 0) + item[2] |
1503 | end | 1544 | end |
1504 | - self:backReward(self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}), {roomId = room.roomId, blockId = block.blockId}) | 1545 | + self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}, {roomId = room.roomId, blockId = block.blockId}) |
1505 | end, | 1546 | end, |
1506 | [3] = function() | 1547 | [3] = function() |
1507 | for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do | 1548 | for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do |
@@ -1989,10 +2030,13 @@ end | @@ -1989,10 +2030,13 @@ end | ||
1989 | function Adv:pushBackEvent(btype, params) | 2030 | function Adv:pushBackEvent(btype, params) |
1990 | table.insert(self.backEvents, {btype = btype, params = params}) | 2031 | table.insert(self.backEvents, {btype = btype, params = params}) |
1991 | end | 2032 | end |
1992 | - | 2033 | +--[=[ |
2034 | +tag | ||
2035 | +1 自动拾取 | ||
2036 | +--]=] | ||
1993 | function Adv:backReward(items, params) | 2037 | function Adv:backReward(items, params) |
1994 | params = params or {} | 2038 | params = params or {} |
1995 | - self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId}) | 2039 | + self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId, tag = params.tag}) |
1996 | end | 2040 | end |
1997 | 2041 | ||
1998 | -- if is player enemyId is nil | 2042 | -- if is player enemyId is nil |
@@ -2033,8 +2077,12 @@ function Adv:backCost(items) | @@ -2033,8 +2077,12 @@ function Adv:backCost(items) | ||
2033 | self:pushBackEvent(AdvBackEventType.Cost, {items = items}) | 2077 | self:pushBackEvent(AdvBackEventType.Cost, {items = items}) |
2034 | end | 2078 | end |
2035 | 2079 | ||
2036 | -function Adv:backUse(items) | ||
2037 | - self:pushBackEvent(AdvBackEventType.Use, {items = items}) | 2080 | +--[=[ |
2081 | +tag | ||
2082 | +1 自动使用 | ||
2083 | +--]=] | ||
2084 | +function Adv:backUse(items, tag) | ||
2085 | + self:pushBackEvent(AdvBackEventType.Use, {items = items, tag = tag}) | ||
2038 | end | 2086 | end |
2039 | 2087 | ||
2040 | 2088 |
src/adv/AdvBlock.lua
@@ -58,6 +58,7 @@ function Block:updateEvent(event, isInit) | @@ -58,6 +58,7 @@ function Block:updateEvent(event, isInit) | ||
58 | end | 58 | end |
59 | self:randomEvent() | 59 | self:randomEvent() |
60 | end | 60 | end |
61 | + self:quickDrop() | ||
61 | end | 62 | end |
62 | 63 | ||
63 | function Block:clear() | 64 | function Block:clear() |
@@ -263,9 +264,20 @@ function Block:open() | @@ -263,9 +264,20 @@ function Block:open() | ||
263 | local adv = map.adv | 264 | local adv = map.adv |
264 | self.isOpen = true | 265 | self.isOpen = true |
265 | self:randomEvent() | 266 | self:randomEvent() |
267 | + self:quickDrop() | ||
266 | return true | 268 | return true |
267 | end | 269 | end |
268 | 270 | ||
271 | +function Block:quickDrop() | ||
272 | + if self:getEventType() == AdvEventType.Drop and self.event.item then | ||
273 | + local itemId, count = table.unpack(self.event.item) | ||
274 | + if globalCsv.adv_auto_collect[itemId] then | ||
275 | + self.room.map.adv:award({[itemId] = count}, {log = {desc = "clickDrop"}}, {roomId = self.room.roomId, blockId = self.blockId, tag = 1}) | ||
276 | + self:clear() | ||
277 | + end | ||
278 | + end | ||
279 | +end | ||
280 | + | ||
269 | function Block:getObstacle() | 281 | function Block:getObstacle() |
270 | local data = self:getEventData() | 282 | local data = self:getEventData() |
271 | if not data then return 0 end | 283 | if not data then return 0 end |
src/adv/AdvPassive.lua
@@ -494,7 +494,7 @@ function Passive:effect8(dropId) | @@ -494,7 +494,7 @@ function Passive:effect8(dropId) | ||
494 | skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) | 494 | skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) |
495 | end | 495 | end |
496 | local item = dropData["range"]:randWeight(true) | 496 | local item = dropData["range"]:randWeight(true) |
497 | - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId}) | 497 | + self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId}) |
498 | 498 | ||
499 | end | 499 | end |
500 | 500 | ||
@@ -509,7 +509,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) | @@ -509,7 +509,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) | ||
509 | return | 509 | return |
510 | end | 510 | end |
511 | if not cond then return end | 511 | if not cond then return end |
512 | - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId}) | 512 | + self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId}) |
513 | end | 513 | end |
514 | 514 | ||
515 | --10=战斗额外掉落次数 | 515 | --10=战斗额外掉落次数 |