Commit ece975b66c07a0c9f7aa865e48ca7975387fce8f
1 parent
4ea1b5ac
属性计算
Showing
3 changed files
with
101 additions
and
1 deletions
Show diff stats
src/models/Hero.lua
| ... | ... | @@ -57,7 +57,7 @@ function Hero:updateProperty(params) |
| 57 | 57 | local datas = {} |
| 58 | 58 | table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)}) |
| 59 | 59 | |
| 60 | - local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, skin = true} | |
| 60 | + local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, skin = true, equip = true, rune = true} | |
| 61 | 61 | if check[params.field] then |
| 62 | 62 | local orginValue = self:getProperty("battleV") |
| 63 | 63 | local curValue = self:saveBattleValue() | ... | ... |
src/models/HeroPlugin.lua
| ... | ... | @@ -24,6 +24,7 @@ function HeroPlugin.bind(Hero) |
| 24 | 24 | end |
| 25 | 25 | return point |
| 26 | 26 | end |
| 27 | + | |
| 27 | 28 | --角色属性值 = 基础属性值(unit)* [ 1 + 升级属性(unit_exp)+ 突破属性(unit_break)] * [ 1 + 觉醒属性(unit_wake)+ 天赋属性(unit_talent)] |
| 28 | 29 | function Hero:getBaseAttrs(params) |
| 29 | 30 | params = params or {} |
| ... | ... | @@ -91,11 +92,93 @@ function HeroPlugin.bind(Hero) |
| 91 | 92 | return attrs |
| 92 | 93 | end |
| 93 | 94 | |
| 95 | + | |
| 94 | 96 | --当前属性 = [ 角色属性值 + 基础装备(固定)+ 专属装备(固定)] * [ 1 + 基础装备(百分比) + 专属装备(百分比)] |
| 95 | 97 | function Hero:getTotalAttrs(params) |
| 96 | 98 | local attrs = self:getBaseAttrs() |
| 99 | + -- 装备零件 | |
| 100 | + local equipAttrs = self:getRuneEquipAttrs() | |
| 101 | + | |
| 102 | + for _, attName in pairs(AttsEnumEx) do | |
| 103 | + attrs[attName] = ((attrs[attName] or 0) + equipAttrs.value[attName]) * (1 + equipAttrs.precent[attName]) | |
| 104 | + end | |
| 105 | + | |
| 106 | + return attrs | |
| 107 | + end | |
| 108 | + | |
| 109 | + -- 当前零件和装备增加属性 | |
| 110 | + function Hero:getRuneEquipAttrs() | |
| 111 | + local attrs = {value = {}, precent = {}} | |
| 112 | + for _, attName in pairs(AttsEnumEx) do | |
| 113 | + attrs.value[attName] = 0 | |
| 114 | + attrs.precent[attName] = 0 | |
| 115 | + end | |
| 116 | + local equipSuits = {} | |
| 117 | + -- 装备效果 | |
| 118 | + for typ,level in pairs(self:getProperty("equip"):toNumMap()) do | |
| 119 | + if level > 0 then | |
| 120 | + local data = csvdb["equipCsv"][typ][level] | |
| 121 | + for k,v in pairs(data.attr1:toNumMap()) do | |
| 122 | + attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + v | |
| 123 | + end | |
| 124 | + for k,v in pairs(data.attr2:toNumMap()) do | |
| 125 | + attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + v | |
| 126 | + end | |
| 127 | + if data.suit ~= "" then | |
| 128 | + if not equipSuits[data.suit] then equipSuits[data.suit] = {} end | |
| 129 | + table.insert(equipSuits[data.suit], data) | |
| 130 | + end | |
| 131 | + end | |
| 132 | + end | |
| 133 | + -- 装备套装效果 | |
| 134 | + for suitId,eDatas in pairs(equipSuits) do | |
| 135 | + local suitCsv = csvdb["equip_suitCsv"][tonumber(suitId)] | |
| 136 | + if suitCsv then | |
| 137 | + local effects = suitCsv.effect:toTableArray(true) | |
| 138 | + local count = #eDatas | |
| 139 | + if count >= 2 then | |
| 140 | + attrs.precent[AttsEnumEx[effects[1][1]]] = attrs.precent[AttsEnumEx[effects[1][1]]] + effects[1][2] | |
| 141 | + end | |
| 142 | + if count >= 3 then | |
| 143 | + attrs.precent[AttsEnumEx[effects[2][1]]] = attrs.precent[AttsEnumEx[effects[2][1]]] + effects[1][2] | |
| 144 | + end | |
| 145 | + if count >= 4 then | |
| 146 | + attrs.precent[AttsEnumEx[effects[3][1]]] = attrs.precent[AttsEnumEx[effects[3][1]]] + effects[3][2] | |
| 147 | + end | |
| 148 | + end | |
| 149 | + end | |
| 150 | + -- 零件效果 | |
| 151 | + local suits = {} | |
| 152 | + for _, uid in pairs(self:getProperty("rune"):toNumMap()) do | |
| 153 | + if uid > 0 then | |
| 154 | + local rune = self.owner.runeBag[uid] | |
| 155 | + local buildData = csvdb["rune_buildCsv"][rune:getProperty("level")] | |
| 156 | + for k,v in pairs(rune:getProperty("attrs"):toNumMap()) do | |
| 157 | + attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + (v * (1 + buildData.effect/100)) | |
| 158 | + | |
| 159 | + end | |
| 160 | + local csvData = csvdb["runeCsv"][rune:getProperty("type")][rune:getProperty("id")] | |
| 161 | + if not suits[csvData.suit] then suits[csvData.suit] = {} end | |
| 162 | + table.insert(suits[csvData.suit],csvData) | |
| 163 | + end | |
| 164 | + end | |
| 165 | + -- 零件套装效果 | |
| 166 | + for suitId,runeDatas in pairs(suits) do | |
| 167 | + local suitCsv = csvdb["rune_suitCsv"][tonumber(suitId)] | |
| 168 | + if suitCsv then | |
| 169 | + local effects = suitCsv.effect:toTableArray(true) | |
| 170 | + local count = #runeDatas | |
| 171 | + if count >= 2 then | |
| 172 | + attrs.precent[AttsEnumEx[effects[1][1]]] = attrs.precent[AttsEnumEx[effects[1][1]]] + effects[1][2] | |
| 173 | + end | |
| 174 | + if count == 6 then | |
| 175 | + attrs.precent[AttsEnumEx[effects[3][1]]] = attrs.precent[AttsEnumEx[effects[3][1]]] + effects[3][2] | |
| 176 | + end | |
| 177 | + end | |
| 178 | + end | |
| 97 | 179 | return attrs |
| 98 | 180 | end |
| 181 | + | |
| 99 | 182 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击 + 命中 * 4)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] |
| 100 | 183 | function Hero:getBattleValue() |
| 101 | 184 | local attrs = self:getTotalAttrs() | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -500,6 +500,23 @@ function RolePlugin.bind(Role) |
| 500 | 500 | end |
| 501 | 501 | return max |
| 502 | 502 | end |
| 503 | + | |
| 504 | + function Role:warningHeartTooQuick() | |
| 505 | + -- 加速器检测 | |
| 506 | + -- local heartWarning = self:getProperty("heartWarning") | |
| 507 | + -- heartWarning = heartWarning + 1 | |
| 508 | + -- self:setProperty("heartWarning", heartWarning) | |
| 509 | + -- if heartWarning == 50 then | |
| 510 | + -- self:setProperty("delete", 1) | |
| 511 | + -- self:sendGmMsg("系统检测到你多次使用加速器,已经将你封杀,请联系管理员。") | |
| 512 | + -- self:log("gmAction",{desc = "ban"}) | |
| 513 | + -- return | |
| 514 | + -- end | |
| 515 | + -- if heartWarning < 50 and heartWarning % 5 == 0 then | |
| 516 | + -- self:sendGmMsg("警告!系统检测到你使用加速器,请立即停止使用!否则我们将封杀此账号!") | |
| 517 | + -- self:log("gmAction",{desc = "heartWarning", count = heartWarning}) | |
| 518 | + -- end | |
| 519 | + end | |
| 503 | 520 | end |
| 504 | 521 | |
| 505 | 522 | return RolePlugin |
| 506 | 523 | \ No newline at end of file | ... | ... |