Commit 6826fdf62f261659fe2120ca0ebe8ee80e08a83b

Authored by zhouhaihai
1 parent b6a2b78b

被动触发

src/adv/Adv.lua
... ... @@ -1883,23 +1883,31 @@ end
1883 1883  
1884 1884 -- 地图上物品变化
1885 1885 function Adv:mapItemChange(ctype)
  1886 + local blocks = {}
  1887 + for roomId, room in pairs(self:getCurMap().rooms) do
  1888 + for blockId, block in pairs(room.blocks) do
  1889 + table.insert(blocks, block)
  1890 + end
  1891 + end
  1892 + self:blockDropChange(ctype, blocks)
  1893 +end
  1894 +
  1895 +function Adv:blockDropChange(ctype, blocks)
1886 1896 local clist = csvdb["transform_itemCsv"][ctype]
1887 1897 if clist then
1888   - for roomId, room in pairs(self:getCurMap().rooms) do
1889   - for blockId, block in pairs(room.blocks) do
1890   - if block:getEventType() == AdvEventType.Drop and block.event.item then
1891   - local id = block.event.item[1]
1892   - local count = block.event.item[2]
1893   - local changeTo = nil
1894   - if clist[id] then
1895   - changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
1896   - elseif clist[-1] then
1897   - changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
1898   - end
1899   - if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
1900   - block.event.item = changeTo
1901   - self:backBlockChange(roomId, blockId, ctype)
1902   - end
  1898 + for _, block in ipairs(blocks) do
  1899 + if block:getEventType() == AdvEventType.Drop and block.event.item then
  1900 + local id = block.event.item[1]
  1901 + local count = block.event.item[2]
  1902 + local changeTo = nil
  1903 + if clist[id] then
  1904 + changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
  1905 + elseif clist[-1] then
  1906 + changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
  1907 + end
  1908 + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
  1909 + block.event.item = changeTo
  1910 + self:backBlockChange(block.room.roomId, block.blockId, ctype)
1903 1911 end
1904 1912 end
1905 1913 end
... ...
src/adv/AdvMap.lua
... ... @@ -256,7 +256,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
256 256  
257 257 if status then
258 258 if isPlayer then
259   - self.adv.battle:triggerPassive(Passive.OPEN_BLOCK)
  259 + self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId})
260 260 self.adv.owner:checkTaskEnter("AdvOpenBlock")
261 261  
262 262 -- 潜行检查
... ... @@ -292,21 +292,38 @@ function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack)
292 292 end
293 293 end
294 294  
295   -function Map:openBlocksIsMonsterByRoom(roomId, isPlayer, ignoreBack)
  295 +function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack)
296 296 local room = self.rooms[roomId]
297 297 if not room then return end
298 298  
299   - local enemys = {}
  299 + local allBlock = {}
300 300 for blockId, block in pairs(room.blocks) do
301   - if block:isMonster() then
302   - if self:openBlock(roomId, blockId, isPlayer, ignoreBack) then
303   - local e = self.adv.battle:getEnemy(block.room.roomId, block.blockId)
304   - if e then
305   - table.insert(enemys, e)
306   - end
  301 + if block:isMonster() and not block.isOpen then
  302 + table.insert(allBlock, blockId)
  303 + end
  304 + end
  305 +
  306 + local enemys = {}
  307 + local openBlock = function(blockId)
  308 + if self:openBlock(roomId, blockId, isPlayer, ignoreBack) then
  309 + local e = self.adv.battle:getEnemy(roomId, blockId)
  310 + if e then
  311 + table.insert(enemys, e)
307 312 end
308 313 end
309 314 end
  315 +
  316 + if not count or count == -1 or count >= len(allBlock) then
  317 + for _, blockId in ipairs(allBlock) do
  318 + openBlock(blockId)
  319 + end
  320 + else
  321 + for i = 1, count do
  322 + local idx = math.randomInt(1, len(allBlock))
  323 + openBlock(allBlock[idx])
  324 + table.remove(allBlock, idx)
  325 + end
  326 + end
310 327 return enemys
311 328 end
312 329  
... ... @@ -327,6 +344,22 @@ function Map:getRBByPos(c, r)
327 344 end
328 345 end
329 346  
  347 +function Map:getDistance(froomId, fblockId, troomId, tblockId)
  348 + local distance = -1
  349 + local room1 = self.rooms[froomId]
  350 + local room2 = self.rooms[troomId]
  351 + if room1 and room2 then
  352 + local block1 = room1[fblockId]
  353 + local block2 = room2[tblockId]
  354 + if block1 and block2 then
  355 + local c1, r1 = room1:tranLtoG(block1.col, block1.row)
  356 + local c2, r2 = room2:tranLtoG(block2.col, block2.row)
  357 + distance = math.max(math.abs(c1 - c2), math.abs(r1 - r2))
  358 + end
  359 + end
  360 + return distance
  361 +end
  362 +
330 363 function Map:getAroundBlocks(room, block)
331 364 local blocks = {}
332 365 local range = {1, -1}
... ...
src/adv/AdvPassive.lua
... ... @@ -7,6 +7,8 @@ Filter.HP_LOW = 4 -- 血量<value%
7 7 Filter.BUFF_BY_TYPE = 5 -- 指定类型buff
8 8 Filter.BUFF_BY_ID = 6 -- 指定id的buff
9 9 Filter.CAMP = 7 -- 玩家是指定阵营
  10 +Filter.RANGE = 8 -- 筛选范围 (触发是地块)
  11 +Filter.CLASSIFY = 9 -- 标签
10 12  
11 13 local FilterFactory = {}
12 14 FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter)
... ... @@ -46,6 +48,23 @@ FilterFactory[Filter.CAMP] = function (_Filter)
46 48 end
47 49 end
48 50  
  51 +FilterFactory[Filter.RANGE] = function (_Filter)
  52 + _Filter._execute = function (self, target, params)
  53 + if self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then
  54 + local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId)
  55 + return distance ~= -1 and distance <= self.value
  56 + end
  57 + return false
  58 + end
  59 +end
  60 +
  61 +FilterFactory[Filter.CLASSIFY] = function (_Filter)
  62 + _Filter._execute = function (self, target)
  63 + if not target.monsterId then return end
  64 + local classify = csvdb["event_monsterCsv"][target.monsterId].classify
  65 + return classify and classify:sismember(self.value, " ")
  66 + end
  67 +end
49 68  
50 69 function Filter:ctor(params)
51 70 self.owner = params.owner
... ... @@ -79,7 +98,7 @@ function Filter:execute(params)
79 98 return
80 99 end
81 100 if self:_execute(target) then
82   - return self:_execute(target)
  101 + return self:_execute(target, params)
83 102 end
84 103 end
85 104  
... ... @@ -120,6 +139,7 @@ Passive.GET_BUFF = 28 --获得指定buff
120 139 Passive.OPEN_BLOCK = 29 --翻开格子
121 140 Passive.OPEN_MONSTER = 30 --翻开怪物
122 141 Passive.PLAYER_BUFF = 31 --玩家获得buff
  142 +
123 143 Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff
124 144  
125 145 -- 不同的开启条件
... ... @@ -442,6 +462,7 @@ end
442 462  
443 463 --3=翻开自己所在格子
444 464 function Passive:effect3(value)
  465 + if not self.owner.roomId or not self.owner.blockId then return end
445 466 if value == 0 then
446 467 self.owner.battle.adv:getCurMap():openBlock(self.owner.roomId, self.owner.blockId)
447 468 elseif value > 0 then
... ... @@ -561,5 +582,22 @@ function Passive:effect14(value, triggerPms, enemyId)
561 582 end
562 583 end
563 584  
  585 +--15=翻开房间内的count 个怪 并且增加一个buff
  586 +function Passive:effect15(count, triggerPms, buffId)
  587 + local roomId = self.owner.roomId
  588 + if not roomId then return end
  589 + local enemys = self.owner.battle.adv:getCurMap():openBlocksIsMonsterByRoom(roomId, count)
  590 + for _, e in ipairs(enemys) do
  591 + e:addBuff(buffId)
  592 + end
  593 +end
  594 +
  595 +--16=转变 value 范围内的掉落物 为 id count
  596 +function Passive:effect16(value, triggerPms, changeType)
  597 + if not self.owner.roomId or not self.owner.blockId then return end
  598 + local blocks = self.owner.battle.adv:getCurMap():getBlocksBySize(self.owner.roomId, self.owner.blockId, value)
  599 + self.owner.battle.adv:blockDropChange(changeType, blocks)
  600 +end
  601 +
564 602  
565 603 return Passive
566 604 \ No newline at end of file
... ...
src/adv/AdvPlayer.lua
... ... @@ -417,7 +417,7 @@ function BaseObject:hurt(value, releaser, params)
417 417 if self.hp == 0 then
418 418 self:triggerPassive(Passive.SELF_DEAD)
419 419 for _, team in ipairs(self:getTeam(1, true)) do
420   - team:triggerPassive(Passive.TEAM_DEAD)
  420 + team:triggerPassive(Passive.TEAM_DEAD, {trigger = self})
421 421 end
422 422  
423 423 if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then
... ...