Commit b53593b50b5bb54689577b9da9e88beaa12bb26f

Authored by zhouhaihai
1 parent 33db89b8

羁绊加成

src/adv/AdvBattle.lua
@@ -27,29 +27,42 @@ function Battle:initAfter() @@ -27,29 +27,42 @@ function Battle:initAfter()
27 self.enemy = enemy 27 self.enemy = enemy
28 end 28 end
29 end 29 end
  30 +--[[
  31 +队伍总属性 = 基础属性 + 等级 × 成长率
  32 + 基础属性: 固定属性,与章节、队伍够成、养成无关,由策划给出
  33 + 等级: 根据进入时的关卡,获得一个【初始等级】;消灭怪物获得经验后,累计N点会提升等级
  34 + 羁绊加成: 加成条件与“战斗”相同,加成目标改为【冒险队】
  35 +
  36 + 成长率: 由【队伍总生存力】决定
  37 + 成长率 =(总生存力 / 80)^0.52 + INT(总角色等级 / 50)* 1
  38 +--]]
30 39
31 function Battle:initPlayer() 40 function Battle:initPlayer()
32 if not next(self.adv.advTeam.heros) then return end 41 if not next(self.adv.advTeam.heros) then return end
33 if not self.adv.advTeam.player then 42 if not self.adv.advTeam.player then
34 - local hp = 0  
35 local player = {} 43 local player = {}
36 player.passives = {} 44 player.passives = {}
  45 + local heroLevel = 0
37 for slot, heroId in pairs(self.adv.advTeam.heros) do 46 for slot, heroId in pairs(self.adv.advTeam.heros) do
38 - if self.adv.owner.heros[heroId] then  
39 - hp = hp + self.adv.owner.heros[heroId]:getProperty("battleV") 47 + local hero = self.adv.owner.heros[heroId]
  48 + if hero then
  49 + heroLevel = heroLevel + hero:getProperty("level")
40 local advSkillId = csvdb["unitCsv"][self.adv.owner.heros[heroId]:getSkinId()]["adv"] 50 local advSkillId = csvdb["unitCsv"][self.adv.owner.heros[heroId]:getSkinId()]["adv"]
41 if advSkillId > 1000 then 51 if advSkillId > 1000 then
42 - table.insert(player.passives, {id = advSkillId, level = self.adv.owner.heros[heroId]:getSkillLevel(4)}) 52 + table.insert(player.passives, {id = advSkillId, level = hero:getSkillLevel(4)})
43 end 53 end
44 end 54 end
45 end 55 end
  56 + player.growth = (self.adv.owner:getRealBattleValue(self.adv.advTeam.heros) / 80) ^ 0.52 + math.floor(heroLevel / 50) / 50
  57 + player.level = 0
  58 + player.exp = 0
46 local activeRelation = self.adv.owner:getHeroActiveRelation() 59 local activeRelation = self.adv.owner:getHeroActiveRelation()
47 - -- todo  
48 - player.hp = hp  
49 - player.atk = tonumber(string.format("%0.0f", player.hp * 0.1)) --todo 系数是临时的  
50 - player.def = 0  
51 - player.miss = 0  
52 - player.hit = 100 60 + local baseAttr = csvdb["adv_unitCsv"][math.floor(self.adv.advInfo.chapter / 100)]
  61 + for _, attr in pairs(AttsEnumEx) do
  62 + if baseAttr[attr] then
  63 + player[attr] = baseAttr[attr] + baseAttr[attr] * player.growth * player.level
  64 + end
  65 + end
53 self.adv.advTeam.player = player 66 self.adv.advTeam.player = player
54 self.isNewPlayer = true 67 self.isNewPlayer = true
55 end 68 end
src/adv/AdvPlayer.lua
@@ -447,4 +447,23 @@ function Player:cutHp(value) @@ -447,4 +447,23 @@ function Player:cutHp(value)
447 self.battle.adv:scoreChange(AdvScoreType.Hurt, value) 447 self.battle.adv:scoreChange(AdvScoreType.Hurt, value)
448 end 448 end
449 449
  450 +function Player:initData(data)
  451 + Player.super.initData(self, data)
  452 + self.level = data.level or 0 --level 每增加1级 属性增长 growth * baseAttr
  453 + self.growth = data.growth or 0
  454 + self.exp = data.exp or 0
  455 +end
  456 +
  457 +function Player:addExp(value)
  458 + -- todo
  459 +end
  460 +
  461 +function Player:getDB()
  462 + local db = Player.super.getDB(self)
  463 + for _ , field in pairs({level, exp, growth}) do
  464 + db[field] = self[field]
  465 + end
  466 + return db
  467 +end
  468 +
450 return table.pack(Player, Enemy) 469 return table.pack(Player, Enemy)
451 \ No newline at end of file 470 \ No newline at end of file
src/models/HeroPlugin.lua
@@ -95,6 +95,7 @@ function HeroPlugin.bind(Hero) @@ -95,6 +95,7 @@ function HeroPlugin.bind(Hero)
95 95
96 --当前属性 = [ 角色属性值 + 基础装备(固定)+ 专属装备(固定)] * [ 1 + 基础装备(百分比) + 专属装备(百分比)] 96 --当前属性 = [ 角色属性值 + 基础装备(固定)+ 专属装备(固定)] * [ 1 + 基础装备(百分比) + 专属装备(百分比)]
97 function Hero:getTotalAttrs(params) 97 function Hero:getTotalAttrs(params)
  98 + params = params or {}
98 local attrs = self:getBaseAttrs() 99 local attrs = self:getBaseAttrs()
99 -- 装备零件 100 -- 装备零件
100 local equipAttrs = self:getRuneEquipAttrs() 101 local equipAttrs = self:getRuneEquipAttrs()
@@ -103,6 +104,12 @@ function HeroPlugin.bind(Hero) @@ -103,6 +104,12 @@ function HeroPlugin.bind(Hero)
103 attrs[attName] = ((attrs[attName] or 0) + equipAttrs.value[attName]) * (1 + equipAttrs.precent[attName] / 100) 104 attrs[attName] = ((attrs[attName] or 0) + equipAttrs.value[attName]) * (1 + equipAttrs.precent[attName] / 100)
104 end 105 end
105 106
  107 + -- 羁绊加成
  108 + if params.activeRelation then
  109 + for k, v in pairs(AttsEnumEx) do
  110 + attrs[v] = (attrs[v] or 0) * (1 + (params.activeRelation[v] or 0) / 100)
  111 + end
  112 + end
106 return attrs 113 return attrs
107 end 114 end
108 115
@@ -180,8 +187,8 @@ function HeroPlugin.bind(Hero) @@ -180,8 +187,8 @@ function HeroPlugin.bind(Hero)
180 end 187 end
181 188
182 -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击 + 命中 * 4)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] 189 -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击 + 命中 * 4)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ]
183 - function Hero:getBattleValue()  
184 - local attrs = self:getTotalAttrs() 190 + function Hero:getBattleValue(activeRelation)
  191 + local attrs = self:getTotalAttrs({activeRelation = activeRelation})
185 local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] + attrs["hit"] * 4) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 60000) ^ 0.8 192 local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] + attrs["hit"] * 4) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 60000) ^ 0.8
186 return math.floor(battleValue) 193 return math.floor(battleValue)
187 end 194 end
src/models/RolePlugin.lua
@@ -568,6 +568,18 @@ function RolePlugin.bind(Role) @@ -568,6 +568,18 @@ function RolePlugin.bind(Role)
568 end 568 end
569 return result 569 return result
570 end 570 end
  571 +
  572 + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成
  573 + local activeRelation = self:getHeroActiveRelation(heros)
  574 + local battleValue = 0
  575 + for _, id in pairs(heros) do
  576 + local hero = self.heros[id]
  577 + if hero then
  578 + battleValue = battleValue + hero:getBattleValue(activeRelation)
  579 + end
  580 + end
  581 + return battleValue
  582 + end
571 end 583 end
572 584
573 return RolePlugin 585 return RolePlugin
574 \ No newline at end of file 586 \ No newline at end of file