46fac6f1
 
  zhouahaihai
 
酱料
 | 
1
2 
 | 
  -- 角色
  local Buff = require "adv.AdvBuff"
 
 | 
1b8336a6
 
  suhongyang
 
skill逻辑与player分开
 | 
3 
 | 
  local Skill = require "adv.AdvSkill"
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
4
5
6
7
8
9
10
11 
 | 
  local Passive = require "adv.AdvPassive"
  
  local BaseObject = class("BaseObject")
  function BaseObject:ctor(battle)
  	self.battle = battle
  	self.hpMax = 0
  	self.hp = 0
  	self.atk = 0
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
12 
 | 
  	self.def = 0
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
13
14
15
16 
 | 
  	self.aType = 0 --攻击类型
  	self.lock = nil
  	self.passives = {} --固有技能
  	self.buffs = {} --buff
 
 | 
42f2d1d3
 
  suhongyang
 
战斗内技能序列逻辑
 | 
17 
 | 
  	self.skillOrder = {} --战斗内技能序列
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
18 
 | 
  	self.isDead = false
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
19
20
21
22
23 
 | 
  end
  --初始化角色
  function BaseObject:initData(data)
  	self.hpMax = data.hpMax or data.hp
  	self.hp = data.hp
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
24
25
26
27 
 | 
  	--可变化的值
  	self.atk = data.atk
  	self.miss = data.miss
  	self.hit = data.hit
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
28 
 | 
  	self.def = data.def
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
29
30
31
32 
 | 
  	--基础值记录
  	self._atk = data._atk or self.atk
  	self._miss = data._miss or self.miss
  	self._hit = data._hit or self.hit
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
33 
 | 
  	self._def = data._def or self.def
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
34 
 | 
  	self._hpMax = data._hpMax or self.hpMax
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
35
36
37
38 
 | 
  end
  -- 角色初始化完以后才是 技能和被动技能  方便初始化 buff 的 释放对象
  function BaseObject:initAfter(data)
  	for _, passive in ipairs(data.passives or {}) do
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
39 
 | 
  		table.insert(self.passives, Passive.new(self, passive))
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
40
41
42
43
44
45 
 | 
  	end
  	for _, buff in ipairs(data.buffs or {}) do
  		table.insert(self.buffs, Buff.load(self, buff))
  	end
  end
  
 
 | 
a734980c
 
  suhongyang
 
冒险战斗数据打完以前不存储
 | 
46
47
48
49
50
51
52 
 | 
  function BaseObject:reset(data)
  	self.passives = {}
  	self.buffs = {}
  	self:initData(data)
  	self:initAfter(data)
  end
  
 
 | 
35e2e3c4
 
  zhouhaihai
 
优化 gm advt  增加感知b...
 | 
53
54
55
56
57 
 | 
  function BaseObject:afterRound(roundType)
  	if roundType == "passive" then
  		for _, passive in ipairs(self.passives) do
  			passive:afterRound(self)
  		end
 
 | 
8fc7d1bc
 
  zhouhaihai
 
buff 回合问题
 | 
58 
 | 
  	elseif roundType == "buffBefore" then
 
 | 
35e2e3c4
 
  zhouhaihai
 
优化 gm advt  增加感知b...
 | 
59 
 | 
  		for _, buff in ipairs(self.buffs) do
 
 | 
8fc7d1bc
 
  zhouhaihai
 
buff 回合问题
 | 
60
61
62
63
64
65
66
67
68 
 | 
  			if buff.buffData.intoEffect == 1 then
  				buff:afterRound()
  			end
  		end
  	elseif roundType == "buffAfter" then
  		for _, buff in ipairs(self.buffs) do
  			if buff.buffData.intoEffect == 0 then
  				buff:afterRound()
  			end
 
 | 
35e2e3c4
 
  zhouhaihai
 
优化 gm advt  增加感知b...
 | 
69 
 | 
  		end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
70
71
72 
 | 
  	end
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
73
74
75 
 | 
  function BaseObject:clearRound()
  	for i = #self.passives, 1, -1 do
  		if self.passives[i].isDel then
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
76
77
78
79
80 
 | 
  			table.remove(self.passives, i)
  		end
  	end
  	for i = #self.buffs, 1, -1 do
  		if self.buffs[i].isDel then
 
 | 
b71a8190
 
  zhouhaihai
 
动态改变 一些buff
 | 
81 
 | 
  			local buff = self.buffs[i]
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
82 
 | 
  			table.remove(self.buffs, i)
 
 | 
b71a8190
 
  zhouhaihai
 
动态改变 一些buff
 | 
83
84
85
86 
 | 
  			buff:endBuff()
  			if self.attrChangeCondBuffCheck then
  				self:attrChangeCondBuffCheck(2, buff.id)
  			end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
87
88
89
90
91
92 
 | 
  		end
  	end
  end
  function BaseObject:clear()
  	self.buffs = {}
  	self.passives = {}
 
 | 
4615ea54
 
  zhouhaihai
 
修改调用位置
 | 
93
94
95
96
97
98 
 | 
  	if self:is("Enemy") then
  		self.battle.player:attrChangeCondBuffCheck(3, self:getClassify())
  		for _, monster in pairs(self.battle.player:getTeam(2)) do
  			monster:attrChangeCondBuffCheck(3, self:getClassify())
  		end
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
99
100 
 | 
  end
  
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
101
102 
 | 
  function BaseObject:addPassive(params)
  	local skillId = params.id
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
103 
 | 
  	local skillData = csvdb["adv_map_passiveCsv"][skillId]
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
104
105
106 
 | 
  	if not skillData then return end
  	local level = params.level or 1
  	if not skillData[level] then return end
 
 | 
7b2dc17c
 
  zhouhaihai
 
地图 层 buff passive
 | 
107
108
109 
 | 
  
  	if self:getPassiveById(skillId) then return end -- 被动技不能重复
  
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
110 
 | 
  	table.insert(self.passives, Passive.new(self, { id = skillId, level = level }))
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
111
112 
 | 
  end
  
 
 | 
7b2dc17c
 
  zhouhaihai
 
地图 层 buff passive
 | 
113
114
115
116
117
118
119
120 
 | 
  function BaseObject:getPassiveById(bId)
  	for idx, passive in ipairs(self.passives) do
  		if passive.id == bId then
  			return passive
  		end
  	end
  end
  
 
 | 
4f0a5fae
 
  zhouhaihai
 
营养剂
 | 
121
122
123 
 | 
  function BaseObject:getPassiveIdx(passive)
  	for idx, passive_ in ipairs(self.passives) do
  		if passive_ == passive then
 
 | 
871b3da3
 
  zhouhaihai
 
被动 取消
 | 
124
125
126
127 
 | 
  			if passive.passiveData.dispel ~= 1 then
  				return idx
  			end
  			return
 
 | 
4f0a5fae
 
  zhouhaihai
 
营养剂
 | 
128
129 
 | 
  		end
  	end
 
 | 
871b3da3
 
  zhouhaihai
 
被动 取消
 | 
130 
 | 
  	return
 
 | 
4f0a5fae
 
  zhouhaihai
 
营养剂
 | 
131
132
133 
 | 
  end
  
  function BaseObject:getDisablePassiveCount()
 
 | 
aa74d6ef
 
  zhouhaihai
 
掉落反馈
 | 
134 
 | 
  	local count
 
 | 
4f0a5fae
 
  zhouhaihai
 
营养剂
 | 
135 
 | 
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
136 
 | 
  		if not buff:isHide() and buff:getType() == Buff.DISABLE_BUFF then
 
 | 
aa74d6ef
 
  zhouhaihai
 
掉落反馈
 | 
137
138
139
140 
 | 
  			if buff:effect() == 0 then
  				return 0
  			end
  			count = (count or 0) + buff:effect()
 
 | 
4f0a5fae
 
  zhouhaihai
 
营养剂
 | 
141
142 
 | 
  		end
  	end
 
 | 
aa74d6ef
 
  zhouhaihai
 
掉落反馈
 | 
143 
 | 
  	return count
 
 | 
4f0a5fae
 
  zhouhaihai
 
营养剂
 | 
144
145 
 | 
  end
  
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
146 
 | 
  function BaseObject:getDisableAuraCount()
 
 | 
22288eb6
 
  zhouhaihai
 
bug
 | 
147 
 | 
  	local count = 0
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
148
149
150
151
152
153
154
155
156
157
158 
 | 
  	for _, buff in ipairs(self.buffs) do
  		if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then
  			if buff:effect() == 0 then
  				return 0
  			end
  			count = (count or 0) + buff:effect()
  		end
  	end
  	return count
  end
  
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
159
160 
 | 
  function BaseObject:addBuff(buffId, releaser, layer)
  	layer = layer or 1
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
161 
 | 
  	local buffData = csvdb["adv_map_buffCsv"][buffId]
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
162
163 
 | 
  	if not buffData then return end
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
164 
 | 
  		if not buff:isHide() and (buff:getType() == Buff.CLEAR_BUFF or buff:getType() == Buff.IMMNUE_BUFF) then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
165 
 | 
  			if buff:canEffect(buffId) then
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
166 
 | 
  				buff:effect()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
167
168
169
170 
 | 
  				return
  			end
  		end
  	end
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
171
172
173 
 | 
  	local oldBuff = self:getBuffById(buffId)
  	if oldBuff then
  		if not oldBuff:checkKeep() then return end
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
174 
 | 
  		oldBuff:overlay(releaser, {}, layer) -- 叠加
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
175
176
177
178
179 
 | 
  	else
  		-- 不能保持的buff 也加不上去
  		if not Buff.checkKeep({
  			owner = self,
  			buffData = buffData,
 
 | 
8781e103
 
  zhouhaihai
 
冒险 bug
 | 
180 
 | 
  			releaseId = releaser and releaser.monsterId or nil
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
181 
 | 
  		}) then return end
 
 | 
b71a8190
 
  zhouhaihai
 
动态改变 一些buff
 | 
182
183 
 | 
  		local buff = Buff.create(self, releaser, {id = buffId})
  		table.insert(self.buffs, buff)
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
184 
 | 
  		buff:createAfter(layer)
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
185 
 | 
  	end
 
 | 
04b84e1e
 
  zhouhaihai
 
被动
 | 
186
187 
 | 
  	self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId})
  	self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify})
 
 | 
1e789624
 
  zhouhaihai
 
新的 buff 效果
 | 
188 
 | 
  	self:attrChangeCondBuffCheck(2, buffId)
 
 | 
c5d9338f
 
  zhouhaihai
 
通用方法 异常
 | 
189 
 | 
  	return true
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
190
191 
 | 
  end
  
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
192
193 
 | 
  function BaseObject:getBuffById(bId)
  	for idx, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
194 
 | 
  		if buff.id == bId and not buff:isHide() then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
195
196
197
198
199 
 | 
  			return buff
  		end
  	end
  end
  
 
 | 
916096ed
 
  zhouhaihai
 
神器效果
 | 
200 
 | 
  function BaseObject:delBuffById(bId)
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
201
202 
 | 
  	for idx, buff in ipairs(self.buffs) do
  		if buff.id == bId then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
203 
 | 
  			table.remove(self.buffs, idx)
 
 | 
b71a8190
 
  zhouhaihai
 
动态改变 一些buff
 | 
204
205
206
207 
 | 
  			buff:endBuff()
  			if self.attrChangeCondBuffCheck then
  				self:attrChangeCondBuffCheck(2, bId)
  			end
 
 | 
916096ed
 
  zhouhaihai
 
神器效果
 | 
208
209
210
211
212
213 
 | 
  			return buff
  		end
  	end
  end
  
  function BaseObject:delPassiveById(pId)
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
214
215 
 | 
  	for idx, passive in ipairs(self.passives) do
  		if passive.id == pId then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
216 
 | 
  			table.remove(self.passives, idx)
 
 | 
916096ed
 
  zhouhaihai
 
神器效果
 | 
217
218
219
220
221 
 | 
  			return passive
  		end
  	end
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
222
223 
 | 
  function BaseObject:hadBuff(bType)
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
224 
 | 
  		if not buff:isHide() and buff:getType() == bType then
 
 | 
7828ffd0
 
  zhouhaihai
 
冒险 连续选择点 和 地图因子
 | 
225 
 | 
  			return buff
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
226
227
228
229 
 | 
  		end
  	end
  end
  
 
 | 
1cb78a24
 
  suhongyang
 
passive的筛选
 | 
230
231 
 | 
  function BaseObject:hadBuffById(bId)
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
232 
 | 
  		if not buff:isHide() and buff.id == bId then
 
 | 
7828ffd0
 
  zhouhaihai
 
冒险 连续选择点 和 地图因子
 | 
233 
 | 
  			return buff
 
 | 
1cb78a24
 
  suhongyang
 
passive的筛选
 | 
234
235
236
237 
 | 
  		end
  	end
  end
  
 
 | 
84c2734c
 
  zhouhaihai
 
怪物增加 spset
 | 
238
239
240 
 | 
  function BaseObject:reSetSpMax()
  end
  
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
241
242
243
244 
 | 
  function BaseObject:checkAuraBuff(buffs)
  end
  
  function BaseObject:getAuras()
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
245 
 | 
  	local disable = self:getDisableAuraCount()
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
246 
 | 
  	local auras = {}
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
247
248
249
250
251
252
253 
 | 
  	local function addAura(one)
  		if disable > 0 then
  			disable = disable - 1
  		else
  			table.insert(auras, one)
  		end
  	end
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
254
255
256
257 
 | 
  	if self:is("Enemy") then
  		local halo = csvdb["event_monsterCsv"][self.monsterId].halo
  		if halo then
  			for _, one in ipairs(halo:toArray(true, "=")) do
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
258 
 | 
  				addAura(one)
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
259
260
261
262
263
264 
 | 
  			end
  		end
  	elseif self:is("Build") then
  		local halo = csvdb["event_buildingCsv"][self.id].halo
  		if halo then
  			for _, one in ipairs(halo:toArray(true, "=")) do
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
265 
 | 
  				addAura(one)
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
266
267 
 | 
  			end
  		end
 
 | 
3139a116
 
  zhouhaihai
 
光环相关buff
 | 
268
269
270
271
272
273
274 
 | 
  	end
  
  	for _, buff in ipairs(self.buffs) do
  		if not buff:isHide() and buff:getType() == Buff.GET_AURA then
  			addAura(buff:effect())
  		end
  	end
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
275
276
277
278 
 | 
  
  	return auras
  end
  
 
 | 
916096ed
 
  zhouhaihai
 
神器效果
 | 
279 
 | 
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
280 
 | 
  -- 通用的buff 效果汇总  -- 0 固定 1百分比  两种分类
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
281 
 | 
  function BaseObject:getCommonBuffEffect(bType, otherCond)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
282
283 
 | 
  	local effect, count = {[0] = 0, [1] = 0}, 0
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
284 
 | 
  		if not buff:isHide() and buff:getType() == bType then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
285
286 
 | 
  			local cType, value, cond = buff:effect()
  			if cType and (not otherCond or otherCond == cond) then
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
287 
 | 
  				effect[cType] = effect[cType] + value
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
288
289
290
291 
 | 
  				count = count + 1
  			end
  		end
  	end
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
292 
 | 
  	effect[1] = effect[1] / 100
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
293
294
295 
 | 
  	return effect, count --效果 和生效的buff 个数
  end
  --伤害反弹
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
296 
 | 
  function BaseObject:getBackHurtBuff()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
297
298 
 | 
  	local effect = {[0] = 0, [1] = 0}
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
299 
 | 
  		if not buff:isHide() and buff:getType() == Buff.BACK_HURT then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
300 
 | 
  			local cType, value = buff:effect()  --  aType 0 全部  1 普通攻击
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
301 
 | 
  			if cType then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
302 
 | 
  				effect[cType] = effect[cType] + value
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318 
 | 
  			end
  		end
  	end
  	return effect
  end
  
  --释放者伤害变化
  function BaseObject:getHurtChange()
  	local change = self:getCommonBuffEffect(Buff.HURT_CHANGE)
  	return change
  end
  --受伤者受伤变化
  function BaseObject:getInjuredChange()
  	local change = self:getCommonBuffEffect(Buff.INJURED_CHANGE)
  	return change
  end
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
319
320
321
322
323
324
325
326 
 | 
  -- 奖励道具变化
  function BaseObject:getRewardChange(itemId)
  	local change = self:getCommonBuffEffect(Buff.ITEM_GET_UP, itemId)
  	return change
  end
  
  -- buff 增益 检疫
  function BaseObject:getBuffEffectChange(classify)
 
 | 
d3da3368
 
  zhouhaihai
 
冒险地图被动技, buff  神器
 | 
327
328
329
330
331 
 | 
  	local classifys = classify:toArray(true, " ")
  	local had = {}
  	for _, one in pairs(classifys) do
  		had[one] = 1
  	end
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
332
333 
 | 
  	local effect = 0
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
334 
 | 
  		if not buff:isHide() and buff:getType() == Buff.Buff_EFFECT_CHANGE then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
335 
 | 
  			local cType, value = buff:effect()
 
 | 
d3da3368
 
  zhouhaihai
 
冒险地图被动技, buff  神器
 | 
336 
 | 
  			if cType and had[cType] then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351 
 | 
  				effect = effect + value
  			end
  		end
  	end
  	effect = effect / 100
  	return effect
  end
  
  function BaseObject:getAttrBuffChange(attr)
  	local AttrBuff = {
  		[Buff.ATTR_CHANGE] = 1,
  		[Buff.ATTR_CHANGE_COND] = 1,
  	}
  	local effect, count = {[0] = 0, [1] = 0}, 0
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
352 
 | 
  		if not buff:isHide() and AttrBuff[buff:getType()] then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
353
354
355
356
357
358
359
360
361
362 
 | 
  			local cType, value, attrName = buff:effect()
  			if cType and attr == attrName then
  				effect[cType] = effect[cType] + value
  				count = count + 1
  			end
  		end
  	end
  	effect[1] = effect[1] / 100
  	return effect, count
  end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
363
364 
 | 
  --重新计算属性
  function BaseObject:reSetAttr(field)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
365 
 | 
  	local old = self[field]
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
366 
 | 
  	self[field] = self["_" .. field] --重置一下
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
367 
 | 
  	local effect = self:getAttrBuffChange(field)
 
 | 
e10edb5f
 
  zhouahaihai
 
冒险事件新
 | 
368 
 | 
  	self[field] = math.ceil((self[field] + effect[0]) * (1 + effect[1]))
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
369 
 | 
  	local delta = self[field] - old
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
370
371 
 | 
  end
  
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
372
373
374
375 
 | 
  -- 重新计算 血量上限
  function BaseObject:reSetHpMax()
  	self.hpMax = self._hpMax
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
376 
 | 
  		if not buff:isHide() and buff:getType() == Buff.HP_MAX_CHANGE then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
377
378
379
380
381
382 
 | 
  			local cv = buff:effect()
  			if cv then
  				self.hpMax = self.hpMax + cv
  			end
  		end
  	end
 
 | 
98761edc
 
  zhouhaihai
 
buff 补充
 | 
383 
 | 
  	local effect = self:getAttrBuffChange("hp")
 
 | 
d3da3368
 
  zhouhaihai
 
冒险地图被动技, buff  神器
 | 
384 
 | 
  	self.hpMax = (self.hpMax + effect[0]) * (1 + effect[1])
 
 | 
98761edc
 
  zhouhaihai
 
buff 补充
 | 
385 
 | 
  	self.hpMax = math.ceil(math.max(1, self.hpMax))
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
386
387
388 
 | 
  	self.hp = math.min(self.hpMax, self.hp)
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
389
390
391
392
393
394
395
396
397 
 | 
  --计算打出伤害加成后的值 
  function BaseObject:getHurtValue(value)
  	value = value or self.atk
  	local hurtChange = self:getHurtChange()
  	return math.max(0, (value + hurtChange[0]) * (1 + hurtChange[1]))
  end
  --计算自己伤害减免后的值
  function BaseObject:getInjuredValue(value)
  	local injuredChange = self:getInjuredChange()
 
 | 
6df85179
 
  zhouhaihai
 
伤害计算
 | 
398 
 | 
  	return math.max(0, (value + injuredChange[0]) * (1 + injuredChange[1]))
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
399
400 
 | 
  end
  
 
 | 
ae9a74b5
 
  suhongyang
 
返回miss,快速战斗逻辑
 | 
401 
 | 
  --最终伤害 = [ (敌方攻击 - 己方防御) * (1+伤害增加百分比-伤害减少百分比)*(1+受伤增加百分比-受伤减少百分比)+(伤害增加固定值-伤害增加固定值+受伤增加固定值-受伤增加固定值)]*(1+侍宠百分比)-侍宠固定值
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
402 
 | 
  -- params   -- hurtType  1 普攻伤害  2 buff伤害  3 反弹伤害  4 真实伤害  5 客户端发回来的伤害  --直接作用 6 buff伤害(真实)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
403
404
405 
 | 
  --进入这个方法之前计算好释放者加成的伤害
  function BaseObject:hurt(value, releaser, params)
  	params = params or {}
 
 | 
d3da3368
 
  zhouhaihai
 
冒险地图被动技, buff  神器
 | 
406
407
408 
 | 
  
  	if params.hurtType and (params.hurtType == 2 or params.hurtType == 6) then
  		self:triggerPassive(Passive.SELF_HURT, {trigger = releaser, buffId = params.buffId})
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
409 
 | 
  		for _, team in ipairs(self:getTeam(1, true)) do
 
 | 
d3da3368
 
  zhouhaihai
 
冒险地图被动技, buff  神器
 | 
410 
 | 
  			team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser, buffId = params.buffId})
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
411 
 | 
  		end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
412 
 | 
  	end
 
 | 
d3da3368
 
  zhouhaihai
 
冒险地图被动技, buff  神器
 | 
413 
 | 
  
 
 | 
6df85179
 
  zhouhaihai
 
伤害计算
 | 
414 
 | 
  	if params.hurtType ~= 5 then
 
 | 
294408d9
 
  zhouhaihai
 
伤害错误
 | 
415 
 | 
  		if params.hurtType ~= 6 and params.hurtType ~= 4 then
 
 | 
6df85179
 
  zhouhaihai
 
伤害计算
 | 
416 
 | 
  			value = math.max(0, value - self.def)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
417 
 | 
  		end
 
 | 
6df85179
 
  zhouhaihai
 
伤害计算
 | 
418 
 | 
  		value = self:getInjuredValue(value) --减伤计算
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433 
 | 
  		if value == 0 then return end
  
  		-- 舍身和恃宠
  		local team = self:getTeam(1)
  		local transfer = {}
  		local absorb = {}
  		for _, one in ipairs(team) do
  			local change1, count1 = one:getCommonBuffEffect(Buff.INJURED_CHANGE)
  			local change2, count2 = one:getCommonBuffEffect(Buff.HURT_ABSORB)
  			if count1 > 0 then
  				table.insert(transfer, {one, change1, count1})
  			end
  			if count2 > 0 then
  				table.insert(absorb, {one, change2, count2})
  			end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
434 
 | 
  		end
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449 
 | 
  		if #absorb == 1 then --舍身优先级高  --舍身生效
  			if absorb[1][1] ~= self then --舍身的人不是自己才有效
  				local absorbV = (value - absorb[1][2][0]) * absorb[1][2][1] + absorb[1][2][0]  --固定值先生效
  				value = value - absorbV
  				absorb[1][1]:hurt(absorbV, releaser, params)
  			end
  		else
  			if #transfer == 1 and transfer[1][1] == self and #team > 1 then --侍宠 生效  
  				local transferValue = (value - transfer[1][2][0])* transfer[1][2][1] + transfer[1][2][0] --固定值先生效
  				value = value - transferValue
  				local oneValue = transferValue / (#team - 1)
  				for _, one in ipairs(team) do
  					if one ~= self then
  						one:hurt(oneValue, releaser, params)
  					end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
450
451
452
453
454 
 | 
  				end
  			end
  		end
  	end
  
 
 | 
e10edb5f
 
  zhouahaihai
 
冒险事件新
 | 
455 
 | 
  	value = math.max(0, math.ceil(value))
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
456
457 
 | 
  	if value == 0 then return end
  	-- 反弹伤害
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
458 
 | 
  	if params.hurtType ~= 3 and params.hurtType ~= 5 and releaser and not releaser.isDead then
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
459 
 | 
  		local backEffect = self:getBackHurtBuff()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
460
461
462
463
464 
 | 
  		local backValue = math.max(0, value * backEffect[1] + backEffect[0])
  		releaser:hurt(backValue, releaser, {hurtType = 3})
  	end
  
  	--受伤了~
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
465
466
467
468 
 | 
  	if self:is("Player") and params.hurtType ~= 5 then
  		self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = -value})
  	end
  
 
 | 
d27a2b20
 
  zhouhaihai
 
怪受伤 更新地块
 | 
469
470
471
472
473 
 | 
  	if params.hurtType ~= 5 then -- 非客户端发回的伤害  返回更新地块
  		if self.roomId and self.blockId then
  			self.battle.adv:backBlockChange(self.roomId, self.blockId)
  		end
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
474 
 | 
  	self.hp = math.max(0, self.hp - value)
 
 | 
b0fe1817
 
  zhouahaihai
 
冒险分数
 | 
475 
 | 
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
476 
 | 
  	if self.hp == 0 then
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
477
478 
 | 
  		self:triggerPassive(Passive.SELF_DEAD)
  		for _, team in ipairs(self:getTeam(1, true)) do
 
 | 
6826fdf6
 
  zhouhaihai
 
被动触发
 | 
479 
 | 
  			team:triggerPassive(Passive.TEAM_DEAD, {trigger = self})
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
480
481 
 | 
  		end
  
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
482 
 | 
  		if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then
 
 | 
b176d7d3
 
  zhouhaihai
 
冒险成就
 | 
483
484 
 | 
  			self.battle.adv:checkAchievement(self.battle.adv.AchievType.KillByBuff, 1, params.buffId)
  		end
 
 | 
d95bc647
 
  zhouhaihai
 
冒险被动技
 | 
485 
 | 
  		self.isDead = true
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
486 
 | 
  	end
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
487
488
489
490 
 | 
  	self:triggerPassive(Passive.HURT_PERCENT_SELF, {value = value / self.hpMax})
  	for _, team in ipairs(self:getTeam(1, true)) do
  		team:triggerPassive(Passive.HURT_PERCENT_TEAM, {value = value / self.hpMax})
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
491
492
493
494 
 | 
  end
  --恢复
  function BaseObject:recover(value, releaser, params)
  	params = params or {}
 
 | 
e10edb5f
 
  zhouahaihai
 
冒险事件新
 | 
495 
 | 
  	value = math.max(0, math.ceil(value))
 
 | 
4500c9b8
 
  zhouhaihai
 
满了不飘字
 | 
496 
 | 
  	local old = self.hp
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
497 
 | 
  	self.hp = math.min(self.hpMax, self.hp + value)
 
 | 
4500c9b8
 
  zhouhaihai
 
满了不飘字
 | 
498 
 | 
  	local change = self.hp - old
 
 | 
59acc11e
 
  zhouhaihai
 
赛季更新
 | 
499 
 | 
  	if self:is("Player") then
 
 | 
4500c9b8
 
  zhouhaihai
 
满了不飘字
 | 
500
501
502 
 | 
  		if change > 0 then
  			self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = value})
  		end
 
 | 
59acc11e
 
  zhouhaihai
 
赛季更新
 | 
503 
 | 
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
504
505 
 | 
  end
  
 
 | 
42f2d1d3
 
  suhongyang
 
战斗内技能序列逻辑
 | 
506
507
508
509
510 
 | 
  function BaseObject:addSpecialSkill(skillId, skillLevel, target)
  	local skillData = {id = skillId, level = skillLevel, target = target}
  	table.insert(self.skillOrder, skillData)
  end
  
 
 | 
d27ad5e0
 
  suhongyang
 
使用营养技
 | 
511 
 | 
  function BaseObject:releaseSkill(skillId, target)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
512 
 | 
  	if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物
 
 | 
d27ad5e0
 
  suhongyang
 
使用营养技
 | 
513 
 | 
  	local skill = Skill.new(self, {id = skillId, target = target})
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
514 
 | 
  	--返回客户端
 
 | 
1b8336a6
 
  suhongyang
 
skill逻辑与player分开
 | 
515 
 | 
  	for _, target in ipairs(skill:getTargets()) do
 
 | 
81032a9c
 
  zhouhaihai
 
抽奖
 | 
516 
 | 
  		self.battle.adv:backSkill(self.monsterId, skillId, target.id)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
517 
 | 
  	end
 
 | 
1b8336a6
 
  suhongyang
 
skill逻辑与player分开
 | 
518 
 | 
  	skill:doEffect()
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
519
520
521
522
523
524 
 | 
  	for _, team in ipairs(self:getTeam(2)) do
  		team:triggerPassive(Passive.TARGET_SKILL)
  	end
  	for _, team in ipairs(self:getTeam(1, true)) do
  		team:triggerPassive(Passive.TEAM_SKILL)
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
525
526
527 
 | 
  end
  
  --0 全部  1 我方  2 敌方
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
528 
 | 
  function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock)
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
529 
 | 
  	mapIdx = mapIdx or self.battle.adv:getCurMapIdx()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
530
531
532
533
534
535
536
537
538
539 
 | 
  	nType = nType or 0
  	local team = {}
  	local function addPlayer()
  		if not noSelf or self.battle.player ~= self then
  			if not self.battle.player.isDead then
  				table.insert(team, self.battle.player)
  			end
  		end
  	end
  	local function addEnemy()
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
540 
 | 
  		for _, enemy in pairs(self.battle.enemys[mapIdx]) do
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
541 
 | 
  			if not noSelf or enemy ~= self then 
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
542 
 | 
  				if not enemy.isDead and (includeLock or not enemy.lock) then -- 已经翻开的
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
543
544
545
546
547
548
549
550
551 
 | 
  					table.insert(team, enemy)
  				end
  			end
  		end
  	end
  	if nType == 0 then
  		addPlayer()
  		addEnemy()
  	elseif nType == 1 then
 
 | 
b594a026
 
  suhongyang
 
Fix bug
 | 
552 
 | 
  		if not self.monsterId then --玩家
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
553
554
555
556
557 
 | 
  			addPlayer()
  		else
  			addEnemy()
  		end
  	elseif nType == 2 then
 
 | 
b594a026
 
  suhongyang
 
Fix bug
 | 
558 
 | 
  		if not self.monsterId then --玩家
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
559
560
561
562
563
564
565
566 
 | 
  			addEnemy()
  		else
  			addPlayer()
  		end
  	end
  	return team
  end
  
 
 | 
1e789624
 
  zhouhaihai
 
新的 buff 效果
 | 
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610 
 | 
  function BaseObject:attrChangeCondBuffCheck(etype, cond)
  	local effect = {}
  	if etype == 3 then
  		if type(cond) ~= "string" then
  			return
  		end
  		local temp = cond:toArray(true, " ")
  		cond = {}
  		for _, one in pairs(temp) do
  			cond[one] = 1
  		end
  	elseif etype == 4 then
  		if not cond then
  			cond = {}
  		end
  		if type(cond) == "number" then
  			cond = {[cond] = 1}
  		end
  	end
  	for _, buff in ipairs(self.buffs) do
  		if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then
  			local _et, _attr, _co = buff:getEffectBy()
  			if etype == _et then
  				if etype == 3 or etype == 4 then
  					if cond[_co] then
  						effect[_attr] = 1
  					end
  				else
  					if (not _co or _co == cond) then
  						effect[_attr] = 1
  					end
  				end
  			end
  		end
  	end
  	for attrName, _ in pairs(effect) do
  		if attrName == "hp" then
  			self:reSetHpMax()
  		else
  			self:reSetAttr(attrName)
  		end
  	end
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
611
612 
 | 
  function BaseObject:getDB()
  	local db = {}
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
613 
 | 
  	db.hp = self.hp
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
614 
 | 
  	local baseAttr = {"atk", "miss", "hit", "def", "hpMax"}
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
615
616
617
618
619
620
621
622 
 | 
  	for _, field in pairs(baseAttr) do
  		db[field] = self[field]
  		db["_"..field] = self["_" .. field]
  	end
  	db.passives = {}
  	for _, passive in ipairs(self.passives) do
  		table.insert(db.passives, passive:getDB())
  	end
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
623 
 | 
  	db.buffs = {}
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
624
625
626
627
628
629
630 
 | 
  	for _, buff in ipairs(self.buffs) do
  		table.insert(db.buffs, buff:getDB())
  	end
  	return db
  end
  
  function BaseObject:triggerPassive(condType, params)
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
631
632
633
634 
 | 
  	if self.isDead then return end
  	for _, passive in ipairs(self.passives) do
  		passive:trigger(condType, params) --检查触发
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
635
636 
 | 
  end
  
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
637
638
639 
 | 
  function BaseObject:changeSp()
  end
  
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
640
641
642
643 
 | 
  function BaseObject:is(what)
  	return self["is" .. what] and self["is" .. what](self)
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
644 
 | 
  local Enemy = class("Enemy", BaseObject)
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
645 
 | 
  function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy, mapIdx)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
646 
 | 
  	Enemy.super.ctor(self, battle)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
647
648 
 | 
  	self.id = mId
  	self.monsterId = monsterId  --数据id
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
649
650
651 
 | 
  	self.roomId = roomId
  	self.blockId = blockId
  	self.lock = lock
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
652 
 | 
  	self.mapIdx = mapIdx
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
653
654 
 | 
  	self:initData(enemy)
  end
 
 | 
a0834e49
 
  zhouhaihai
 
增加潜行 功能
 | 
655 
 | 
  function Enemy:unlock()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
656
657
658 
 | 
  	self.lock = nil
  end
  
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
659
660
661
662 
 | 
  function Enemy:isEnemy()
  	return true
  end
  
 
 | 
b6a2b78b
 
  zhouhaihai
 
冒险 buff 类型 34 35
 | 
663
664 
 | 
  function Enemy:getObstacle()
  	local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle
 
 | 
161c50cc
 
  zhouhaihai
 
宝藏怪活动
 | 
665 
 | 
  	if obstacle == 2 and self:hadBuff(Buff.OBSTACLE_CHANGE) then
 
 | 
b6a2b78b
 
  zhouhaihai
 
冒险 buff 类型 34 35
 | 
666
667
668
669
670 
 | 
  		obstacle = 1
  	end
  	return obstacle
  end
  
 
 | 
1e789624
 
  zhouhaihai
 
新的 buff 效果
 | 
671
672
673
674
675
676
677
678
679 
 | 
  function Enemy:isClassify(check)
  	local classify = self:getClassify()
  	return classify and classify:sismember(check, " ")
  end
  
  function Enemy:getClassify()
  	return csvdb["event_monsterCsv"][self.monsterId].classify
  end
  
 
 | 
f773a677
 
  zhouhaihai
 
假的boss 没有效果
 | 
680
681
682
683 
 | 
  function Enemy:getMonsterCsv()
  	return csvdb["event_monsterCsv"][self.monsterId]
  end
  
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705 
 | 
  -- 0=所有  1=怪物  2=玩家
  function Enemy:checkAuraBuff(buffs)
  	local needBuffs = {}
  
  	for buffId, info in pairs(buffs[0] or {}) do
  		needBuffs[buffId] = needBuffs[buffId] or {}
  		needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  		needBuffs[buffId].exist = info.exist
  	end
  
  	for buffId, info in pairs(buffs[1] or {}) do
  		needBuffs[buffId] = needBuffs[buffId] or {}
  		needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  		needBuffs[buffId].exist = info.exist
  	end
  
  	for buffId, info in pairs(needBuffs) do
  		if info.count < 0 then
  			local buff = self:getBuffById(buffId)
  			if buff then
  				buff:uncover(info.exist and -info.count or -1, true)
  			end
 
 | 
0c7b1a2c
 
  zhouhaihai
 
光环 buga
 | 
706 
 | 
  		elseif info.count > 0 then
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
707
708
709
710 
 | 
  			self:addBuff(buffId, nil, info.count)
  		end
  	end
  end
 
 | 
1e789624
 
  zhouhaihai
 
新的 buff 效果
 | 
711 
 | 
  
 
 | 
7b2dc17c
 
  zhouhaihai
 
地图 层 buff passive
 | 
712
713
714
715 
 | 
  function Enemy:kill()
  	self:hurt(self.hp, self.battle.player, {hurtType = 5})
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
716
717
718
719
720
721 
 | 
  local Player = class("Player", BaseObject)
  function Player:ctor(battle, data)
  	Player.super.ctor(self, battle)
  	self:initData(data)
  end
  
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
722
723 
 | 
  function Player:initData(data)
  	Player.super.initData(self, data)
 
 | 
a95b35ce
 
  zhouhaihai
 
删除等级
 | 
724 
 | 
  	-- self.level = data.level or 1  --level 每增加1级  属性增长 growth * baseAttr
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
725 
 | 
  	self.growth = data.growth
 
 | 
a95b35ce
 
  zhouhaihai
 
删除等级
 | 
726 
 | 
  	-- self.exp = data.exp or 0
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
727 
 | 
  	self.sp = data.sp or 100
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
728
729 
 | 
  	self.spMax = data.spMax or 100
  	self._spMax = data._spMax or 100
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
730
731 
 | 
  end
  
 
 | 
a95b35ce
 
  zhouhaihai
 
删除等级
 | 
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761 
 | 
  -- function Player:addExp(value)
  -- 	-- buff 经验加成
  -- 	local up = self:getCommonBuffEffect(Buff.EXP_UP)
  -- 	value = math.ceil((value + up[0]) * (1 + up[1]))
  
  -- 	if value <= 0 then return end
  -- 	local newExp = self.exp + value
  -- 	local level = self.level
  -- 	if level >= #csvdb["adv_levelCsv"] then return end
  -- 	while true do
  -- 		local curData = csvdb["adv_levelCsv"][level]
  -- 		if newExp < curData.exp then break end
  -- 		level = level + 1
  -- 		newExp = newExp - curData.exp
  -- 		if level >= #csvdb["adv_levelCsv"] then break end
  -- 	end
  -- 	local delta = level - self.level
  
  -- 	self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value})
  
  -- 	if delta > 0 then
  -- 		for attr, _ in pairs(AdvAttsEnum) do
  -- 			self:addBaseAttr(attr, self.growth[attr] * delta, 0, true)
  -- 		end
  -- 		self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta})
  -- 	end
  -- 	self.level = level
  -- 	self.exp = newExp
  -- 	return value
  -- end
 
 | 
1ffc16b9
 
  zhouhaihai
 
冒险 选择点和 建筑
 | 
762 
 | 
  --vtype 0/1 值/%
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
763 
 | 
  function Player:addBaseAttr(attr, value, vtype, ignoreBack)
 
 | 
1ffc16b9
 
  zhouhaihai
 
冒险 选择点和 建筑
 | 
764
765
766 
 | 
  	local attrName = attr
  	if attr == "hp" then
  		attrName = "hpMax"
 
 | 
e1679483
 
  zhouhaihai
 
bug
 | 
767 
 | 
  	elseif attr == "sp" then
 
 | 
1ffc16b9
 
  zhouhaihai
 
冒险 选择点和 建筑
 | 
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787 
 | 
  		attrName = "spMax"
  	end
  	local baseName = "_" .. attrName
  	if not self[baseName] then return end
  	local oldV = self[baseName]
  
  	local change = value
  	if vtype == 1 then
  		change = oldV * value / 100
  	end
  	self[baseName] = self[baseName] + change
  	if attr == "hp" then
  		self.hp = self.hp + change
  		self:reSetHpMax()
  	elseif attr == "sp" then
  		self.sp = self.sp + change
  		self:reSetSpMax()
  	else
  		self:reSetAttr(attr)
  	end
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
788
789
790
791 
 | 
  
  	if not ignoreBack then
  		self.battle.adv:pushBackEvent(AdvBackEventType.BaseAttrChange, {type = AdvAttsEnum[attr] or 0, change = change})
  	end
 
 | 
1ffc16b9
 
  zhouhaihai
 
冒险 选择点和 建筑
 | 
792 
 | 
  end
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
793 
 | 
  
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
794
795 
 | 
  --cType 0 or nil  值  1 百分比
  function Player:changeSp(value, cType)
 
 | 
85ded242
 
  zhouhaihai
 
丰富返回事件
 | 
796 
 | 
  	local oldSp = self.sp
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
797 
 | 
  	cType = cType or 0
 
 | 
cac28f5f
 
  zhouhaihai
 
魔力改变
 | 
798 
 | 
  	local change = 0
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
799 
 | 
  	if cType == 0 then
 
 | 
cac28f5f
 
  zhouhaihai
 
魔力改变
 | 
800 
 | 
  		change = value
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
801 
 | 
  	elseif cType == 1 then
 
 | 
3da4db4f
 
  zhouhaihai
 
回魔 百分比 以上限
 | 
802 
 | 
  		change = self.spMax * value / 100
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
803 
 | 
  	end
 
 | 
6c012309
 
  zhouhaihai
 
sp 满了不加
 | 
804 
 | 
  	local old = self.sp
 
 | 
cac28f5f
 
  zhouhaihai
 
魔力改变
 | 
805 
 | 
  	self.sp = math.floor(math.min(self.spMax, math.max(0, self.sp + change)))
 
 | 
6c012309
 
  zhouhaihai
 
sp 满了不加
 | 
806 
 | 
  	change = self.sp - old
 
 | 
cac28f5f
 
  zhouhaihai
 
魔力改变
 | 
807
808 
 | 
  	if change ~= 0 then
  		self.battle.adv:pushBackEvent(AdvBackEventType.SpChange, {change = math.floor(change)})
 
 | 
81032a9c
 
  zhouhaihai
 
抽奖
 | 
809 
 | 
  	end
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
810
811 
 | 
  end
  
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
812 
 | 
  -- 重新计算 魔法上限
 
 | 
3df73a9e
 
  zhouhaihai
 
复兴奖励
 | 
813 
 | 
  function Player:reSetSpMax()
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
814
815
816
817
818
819
820 
 | 
  	self.spMax = self._spMax
  	local change = self:getCommonBuffEffect(Buff.SP_MAX_CHANGE)
  	self.spMax = math.ceil((self.spMax + change[0]) * (1 + change[1]))
  	self.spMax = math.max(1, self.spMax)
  	self.sp = math.min(self.spMax, self.sp)
  end
  
 
 | 
e90b4d20
 
  zhouhaihai
 
战斗buff
 | 
821
822
823 
 | 
  --战斗结束了扣战斗buff次数
  function Player:effectBattleBuff()
  	for _, buff in ipairs(self.buffs) do
 
 | 
9c8e9482
 
  zhouhaihai
 
buff  被动 限定地图
 | 
824 
 | 
  		if not buff:isHide() and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then
 
 | 
e90b4d20
 
  zhouhaihai
 
战斗buff
 | 
825 
 | 
  			buff:effect()
 
 | 
53ce7853
 
  zhouhaihai
 
队长技能 不失效
 | 
826 
 | 
  			if not buff.buffData.classify:sismember(7, " ") and not buff.buffData.classify:sismember(8, " ") then -- 神器buff 不会清除 队长技
 
 | 
f927f229
 
  zhouhaihai
 
增加神器标签
 | 
827
828 
 | 
  				buff:uncover()
  			end
 
 | 
e90b4d20
 
  zhouhaihai
 
战斗buff
 | 
829
830
831 
 | 
  		end
  	end
  end
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
832 
 | 
  
 
 | 
596ac19f
 
  zhouhaihai
 
buff
 | 
833 
 | 
  function Player:afterLayer()
 
 | 
7b2dc17c
 
  zhouhaihai
 
地图 层 buff passive
 | 
834
835
836
837
838 
 | 
  	for _, passive in ipairs(self.passives) do
  		if not passive.isDel then
  			passive:afterLayer()
  		end
  	end
 
 | 
596ac19f
 
  zhouhaihai
 
buff
 | 
839
840
841
842
843 
 | 
  	for _, buff in ipairs(self.buffs) do
  		if not buff.isDel then
  			buff:afterLayer()
  		end
  	end	
 
 | 
7b2dc17c
 
  zhouhaihai
 
地图 层 buff passive
 | 
844
845 
 | 
  
  	self:clearRound()
 
 | 
596ac19f
 
  zhouhaihai
 
buff
 | 
846
847 
 | 
  end
  
 
 | 
e852b350
 
  zhouhaihai
 
冒险成就类型增加
 | 
848 
 | 
  function Player:addBuff(buffId, releaser)
 
 | 
c5d9338f
 
  zhouhaihai
 
通用方法 异常
 | 
849
850 
 | 
  	local status = Player.super.addBuff(self, buffId, releaser)
  	if  status then
 
 | 
c5d9338f
 
  zhouhaihai
 
通用方法 异常
 | 
851 
 | 
  		self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId)
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
852 
 | 
  		self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId})
 
 | 
ead2c938
 
  zhouhaihai
 
被动新
 | 
853 
 | 
  		self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId})
 
 | 
c5d9338f
 
  zhouhaihai
 
通用方法 异常
 | 
854
855 
 | 
  	end
  	return status
 
 | 
e852b350
 
  zhouhaihai
 
冒险成就类型增加
 | 
856 
 | 
  end
 
 | 
a80fee7c
 
  zhouhaihai
 
光环
 | 
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883 
 | 
  -- 0=所有  1=怪物  2=玩家
  function Player:checkAuraBuff(buffs)
  	local needBuffs = {}
  
  	for buffId, info in pairs(buffs[0] or {}) do
  		needBuffs[buffId] = needBuffs[buffId] or {}
  		needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  		needBuffs[buffId].exist = info.exist
  	end
  
  	for buffId, info in pairs(buffs[2] or {}) do
  		needBuffs[buffId] = needBuffs[buffId] or {}
  		needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  		needBuffs[buffId].exist = info.exist
  	end
  
  	for buffId, info in pairs(needBuffs) do
  		if info.count < 0 then
  			local buff = self:getBuffById(buffId)
  			if buff then
  				buff:uncover(info.exist and -info.count or -1, true)
  			end
  		elseif info.count  > 0 then
  			self:addBuff(buffId, nil, info.count)
  		end
  	end
  end
 
 | 
e852b350
 
  zhouhaihai
 
冒险成就类型增加
 | 
884 
 | 
  
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
885
886
887
888 
 | 
  function Player:isPlayer()
  	return true
  end
  
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
889
890 
 | 
  function Player:getDB()
  	local db = Player.super.getDB(self)
 
 | 
a95b35ce
 
  zhouhaihai
 
删除等级
 | 
891
892 
 | 
  	-- for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do
  	for _ , field in pairs({"level", "growth", "sp", "spMax"}) do
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
893
894 
 | 
  		db[field] = self[field]
  	end
 
 | 
ccbafe67
 
  zhouhaihai
 
冒险神器和buff
 | 
895 
 | 
  	db["_spMax"] = self._spMax
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
896
897
898 
 | 
  	return db
  end
  
 
 | 
9687f887
 
  zhouhaihai
 
建筑被动
 | 
899
900
901
902
903
904 
 | 
  -- 建筑 拥有被动技  
  local Build = class("Build", BaseObject)
  
  function Build:ctor(battle, id, roomId, blockId, lock, build, mapIdx)
  	Enemy.super.ctor(self, battle)
  	self.id = id
 
 | 
9687f887
 
  zhouhaihai
 
建筑被动
 | 
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920 
 | 
  	self.roomId = roomId
  	self.blockId = blockId
  	self.lock = lock
  	self.mapIdx = mapIdx
  	self:initData(build)
  end
  
  function Build:initData(data)
  end
  
  function Build:addBuff(buffId, releaser)
  end
  
  function Build:hurt()
  end
  
 
 | 
d232676a
 
  zhouhaihai
 
功能解锁  冒险返回
 | 
921
922
923 
 | 
  function Build:isBuild()
  	return true
  end
 
 | 
9687f887
 
  zhouhaihai
 
建筑被动
 | 
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955 
 | 
  --0 全部  1 怪物  2 玩家  
  function Build:getTeam(nType, noSelf, mapIdx, includeLock)
  	noSelf = false  -- 不管怎么都取不到自己
  	mapIdx = mapIdx or self.battle.adv:getCurMapIdx()
  	nType = nType or 0
  	local team = {}
  	local function addPlayer()
  		if not noSelf or self.battle.player ~= self then
  			if not self.battle.player.isDead then
  				table.insert(team, self.battle.player)
  			end
  		end
  	end
  	local function addEnemy()
  		for _, enemy in pairs(self.battle.enemys[mapIdx]) do
  			if not noSelf or enemy ~= self then 
  				if not enemy.isDead and (includeLock or not enemy.lock) then -- 已经翻开的
  					table.insert(team, enemy)
  				end
  			end
  		end
  	end
  	if nType == 0 then
  		addPlayer()
  		addEnemy()
  	elseif nType == 1 then
  		addEnemy()
  	elseif nType == 2 then
  		addPlayer()
  	end
  	return team
  end
 
 | 
26aeaf48
 
  zhouhaihai
 
bug
 | 
956 
 | 
  function Build:unlock()
 
 | 
9687f887
 
  zhouhaihai
 
建筑被动
 | 
957
958
959 
 | 
  	self.lock = nil
  end
  
 
 | 
26aeaf48
 
  zhouhaihai
 
bug
 | 
960 
 | 
  function Build:getDB()
 
 | 
9687f887
 
  zhouhaihai
 
建筑被动
 | 
961
962
963
964
965
966
967 
 | 
  	local db = {}
  	db.passives = {}
  	for _, passive in ipairs(self.passives) do
  		table.insert(db.passives, passive:getDB())
  	end
  	return db
  end
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
968
969 
 | 
  
  
 
 | 
26aeaf48
 
  zhouhaihai
 
bug
 | 
970 
 | 
  return table.pack(Player, Enemy, Build)
 
 |