|
|
@@ -55,18 +55,20 @@ local EquipLogic = require("equip.EquipLogic")
|
|
|
local ItemDefine = require("bag.ItemDefine")
|
|
|
local HeroLogic = require("hero.HeroLogic")
|
|
|
local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
|
|
|
-local MoshouLogic = require("moshou.MoshouLogic")
|
|
|
+-- local MoshouLogic = require("moshou.MoshouLogic")
|
|
|
local LostTempleCombatLogic = require("lostTemple.lostTempleCombatLogic")
|
|
|
local SkinExcel = require("excel.skin")
|
|
|
local BattleLogic = require("battle.BattleLogic")
|
|
|
local HeroExclusiveWeapon = require("hero.HeroExclusiveWeapon")
|
|
|
+local ItemConfig = require("excel.item").item
|
|
|
+local ElfLogic = require("elf.ElfLogic")
|
|
|
|
|
|
-- 用于在切磋时取目标玩家db数据中的计算属性数据, 如果在 RoleAttr.calcHeroGrid中用到了,需要加到这个里面
|
|
|
FieldsCombat = {
|
|
|
lv = 1, name = 1, head = 1, headFrame = 1, unionUuid = 1, lastLogoutTime = 1,
|
|
|
combatHero = 1, heroBag = 1, moshou = 1, technology=1, chengjiu=1, realmLv = 1, talismanData = 1,
|
|
|
headList = 1, headFrameList = 1, bodyList = 1, chenghaoList = 1,animationList =1,backgroundList =1,
|
|
|
- skinBag = 1, relic = 1, heroPubData = 1,
|
|
|
+ skinBag = 1, relic = 1, heroPubData = 1, elfData = 1,
|
|
|
}
|
|
|
|
|
|
COMBAT_CACHE = COMBAT_CACHE or {}
|
|
|
@@ -160,11 +162,11 @@ function getCombatObjList(human, side, combatType, args)
|
|
|
if type(args) == "table" then
|
|
|
if side == CombatDefine.ATTACK_SIDE then
|
|
|
if args.attacker then
|
|
|
- return args.attacker, args.atkHelp, args.atkRBase, args.atkFormation,args.atkJiban
|
|
|
+ return args.attacker, args.atkHelp, args.atkRBase, args.atkFormation,args.atkJiban,args.atkElfList
|
|
|
end
|
|
|
else
|
|
|
if args.defender then
|
|
|
- return args.defender, args.defHelp, args.defRBase, args.defFormation,args.defJiban
|
|
|
+ return args.defender, args.defHelp, args.defRBase, args.defFormation,args.defJiban, args.defElfList
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
@@ -172,19 +174,19 @@ function getCombatObjList(human, side, combatType, args)
|
|
|
if not moduleFn then return end
|
|
|
|
|
|
if moduleFn.getCombatObjList then
|
|
|
- local objList, helpList, rolebase, formation,jiban = moduleFn.getCombatObjList(human, side, args, combatType)
|
|
|
+ local objList, helpList, rolebase, formation,jiban, elfList = moduleFn.getCombatObjList(human, side, args, combatType)
|
|
|
if objList then
|
|
|
- return objList, helpList, rolebase ,formation,jiban
|
|
|
+ return objList, helpList, rolebase ,formation,jiban, elfList
|
|
|
end
|
|
|
end
|
|
|
|
|
|
local monsterOutID, zhandouli = getCombatMonsterOutID(human, side, combatType, args)
|
|
|
if monsterOutID then
|
|
|
- local objList, helpList, rolebase, formation, jiban = getMonsterObjList(monsterOutID, nil, args)
|
|
|
+ local objList, helpList, rolebase, formation, jiban, elfList = getMonsterObjList(monsterOutID, nil, args)
|
|
|
if zhandouli then
|
|
|
rolebase.zhandouli = zhandouli
|
|
|
end
|
|
|
- return objList, helpList, rolebase,formation,jiban
|
|
|
+ return objList, helpList, rolebase,formation,jiban, elfList
|
|
|
end
|
|
|
|
|
|
if moduleFn.getHumanObjList then
|
|
|
@@ -280,6 +282,20 @@ function getPos(side, index)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+-- 通过位置确定阵营
|
|
|
+function getSideByPos(helpType, pos)
|
|
|
+ if helpType == CombatDefine.HELP_TYPE0 then
|
|
|
+ return pos > CombatDefine.COMBAT_HERO_CNT and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
|
|
|
+ elseif helpType == CombatDefine.HELP_TYPE1 then
|
|
|
+ return pos >= CombatDefine.PET_DEFPOS and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
|
|
|
+ elseif helpType == CombatDefine.HELP_TYPE2 then
|
|
|
+ local atkElfMaxPos = CombatDefine.COMBAT_HERO_ALL_CNT + CombatDefine.COMBAT_HELP_ALL_CNT + CombatDefine.COMBAT_ELF_CNT
|
|
|
+ return pos > atkElfMaxPos and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
|
|
|
+ else
|
|
|
+ assert(false, "helpType 错误")
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
function getIndexByPos(side, pos)
|
|
|
if side == CombatDefine.ATTACK_SIDE then
|
|
|
return pos
|
|
|
@@ -526,6 +542,29 @@ function getMonsterObjList(monsterOutID, objType, args)
|
|
|
return objList, nil, rolebase,formation,jiban
|
|
|
end
|
|
|
|
|
|
+-- 创建战斗精灵对象
|
|
|
+function createElfObj(human, elfId, pos)
|
|
|
+ local itemCfg = ItemConfig[elfId]
|
|
|
+ local elfObj = {}
|
|
|
+ elfObj.id = elfId
|
|
|
+ elfObj.isElf = true
|
|
|
+ elfObj.head = itemCfg and itemCfg.icon or 0
|
|
|
+ elfObj.body = itemCfg and itemCfg.icon or 0
|
|
|
+
|
|
|
+ elfObj.attrs = {}
|
|
|
+
|
|
|
+ local skillId = ElfLogic.GetElfSkill(human, elfId)
|
|
|
+ local skillCfg = Skill.GetSkillConfig(skillId)
|
|
|
+ if not skillCfg then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ elfObj.skillList = {
|
|
|
+ [1] = {skillId, pos, skillCfg.cd[2] or 0 }
|
|
|
+ }
|
|
|
+
|
|
|
+ return elfObj
|
|
|
+end
|
|
|
|
|
|
-- 获取human出战英雄列表 objList, helpList, rolebase, formation
|
|
|
function getHumanObjList(human, combatType)
|
|
|
@@ -552,7 +591,21 @@ function getHumanObjList(human, combatType)
|
|
|
local pet = MoshouLogic.createCombatMoshow(human,combatType)
|
|
|
helpList[CombatDefine.HELP_TYPE1] = pet
|
|
|
local rolebase = createRoleBaseByDB(human.db, zhandouli)
|
|
|
- return objList, helpList, rolebase,formation,jiban
|
|
|
+
|
|
|
+ -- 精灵
|
|
|
+ local combatElf = combatHeroDB.elfList
|
|
|
+ local elfList = {}
|
|
|
+ if combatElf then
|
|
|
+ for i=1, CombatDefine.COMBAT_ELF_CNT do
|
|
|
+ local elfId = combatElf[i]
|
|
|
+ local elfObj = createElfObj(human, elfId, i)
|
|
|
+ if elfObj then
|
|
|
+ elfList[i] = elfObj
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ return objList, helpList, rolebase,formation,jiban, elfList
|
|
|
end
|
|
|
|
|
|
|
|
|
@@ -668,6 +721,33 @@ function fontCombatHelpNet(net, help)
|
|
|
end
|
|
|
|
|
|
|
|
|
+-- 封装辅助对象
|
|
|
+function fontCombatElfpNet(net, elf)
|
|
|
+ net.pos = elf.pos
|
|
|
+ net.id = elf.id or 0
|
|
|
+ net.head = elf.head or 0
|
|
|
+ net.body = elf.body or 0
|
|
|
+
|
|
|
+ net.skill[0] = 0
|
|
|
+ local skillId = elf.skillList[1][1]
|
|
|
+ local skillConfig = Skill.GetSkillConfig(skillId)
|
|
|
+ if skillConfig then
|
|
|
+ net.skill[1].id = skillId
|
|
|
+ net.skill[1].icon = skillConfig.icon
|
|
|
+ net.skill[1].name = skillConfig.name
|
|
|
+ net.skill[1].desc = skillConfig.desc
|
|
|
+ net.skill[1].lv = skillConfig.skillLV or 0
|
|
|
+ net.skill[1].index = 0
|
|
|
+ net.skill[1].state = 2
|
|
|
+ net.skill[0] = 1
|
|
|
+ end
|
|
|
+
|
|
|
+ net.args[0] = 0
|
|
|
+ return true
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
-- 封装战斗技能信息
|
|
|
function fontCombatSkillNet(skillNet, skillID)
|
|
|
--local skillConfig = SkillExcel.skill[skillID]
|
|
|
@@ -797,7 +877,14 @@ local function sendCombatBegin(human, combatInfo, isLogin)
|
|
|
if fontCombatHelpNet(msgRet.helps[msgRet.helps[0] + 1], help) then
|
|
|
msgRet.helps[0] = msgRet.helps[0] + 1
|
|
|
end
|
|
|
- end
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, elf in pairs(combatInfo.elfList or {}) do
|
|
|
+ if fontCombatElfpNet(msgRet.helps[msgRet.helps[0] + 1], elf) then
|
|
|
+ msgRet.helps[0] = msgRet.helps[0] + 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
msgRet.skillList[0] = 0
|
|
|
for skillID in pairs(combatInfo.skillUseList) do
|
|
|
if fontCombatSkillNet(msgRet.skillList[msgRet.skillList[0] + 1], skillID) then
|
|
|
@@ -1115,6 +1202,21 @@ local function getMonsterBossName(param)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+-- 从某方战斗英雄阵容中获取某个属性的最大值
|
|
|
+local function getHeroAttrMaxVal(side, attrId)
|
|
|
+ local maxVal = 0
|
|
|
+ for _, pos in ipairs(CombatDefine.SIDE2POS[side]) do
|
|
|
+ local obj = CombatImpl.objList[pos]
|
|
|
+ if obj then
|
|
|
+ local attrVal = CombatObj.getValue(obj,attrId)
|
|
|
+ if attrVal > maxVal then
|
|
|
+ maxVal = attrVal
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ return maxVal
|
|
|
+end
|
|
|
+
|
|
|
-- 在各种战前加成后,重新设置血量
|
|
|
function recalcHpFightBegin(human, combatType, cbParam)
|
|
|
for i = 1,CombatDefine.COMBAT_HERO_CNT do
|
|
|
@@ -1158,6 +1260,46 @@ function recalcHpFightBegin(human, combatType, cbParam)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+
|
|
|
+-- 精灵继承英雄属性列表, key为属性Id, value为继承属性值的倍数
|
|
|
+local inheritAttrList = {
|
|
|
+ [RoleDefine.ATK] = 1,
|
|
|
+}
|
|
|
+-- 精灵继承英雄部分属性
|
|
|
+function ElfInheritHeroAttr()
|
|
|
+ local attrList = {}
|
|
|
+
|
|
|
+ local function genAttrVal()
|
|
|
+ for attrId, mul in pairs(inheritAttrList) do
|
|
|
+ attrList[attrId] = { [CombatDefine.ATTACK_SIDE] = 0, [CombatDefine.DEFEND_SIDE] = 0,}
|
|
|
+ local atkMaxVal = getHeroAttrMaxVal(CombatDefine.ATTACK_SIDE, attrId)
|
|
|
+ local defMaxVal = getHeroAttrMaxVal(CombatDefine.DEFEND_SIDE, attrId)
|
|
|
+ attrList[attrId][CombatDefine.ATTACK_SIDE] = atkMaxVal * mul
|
|
|
+ attrList[attrId][CombatDefine.DEFEND_SIDE] = defMaxVal * mul
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ local function updateELfAttr(elfObj, side)
|
|
|
+ for attrId, valData in pairs(attrList) do
|
|
|
+ CombatObj.updateValue(elfObj, attrId, valData[side] or 0)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, pos in ipairs(CombatDefine.SIDE2ELFPOS[CombatDefine.ALL]) do
|
|
|
+ local elfObj = CombatImpl.elfList[pos]
|
|
|
+ if elfObj then
|
|
|
+ if next(inheritAttrList) and not next(attrList) then
|
|
|
+ genAttrVal()
|
|
|
+ end
|
|
|
+
|
|
|
+ local elfSide = getSideByPos(CombatDefine.HELP_TYPE2, pos)
|
|
|
+ updateELfAttr(elfObj, elfSide)
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
--战前加属性(包括各系统,被动技能,阵营光环)
|
|
|
function onFightBegin(human, combatType, cbParam, param)
|
|
|
local moduleFn = getModule(combatType)
|
|
|
@@ -1169,6 +1311,7 @@ function onFightBegin(human, combatType, cbParam, param)
|
|
|
SkinLogic.onFightBegin(human) -- 处理皮肤属性
|
|
|
CombatPosLogic.onFightBegin(human)
|
|
|
recalcHpFightBegin(human, combatType, cbParam)
|
|
|
+ ElfInheritHeroAttr()
|
|
|
end
|
|
|
|
|
|
|
|
|
@@ -1202,6 +1345,21 @@ local function setHelp(helpList, side)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+-- 设置精灵出战
|
|
|
+local function setElf(elfList, side)
|
|
|
+ if not elfList or not next(elfList) then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ for index = 1, CombatDefine.COMBAT_ELF_CNT do
|
|
|
+ local elfObj = elfList[index]
|
|
|
+ if elfObj then
|
|
|
+ local pos = CombatDefine.SIDE2ELFPOS[side][index]
|
|
|
+ CombatImpl.setElf(pos, elfObj)
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
-- 初始combatInfo
|
|
|
local function initCombatInfo(human, combatType, mapID)
|
|
|
local combatInfo = {}
|
|
|
@@ -1222,6 +1380,7 @@ local function initCombatInfo(human, combatType, mapID)
|
|
|
combatInfo.bufferUseList = nil -- 战斗buff
|
|
|
combatInfo.objList = nil -- 战斗英雄列表
|
|
|
combatInfo.helpList = nil -- 战斗魔兽列表
|
|
|
+ combatInfo.elfList = nil -- 战斗精灵列表
|
|
|
combatInfo.rewardItem = {} -- 奖励
|
|
|
combatInfo.endParam = nil -- 额外参数
|
|
|
combatInfo.isVideo = nil -- 是否录像
|
|
|
@@ -1243,6 +1402,7 @@ local function copyToCombatInfo(combatInfo)
|
|
|
combatInfo.bufferUseList = Util.copyTable(CombatImpl.bufferUseList)
|
|
|
combatInfo.objList = Util.copyTable(CombatImpl.objList)
|
|
|
combatInfo.helpList = Util.copyTable(CombatImpl.helpList)
|
|
|
+ combatInfo.elfList = Util.copyTable(CombatImpl.elfList)
|
|
|
combatInfo.totalAtkCnt = CombatImpl.totalAtkCnt
|
|
|
end
|
|
|
|
|
|
@@ -1265,10 +1425,10 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
|
|
|
-- 获得地图ID
|
|
|
CombatImpl.init(combatType)
|
|
|
mapID = getMapID(human, combatType, param)
|
|
|
- local defender, defHelp, defRBase,defFormation,defJiban = getCombatObjList(human, CombatDefine.DEFEND_SIDE, combatType, param)
|
|
|
- local attacker, atkHelp, atkRBase, atkFormation,atkJiban
|
|
|
+ local defender, defHelp, defRBase,defFormation,defJiban, defElfList = getCombatObjList(human, CombatDefine.DEFEND_SIDE, combatType, param)
|
|
|
+ local attacker, atkHelp, atkRBase, atkFormation,atkJiban, atkElfList
|
|
|
if defender then
|
|
|
- attacker, atkHelp, atkRBase, atkFormation,atkJiban = getCombatObjList(human, CombatDefine.ATTACK_SIDE, combatType, param)
|
|
|
+ attacker, atkHelp, atkRBase, atkFormation,atkJiban, atkElfList = getCombatObjList(human, CombatDefine.ATTACK_SIDE, combatType, param)
|
|
|
end
|
|
|
|
|
|
if not (attacker and next(attacker)) then
|
|
|
@@ -1317,6 +1477,10 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
|
|
|
setCombatInfo(defFormation, defender, CombatDefine.DEFEND_SIDE)
|
|
|
setHelp(atkHelp, CombatDefine.ATTACK_SIDE)
|
|
|
setHelp(defHelp, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
+ setElf(atkElfList, CombatDefine.ATTACK_SIDE)
|
|
|
+ setElf(defElfList, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
CombatImpl.setMaxRound(combatInfo.maxRound)
|
|
|
CombatImpl.setFightMode(combatInfo.fightMode)
|
|
|
--需要对技能特殊处理的(比如不重置cd)
|
|
|
@@ -1376,6 +1540,10 @@ function combatGm(human,mapID,atkFormation,attacker,defFormation,defender,atkPet
|
|
|
setCombatInfo(defFormation,defender, CombatDefine.DEFEND_SIDE)
|
|
|
setHelp({atkPet}, CombatDefine.ATTACK_SIDE)
|
|
|
setHelp({defPet}, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
+ setElf({}, CombatDefine.ATTACK_SIDE)
|
|
|
+ setElf({}, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
combatInfo.maxRound = getMaxRound(human,combatType)
|
|
|
CombatImpl.setMaxRound(combatInfo.maxRound)
|
|
|
CombatImpl.setFightMode(combatInfo.fightMode)
|
|
|
@@ -1416,6 +1584,10 @@ function combatGuide(human, atkFormation,attacker,defFormation,defender,atkPet,d
|
|
|
setCombatInfo(defFormation,defender, CombatDefine.DEFEND_SIDE)
|
|
|
setHelp({atkPet}, CombatDefine.ATTACK_SIDE)
|
|
|
setHelp({defPet}, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
+ setElf({}, CombatDefine.ATTACK_SIDE)
|
|
|
+ setElf({}, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
combatInfo.maxRound = getMaxRound(human, combatType)
|
|
|
CombatImpl.setMaxRound(combatInfo.maxRound)
|
|
|
CombatImpl.setFightMode(combatInfo.fightMode)
|
|
|
@@ -1453,6 +1625,10 @@ function combatVedio(human, atkFormation, attacker,defFormation,defender,atkPet,
|
|
|
setCombatInfo(defFormation,defender, CombatDefine.DEFEND_SIDE)
|
|
|
setHelp({atkPet}, CombatDefine.ATTACK_SIDE)
|
|
|
setHelp({defPet}, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
+ setElf({}, CombatDefine.ATTACK_SIDE)
|
|
|
+ setElf({}, CombatDefine.DEFEND_SIDE)
|
|
|
+
|
|
|
combatInfo.maxRound = getMaxRound(human, combatType)
|
|
|
CombatImpl.setMaxRound(combatInfo.maxRound)
|
|
|
CombatImpl.setFightMode(combatInfo.fightMode)
|