8c74292c
zhouahaihai
增加item 以及 角色突破
|
1
2
3
4
5
|
local HeroPlugin = {}
function HeroPlugin.bind(Hero)
|
3133cb76
zhouhaihai
日志
|
6
7
8
9
10
11
12
13
14
15
16
|
function Hero:log(contents)
contents = contents or {}
if contents["cint1"] or contents["cint2"] or contents["cint3"] then
print("heroLog error log have cint1 or cint2 or cint3 ", debug.traceback())
end
contents["cint1"] = self:getProperty("id")
contents["cint2"] = self:getProperty("type")
self.owner:log("hero_action", contents)
end
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
17
18
19
20
|
function Hero:getMaxLevel()
return math.min(#csvdb["unit_expCsv"], csvdb["unit_breakCsv"][self:getProperty("breakL")].levelLimit)
end
|
c4262012
zhouhaihai
基础属性修改
|
21
|
--角色自身 = 初始 *(1+升级)*(1+突破)*(1+觉醒)+ 天赋升级 + 天赋阶段
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
22
23
24
25
26
27
28
29
|
function Hero:getBaseAttrs(params)
params = params or {}
local unitData = csvdb["unitCsv"][self:getProperty("type")]
local level = params.level or self:getProperty("level")
local breakL = params.breakL or self:getProperty("breakL")
local wakeL = params.wakeL or self:getProperty("wakeL")
local talent = params.talent or self:getProperty("talent")
|
c4262012
zhouhaihai
基础属性修改
|
30
|
--天赋
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
31
|
local talentAttrS = {}
|
c4262012
zhouhaihai
基础属性修改
|
32
|
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
33
|
-- 四个基础属性
|
1c35c4cf
gaofengduan
fix hero awake
|
34
|
local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)]
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
35
|
if not curData then -- 已经满阶段了
|
1c35c4cf
gaofengduan
fix hero awake
|
36
|
curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]]
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
37
38
|
local strength = curData[#curData].strength
for i = 1, 4 do
|
0446679e
zhouhaihai
bug
|
39
|
talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + strength
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
40
41
42
|
end
else
for i = 1, 4 do --4个天赋
|
0446679e
zhouhaihai
bug
|
43
|
talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + curData[talent:getv(i, 0)].strength
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
44
45
|
end
end
|
c4262012
zhouhaihai
基础属性修改
|
46
47
48
49
|
--阶段属性
for i = 1, (talent:getv(0, 1) - 1) do
local curData = csvdb["unit_talentCsv"][i]
local effect = curData[#curData].effect:toArray(true, "=")
|
cdbe8a36
zhouhaihai
天赋
|
50
|
talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2]
|
c4262012
zhouhaihai
基础属性修改
|
51
|
end
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
52
|
|
c4262012
zhouhaihai
基础属性修改
|
53
|
|
cdbe8a36
zhouhaihai
天赋
|
54
55
|
for _, attrName in pairs(AttsEnumEx) do
if talentAttrS[attrName] then
|
5deaf049
zhouhaihai
属性除以100
|
56
|
talentAttrS[attrName] = (unitData[attrName] or 0) * talentAttrS[attrName] / 100
|
cdbe8a36
zhouhaihai
天赋
|
57
|
end
|
c4262012
zhouhaihai
基础属性修改
|
58
|
end
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
59
|
|
c4262012
zhouhaihai
基础属性修改
|
60
61
62
63
64
65
66
|
local attrs = {}
for _, attName in pairs(AttsEnumEx) do
attrs[attName] = unitData[attName] or 0
end
--升级、突破、觉醒
local lData = csvdb["unit_expCsv"][level]
local blData = csvdb["unit_breakCsv"][breakL]
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
67
68
|
local wData = csvdb["unit_wakeCsv"][wakeL]
for attr, value in pairs(attrs) do
|
c4262012
zhouhaihai
基础属性修改
|
69
70
71
|
attrs[attr] = attrs[attr] * (1 + (lData[attr .. "Level"] or 0) / 100)
* (1 + (blData[attr .. "Level"] or 0) / 100)
* (1 + (wData[attr .. "Level"] or 0) / 100) + (talentAttrS[attr] or 0)
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
72
73
74
75
76
|
end
return attrs
end
|
ece975b6
zhouhaihai
属性计算
|
77
|
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
78
79
|
--当前属性 = [ 角色属性值 + 基础装备(固定)+ 专属装备(固定)] * [ 1 + 基础装备(百分比) + 专属装备(百分比)]
function Hero:getTotalAttrs(params)
|
b53593b5
zhouhaihai
羁绊加成
|
80
|
params = params or {}
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
81
|
local attrs = self:getBaseAttrs()
|
ece975b6
zhouhaihai
属性计算
|
82
83
84
85
|
-- 装备零件
local equipAttrs = self:getRuneEquipAttrs()
for _, attName in pairs(AttsEnumEx) do
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
86
|
attrs[attName] = ((attrs[attName] or 0) + equipAttrs.value[attName]) * (1 + equipAttrs.percent[attName] / 100)
|
ece975b6
zhouhaihai
属性计算
|
87
88
|
end
|
b53593b5
zhouhaihai
羁绊加成
|
89
90
91
92
93
94
|
-- 羁绊加成
if params.activeRelation then
for k, v in pairs(AttsEnumEx) do
attrs[v] = (attrs[v] or 0) * (1 + (params.activeRelation[v] or 0) / 100)
end
end
|
ece975b6
zhouhaihai
属性计算
|
95
96
97
98
99
|
return attrs
end
-- 当前零件和装备增加属性
function Hero:getRuneEquipAttrs()
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
100
|
local attrs = {value = {}, percent = {}}
|
ece975b6
zhouhaihai
属性计算
|
101
102
|
for _, attName in pairs(AttsEnumEx) do
attrs.value[attName] = 0
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
103
|
attrs.percent[attName] = 0
|
ece975b6
zhouhaihai
属性计算
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
end
local equipSuits = {}
-- 装备效果
for typ,level in pairs(self:getProperty("equip"):toNumMap()) do
if level > 0 then
local data = csvdb["equipCsv"][typ][level]
for k,v in pairs(data.attr1:toNumMap()) do
attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + v
end
for k,v in pairs(data.attr2:toNumMap()) do
attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + v
end
if data.suit ~= "" then
if not equipSuits[data.suit] then equipSuits[data.suit] = {} end
table.insert(equipSuits[data.suit], data)
end
end
end
-- 装备套装效果
for suitId,eDatas in pairs(equipSuits) do
local suitCsv = csvdb["equip_suitCsv"][tonumber(suitId)]
if suitCsv then
local effects = suitCsv.effect:toTableArray(true)
local count = #eDatas
if count >= 2 then
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
129
|
attrs.percent[AttsEnumEx[effects[1][1]]] = attrs.percent[AttsEnumEx[effects[1][1]]] + effects[1][2]
|
ece975b6
zhouhaihai
属性计算
|
130
131
|
end
if count >= 3 then
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
132
|
attrs.percent[AttsEnumEx[effects[2][1]]] = attrs.percent[AttsEnumEx[effects[2][1]]] + effects[1][2]
|
ece975b6
zhouhaihai
属性计算
|
133
134
|
end
if count >= 4 then
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
135
|
attrs.percent[AttsEnumEx[effects[3][1]]] = attrs.percent[AttsEnumEx[effects[3][1]]] + effects[3][2]
|
ece975b6
zhouhaihai
属性计算
|
136
137
138
139
140
141
142
143
144
145
|
end
end
end
-- 零件效果
local suits = {}
for _, uid in pairs(self:getProperty("rune"):toNumMap()) do
if uid > 0 then
local rune = self.owner.runeBag[uid]
local buildData = csvdb["rune_buildCsv"][rune:getProperty("level")]
for k,v in pairs(rune:getProperty("attrs"):toNumMap()) do
|
b58b5b49
zhouhaihai
零件bug
|
146
|
attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + (v / 10 * (1 + buildData.effect/100)) -- 零件的加成属性有特殊需求 填的是 10倍的值
|
ece975b6
zhouhaihai
属性计算
|
147
148
149
150
151
152
153
154
155
156
157
158
159
|
end
local csvData = csvdb["runeCsv"][rune:getProperty("type")][rune:getProperty("id")]
if not suits[csvData.suit] then suits[csvData.suit] = {} end
table.insert(suits[csvData.suit],csvData)
end
end
-- 零件套装效果
for suitId,runeDatas in pairs(suits) do
local suitCsv = csvdb["rune_suitCsv"][tonumber(suitId)]
if suitCsv then
local effects = suitCsv.effect:toTableArray(true)
local count = #runeDatas
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
160
161
162
163
164
|
if count >= 2 and AttsEnumEx[effects[1][1]]then
attrs.percent[AttsEnumEx[effects[1][1]]] = attrs.percent[AttsEnumEx[effects[1][1]]] + effects[1][2]
end
if count >= 4 and AttsEnumEx[effects[2][1]] then
attrs.percent[AttsEnumEx[effects[2][1]]] = attrs.percent[AttsEnumEx[effects[2][1]]] + effects[2][2]
|
ece975b6
zhouhaihai
属性计算
|
165
|
end
|
acfc2f02
zhouhaihai
零件套装增加冒险战斗被动
|
166
167
|
if count >= 6 and AttsEnumEx[effects[3][1]] then
attrs.percent[AttsEnumEx[effects[3][1]]] = attrs.percent[AttsEnumEx[effects[3][1]]] + effects[3][2]
|
ece975b6
zhouhaihai
属性计算
|
168
169
170
|
end
end
end
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
171
172
|
return attrs
end
|
ece975b6
zhouhaihai
属性计算
|
173
|
|
475a6d03
zhouhaihai
战斗力
|
174
175
176
177
178
179
|
-- 战斗力(当前属性)= POWER[(生命 + 防御 * 23 + 闪避 * 4)*(攻击*14 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ]
function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成
local attrs = self:getTotalAttrs({activeRelation = activeRelation})
local battleValue = ((attrs["hp"] + attrs["def"] * 23 + attrs["miss"] * 4) * (attrs["atk"] * 14 + attrs["hit"] * 2) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 600000) ^ 0.8
return math.floor(battleValue)
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
180
181
182
183
184
185
186
187
188
189
|
end
function Hero:saveBattleValue()
local battleValue = self:getBattleValue()
if battleValue ~= self:getProperty("battleV") then
self:setProperty("battleV", battleValue)
end
return battleValue
end
|
1c35c4cf
gaofengduan
fix hero awake
|
190
|
-- 技能1234 对应必杀技,冒险技,被动技,战斗技
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
191
|
function Hero:getSkillLevel(idx)
|
0889982f
zhouhaihai
优化角色技能等级
|
192
193
194
195
196
197
198
199
200
201
|
local level = 1
for wakeL = 1, self:getProperty("wakeL") do
local wakeData = csvdb["unit_wakeCsv"][wakeL]
for _, slot in ipairs(wakeData.skill:toArray(true,"=")) do
if slot == idx then
level = level + 1
end
end
end
return level
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
202
203
|
end
|
f2fa488d
wangyujie
删除skin相关
|
204
|
function Hero:getSkillData(idx)
|
1c35c4cf
gaofengduan
fix hero awake
|
205
|
local unitData = csvdb["unitCsv"][self:getProperty("type")]
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
206
|
if idx == 1 then
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
207
|
return csvdb["skill_specialCsv"][unitData.special]
|
1c35c4cf
gaofengduan
fix hero awake
|
208
|
elseif idx == 2 then
|
61421173
zhouhaihai
冒险技能取战斗的
|
209
|
return csvdb["adv_battle_specialCsv"][unitData.adv]
|
1c35c4cf
gaofengduan
fix hero awake
|
210
211
212
213
|
elseif idx == 3 then
return csvdb["skill_passiveCsv"][unitData.passive]
elseif idx == 4 then
return csvdb["skill_blockCsv"][unitData.block]
|
a43410e1
zhengshouren
整理格式,使用tab替代空格
|
214
215
216
|
end
return {}
end
|
a6508219
zhouhaihai
挂机奖励
|
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
function Hero:getRunes()
local rune = self:getProperty("rune")
if not rune or rune == "" then
rune = "1=0 2=0 3=0 4=0 5=0 6=0"
end
local result = rune:toNumMap()
for i = 1, 6 do
if not result[i] then
result[i] = 0
end
end
return result
end
-- 101 冒险战斗被动技
-- 102 挂机战斗被动技
function Hero:getRuneSkill(skillType)
local suits = {}
for _,uid in pairs(self:getRunes()) do
if uid > 0 then
local runeData = self.owner.runeBag[uid]
if not runeData then return end
local csvData = csvdb["runeCsv"][runeData.type][runeData.id]
if not suits[csvData.suit] then suits[csvData.suit] = {} end
table.insert(suits[csvData.suit],csvData)
end
end
for suitId,runes in pairs(suits) do
local suitCsv = csvdb["rune_suitCsv"][tonumber(suitId)]
if not suitCsv then return end
local effects = suitCsv.effect:toTableArray(true)
local count = #runes
if count >= 2 and effects[1][1] == skillType then
return effects[1][2]
end
if count >= 4 and effects[2][1] == skillType then
return effects[2][2]
end
if count >= 6 and effects[3][1] == skillType then
return effects[3][2]
end
end
return
end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
263
264
265
266
|
end
return HeroPlugin
|