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,8 +273,9 @@ function Block:open(adv, room) | ||
273 | if enemy then | 273 | if enemy then |
274 | enemy:unlock(self.event.mId) | 274 | enemy:unlock(self.event.mId) |
275 | else | 275 | else |
276 | - adv.battle:addEnemy(room, self) | 276 | + enemy = adv.battle:addEnemy(room, self) |
277 | end | 277 | end |
278 | + enemy:triggerPassive(Passive.BORN_ONCE) | ||
278 | end | 279 | end |
279 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] | 280 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] |
280 | --掉落 | 281 | --掉落 |
@@ -525,30 +526,37 @@ function Adv:getAroundBlocks(room, block) | @@ -525,30 +526,37 @@ function Adv:getAroundBlocks(room, block) | ||
525 | end | 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 | end | 540 | end |
535 | end | 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 | end | 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 | if not monsterId then | 547 | if not monsterId then |
544 | local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster) | 548 | local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster) |
545 | if not next(eventLib[AdvEventType.Monster]) then return false end | 549 | if not next(eventLib[AdvEventType.Monster]) then return false end |
546 | monsterId = math.randWeight(eventLib[AdvEventType.Monster], "showup") | 550 | monsterId = math.randWeight(eventLib[AdvEventType.Monster], "showup") |
547 | end | 551 | end |
552 | + | ||
553 | + local event = {etype = AdvEventType.Monster, mId = self.advInfo.enemyId} | ||
554 | + self.advInfo.enemyId = self.advInfo.enemyId + 1 | ||
548 | event.id = monsterId | 555 | event.id = monsterId |
549 | block.event = event | 556 | block.event = event |
550 | room.info.event[block.blockId] = event | 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 | return room, block | 560 | return room, block |
553 | end | 561 | end |
554 | 562 | ||
@@ -579,7 +587,9 @@ end | @@ -579,7 +587,9 @@ end | ||
579 | -- 打开一个地块 | 587 | -- 打开一个地块 |
580 | function Adv:openBlock(roomId, blockId) | 588 | function Adv:openBlock(roomId, blockId) |
581 | local room = self.rooms[roomId] | 589 | local room = self.rooms[roomId] |
590 | + if not room then return end | ||
582 | local block = room.blocks[blockId] | 591 | local block = room.blocks[blockId] |
592 | + if not block then return end | ||
583 | room:openBlock(block, self) | 593 | room:openBlock(block, self) |
584 | self:backBlockChange(roomId, blockId) | 594 | self:backBlockChange(roomId, blockId) |
585 | end | 595 | end |
@@ -696,7 +706,7 @@ local function clickChoose(self, room, block, params) | @@ -696,7 +706,7 @@ local function clickChoose(self, room, block, params) | ||
696 | } | 706 | } |
697 | assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) | 707 | assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) |
698 | if cond[1] and not checkCond[cond[1]]() then return end | 708 | if cond[1] and not checkCond[cond[1]]() then return end |
699 | - | 709 | + local clearBlock = true |
700 | local effect = block.event.effect[choose] | 710 | local effect = block.event.effect[choose] |
701 | local doEffect = { | 711 | local doEffect = { |
702 | [1] = function() -- 获得某道具N个 | 712 | [1] = function() -- 获得某道具N个 |
@@ -706,17 +716,17 @@ local function clickChoose(self, room, block, params) | @@ -706,17 +716,17 @@ local function clickChoose(self, room, block, params) | ||
706 | self.battle.player:addBuff(effect[2]) | 716 | self.battle.player:addBuff(effect[2]) |
707 | end, | 717 | end, |
708 | [3] = function() --发现怪物 | 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 | end, | 721 | end, |
714 | [4] = function() --无事发生 | 722 | [4] = function() --无事发生 |
715 | end | 723 | end |
716 | } | 724 | } |
717 | assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) | 725 | assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) |
718 | doEffect[effect[1]]() | 726 | doEffect[effect[1]]() |
719 | - room:clearBEvent(block) | 727 | + if clearBlock then |
728 | + room:clearBEvent(block) | ||
729 | + end | ||
720 | return true | 730 | return true |
721 | end | 731 | end |
722 | 732 | ||
@@ -749,6 +759,7 @@ local function clickBuild(self, room, block, params) | @@ -749,6 +759,7 @@ local function clickBuild(self, room, block, params) | ||
749 | local buildData = csvdb["event_buildingCsv"][block.event.id] | 759 | local buildData = csvdb["event_buildingCsv"][block.event.id] |
750 | if not buildData then return end-- 偷偷改表了 | 760 | if not buildData then return end-- 偷偷改表了 |
751 | if not block.event.effect then return end -- 没有效果 气人不 | 761 | if not block.event.effect then return end -- 没有效果 气人不 |
762 | + local clearBlock = true | ||
752 | local effect = block.event.effect | 763 | local effect = block.event.effect |
753 | --todo 效果生效 | 764 | --todo 效果生效 |
754 | local doEffect = { | 765 | local doEffect = { |
@@ -759,8 +770,8 @@ local function clickBuild(self, room, block, params) | @@ -759,8 +770,8 @@ local function clickBuild(self, room, block, params) | ||
759 | self.battle.player:addBuff(effect[2]) | 770 | self.battle.player:addBuff(effect[2]) |
760 | end, | 771 | end, |
761 | [3] = function() --发现怪物 | 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 | end, | 775 | end, |
765 | [4] = function() --无事发生 | 776 | [4] = function() --无事发生 |
766 | end | 777 | end |
@@ -768,7 +779,9 @@ local function clickBuild(self, room, block, params) | @@ -768,7 +779,9 @@ local function clickBuild(self, room, block, params) | ||
768 | assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id) | 779 | assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id) |
769 | if not self:cost({[buildData.type] = 1}, {}) then return end | 780 | if not self:cost({[buildData.type] = 1}, {}) then return end |
770 | doEffect[effect[1]]() | 781 | doEffect[effect[1]]() |
771 | - room:clearBEvent(block) | 782 | + if clearBlock then |
783 | + room:clearBEvent(block) | ||
784 | + end | ||
772 | return true | 785 | return true |
773 | end | 786 | end |
774 | 787 | ||
@@ -884,7 +897,7 @@ function Adv:useSkill(skillId, target) | @@ -884,7 +897,7 @@ function Adv:useSkill(skillId, target) | ||
884 | end | 897 | end |
885 | 898 | ||
886 | --敌人死亡 | 899 | --敌人死亡 |
887 | -function Adv:enemyDead(roomId, blockId) | 900 | +function Adv:enemyDead(roomId, blockId, escape) |
888 | local room = self.rooms[roomId] | 901 | local room = self.rooms[roomId] |
889 | local block = room.blocks[blockId] | 902 | local block = room.blocks[blockId] |
890 | --死了以后掉东西 | 903 | --死了以后掉东西 |
@@ -892,19 +905,23 @@ function Adv:enemyDead(roomId, blockId) | @@ -892,19 +905,23 @@ function Adv:enemyDead(roomId, blockId) | ||
892 | if block.event.etype == AdvEventType.BOSS then | 905 | if block.event.etype == AdvEventType.BOSS then |
893 | room.isBossRoom = false | 906 | room.isBossRoom = false |
894 | end | 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 | end | 920 | end |
921 | + table.clear(block.event) | ||
922 | + block.event.etype = AdvEventType.Drop | ||
923 | + block.event.item = item | ||
904 | end | 924 | end |
905 | - table.clear(block.event) | ||
906 | - block.event.etype = AdvEventType.Drop | ||
907 | - block.event.item = item | ||
908 | end | 925 | end |
909 | self:backBlockChange(roomId, blockId) | 926 | self:backBlockChange(roomId, blockId) |
910 | end | 927 | end |
src/adv/AdvBattle.lua
@@ -4,10 +4,14 @@ local Battle = class("Battle") | @@ -4,10 +4,14 @@ local Battle = class("Battle") | ||
4 | function Battle:ctor(adv) | 4 | function Battle:ctor(adv) |
5 | self.adv = adv | 5 | self.adv = adv |
6 | self.player = nil --玩家 | 6 | self.player = nil --玩家 |
7 | + self.isNewPlayer = false | ||
7 | self.enemys = {} --怪 | 8 | self.enemys = {} --怪 |
8 | self:initPlayer() | 9 | self:initPlayer() |
9 | self:initEnemys() | 10 | self:initEnemys() |
10 | self:initAfter() | 11 | self:initAfter() |
12 | + if self.isNewPlayer then | ||
13 | + self.player:triggerPassive(Passive.BORN_ONCE) | ||
14 | + end | ||
11 | end | 15 | end |
12 | 16 | ||
13 | function Battle:initAfter() | 17 | function Battle:initAfter() |
@@ -37,6 +41,7 @@ function Battle:initPlayer() | @@ -37,6 +41,7 @@ function Battle:initPlayer() | ||
37 | player.miss = 0 | 41 | player.miss = 0 |
38 | player.hit = 100 | 42 | player.hit = 100 |
39 | self.adv.advTeam.player = player | 43 | self.adv.advTeam.player = player |
44 | + self.isNewPlayer = true | ||
40 | end | 45 | end |
41 | self.player = Player.new(self, self.adv.advTeam.player) | 46 | self.player = Player.new(self, self.adv.advTeam.player) |
42 | end | 47 | end |
@@ -64,7 +69,9 @@ function Battle:addEnemy(room, block) | @@ -64,7 +69,9 @@ function Battle:addEnemy(room, block) | ||
64 | end | 69 | end |
65 | block.event.enemy = enemy | 70 | block.event.enemy = enemy |
66 | end | 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 | end | 75 | end |
69 | end | 76 | end |
70 | 77 | ||
@@ -98,7 +105,10 @@ function Battle:playerAtk(roomId, blockId) | @@ -98,7 +105,10 @@ function Battle:playerAtk(roomId, blockId) | ||
98 | end | 105 | end |
99 | --触发全员被动技能 | 106 | --触发全员被动技能 |
100 | function Battle:triggerPassive(condType, params) | 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 | end | 112 | end |
103 | 113 | ||
104 | --回合 | 114 | --回合 |
src/adv/AdvBuff.lua
@@ -232,7 +232,6 @@ end | @@ -232,7 +232,6 @@ end | ||
232 | 232 | ||
233 | function Buff:afterRound() | 233 | function Buff:afterRound() |
234 | if self.isDel or self.owner.isDead then return end | 234 | if self.isDel or self.owner.isDead then return end |
235 | - | ||
236 | if self._afterRount then | 235 | if self._afterRount then |
237 | self:_afterRount() | 236 | self:_afterRount() |
238 | end | 237 | end |
src/adv/AdvPassive.lua
@@ -3,8 +3,8 @@ local Passive = class("Passive") | @@ -3,8 +3,8 @@ local Passive = class("Passive") | ||
3 | -- 每回合触发的使用 afterRound | 3 | -- 每回合触发的使用 afterRound |
4 | -- 其他触发的使用 triggerPassive | 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 | Passive.HURT_PERCENT_SELF = 3 --自身,每损失N%生命值,触发1次 | 8 | Passive.HURT_PERCENT_SELF = 3 --自身,每损失N%生命值,触发1次 |
9 | Passive.HURT_PERCENT_TEAM = 4 --队友,每损失N%生命值,触发1次 | 9 | Passive.HURT_PERCENT_TEAM = 4 --队友,每损失N%生命值,触发1次 |
10 | Passive.HP_LOW_SELF = 5 --自身生命值<N%时,每回合触发 | 10 | Passive.HP_LOW_SELF = 5 --自身生命值<N%时,每回合触发 |
@@ -21,12 +21,98 @@ Passive.SELF_DEAD = 15 --自身死亡后,触发1次 | @@ -21,12 +21,98 @@ Passive.SELF_DEAD = 15 --自身死亡后,触发1次 | ||
21 | Passive.TEAM_DEAD = 16 --队友死亡后,触发1次 | 21 | Passive.TEAM_DEAD = 16 --队友死亡后,触发1次 |
22 | Passive.TARGET_SKILL = 17 --目标每使用N次技能,触发1次 | 22 | Passive.TARGET_SKILL = 17 --目标每使用N次技能,触发1次 |
23 | Passive.TEAM_SKILL = 18 --队友每使用N次技能,触发1次 | 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 | function Passive:ctor(owner, data) | 117 | function Passive:ctor(owner, data) |
32 | self.owner = owner | 118 | self.owner = owner |
@@ -36,8 +122,11 @@ function Passive:ctor(owner, data) | @@ -36,8 +122,11 @@ function Passive:ctor(owner, data) | ||
36 | self.isDel = false | 122 | self.isDel = false |
37 | self.round = data.round or 0 --触发剩余回合数 | 123 | self.round = data.round or 0 --触发剩余回合数 |
38 | self.count = data.count or 0 --触发剩余次数 | 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 | end | 130 | end |
42 | end | 131 | end |
43 | 132 | ||
@@ -46,8 +135,8 @@ function Passive:getCondType() | @@ -46,8 +135,8 @@ function Passive:getCondType() | ||
46 | end | 135 | end |
47 | 136 | ||
48 | function Passive:effect() | 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 | end | 140 | end |
52 | --次数为 -1 一局只能触发一次,触发过后删掉就可以 | 141 | --次数为 -1 一局只能触发一次,触发过后删掉就可以 |
53 | if self.count == -1 then | 142 | if self.count == -1 then |
@@ -78,16 +167,19 @@ function Passive:isActive( ) | @@ -78,16 +167,19 @@ function Passive:isActive( ) | ||
78 | end | 167 | end |
79 | 168 | ||
80 | function Passive:trigger(condType, params) --触发检查 | 169 | function Passive:trigger(condType, params) --触发检查 |
170 | + params = params or {} | ||
171 | + if self.isDel or self.owner.isDead then return end | ||
81 | if self:getCondType() ~= condType then return end | 172 | if self:getCondType() ~= condType then return end |
173 | + if self.owner.lock and self.passiveData.effect ~= 3 then return end -- 锁定的只能触发翻开自己格子的固有技 | ||
82 | if self:isActive() then return end | 174 | if self:isActive() then return end |
83 | if self._trigger then | 175 | if self._trigger then |
84 | - if not self._trigger(params) then return end --检查 | 176 | + if not self:_trigger(params) then return end --检查 |
85 | end | 177 | end |
86 | self.round = self.passiveData.delay --首次 | 178 | self.round = self.passiveData.delay --首次 |
87 | self.count = self.passiveData.count --次数 | 179 | self.count = self.passiveData.count --次数 |
88 | -- 没有延迟就直接触发 | 180 | -- 没有延迟就直接触发 |
89 | if self.round == 0 then | 181 | if self.round == 0 then |
90 | - self:effect() | 182 | + self:effect(params.trigger) |
91 | end | 183 | end |
92 | end | 184 | end |
93 | 185 | ||
@@ -102,4 +194,30 @@ function Passive:getDB() | @@ -102,4 +194,30 @@ function Passive:getDB() | ||
102 | db.count = self.count | 194 | db.count = self.count |
103 | return db | 195 | return db |
104 | end | 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 | return Passive | 223 | return Passive |
106 | \ No newline at end of file | 224 | \ No newline at end of file |
src/adv/AdvPlayer.lua
@@ -165,12 +165,20 @@ end | @@ -165,12 +165,20 @@ end | ||
165 | function BaseObject:hurt(value, releaser, params) | 165 | function BaseObject:hurt(value, releaser, params) |
166 | params = params or {} | 166 | params = params or {} |
167 | if params.hurtType and params.hurtType == 1 then | 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 | if self:hadBuff(Buff.IMMNUE_ATK) then return end --无视普通攻击 | 172 | if self:hadBuff(Buff.IMMNUE_ATK) then return end --无视普通攻击 |
169 | 173 | ||
170 | local hit = releaser.hit - self.miss --命中率 | 174 | local hit = releaser.hit - self.miss --命中率 |
171 | if hit < math.randomInt(1, 100) then --miss | 175 | if hit < math.randomInt(1, 100) then --miss |
172 | return | 176 | return |
173 | end | 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 | end | 182 | end |
175 | 183 | ||
176 | value = self:getInjuredValue(value) --减伤计算 | 184 | value = self:getInjuredValue(value) --减伤计算 |
@@ -222,8 +230,17 @@ function BaseObject:hurt(value, releaser, params) | @@ -222,8 +230,17 @@ function BaseObject:hurt(value, releaser, params) | ||
222 | self.battle.adv:backHpChange(self.id, -value) | 230 | self.battle.adv:backHpChange(self.id, -value) |
223 | self.hp = math.max(0, self.hp - value) | 231 | self.hp = math.max(0, self.hp - value) |
224 | if self.hp == 0 then | 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 | self.isDead = true | 238 | self.isDead = true |
226 | end | 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 | end | 244 | end |
228 | --恢复 | 245 | --恢复 |
229 | function BaseObject:recover(value, releaser, params) | 246 | function BaseObject:recover(value, releaser, params) |
@@ -317,6 +334,13 @@ function BaseObject:releaseSkill(skillId, skillLevel, target) | @@ -317,6 +334,13 @@ function BaseObject:releaseSkill(skillId, skillLevel, target) | ||
317 | target_:addBuff(buffId, self) | 334 | target_:addBuff(buffId, self) |
318 | end | 335 | end |
319 | end | 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 | end | 344 | end |
321 | 345 | ||
322 | --0 全部 1 我方 2 敌方 | 346 | --0 全部 1 我方 2 敌方 |
@@ -379,7 +403,10 @@ function BaseObject:getDB() | @@ -379,7 +403,10 @@ function BaseObject:getDB() | ||
379 | end | 403 | end |
380 | 404 | ||
381 | function BaseObject:triggerPassive(condType, params) | 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 | end | 410 | end |
384 | 411 | ||
385 | local Enemy = class("Enemy", BaseObject) | 412 | local Enemy = class("Enemy", BaseObject) |