From b53593b50b5bb54689577b9da9e88beaa12bb26f Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Thu, 25 Jul 2019 16:41:01 +0800 Subject: [PATCH] 羁绊加成 --- src/adv/AdvBattle.lua | 33 +++++++++++++++++++++++---------- src/adv/AdvPlayer.lua | 19 +++++++++++++++++++ src/models/HeroPlugin.lua | 11 +++++++++-- src/models/RolePlugin.lua | 12 ++++++++++++ 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/adv/AdvBattle.lua b/src/adv/AdvBattle.lua index 026fc23..19c933f 100644 --- a/src/adv/AdvBattle.lua +++ b/src/adv/AdvBattle.lua @@ -27,29 +27,42 @@ function Battle:initAfter() self.enemy = enemy end end +--[[ +队伍总属性 = 基础属性 + 等级 × 成长率 + 基础属性: 固定属性,与章节、队伍够成、养成无关,由策划给出 + 等级: 根据进入时的关卡,获得一个【初始等级】;消灭怪物获得经验后,累计N点会提升等级 + 羁绊加成: 加成条件与“战斗”相同,加成目标改为【冒险队】 + + 成长率: 由【队伍总生存力】决定 + 成长率 =(总生存力 / 80)^0.52 + INT(总角色等级 / 50)* 1 +--]] function Battle:initPlayer() if not next(self.adv.advTeam.heros) then return end if not self.adv.advTeam.player then - local hp = 0 local player = {} player.passives = {} + local heroLevel = 0 for slot, heroId in pairs(self.adv.advTeam.heros) do - if self.adv.owner.heros[heroId] then - hp = hp + self.adv.owner.heros[heroId]:getProperty("battleV") + local hero = self.adv.owner.heros[heroId] + if hero then + heroLevel = heroLevel + hero:getProperty("level") local advSkillId = csvdb["unitCsv"][self.adv.owner.heros[heroId]:getSkinId()]["adv"] if advSkillId > 1000 then - table.insert(player.passives, {id = advSkillId, level = self.adv.owner.heros[heroId]:getSkillLevel(4)}) + table.insert(player.passives, {id = advSkillId, level = hero:getSkillLevel(4)}) end end end + player.growth = (self.adv.owner:getRealBattleValue(self.adv.advTeam.heros) / 80) ^ 0.52 + math.floor(heroLevel / 50) / 50 + player.level = 0 + player.exp = 0 local activeRelation = self.adv.owner:getHeroActiveRelation() - -- todo - player.hp = hp - player.atk = tonumber(string.format("%0.0f", player.hp * 0.1)) --todo 系数是临时的 - player.def = 0 - player.miss = 0 - player.hit = 100 + local baseAttr = csvdb["adv_unitCsv"][math.floor(self.adv.advInfo.chapter / 100)] + for _, attr in pairs(AttsEnumEx) do + if baseAttr[attr] then + player[attr] = baseAttr[attr] + baseAttr[attr] * player.growth * player.level + end + end self.adv.advTeam.player = player self.isNewPlayer = true end diff --git a/src/adv/AdvPlayer.lua b/src/adv/AdvPlayer.lua index 581e13f..da1e575 100644 --- a/src/adv/AdvPlayer.lua +++ b/src/adv/AdvPlayer.lua @@ -447,4 +447,23 @@ function Player:cutHp(value) self.battle.adv:scoreChange(AdvScoreType.Hurt, value) end +function Player:initData(data) + Player.super.initData(self, data) + self.level = data.level or 0 --level 每增加1级 属性增长 growth * baseAttr + self.growth = data.growth or 0 + self.exp = data.exp or 0 +end + +function Player:addExp(value) + -- todo +end + +function Player:getDB() + local db = Player.super.getDB(self) + for _ , field in pairs({level, exp, growth}) do + db[field] = self[field] + end + return db +end + return table.pack(Player, Enemy) \ No newline at end of file diff --git a/src/models/HeroPlugin.lua b/src/models/HeroPlugin.lua index 6092714..e5a44ca 100644 --- a/src/models/HeroPlugin.lua +++ b/src/models/HeroPlugin.lua @@ -95,6 +95,7 @@ function HeroPlugin.bind(Hero) --当前属性 = [ 角色属性值 + 基础装备(固定)+ 专属装备(固定)] * [ 1 + 基础装备(百分比) + 专属装备(百分比)] function Hero:getTotalAttrs(params) + params = params or {} local attrs = self:getBaseAttrs() -- 装备零件 local equipAttrs = self:getRuneEquipAttrs() @@ -103,6 +104,12 @@ function HeroPlugin.bind(Hero) attrs[attName] = ((attrs[attName] or 0) + equipAttrs.value[attName]) * (1 + equipAttrs.precent[attName] / 100) end + -- 羁绊加成 + 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 return attrs end @@ -180,8 +187,8 @@ function HeroPlugin.bind(Hero) end -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击 + 命中 * 4)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] - function Hero:getBattleValue() - local attrs = self:getTotalAttrs() + function Hero:getBattleValue(activeRelation) + local attrs = self:getTotalAttrs({activeRelation = activeRelation}) 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 return math.floor(battleValue) end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 8b2f124..f8fd90f 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -568,6 +568,18 @@ function RolePlugin.bind(Role) end return result end + + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成 + local activeRelation = self:getHeroActiveRelation(heros) + local battleValue = 0 + for _, id in pairs(heros) do + local hero = self.heros[id] + if hero then + battleValue = battleValue + hero:getBattleValue(activeRelation) + end + end + return battleValue + end end return RolePlugin \ No newline at end of file -- libgit2 0.21.2