Commit b71a819081da541ad962158706e1cd3656390e8e
1 parent
e1355da3
动态改变 一些buff
Showing
3 changed files
with
79 additions
and
59 deletions
Show diff stats
src/adv/Adv.lua
... | ... | @@ -115,7 +115,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt |
115 | 115 | self.maps = {} |
116 | 116 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) |
117 | 117 | |
118 | - self:initBattle() | |
118 | + self:initBattle(true) | |
119 | 119 | |
120 | 120 | self:initLayerTask() |
121 | 121 | |
... | ... | @@ -371,7 +371,7 @@ function Adv:clearAdvUnlockCache() |
371 | 371 | self.cacheUnlock = {} |
372 | 372 | end |
373 | 373 | |
374 | -function Adv:initBattle() | |
374 | +function Adv:initBattle(notDb) | |
375 | 375 | self.battle = require("adv.AdvBattle").new(self) |
376 | 376 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do |
377 | 377 | self.battle:triggerPassive(passiveC[1], passiveC[2]) |
... | ... | @@ -382,6 +382,10 @@ function Adv:initBattle() |
382 | 382 | for idx, map in pairs(self.maps) do |
383 | 383 | map:initBattleAfter() |
384 | 384 | end |
385 | + --下层 | |
386 | + if notDb and self.level ~= 1 then | |
387 | + self.battle.player:attrChangeCondBuffCheck(1) | |
388 | + end | |
385 | 389 | end |
386 | 390 | |
387 | 391 | function Adv:triggerPassive(condType, params) |
... | ... | @@ -758,6 +762,10 @@ function Adv:award(gift, params) |
758 | 762 | if items ~= oldItems then |
759 | 763 | self.owner:updateProperty({field = "advItems", value = items, notNotify = params.notNotify}) |
760 | 764 | end |
765 | + | |
766 | + if tgift[ItemId.OldCoin] then | |
767 | + self.battle.player:attrChangeCondBuffCheck(0) | |
768 | + end | |
761 | 769 | return tgift |
762 | 770 | end |
763 | 771 | ... | ... |
src/adv/AdvBuff.lua
... | ... | @@ -35,7 +35,7 @@ Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 |
35 | 35 | |
36 | 36 | --角色一些属性的变化 |
37 | 37 | local function commonAttr(_Buff, attrName) |
38 | - _Buff._init = function(self, data) --初始化变化值 | |
38 | + _Buff._init = function(self) --初始化变化值 | |
39 | 39 | self.owner:reSetAttr(attrName) |
40 | 40 | end |
41 | 41 | _Buff._effectValue = function(self) |
... | ... | @@ -55,38 +55,19 @@ local function commonAttr(_Buff, attrName) |
55 | 55 | end |
56 | 56 | end |
57 | 57 | local function commonAttCond(_Buff, attrName) |
58 | - _Buff._init = function(self, data) --初始化变化值 | |
59 | - self._changeV = self:_calculate() | |
60 | - self:_reSetAttr(true) | |
58 | + _Buff._init = function(self) --初始化变化值 | |
59 | + self:_reSetAttr() | |
61 | 60 | end |
62 | 61 | _Buff._overlay = function(self) |
63 | - self._changeV = (self._changeV or 0) + self:_calculate() | |
64 | - self:_reSetAttr(true) | |
62 | + self:_reSetAttr() | |
65 | 63 | end |
66 | 64 | _Buff._uncover = function(self) |
67 | - self._changeV = self._changeV - self._changeV / (self.layer + 1) | |
68 | 65 | self:_reSetAttr() |
69 | 66 | end |
70 | 67 | |
71 | - _Buff._hpChange = function(self) | |
72 | - local oldHpMax = self.owner.hpMax | |
73 | - self.owner:reSetHpMax() | |
74 | - | |
75 | - local curValue = self.owner.hpMax - oldHpMax | |
76 | - if curValue > 0 then | |
77 | - self.owner:recover(curValue, self.release) -- 防止release不存在,地图点buff | |
78 | - elseif curValue < 0 then | |
79 | - self.owner:hurt(self.release and self.release:getHurtValue(-curValue) or -curValue, self.release, {hurtType = 2, buffId = self.id}) | |
80 | - end | |
81 | - end | |
82 | - | |
83 | - _Buff._reSetAttr = function(self, isInit) | |
68 | + _Buff._reSetAttr = function(self) | |
84 | 69 | if attrName == "hp" then |
85 | - if isInit then | |
86 | - self:_hpChange() | |
87 | - else | |
88 | - self.owner:reSetHpMax() | |
89 | - end | |
70 | + self.owner:reSetHpMax() | |
90 | 71 | else |
91 | 72 | self.owner:reSetAttr(attrName) |
92 | 73 | end |
... | ... | @@ -95,27 +76,37 @@ local function commonAttCond(_Buff, attrName) |
95 | 76 | _Buff._calculate = function(self) |
96 | 77 | local effectCount = 0 |
97 | 78 | if self.buffData.effectValue4 == 0 then |
98 | - effectCount = self.owner.battle.adv.owner:getProperty("advItems"):getv(ItemId.OldCoin, 0) | |
79 | + effectCount = self.owner.battle.adv.owner:getProperty("advItems"):getv(ItemId.OldCoin, 0) / tonumber(self.buffData.effectValue5) | |
80 | + elseif self.buffData.effectValue4 == 1 then | |
81 | + effectCount = self.owner.battle.adv.level | |
82 | + elseif self.buffData.effectValue4 == 2 then | |
83 | + local buff = self.owner.battle.player:getBuffById(tonumber(self.buffData.effectValue5)) | |
84 | + effectCount = buff.layer | |
99 | 85 | end |
100 | - return self.buffData.effectValue2 * effectCount / tonumber(self.buffData.effectValue5) | |
86 | + return self.buffData.effectValue2 * effectCount | |
101 | 87 | end |
102 | - _Buff._initDB = function(self, data) | |
103 | - self._changeV = data.cv | |
88 | + | |
89 | + _Buff.getEffectBy = function(self) | |
90 | + local cond = nil | |
91 | + if self.buffData.effectValue4 == 2 then | |
92 | + cond = tonumber(self.buffData.effectValue5) | |
93 | + end | |
94 | + return self.buffData.effectValue4, attrName, cond | |
104 | 95 | end |
96 | + | |
105 | 97 | _Buff._effectValue = function(self) |
106 | - return self.buffData.effectValue1, self._changeV, attrName | |
98 | + print(self:_calculate() * self.layer) | |
99 | + return self.buffData.effectValue1, self:_calculate() * self.layer, attrName | |
107 | 100 | end |
101 | + | |
108 | 102 | _Buff._endBuff = function(self, data) |
109 | 103 | self:_reSetAttr() |
110 | 104 | end |
111 | - _Buff._getDB = function(self) | |
112 | - return {cv = self._changeV} | |
113 | - end | |
114 | 105 | end |
115 | 106 | |
116 | 107 | local BuffFactory = { |
117 | 108 | [Buff.HP_CHANGE] = function(_Buff) |
118 | - _Buff._init = function(self, data) --初始化变化值 | |
109 | + _Buff._init = function(self) --初始化变化值 | |
119 | 110 | self._changeV = self:_calculate() |
120 | 111 | end |
121 | 112 | _Buff._overlay = function(self) |
... | ... | @@ -161,13 +152,13 @@ local BuffFactory = { |
161 | 152 | end, |
162 | 153 | |
163 | 154 | [Buff.HP_MAX_CHANGE] = function(_Buff) |
164 | - _Buff._init = function(self, data) --初始化变化值 | |
155 | + _Buff._init = function(self) --初始化变化值 | |
165 | 156 | self._changeV = self:_calculate() |
166 | - self:_hpChange() | |
157 | + self.owner:reSetHpMax() | |
167 | 158 | end |
168 | 159 | _Buff._overlay = function(self) |
169 | 160 | self._changeV = (self._changeV or 0) + self:_calculate() |
170 | - self:_hpChange() | |
161 | + self.owner:reSetHpMax() | |
171 | 162 | end |
172 | 163 | |
173 | 164 | _Buff._uncover = function(self) |
... | ... | @@ -175,19 +166,6 @@ local BuffFactory = { |
175 | 166 | self.owner:reSetHpMax() |
176 | 167 | end |
177 | 168 | |
178 | - -- 提高生命上限的时候要相应提高生命值 | |
179 | - _Buff._hpChange = function(self) | |
180 | - local oldHpMax = self.owner.hpMax | |
181 | - self.owner:reSetHpMax() | |
182 | - | |
183 | - local curValue = self.owner.hpMax - oldHpMax | |
184 | - if curValue > 0 then | |
185 | - self.owner:recover(curValue, self.release) -- 防止release不存在,地图点buff | |
186 | - elseif curValue < 0 then | |
187 | - self.owner:hurt(self.release and self.release:getHurtValue(-curValue) or -curValue, self.release, {hurtType = 2, buffId = self.id}) | |
188 | - end | |
189 | - end | |
190 | - | |
191 | 169 | _Buff._calculate = function(self) |
192 | 170 | local curValue = 0 |
193 | 171 | if self.buffData.effectValue1 == 0 then --固定值 |
... | ... | @@ -258,7 +236,7 @@ local BuffFactory = { |
258 | 236 | end, |
259 | 237 | |
260 | 238 | [Buff.CLEAR_BUFF] = function(_Buff) |
261 | - _Buff._init = function(self, data) | |
239 | + _Buff._init = function(self) | |
262 | 240 | for _, buff in ipairs(self.owner.buffs) do -- 挂上就清除一下子 |
263 | 241 | if not buff.isDel and self:canEffect(buff.id) and not self.isDel then |
264 | 242 | if not buff.isDel and not self.isDel then |
... | ... | @@ -326,7 +304,7 @@ local BuffFactory = { |
326 | 304 | end, |
327 | 305 | |
328 | 306 | [Buff.SP_MAX_CHANGE] = function(_Buff) |
329 | - _Buff._init = function(self, data) --初始化变化值 | |
307 | + _Buff._init = function(self) --初始化变化值 | |
330 | 308 | self:_spChange() |
331 | 309 | end |
332 | 310 | _Buff._overlay = function(self) |
... | ... | @@ -444,8 +422,11 @@ function Buff:initNew(release, data) |
444 | 422 | if self.buffData.effectTime > 0 then |
445 | 423 | self.count = self.buffData.effectTime |
446 | 424 | end |
425 | +end | |
426 | + | |
427 | +function Buff:createAfter() | |
447 | 428 | if self._init then |
448 | - self:_init(data) | |
429 | + self:_init() | |
449 | 430 | end |
450 | 431 | end |
451 | 432 | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -68,9 +68,13 @@ function BaseObject:clearRound() |
68 | 68 | end |
69 | 69 | for i = #self.buffs, 1, -1 do |
70 | 70 | if self.buffs[i].isDel then |
71 | - self.battle.adv:backBuff(self.monsterId, self.buffs[i].id, true) | |
72 | - self.buffs[i]:endBuff() | |
71 | + local buff = self.buffs[i] | |
72 | + self.battle.adv:backBuff(self.monsterId, buff.id, true) | |
73 | 73 | table.remove(self.buffs, i) |
74 | + buff:endBuff() | |
75 | + if self.attrChangeCondBuffCheck then | |
76 | + self:attrChangeCondBuffCheck(2, buff.id) | |
77 | + end | |
74 | 78 | end |
75 | 79 | end |
76 | 80 | end |
... | ... | @@ -142,7 +146,9 @@ function BaseObject:addBuff(buffId, releaser) |
142 | 146 | buffData = buffData, |
143 | 147 | releaseId = releaser and releaser.monsterId or nil |
144 | 148 | }) then return end |
145 | - table.insert(self.buffs, Buff.create(self, releaser, {id = buffId})) | |
149 | + local buff = Buff.create(self, releaser, {id = buffId}) | |
150 | + table.insert(self.buffs, buff) | |
151 | + buff:createAfter() | |
146 | 152 | end |
147 | 153 | self:triggerPassive(Passive.GET_BUFF, {buffId = buffId}) |
148 | 154 | self.battle.adv:backBuff(self.monsterId, buffId) |
... | ... | @@ -160,8 +166,11 @@ function BaseObject:delBuffById(bId) |
160 | 166 | for idx, buff in ipairs(self.buffs) do |
161 | 167 | if buff.id == bId then |
162 | 168 | self.battle.adv:backBuff(self.monsterId, buff.id, true) |
163 | - buff:endBuff() | |
164 | 169 | table.remove(self.buffs, idx) |
170 | + buff:endBuff() | |
171 | + if self.attrChangeCondBuffCheck then | |
172 | + self:attrChangeCondBuffCheck(2, bId) | |
173 | + end | |
165 | 174 | return buff |
166 | 175 | end |
167 | 176 | end |
... | ... | @@ -639,9 +648,31 @@ end |
639 | 648 | |
640 | 649 | function Player:addBuff(buffId, releaser) |
641 | 650 | Player.super.addBuff(self, buffId, releaser) |
651 | + self.battle.player:attrChangeCondBuffCheck(2, buffId) | |
642 | 652 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) |
643 | 653 | end |
644 | 654 | |
655 | +function Player:attrChangeCondBuffCheck(etype, cond) | |
656 | + local effect = {} | |
657 | + for _, buff in ipairs(self.buffs) do | |
658 | + if not buff.isDel and (buff:getType() == Buff.ATTR_CHANGE_COND) then | |
659 | + local _et, _attr, _co = buff:getEffectBy() | |
660 | + if etype == _et and (not _co or _co == cond) then | |
661 | + effect[_attr] = 1 | |
662 | + end | |
663 | + | |
664 | + end | |
665 | + end | |
666 | + dump(effect) | |
667 | + for attrName, _ in pairs(effect) do | |
668 | + if attrName == "hp" then | |
669 | + self:reSetHpMax() | |
670 | + else | |
671 | + self:reSetAttr(attrName) | |
672 | + end | |
673 | + end | |
674 | +end | |
675 | + | |
645 | 676 | function Player:getDB() |
646 | 677 | local db = Player.super.getDB(self) |
647 | 678 | for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do | ... | ... |