46fac6f1
zhouahaihai
酱料
|
1
2
3
4
5
|
local Buff = class("Buff")
Buff.HP_CHANGE = 1 --生命变化(每回合生效)
Buff.HP_MAX_CHANGE = 2 --生命上限变化(状态)
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
6
|
Buff.ATTR_CHANGE = 3 --属性变化(状态)
|
46fac6f1
zhouahaihai
酱料
|
7
8
9
10
11
12
13
14
15
16
17
|
Buff.IMMNUE_ATK = 4 -- 免疫普通攻击
Buff.BACK_HURT = 5 -- 伤害反弹
Buff.HURT_CHANGE = 6 -- 伤害变化
Buff.INJURED_CHANGE = 7 -- 受伤变化
Buff.HURT_TRANSFER = 8 -- 侍宠(转移自己受到的伤害)
Buff.HURT_ABSORB = 9 -- 舍身(吸收他人受到的伤害)
Buff.CANT_BACK_ATK = 10 -- 无法反击
Buff.IMMNUE_BUFF = 11 -- 免疫buff
Buff.CLEAR_BUFF = 12 -- 清除buff
Buff.CANT_SKILL = 13 -- 禁止技能
Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合)
|
040c6558
suhongyang
体力改为mp
|
18
|
Buff.POWER_CHANGE = 15 -- MP变化(每回合)
|
6cd12079
suhongyang
扣血buff立刻生效
|
19
|
Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
|
46fac6f1
zhouahaihai
酱料
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
--角色一些属性的变化
local function commonAttr(_Buff, attrName)
_Buff._init = function(self, data) --初始化变化值
self.owner:reSetAttr(attrName)
end
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
_Buff._endBuff = function(self, data)
self.owner:reSetAttr(attrName)
end
end
local BuffFactory = {
[Buff.HP_CHANGE] = function(_Buff)
_Buff._init = function(self, data) --初始化变化值
self._changeV = 0
if self.buffData.effectValue1 == 0 then --固定值
self._changeV = self.buffData.effectValue2
elseif self.buffData.effectValue1 == 1 then
local baseOwner = self.buffData.effectValue4 == 1 and self.owner or self.release
local attrs = {[0] = "hp", [1] = "hpMax", [2] = "atk"}
|
4ae223df
zhouahaihai
Buff bug
|
43
|
self._changeV = baseOwner[attrs[self.buffData.effectValue3]] * self.buffData.effectValue2 / 100
|
46fac6f1
zhouahaihai
酱料
|
44
45
|
end
if self._changeV < 0 then
|
c047749a
zhouhaihai
buff
|
46
47
48
|
if self.release then
self._changeV = -self.release:getHurtValue(-self._changeV)
end
|
46fac6f1
zhouahaihai
酱料
|
49
50
51
52
53
|
end
end
_Buff._initDB = function(self, data)
self._changeV = data.cv
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
54
55
56
57
58
59
|
_Buff._afterRound = function(self)
local value = self:effect()
if value > 0 then
self.owner:recover(value, self.release)
elseif value < 0 then
self.owner:hurt(-value, self.release, {hurtType = 2})
|
46fac6f1
zhouahaihai
酱料
|
60
61
|
end
end
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
62
63
64
65
66
67
68
69
|
_Buff._afterTurn = function(self)
local value = self:effect()
if value > 0 then
self.owner:recover(value, self.release)
elseif value < 0 then
self.owner:hurt(-value, self.release, {hurtType = 2})
end
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
70
71
72
|
_Buff._effectValue = function(self)
return self._changeV
end
|
46fac6f1
zhouahaihai
酱料
|
73
74
75
76
77
78
79
80
81
82
83
84
85
|
_Buff._getDB = function(self)
return {cv = self._changeV}
end
end,
[Buff.HP_MAX_CHANGE] = function(_Buff)
_Buff._init = function(self, data) --初始化变化值
self._changeV = 0
if self.buffData.effectValue1 == 0 then --固定值
self._changeV = self.buffData.effectValue2
elseif self.buffData.effectValue1 == 1 then
local baseOwner = self.buffData.effectValue4 == 1 and self.owner or self.release
local attrs = {[0] = "hp", [1] = "hpMax", [2] = "atk"}
|
4ae223df
zhouahaihai
Buff bug
|
86
|
self._changeV = baseOwner[attrs[self.buffData.effectValue3]] * self.buffData.effectValue2 / 100
|
46fac6f1
zhouahaihai
酱料
|
87
88
89
90
91
|
end
local old = self.owner.hpMax
self.owner.hpMax = math.max(1, self.owner.hpMax + self._changeV)
self._changeV = self.owner.hpMax - old
if self._changeV > 0 then
|
6d238bc6
suhongyang
Fix bug
|
92
|
self.owner:recover(self._changeV, self.release) -- 防止release不存在,地图点buff
|
46fac6f1
zhouahaihai
酱料
|
93
|
elseif self._changeV < 0 then
|
c047749a
zhouhaihai
buff
|
94
|
self.owner:hurt(self.release and self.release:getHurtValue(-self._changeV) or -self._changeV, self.release, {hurtType = 2})
|
46fac6f1
zhouahaihai
酱料
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
self.owner.hp = math.min(self.owner.hpMax, self.owner.hp)
end
end
_Buff._initDB = function(self, data)
self._changeV = data.cv
end
_Buff._endBuff = function(self, data)
if self._changeV then
self.owner.hpMax = math.max(1, self.owner.hpMax - self._changeV)
self.owner.hp = math.min(self.owner.hpMax, self.owner.hp)
end
end
_Buff._getDB = function(self)
return {cv = self._changeV}
end
end,
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
111
|
[Buff.ATTR_CHANGE] = function(_Buff)
|
d78bc768
suhongyang
Fix bug
|
112
|
local attrName = AttsEnumEx[_Buff.buffData.effectValue3]
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
113
|
commonAttr(_Buff, attrName)
|
46fac6f1
zhouahaihai
酱料
|
114
|
end,
|
46fac6f1
zhouahaihai
酱料
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
[Buff.BACK_HURT] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2, self.buffData.effectValue3
end
end,
[Buff.HURT_CHANGE] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.INJURED_CHANGE] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.HURT_TRANSFER] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.HURT_ABSORB] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.IMMNUE_BUFF] = function(_Buff)
_Buff._init = function(self, data)
self.count = self.buffData.effectValue3
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
149
150
151
152
153
|
_Buff._canEffect = function(self, buffId, buffGroup)
local cType, aim = self.buffData.effectValue1, self.buffData.effectValue2
if (cType == 0 and buffId == aim) or (cType == 1 and buffGroup == aim) then
return true
end
|
46fac6f1
zhouahaihai
酱料
|
154
155
156
157
158
159
|
end
end,
[Buff.CLEAR_BUFF] = function(_Buff)
_Buff._init = function(self, data)
self.count = self.buffData.effectValue3
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
160
|
for _, buff in ipairs(self.buffs) do -- 挂上就清除一下子
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
161
|
if not buff.isDel and self:canEffect(buff.id, buff:getGroup()) then
|
46fac6f1
zhouahaihai
酱料
|
162
|
buff.isDel = true
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
163
|
self:effect()
|
46fac6f1
zhouahaihai
酱料
|
164
|
end
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
165
|
end
|
46fac6f1
zhouahaihai
酱料
|
166
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
167
168
169
170
171
|
_Buff._canEffect = function(self, buffId, buffGroup)
local cType, aim = self.buffData.effectValue1, self.buffData.effectValue2
if (cType == 0 and buffId == aim) or (cType == 1 and buffGroup == aim) then
return true
end
|
46fac6f1
zhouahaihai
酱料
|
172
173
174
175
|
end
end,
[Buff.OPEN_BLOCK] = function(_Buff)
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
176
177
178
179
|
_Buff._afterRound = function(self)
local roomNum = self:effect()
self.owner.battle.adv:openBlockRand(roomNum)
end
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
180
181
182
183
|
_Buff._afterTurn = function(self)
local roomNum = self:effect()
self.owner.battle.adv:openBlockRand(roomNum)
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
184
185
|
_Buff._effectValue = function(self)
return self.buffData.effectValue1
|
46fac6f1
zhouahaihai
酱料
|
186
187
188
189
|
end
end,
[Buff.POWER_CHANGE] = function(_Buff)
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
190
191
192
|
--cType 0 or nil 值 1 百分比
_Buff._afterRound = function(self)
local value, cType = self:effect()
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
193
194
195
196
|
self.owner.battle.adv:changePower(value, cType)
end
_Buff._afterTurn = function(self)
local value, cType = self:effect()
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
197
198
199
|
self.owner.battle.adv:changePower(value, cType)
end
_Buff._effectValue = function(self)
|
f616aa94
suhongyang
Fix bug
|
200
|
return self.buffData.effectValue2, self.buffData.effectValue1
|
46fac6f1
zhouahaihai
酱料
|
201
|
end
|
6cd12079
suhongyang
扣血buff立刻生效
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
end,
[Buff.HP_CHANGE_NOW] = function(_Buff)
_Buff._init = function(self, data) --初始化变化值
self._changeV = 0
if self.buffData.effectValue1 == 0 then --固定值
self._changeV = self.buffData.effectValue2
elseif self.buffData.effectValue1 == 1 then
local baseOwner = self.buffData.effectValue4 == 1 and self.owner or self.release
local attrs = {[0] = "hp", [1] = "hpMax", [2] = "atk"}
self._changeV = baseOwner[attrs[self.buffData.effectValue3]] * self.buffData.effectValue2 / 100
end
if self._changeV < 0 then
self._changeV = -self.release:getHurtValue(-self._changeV)
end
self:afterTurn()
end
_Buff._initDB = function(self, data)
self._changeV = data.cv
end
_Buff._afterRound = function(self)
local value = self:effect()
if value > 0 then
self.owner:recover(value, self.release)
elseif value < 0 then
self.owner:hurt(-value, self.release, {hurtType = 2})
end
end
_Buff._afterTurn = function(self)
local value = self:effect()
if value > 0 then
self.owner:recover(value, self.release)
elseif value < 0 then
self.owner:hurt(-value, self.release, {hurtType = 2})
end
end
_Buff._effectValue = function(self)
return self._changeV
end
_Buff._getDB = function(self)
return {cv = self._changeV}
end
end,
|
46fac6f1
zhouahaihai
酱料
|
244
245
|
}
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
246
247
248
249
250
|
function Buff:ctor(owner, id)
self.owner = owner
self.id = id
self.buffData = csvdb["adv_buffCsv"][self.id]
self.isDel = false
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
251
252
253
254
255
256
257
258
259
260
|
self.roundSpace = 0 --生效间隔
self.turnSpace = 0 --生效间隔
self.round = 0 --剩余的回合
self.turn = 0 --剩余战斗内回合
self.count = -1 -- 可生效的次数 -1 无次数限制
if BuffFactory[self.buffData.type] then
BuffFactory[self.buffData.type](self)
end
end
|
46fac6f1
zhouahaihai
酱料
|
261
262
263
264
265
266
267
268
269
270
271
272
273
|
function Buff.create(owner, release, data)
local buff = Buff.new(owner, data.id)
buff:initNew(release, data)
return buff
end
function Buff.load(owner, data)
local buff = Buff.new(owner, data.id)
buff:initByDB(data)
return buff
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
274
|
function Buff:initNew(release, data)
|
6d238bc6
suhongyang
Fix bug
|
275
|
self.release = release or self.owner
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
276
277
278
279
280
281
282
|
self.round = self.buffData.round
self.turn = self.buffData.turn
if self.buffData.effectTime > 0 then
self.count = self.buffData.effectTime
end
if self._init then
self:_init(data)
|
46fac6f1
zhouahaihai
酱料
|
283
284
285
286
287
288
289
290
291
292
293
|
end
end
function Buff:initByDB(data)
if data.rele then
if data.rele == 0 then
self.release = self.owner.battle.player
else
self.release = self.owner.battle:getEnemyById(data.rele)
end
end
|
821f2b60
suhongyang
冒险战斗完善,增加battlebe...
|
294
|
self.round = data.round
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
295
|
self.roundSpace = data.roundSp -- 可以优化为0的时候不记录
|
46fac6f1
zhouahaihai
酱料
|
296
297
298
299
300
301
302
303
304
|
if data.count then
self.count = data.count
end
if self._initDB then
self:_initDB(data)
end
end
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
305
306
307
308
|
function Buff:battleEnd()
if self.buffData.turn ~= 0 then
self.isDel = true -- turn类型buff战斗结束后移除
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
309
310
311
|
end
function Buff:beforeTurn()
|
5b3f595a
suhongyang
区分round型和turn型buff
|
312
|
if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
313
314
315
316
317
318
319
320
321
|
if self.turnSpace > 0 then
return
end
if self._beforeTurn then
self:_beforeTurn()
end
end
function Buff:afterTurn()
|
5b3f595a
suhongyang
区分round型和turn型buff
|
322
|
if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
if self.turnSpace > 0 then
self.turnSpace = self.turnSpace - 1
self:decTurn()
return
end
if self._afterTurn then
self:_afterTurn()
end
if self.buffData.turnTime > 0 then
self.turnSpace = self.buffData.turnTime
end
self:decTurn()
end
function Buff:decTurn()
if self.buffData.turn == 0 then
return
end
self.turn = self.turn - 1
if self.turn <= 0 then
self.isDel = true
|
46fac6f1
zhouahaihai
酱料
|
344
345
346
347
|
end
end
function Buff:afterRound()
|
5b3f595a
suhongyang
区分round型和turn型buff
|
348
|
if self.isDel or self.owner.isDead or self.buffData.round == 0 then return end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
349
|
if self.roundSpace > 0 then
|
8d8bf91a
suhongyang
fix bug
|
350
|
self.roundSpace = self.roundSpace - 1
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
351
352
353
354
355
356
|
self:decRound()
return
end
if self._afterRound then
self:_afterRound()
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
357
|
if self.buffData.roundTime > 0 then
|
8d8bf91a
suhongyang
fix bug
|
358
|
self.roundSpace = self.buffData.roundTime
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
359
360
361
|
end
self:decRound()
end
|
46fac6f1
zhouahaihai
酱料
|
362
|
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
363
364
365
366
367
368
369
370
371
372
373
374
375
|
function Buff:decRound()
if self.buffData.round == 0 then
return
end
self.round = self.round - 1
if self.round <= 0 then
self.isDel = true
end
end
function Buff:canEffect(...)
if not self._canEffect then
return true
|
46fac6f1
zhouahaihai
酱料
|
376
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
377
|
return self:_canEffect(...)
|
46fac6f1
zhouahaihai
酱料
|
378
379
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
380
|
function Buff:effect()
|
3c89adfb
zhouhaihai
buff 减次数
|
381
|
self:decCount()
|
46fac6f1
zhouahaihai
酱料
|
382
383
384
|
if self._effectValue then
return self:_effectValue()
end
|
46fac6f1
zhouahaihai
酱料
|
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
end
--删除buff 时调用
function Buff:endBuff()
if self._endBuff then
self:_endBuff()
end
end
function Buff:getType()
return self.buffData.type
end
function Buff:decCount()
if self.count == -1 then return end
self.count = self.count - 1
if self.count <= 0 then
self.isDel = true
end
end
function Buff:getGroup()
return self.buffData.group
end
function Buff:getDB()
local db = {}
if self._getDB then
db = self:_getDB()
end
db.id = self.id
if self.release and not self.release.isDead then
db.rele = self.release.id or 0 --释放者的id (0 为玩家) (不存在 则释放者不存在或者已经死亡)
end
|
821f2b60
suhongyang
冒险战斗完善,增加battlebe...
|
418
419
|
if self.buffData.round ~= 0 then
db.round = self.round
|
46fac6f1
zhouahaihai
酱料
|
420
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
421
|
db.roundSp = self.roundSpace
|
46fac6f1
zhouahaihai
酱料
|
422
423
424
425
426
427
428
|
if self.count ~= -1 then
db.count = self.count
end
return db
end
return Buff
|