c8ade4f6
suhongyang
被动筛选逻辑
|
1
2
3
|
local Filter = class("Filter")
Filter.HP_UP_WITH_EQUAL = 1 -- 血量>=value%
|
1cb78a24
suhongyang
passive的筛选
|
4
5
6
7
8
|
Filter.HP_UP = 2 -- 血量>value%
Filter.HP_LOW_WITH_EQUAL = 3 -- 血量<=value%
Filter.HP_LOW = 4 -- 血量<value%
Filter.BUFF_BY_TYPE = 5 -- 指定类型buff
Filter.BUFF_BY_ID = 6 -- 指定id的buff
|
c8ade4f6
suhongyang
被动筛选逻辑
|
9
10
11
12
13
14
15
|
local FilterFactory = {}
FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter)
_Filter._execute = function (self, target)
return target.hp >= self.value * target.hpMax / 100
end
end
|
1cb78a24
suhongyang
passive的筛选
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
FilterFactory[Filter.HP_UP] = function (_Filter)
_Filter._execute = function (self, target)
return target.hp > self.value * target.hpMax / 100
end
end
FilterFactory[Filter.HP_LOW_WITH_EQUAL] = function (_Filter)
_Filter._execute = function (self, target)
return target.hp <= self.value * target.hpMax / 100
end
end
FilterFactory[Filter.HP_LOW] = function (_Filter)
_Filter._execute = function (self, target)
return target.hp < self.value * target.hpMax / 100
end
end
FilterFactory[Filter.BUFF_BY_TYPE] = function (_Filter)
_Filter._execute = function (self, target)
return target:hadBuff(self.value)
end
end
FilterFactory[Filter.BUFF_BY_ID] = function (_Filter)
_Filter._execute = function (self, target)
return target:hadBuffById(self.value)
end
end
|
c8ade4f6
suhongyang
被动筛选逻辑
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
function Filter:ctor(params)
self.owner = params.owner
self.skill = params.skill
self.fType = params.fType -- 筛选类型
self.oType = params.oType -- 主体类型 0:owner 1:trigger 2:releaser
self.value = params.value -- 筛选值
if FilterFactory[self.fType] then
FilterFactory[self.fType](self)
end
end
function Filter:getTarget(params)
local target
if self.oType == 0 then
target = self.owner
end
if self.oType == 1 and params.trigger then
target = params.trigger
end
if self.oType == 2 and params.releaser then
target = params.releaser
end
return target
end
function Filter:execute(params)
local target = self:getTarget(params)
if not target then
return
end
if self:_execute(target) then
return self:_execute(target)
end
end
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
46fac6f1
zhouahaihai
酱料
|
79
80
81
82
83
|
local Passive = class("Passive")
-- 每回合触发的使用 afterRound
-- 其他触发的使用 triggerPassive
|
02c4de8d
zhouahaihai
增加 固有技
|
84
85
|
Passive.BORN_ONCE = 1 -- 自身出生(翻开所在格子)触发
Passive.ROOM_SHOW = 2 --自身所在房间被展示时,触发1次
|
46fac6f1
zhouahaihai
酱料
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
Passive.HURT_PERCENT_SELF = 3 --自身,每损失N%生命值,触发1次
Passive.HURT_PERCENT_TEAM = 4 --队友,每损失N%生命值,触发1次
Passive.HP_LOW_SELF = 5 --自身生命值<N%时,每回合触发
Passive.HP_LOW_TEAM = 6 --敌人生命值<N%时,每回合触发
Passive.HP_UP_SELF = 7 --自身生命值>N%时,每回合触发
Passive.HP_UP_TEAM = 8 --敌人生命值>N%时,每回合触发
Passive.SELF_ATK = 9 --自身攻击N次后,触发1次
Passive.SELF_HURT = 10 --自身受击N次后,触发1次
Passive.TEAM_ATK = 11 --队友攻击N次后,触发1次
Passive.TEAM_HURT = 12 --队友受击N次后,触发1次
Passive.MONSTER_COUNT_UP = 13 --场上存在N个以上怪物,每回合触发
Passive.MONSTER_COUNT_LOW = 14 --场上存在N个以下怪物,每回合触发
Passive.SELF_DEAD = 15 --自身死亡后,触发1次
Passive.TEAM_DEAD = 16 --队友死亡后,触发1次
Passive.TARGET_SKILL = 17 --目标每使用N次技能,触发1次
Passive.TEAM_SKILL = 18 --队友每使用N次技能,触发1次
|
02c4de8d
zhouahaihai
增加 固有技
|
102
|
|
46fac6f1
zhouahaihai
酱料
|
103
104
|
-- 不同的开启条件
|
02c4de8d
zhouahaihai
增加 固有技
|
105
106
107
108
109
110
111
112
113
114
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
local PassiveCondFactory = {}
PassiveCondFactory[Passive.HURT_PERCENT_SELF] = function(_Passive)
_Passive._trigger = function(self, params)
local value = params.value or 1
self.rv = math.floor(self.rv + value)
if self.rv >= self.passiveData.value then
self.rv = self.rv % self.passiveData.value -- 取余
return true
end
end
_Passive._initDB = function(self, data)
self.rv = data.rv or 0
end
_Passive._getDB = function(self)
return {rv = self.rv}
end
end
PassiveCondFactory[Passive.HURT_PERCENT_TEAM] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.SELF_ATK] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.SELF_HURT] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.TEAM_ATK] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.TEAM_HURT] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.TARGET_SKILL] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.TEAM_SKILL] = PassiveCondFactory[Passive.HURT_PERCENT_SELF] --逻辑相同
PassiveCondFactory[Passive.ROOM_SHOW] = function(_Passive)
_Passive._trigger = function(self, params)
local roomId = params.roomId
if self.roomId == roomId then
return true
end
end
end
PassiveCondFactory[Passive.HP_LOW_SELF] = function(_Passive)
_Passive._afterRound = function(self)
if self.owner.hp / self.owner.hpMax * 100 < self.passiveData.value then
self:trigger(Passive.HP_LOW_SELF)
end
end
end
PassiveCondFactory[Passive.HP_LOW_TEAM] = function(_Passive)
_Passive._afterRound = function(self)
for _, player in ipairs(self.owner:getTeam(2)) do
if player.hp / player.hpMax * 100 < self.passiveData.value then
self:trigger(Passive.HP_LOW_TEAM, {trigger = player})
end
end
end
end
PassiveCondFactory[Passive.HP_UP_SELF] = function(_Passive)
_Passive._afterRound = function(self)
if self.owner.hp / self.owner.hpMax * 100 > self.passiveData.value then
self:trigger(Passive.HP_UP_SELF)
end
end
end
PassiveCondFactory[Passive.HP_UP_TEAM] = function(_Passive)
_Passive._afterRound = function(self)
for _, player in ipairs(self.owner:getTeam(2)) do
if player.hp / player.hpMax * 100 > self.passiveData.value then
self:trigger(Passive.HP_UP_TEAM, {trigger = player})
end
end
end
end
PassiveCondFactory[Passive.MONSTER_COUNT_UP] = function(_Passive)
_Passive._afterRound = function(self)
local monsters = self.owner.battle.player:getTeam(2)
if #monsters > self.passiveData.value then
self:trigger(Passive.MONSTER_COUNT_UP)
end
end
end
PassiveCondFactory[Passive.MONSTER_COUNT_LOW] = function(_Passive)
_Passive._afterRound = function(self)
local monsters = self.owner.battle.player:getTeam(2)
if #monsters < self.passiveData.value then
self:trigger(Passive.MONSTER_COUNT_LOW)
end
end
end
|
46fac6f1
zhouahaihai
酱料
|
194
195
196
197
198
199
200
201
|
function Passive:ctor(owner, data)
self.owner = owner
self.id = data.id
self.level = data.level or 1
self.passiveData = csvdb["adv_skill_passiveCsv"][self.id][self.level]
self.isDel = false
self.round = data.round or 0 --触发剩余回合数
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
202
203
204
|
self.count = data.count or self.passiveData.count --触发剩余次数
self.delay = data.delay or self.passiveData.delayRound --触发延迟回合数
self.turn = 0 --战斗内回合数
|
39a6e08b
suhongyang
冒险战斗内逻辑调整
|
205
|
self.delayTurn = self.passiveData.delayTurn --战斗内延迟回合数
|
1b0d767f
suhongyang
一個被動支持多種effect
|
206
207
|
self.effects = self.passiveData.effect:toTableArray(true)
|
c8ade4f6
suhongyang
被动筛选逻辑
|
208
|
self.filters = {}
|
821f2b60
suhongyang
冒险战斗完善,增加battlebe...
|
209
210
211
212
|
if self.passiveData.count < 0 then -- count < 0 无限次触发
self.count = 999
end
|
1b0d767f
suhongyang
一個被動支持多種effect
|
213
|
|
02c4de8d
zhouahaihai
增加 固有技
|
214
215
216
|
if PassiveCondFactory[self.passiveData.condition] then
PassiveCondFactory[self.passiveData.condition](self)
end
|
c8ade4f6
suhongyang
被动筛选逻辑
|
217
|
self:initFilter()
|
02c4de8d
zhouahaihai
增加 固有技
|
218
219
|
if self._initDB then
self:_initDB(data)
|
46fac6f1
zhouahaihai
酱料
|
220
221
222
|
end
end
|
c8ade4f6
suhongyang
被动筛选逻辑
|
223
224
225
226
227
228
229
230
|
function Passive:initFilter()
local filterList = self.passiveData.filter:toTableArray(true)
for _, fParams in ipairs(filterList) do
local filter = Filter.new({owner = self.owner, skill = self, oType = fParams[1], fType = fParams[2], value = fParams[3] })
table.insert(self.filters, filter)
end
end
|
46fac6f1
zhouahaihai
酱料
|
231
232
233
234
|
function Passive:getCondType()
return self.passiveData.condition, self.passiveData.value
end
|
c8ade4f6
suhongyang
被动筛选逻辑
|
235
|
-- effect 生效篩選
|
1b0d767f
suhongyang
一個被動支持多種effect
|
236
237
238
239
240
241
242
243
|
function Passive:canEffect(effType, effValue)
if self.owner.lock and effType ~= 3 then -- 锁定的只能触发翻开自己格子的固有技
return
end
return true
end
function Passive:effect(trigger)
|
1b0d767f
suhongyang
一個被動支持多種effect
|
244
245
246
247
248
|
for _, effect in pairs(self.effects) do
local effType = effect[1]
local effValue = effect[2]
if self:canEffect(effType, effValue) then
self["effect" .. effType](self, effValue, trigger)
|
1b0d767f
suhongyang
一個被動支持多種effect
|
249
250
|
end
end
|
35305a02
suhongyang
被动次数是否刷新
|
251
252
253
|
if self.count <= 0 and self.passiveData.refresh == 1 then -- 次数 <= 0 并且一次冒险内不刷新,被动可以直接移除
self.isDel = true
end
|
46fac6f1
zhouahaihai
酱料
|
254
|
if self.count > 0 then
|
821f2b60
suhongyang
冒险战斗完善,增加battlebe...
|
255
|
self.count = self.count < 999 and self.count - 1 or self.count
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
self.round = self.passiveData.round
end
end
function Passive:battleBegin()
if self.isDel or self.owner.isDead then return end
self.turn = 0
self.delayTurn = self.passiveData.delayTurn
end
function Passive:afterTurn()
if self.isDel or self.owner.isDead then return end
if self._afterTurn then
self:_afterTurn() --有的触发自己检测在这里检查
end
if self.turn > 0 then --战斗内回合
self.turn = self.turn - 1
end
if self.delayTurn > 0 then
self.delayTurn = self.delayTurn - 1
|
46fac6f1
zhouahaihai
酱料
|
276
277
278
279
280
281
282
283
284
285
|
end
end
function Passive:afterRound()
if self.isDel or self.owner.isDead then return end
if self._afterRound then
self:_afterRound() --有的触发自己检测在这里检查
end
if self.round > 0 then --回合触发的
self.round = self.round - 1
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
286
287
288
|
end
if self.delay > 0 then
self.delay = self.delay - 1
|
46fac6f1
zhouahaihai
酱料
|
289
290
291
|
end
end
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
292
293
294
|
-- 可以触发
function Passive:canTrigger( )
return self.count > 0 and self.delay <= 0 and self.delayTurn <= 0
|
46fac6f1
zhouahaihai
酱料
|
295
296
297
|
end
function Passive:trigger(condType, params) --触发检查
|
02c4de8d
zhouahaihai
增加 固有技
|
298
299
|
params = params or {}
if self.isDel or self.owner.isDead then return end
|
46fac6f1
zhouahaihai
酱料
|
300
|
if self:getCondType() ~= condType then return end
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
301
|
if not self:canTrigger() then return end
|
36c30c5c
zhouahaihai
冒险
|
302
|
if self._trigger then
|
02c4de8d
zhouahaihai
增加 固有技
|
303
|
if not self:_trigger(params) then return end --检查
|
36c30c5c
zhouahaihai
冒险
|
304
|
end
|
c8ade4f6
suhongyang
被动筛选逻辑
|
305
306
307
308
309
310
|
if not self:filter(params) then
return
end
if math.randomInt(1, 100) > self.passiveData.chance then
return
end
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
311
312
|
if self.round > 0 and self.turn > 0 then -- cd
return
|
46fac6f1
zhouahaihai
酱料
|
313
|
end
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
314
|
self:effect(params.trigger)
|
46fac6f1
zhouahaihai
酱料
|
315
316
|
end
|
c8ade4f6
suhongyang
被动筛选逻辑
|
317
318
319
320
321
322
323
324
325
|
function Passive:filter(params)
for _, filter in ipairs(self.filters) do
if not filter:execute(params) then
return
end
end
return true
end
|
46fac6f1
zhouahaihai
酱料
|
326
327
328
329
330
331
332
333
334
|
function Passive:getDB()
local db = {}
if self._getDB then
db = self:_getDB()
end
db.id = self.id
db.level = self.level
db.round = self.round
db.count = self.count
|
65de8cf1
suhongyang
被动逻辑进一步修缮
|
335
|
db.delay = self.delay
|
36c30c5c
zhouahaihai
冒险
|
336
|
return db
|
46fac6f1
zhouahaihai
酱料
|
337
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
338
339
|
--默认=0=使用技能,
|
1b0d767f
suhongyang
一個被動支持多種effect
|
340
341
|
function Passive:effect0(value)
self.owner:releaseSkill(value)
|
02c4de8d
zhouahaihai
增加 固有技
|
342
343
|
end
--1=自身获得buff
|
1b0d767f
suhongyang
一個被動支持多種effect
|
344
|
function Passive:effect1(value)
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
345
|
self.owner:addBuff(value, self.owner)
|
02c4de8d
zhouahaihai
增加 固有技
|
346
347
|
end
--2=触发目标获得buff
|
1b0d767f
suhongyang
一個被動支持多種effect
|
348
|
function Passive:effect2(value, trigger)
|
02c4de8d
zhouahaihai
增加 固有技
|
349
|
if trigger then
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
350
|
trigger:addBuff(value, self.owner)
|
02c4de8d
zhouahaihai
增加 固有技
|
351
352
|
end
end
|
23a38f47
suhongyang
new passives effect
|
353
|
--3=翻开自己所在格子
|
02c4de8d
zhouahaihai
增加 固有技
|
354
355
356
357
358
359
360
361
|
function Passive:effect3()
self.owner.battle.adv:openBlock(self.owner.roomId, self.owner.blockId)
end
--4=逃跑
function Passive:effect4()
self.owner.isDead = true --跑了
self.owner.battle.adv:enemyDead(self.owner.roomId,self.owner.blockId, true)
end
|
23a38f47
suhongyang
new passives effect
|
362
|
--5=给随机一个敌方增加一个buff
|
1b0d767f
suhongyang
一個被動支持多種effect
|
363
|
function Passive:effect5(value)
|
23a38f47
suhongyang
new passives effect
|
364
365
|
local monsters = self.owner.battle.player:getTeam(2)
local randomId = math.random( 1, #monsters )
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
366
|
monsters[randomId]:addBuff(value, self.owner)
|
23a38f47
suhongyang
new passives effect
|
367
368
|
end
--6=给自己加一個被動技能
|
1b0d767f
suhongyang
一個被動支持多種effect
|
369
370
|
function Passive:effect6(value)
self.owner:addPassive({id = value})
|
23a38f47
suhongyang
new passives effect
|
371
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
372
|
|
46fac6f1
zhouahaihai
酱料
|
373
|
return Passive
|