Commit 02c4de8dfa830af31b34ad7e1e32f4907c667139
1 parent
4ae223df
增加 固有技
Showing
5 changed files
with
222 additions
and
51 deletions
Show diff stats
src/adv/Adv.lua
| ... | ... | @@ -273,8 +273,9 @@ function Block:open(adv, room) |
| 273 | 273 | if enemy then |
| 274 | 274 | enemy:unlock(self.event.mId) |
| 275 | 275 | else |
| 276 | - adv.battle:addEnemy(room, self) | |
| 276 | + enemy = adv.battle:addEnemy(room, self) | |
| 277 | 277 | end |
| 278 | + enemy:triggerPassive(Passive.BORN_ONCE) | |
| 278 | 279 | end |
| 279 | 280 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] |
| 280 | 281 | --掉落 |
| ... | ... | @@ -525,30 +526,37 @@ function Adv:getAroundBlocks(room, block) |
| 525 | 526 | end |
| 526 | 527 | |
| 527 | 528 | --随机一个空的位置生成怪, 如果没有就没有 |
| 528 | -function Adv:addNewMonsterRand(monsterId) | |
| 529 | - local pool = {} | |
| 530 | - for _, room in pairs(self.rooms) do | |
| 531 | - for _, block in pairs(room.blocks) do | |
| 532 | - if block.isOpen and not block.event then | |
| 533 | - table.insert(pool, {room, block}) | |
| 529 | +function Adv:addNewMonsterRand(monsterId, where) | |
| 530 | + local room, block | |
| 531 | + if where then | |
| 532 | + room, block = where[1], where[2] | |
| 533 | + else | |
| 534 | + local pool = {} | |
| 535 | + for _, room_ in pairs(self.rooms) do | |
| 536 | + for _, block_ in pairs(room_.blocks) do | |
| 537 | + if block_.isOpen and not block_.event then | |
| 538 | + table.insert(pool, {room_, block_}) | |
| 539 | + end | |
| 534 | 540 | end |
| 535 | 541 | end |
| 542 | + if not next(pool) then return end | |
| 543 | + local idx = math.randomInt(1, #pool) | |
| 544 | + room, block = pool[idx][1], pool[idx][2] | |
| 536 | 545 | end |
| 537 | - if not next(pool) then return end | |
| 538 | - local idx = math.randomInt(1, #pool) | |
| 539 | - local room, block = pool[idx][1], pool[idx][2] | |
| 540 | - | |
| 541 | - local event = {etype = AdvEventType.Monster, mId = self.advInfo.enemyId} | |
| 542 | - self.advInfo.enemyId = self.advInfo.enemyId + 1 | |
| 546 | + | |
| 543 | 547 | if not monsterId then |
| 544 | 548 | local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster) |
| 545 | 549 | if not next(eventLib[AdvEventType.Monster]) then return false end |
| 546 | 550 | monsterId = math.randWeight(eventLib[AdvEventType.Monster], "showup") |
| 547 | 551 | end |
| 552 | + | |
| 553 | + local event = {etype = AdvEventType.Monster, mId = self.advInfo.enemyId} | |
| 554 | + self.advInfo.enemyId = self.advInfo.enemyId + 1 | |
| 548 | 555 | event.id = monsterId |
| 549 | 556 | block.event = event |
| 550 | 557 | room.info.event[block.blockId] = event |
| 551 | - self.battle:addEnemy(room, block) | |
| 558 | + self.battle:addEnemy(room, block):triggerPassive(Passive.BORN_ONCE) | |
| 559 | + | |
| 552 | 560 | return room, block |
| 553 | 561 | end |
| 554 | 562 | |
| ... | ... | @@ -579,7 +587,9 @@ end |
| 579 | 587 | -- 打开一个地块 |
| 580 | 588 | function Adv:openBlock(roomId, blockId) |
| 581 | 589 | local room = self.rooms[roomId] |
| 590 | + if not room then return end | |
| 582 | 591 | local block = room.blocks[blockId] |
| 592 | + if not block then return end | |
| 583 | 593 | room:openBlock(block, self) |
| 584 | 594 | self:backBlockChange(roomId, blockId) |
| 585 | 595 | end |
| ... | ... | @@ -696,7 +706,7 @@ local function clickChoose(self, room, block, params) |
| 696 | 706 | } |
| 697 | 707 | assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) |
| 698 | 708 | if cond[1] and not checkCond[cond[1]]() then return end |
| 699 | - | |
| 709 | + local clearBlock = true | |
| 700 | 710 | local effect = block.event.effect[choose] |
| 701 | 711 | local doEffect = { |
| 702 | 712 | [1] = function() -- 获得某道具N个 |
| ... | ... | @@ -706,17 +716,17 @@ local function clickChoose(self, room, block, params) |
| 706 | 716 | self.battle.player:addBuff(effect[2]) |
| 707 | 717 | end, |
| 708 | 718 | [3] = function() --发现怪物 |
| 709 | - local r, b = self:addNewMonsterRand(effect[2]) | |
| 710 | - if r then | |
| 711 | - self:backBlockChange(r.roomId, b.blockId) | |
| 712 | - end | |
| 719 | + self:addNewMonsterRand(effect[2], {room, block}) | |
| 720 | + clearBlock = false | |
| 713 | 721 | end, |
| 714 | 722 | [4] = function() --无事发生 |
| 715 | 723 | end |
| 716 | 724 | } |
| 717 | 725 | assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) |
| 718 | 726 | doEffect[effect[1]]() |
| 719 | - room:clearBEvent(block) | |
| 727 | + if clearBlock then | |
| 728 | + room:clearBEvent(block) | |
| 729 | + end | |
| 720 | 730 | return true |
| 721 | 731 | end |
| 722 | 732 | |
| ... | ... | @@ -749,6 +759,7 @@ local function clickBuild(self, room, block, params) |
| 749 | 759 | local buildData = csvdb["event_buildingCsv"][block.event.id] |
| 750 | 760 | if not buildData then return end-- 偷偷改表了 |
| 751 | 761 | if not block.event.effect then return end -- 没有效果 气人不 |
| 762 | + local clearBlock = true | |
| 752 | 763 | local effect = block.event.effect |
| 753 | 764 | --todo 效果生效 |
| 754 | 765 | local doEffect = { |
| ... | ... | @@ -759,8 +770,8 @@ local function clickBuild(self, room, block, params) |
| 759 | 770 | self.battle.player:addBuff(effect[2]) |
| 760 | 771 | end, |
| 761 | 772 | [3] = function() --发现怪物 |
| 762 | - local r, b = self:addNewMonsterRand(effect[2]) | |
| 763 | - if r then self:backBlockChange(r.roomId, b.blockId) end | |
| 773 | + self:addNewMonsterRand(effect[2], {room, block}) | |
| 774 | + clearBlock = false | |
| 764 | 775 | end, |
| 765 | 776 | [4] = function() --无事发生 |
| 766 | 777 | end |
| ... | ... | @@ -768,7 +779,9 @@ local function clickBuild(self, room, block, params) |
| 768 | 779 | assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id) |
| 769 | 780 | if not self:cost({[buildData.type] = 1}, {}) then return end |
| 770 | 781 | doEffect[effect[1]]() |
| 771 | - room:clearBEvent(block) | |
| 782 | + if clearBlock then | |
| 783 | + room:clearBEvent(block) | |
| 784 | + end | |
| 772 | 785 | return true |
| 773 | 786 | end |
| 774 | 787 | |
| ... | ... | @@ -884,7 +897,7 @@ function Adv:useSkill(skillId, target) |
| 884 | 897 | end |
| 885 | 898 | |
| 886 | 899 | --敌人死亡 |
| 887 | -function Adv:enemyDead(roomId, blockId) | |
| 900 | +function Adv:enemyDead(roomId, blockId, escape) | |
| 888 | 901 | local room = self.rooms[roomId] |
| 889 | 902 | local block = room.blocks[blockId] |
| 890 | 903 | --死了以后掉东西 |
| ... | ... | @@ -892,19 +905,23 @@ function Adv:enemyDead(roomId, blockId) |
| 892 | 905 | if block.event.etype == AdvEventType.BOSS then |
| 893 | 906 | room.isBossRoom = false |
| 894 | 907 | end |
| 895 | - local item = block.event.item | |
| 896 | - if not item then | |
| 897 | - if block.event.etype == AdvEventType.BOSS then | |
| 898 | - item = {ItemId.AdvKey, 1} | |
| 899 | - else | |
| 900 | - local monsterData = csvdb["event_monsterCsv"][block.event.id] | |
| 901 | - local dropData = csvdb["event_dropCsv"][monsterData.dropid] | |
| 902 | - item = dropData["range"]:randWeight(true) | |
| 908 | + if escape then | |
| 909 | + room:clearBEvent(block) | |
| 910 | + else | |
| 911 | + local item = block.event.item | |
| 912 | + if not item then | |
| 913 | + if block.event.etype == AdvEventType.BOSS then | |
| 914 | + item = {ItemId.AdvKey, 1} | |
| 915 | + else | |
| 916 | + local monsterData = csvdb["event_monsterCsv"][block.event.id] | |
| 917 | + local dropData = csvdb["event_dropCsv"][monsterData.dropid] | |
| 918 | + item = dropData["range"]:randWeight(true) | |
| 919 | + end | |
| 903 | 920 | end |
| 921 | + table.clear(block.event) | |
| 922 | + block.event.etype = AdvEventType.Drop | |
| 923 | + block.event.item = item | |
| 904 | 924 | end |
| 905 | - table.clear(block.event) | |
| 906 | - block.event.etype = AdvEventType.Drop | |
| 907 | - block.event.item = item | |
| 908 | 925 | end |
| 909 | 926 | self:backBlockChange(roomId, blockId) |
| 910 | 927 | end | ... | ... |
src/adv/AdvBattle.lua
| ... | ... | @@ -4,10 +4,14 @@ local Battle = class("Battle") |
| 4 | 4 | function Battle:ctor(adv) |
| 5 | 5 | self.adv = adv |
| 6 | 6 | self.player = nil --玩家 |
| 7 | + self.isNewPlayer = false | |
| 7 | 8 | self.enemys = {} --怪 |
| 8 | 9 | self:initPlayer() |
| 9 | 10 | self:initEnemys() |
| 10 | 11 | self:initAfter() |
| 12 | + if self.isNewPlayer then | |
| 13 | + self.player:triggerPassive(Passive.BORN_ONCE) | |
| 14 | + end | |
| 11 | 15 | end |
| 12 | 16 | |
| 13 | 17 | function Battle:initAfter() |
| ... | ... | @@ -37,6 +41,7 @@ function Battle:initPlayer() |
| 37 | 41 | player.miss = 0 |
| 38 | 42 | player.hit = 100 |
| 39 | 43 | self.adv.advTeam.player = player |
| 44 | + self.isNewPlayer = true | |
| 40 | 45 | end |
| 41 | 46 | self.player = Player.new(self, self.adv.advTeam.player) |
| 42 | 47 | end |
| ... | ... | @@ -64,7 +69,9 @@ function Battle:addEnemy(room, block) |
| 64 | 69 | end |
| 65 | 70 | block.event.enemy = enemy |
| 66 | 71 | end |
| 67 | - table.insert(self.enemys, Enemy.new(self, block.event.mId or 999, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.enemy)) | |
| 72 | + local player = Enemy.new(self, block.event.mId or 999, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.enemy) | |
| 73 | + table.insert(self.enemys, player) | |
| 74 | + return player | |
| 68 | 75 | end |
| 69 | 76 | end |
| 70 | 77 | |
| ... | ... | @@ -98,7 +105,10 @@ function Battle:playerAtk(roomId, blockId) |
| 98 | 105 | end |
| 99 | 106 | --触发全员被动技能 |
| 100 | 107 | function Battle:triggerPassive(condType, params) |
| 101 | - | |
| 108 | + self.player:triggerPassive(condType, params) | |
| 109 | + for _, enemy in ipairs(self.enemys) do | |
| 110 | + enemy:triggerPassive(condType, params) | |
| 111 | + end | |
| 102 | 112 | end |
| 103 | 113 | |
| 104 | 114 | --回合 | ... | ... |
src/adv/AdvBuff.lua
src/adv/AdvPassive.lua
| ... | ... | @@ -3,8 +3,8 @@ local Passive = class("Passive") |
| 3 | 3 | -- 每回合触发的使用 afterRound |
| 4 | 4 | -- 其他触发的使用 triggerPassive |
| 5 | 5 | |
| 6 | -Passive.BORN_ONCE = 1 -- 自身出生(翻开所在格子)后M回合触发(1次) | |
| 7 | -Passive.BORN_PRE = 2 --自身出生(翻开所在格子)后每N回合触发1次 | |
| 6 | +Passive.BORN_ONCE = 1 -- 自身出生(翻开所在格子)触发 | |
| 7 | +Passive.ROOM_SHOW = 2 --自身所在房间被展示时,触发1次 | |
| 8 | 8 | Passive.HURT_PERCENT_SELF = 3 --自身,每损失N%生命值,触发1次 |
| 9 | 9 | Passive.HURT_PERCENT_TEAM = 4 --队友,每损失N%生命值,触发1次 |
| 10 | 10 | Passive.HP_LOW_SELF = 5 --自身生命值<N%时,每回合触发 |
| ... | ... | @@ -21,12 +21,98 @@ Passive.SELF_DEAD = 15 --自身死亡后,触发1次 |
| 21 | 21 | Passive.TEAM_DEAD = 16 --队友死亡后,触发1次 |
| 22 | 22 | Passive.TARGET_SKILL = 17 --目标每使用N次技能,触发1次 |
| 23 | 23 | Passive.TEAM_SKILL = 18 --队友每使用N次技能,触发1次 |
| 24 | -Passive.ROOM_SHOW = 19 --自身所在房间被展示时,触发1次 | |
| 24 | + | |
| 25 | 25 | |
| 26 | 26 | -- 不同的开启条件 |
| 27 | -local PassiveFactory = { | |
| 28 | - | |
| 29 | -} | |
| 27 | +local PassiveCondFactory = {} | |
| 28 | +PassiveCondFactory[Passive.HURT_PERCENT_SELF] = function(_Passive) | |
| 29 | + _Passive._trigger = function(self, params) | |
| 30 | + local value = params.value or 1 | |
| 31 | + self.rv = math.floor(self.rv + value) | |
| 32 | + if self.rv >= self.passiveData.value then | |
| 33 | + self.rv = self.rv % self.passiveData.value -- 取余 | |
| 34 | + return true | |
| 35 | + end | |
| 36 | + end | |
| 37 | + _Passive._initDB = function(self, data) | |
| 38 | + self.rv = data.rv or 0 | |
| 39 | + end | |
| 40 | + _Passive._getDB = function(self) | |
| 41 | + return {rv = self.rv} | |
| 42 | + end | |
| 43 | +end | |
| 44 | + | |
| 45 | +PassiveCondFactory[Passive.HURT_PERCENT_TEAM] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 46 | +PassiveCondFactory[Passive.SELF_ATK] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 47 | +PassiveCondFactory[Passive.SELF_HURT] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 48 | +PassiveCondFactory[Passive.TEAM_ATK] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 49 | +PassiveCondFactory[Passive.TEAM_HURT] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 50 | +PassiveCondFactory[Passive.TARGET_SKILL] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 51 | +PassiveCondFactory[Passive.TEAM_SKILL] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同 | |
| 52 | + | |
| 53 | +PassiveCondFactory[Passive.ROOM_SHOW] = function(_Passive) | |
| 54 | + _Passive._trigger = function(self, params) | |
| 55 | + local roomId = params.roomId | |
| 56 | + if self.roomId == roomId then | |
| 57 | + return true | |
| 58 | + end | |
| 59 | + end | |
| 60 | +end | |
| 61 | + | |
| 62 | +PassiveCondFactory[Passive.HP_LOW_SELF] = function(_Passive) | |
| 63 | + _Passive._afterRound = function(self) | |
| 64 | + if self.owner.hp / self.owner.hpMax * 100 < self.passiveData.value then | |
| 65 | + self:trigger(Passive.HP_LOW_SELF) | |
| 66 | + end | |
| 67 | + end | |
| 68 | +end | |
| 69 | + | |
| 70 | +PassiveCondFactory[Passive.HP_LOW_TEAM] = function(_Passive) | |
| 71 | + _Passive._afterRound = function(self) | |
| 72 | + for _, player in ipairs(self.owner:getTeam(2)) do | |
| 73 | + if player.hp / player.hpMax * 100 < self.passiveData.value then | |
| 74 | + self:trigger(Passive.HP_LOW_TEAM, {trigger = player}) | |
| 75 | + end | |
| 76 | + end | |
| 77 | + end | |
| 78 | +end | |
| 79 | + | |
| 80 | +PassiveCondFactory[Passive.HP_UP_SELF] = function(_Passive) | |
| 81 | + _Passive._afterRound = function(self) | |
| 82 | + if self.owner.hp / self.owner.hpMax * 100 > self.passiveData.value then | |
| 83 | + self:trigger(Passive.HP_UP_SELF) | |
| 84 | + end | |
| 85 | + end | |
| 86 | +end | |
| 87 | + | |
| 88 | +PassiveCondFactory[Passive.HP_UP_TEAM] = function(_Passive) | |
| 89 | + _Passive._afterRound = function(self) | |
| 90 | + for _, player in ipairs(self.owner:getTeam(2)) do | |
| 91 | + if player.hp / player.hpMax * 100 > self.passiveData.value then | |
| 92 | + self:trigger(Passive.HP_UP_TEAM, {trigger = player}) | |
| 93 | + end | |
| 94 | + end | |
| 95 | + end | |
| 96 | +end | |
| 97 | + | |
| 98 | +PassiveCondFactory[Passive.MONSTER_COUNT_UP] = function(_Passive) | |
| 99 | + _Passive._afterRound = function(self) | |
| 100 | + local monsters = self.owner.battle.player:getTeam(2) | |
| 101 | + if #monsters > self.passiveData.value then | |
| 102 | + self:trigger(Passive.MONSTER_COUNT_UP) | |
| 103 | + end | |
| 104 | + end | |
| 105 | +end | |
| 106 | + | |
| 107 | +PassiveCondFactory[Passive.MONSTER_COUNT_LOW] = function(_Passive) | |
| 108 | + _Passive._afterRound = function(self) | |
| 109 | + local monsters = self.owner.battle.player:getTeam(2) | |
| 110 | + if #monsters < self.passiveData.value then | |
| 111 | + self:trigger(Passive.MONSTER_COUNT_LOW) | |
| 112 | + end | |
| 113 | + end | |
| 114 | +end | |
| 115 | + | |
| 30 | 116 | |
| 31 | 117 | function Passive:ctor(owner, data) |
| 32 | 118 | self.owner = owner |
| ... | ... | @@ -36,8 +122,11 @@ function Passive:ctor(owner, data) |
| 36 | 122 | self.isDel = false |
| 37 | 123 | self.round = data.round or 0 --触发剩余回合数 |
| 38 | 124 | self.count = data.count or 0 --触发剩余次数 |
| 39 | - if PassiveFactory[self.passiveData.condition] then | |
| 40 | - PassiveFactory[self.passiveData.condition](self) | |
| 125 | + if PassiveCondFactory[self.passiveData.condition] then | |
| 126 | + PassiveCondFactory[self.passiveData.condition](self) | |
| 127 | + end | |
| 128 | + if self._initDB then | |
| 129 | + self:_initDB(data) | |
| 41 | 130 | end |
| 42 | 131 | end |
| 43 | 132 | |
| ... | ... | @@ -46,8 +135,8 @@ function Passive:getCondType() |
| 46 | 135 | end |
| 47 | 136 | |
| 48 | 137 | function Passive:effect() |
| 49 | - if self._effect then | |
| 50 | - self:_effect() | |
| 138 | + if math.randomInt(1, 100) <= self.passiveData.chance and self["effect" .. self.passiveData.effect] then | |
| 139 | + self["effect" .. self.passiveData.effect](self) | |
| 51 | 140 | end |
| 52 | 141 | --次数为 -1 一局只能触发一次,触发过后删掉就可以 |
| 53 | 142 | if self.count == -1 then |
| ... | ... | @@ -78,16 +167,19 @@ function Passive:isActive( ) |
| 78 | 167 | end |
| 79 | 168 | |
| 80 | 169 | function Passive:trigger(condType, params) --触发检查 |
| 170 | + params = params or {} | |
| 171 | + if self.isDel or self.owner.isDead then return end | |
| 81 | 172 | if self:getCondType() ~= condType then return end |
| 173 | + if self.owner.lock and self.passiveData.effect ~= 3 then return end -- 锁定的只能触发翻开自己格子的固有技 | |
| 82 | 174 | if self:isActive() then return end |
| 83 | 175 | if self._trigger then |
| 84 | - if not self._trigger(params) then return end --检查 | |
| 176 | + if not self:_trigger(params) then return end --检查 | |
| 85 | 177 | end |
| 86 | 178 | self.round = self.passiveData.delay --首次 |
| 87 | 179 | self.count = self.passiveData.count --次数 |
| 88 | 180 | -- 没有延迟就直接触发 |
| 89 | 181 | if self.round == 0 then |
| 90 | - self:effect() | |
| 182 | + self:effect(params.trigger) | |
| 91 | 183 | end |
| 92 | 184 | end |
| 93 | 185 | |
| ... | ... | @@ -102,4 +194,30 @@ function Passive:getDB() |
| 102 | 194 | db.count = self.count |
| 103 | 195 | return db |
| 104 | 196 | end |
| 197 | + | |
| 198 | +--默认=0=使用技能, | |
| 199 | +function Passive:effect0() | |
| 200 | + self.owner:releaseSkill(self.passiveData.effectValue) | |
| 201 | +end | |
| 202 | +--1=自身获得buff | |
| 203 | +function Passive:effect1() | |
| 204 | + self.owner:addBuff(self.passiveData.effectValue) | |
| 205 | +end | |
| 206 | +--2=触发目标获得buff | |
| 207 | +function Passive:effect2(trigger) | |
| 208 | + if trigger then | |
| 209 | + trigger:addBuff(self.passiveData.effectValue) | |
| 210 | + end | |
| 211 | +end | |
| 212 | +--3=翻开自己所在格子, | |
| 213 | +function Passive:effect3() | |
| 214 | + self.owner.battle.adv:openBlock(self.owner.roomId, self.owner.blockId) | |
| 215 | +end | |
| 216 | +--4=逃跑 | |
| 217 | +function Passive:effect4() | |
| 218 | + self.owner.isDead = true --跑了 | |
| 219 | + self.owner.battle.adv:enemyDead(self.owner.roomId,self.owner.blockId, true) | |
| 220 | +end | |
| 221 | + | |
| 222 | + | |
| 105 | 223 | return Passive |
| 106 | 224 | \ No newline at end of file | ... | ... |
src/adv/AdvPlayer.lua
| ... | ... | @@ -165,12 +165,20 @@ end |
| 165 | 165 | function BaseObject:hurt(value, releaser, params) |
| 166 | 166 | params = params or {} |
| 167 | 167 | if params.hurtType and params.hurtType == 1 then |
| 168 | + releaser:triggerPassive(Passive.SELF_ATK) | |
| 169 | + for _, team in ipairs(releaser:getTeam(1, true)) do | |
| 170 | + team:triggerPassive(Passive.TEAM_ATK) | |
| 171 | + end | |
| 168 | 172 | if self:hadBuff(Buff.IMMNUE_ATK) then return end --无视普通攻击 |
| 169 | 173 | |
| 170 | 174 | local hit = releaser.hit - self.miss --命中率 |
| 171 | 175 | if hit < math.randomInt(1, 100) then --miss |
| 172 | 176 | return |
| 173 | 177 | end |
| 178 | + self:triggerPassive(Passive.SELF_HURT, {trigger = releaser}) | |
| 179 | + for _, team in ipairs(self:getTeam(1, true)) do | |
| 180 | + team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser}) | |
| 181 | + end | |
| 174 | 182 | end |
| 175 | 183 | |
| 176 | 184 | value = self:getInjuredValue(value) --减伤计算 |
| ... | ... | @@ -222,8 +230,17 @@ function BaseObject:hurt(value, releaser, params) |
| 222 | 230 | self.battle.adv:backHpChange(self.id, -value) |
| 223 | 231 | self.hp = math.max(0, self.hp - value) |
| 224 | 232 | if self.hp == 0 then |
| 233 | + self:triggerPassive(Passive.SELF_DEAD) | |
| 234 | + for _, team in ipairs(self:getTeam(1, true)) do | |
| 235 | + team:triggerPassive(Passive.TEAM_DEAD) | |
| 236 | + end | |
| 237 | + | |
| 225 | 238 | self.isDead = true |
| 226 | 239 | end |
| 240 | + self:triggerPassive(Passive.HURT_PERCENT_SELF, {value = value / self.hpMax}) | |
| 241 | + for _, team in ipairs(self:getTeam(1, true)) do | |
| 242 | + team:triggerPassive(Passive.HURT_PERCENT_TEAM, {value = value / self.hpMax}) | |
| 243 | + end | |
| 227 | 244 | end |
| 228 | 245 | --恢复 |
| 229 | 246 | function BaseObject:recover(value, releaser, params) |
| ... | ... | @@ -317,6 +334,13 @@ function BaseObject:releaseSkill(skillId, skillLevel, target) |
| 317 | 334 | target_:addBuff(buffId, self) |
| 318 | 335 | end |
| 319 | 336 | end |
| 337 | + | |
| 338 | + for _, team in ipairs(self:getTeam(2)) do | |
| 339 | + team:triggerPassive(Passive.TARGET_SKILL) | |
| 340 | + end | |
| 341 | + for _, team in ipairs(self:getTeam(1, true)) do | |
| 342 | + team:triggerPassive(Passive.TEAM_SKILL) | |
| 343 | + end | |
| 320 | 344 | end |
| 321 | 345 | |
| 322 | 346 | --0 全部 1 我方 2 敌方 |
| ... | ... | @@ -379,7 +403,10 @@ function BaseObject:getDB() |
| 379 | 403 | end |
| 380 | 404 | |
| 381 | 405 | function BaseObject:triggerPassive(condType, params) |
| 382 | - | |
| 406 | + if self.isDead then return end | |
| 407 | + for _, passive in ipairs(self.passives) do | |
| 408 | + passive:trigger(condType, params) --检查触发 | |
| 409 | + end | |
| 383 | 410 | end |
| 384 | 411 | |
| 385 | 412 | local Enemy = class("Enemy", BaseObject) | ... | ... |