Ver código fonte

精灵战斗相关代码

gitxsm 6 meses atrás
pai
commit
5dda1dfe41

+ 2 - 2
script/module/combat/BeSkill.lua

@@ -561,7 +561,7 @@ local function use(attacker,targets,data,newFrame, packBuff, hitObj)
 end
 
 function onHit(attacker,targets,skillID)
-	if attacker.isPet then
+	if attacker.isPet or attacker.isElf then
 		return
 	end
 
@@ -1360,7 +1360,7 @@ function onRoundBegin(round)
 end
 
 function beforeFanji(obj, hitObj, isEnd)
-	if not obj or obj.isPet then
+	if not obj or obj.isPet or obj.isElf then
 		return 
 	end
 

+ 30 - 11
script/module/combat/CombatBuff.lua

@@ -45,7 +45,7 @@ end
 function isControlCmd(cmd)
 	if  cmd == "xuanyun" or cmd == "shihua" or cmd == "bingdong"
 		or cmd == "chanrao" or cmd == "xuanyun2" or cmd == "chenshui"
-		or cmd == "donghe" then
+		or cmd == "donghe" or cmd == "gandian" then
 		return true
 	end
 end
@@ -59,7 +59,7 @@ function isStop(obj)
 	local ret
 	if bufferCmd["xuanyun"] or bufferCmd["shihua"] or bufferCmd["bingdong"]
 		or bufferCmd["chanrao"] or bufferCmd["xuanyun2"] or bufferCmd["chenshui"]
-		or bufferCmd["donghe"] then
+		or bufferCmd["donghe"] or bufferCmd["gandian"] then
 
 		ret = 1
 	elseif bufferCmd["xuanyun"] or bufferCmd["xuanyun2"] then
@@ -79,7 +79,7 @@ function IsJustHaveChanraoBuff(obj)
 		return false
 	end
 	
-	if bufferCmd["xuanyun"] or bufferCmd["shihua"] or bufferCmd["bingdong"] or bufferCmd["xuanyun2"] or bufferCmd["donghe"] then
+	if bufferCmd["xuanyun"] or bufferCmd["shihua"] or bufferCmd["bingdong"] or bufferCmd["xuanyun2"] or bufferCmd["donghe"] or bufferCmd["gandian"] then
 		return false
 	end
 
@@ -232,6 +232,14 @@ function isMianyi(obj,cmd)
     end
 end
 
+-- 特殊的控制buff, 不受控率属性和抗控属性影响
+local sp_ctr_buff_list = {
+	["xuanyun2"] = true,
+	["donghe"] = true,
+	["gandian"] = true,
+}
+
+
 local function isMiankong(obj, cmd, attacker, skillKongRate)
     if not isControlCmd(cmd) then return end
     if not attacker then return end
@@ -251,7 +259,11 @@ local function isMiankong(obj, cmd, attacker, skillKongRate)
     kongRate = kongRate < 0 and 0 or kongRate
 
 
-	if cmd == "xuanyun2" or cmd == "donghe" then
+	-- if cmd == "xuanyun2" or cmd == "donghe" then
+	-- 	kongRate = skillKongRate
+	-- end
+
+	if sp_ctr_buff_list[cmd] then
 		kongRate = skillKongRate
 	end
 
@@ -369,7 +381,8 @@ function onBufferChange(obj)
         conf.cmd == "defRate" or 
         conf.cmd == "defRate2" or 
         conf.cmd == "attrQusan" or 
-		conf.cmd == "qianxing"	then
+		conf.cmd == "qianxing" or 
+		conf.cmd == "gandian" then
 
 			if type(buffer.arg) == "table" then
 				for j = 1,#buffer.arg do
@@ -905,10 +918,12 @@ function addBuffer(attackPos,obj, id, skillID,arg,parentConf)
 	end
 
 	local attacker
-	if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
-		attacker = CombatImpl.helpList[attackPos]
-	else
+	if attackPos <= CombatDefine.COMBAT_HERO_ALL_CNT then
 		attacker = CombatImpl.objList[attackPos]
+	elseif attackPos > CombatDefine.COMBAT_HERO_ALL_CNT and attackPos < CombatDefine.COMBAT_HERO_ALL_CNT + CombatDefine.COMBAT_HELP_ALL_CNT then
+		attacker = CombatImpl.helpList[attackPos]
+	elseif attackPos >= CombatDefine.ELF_MIN_POS then
+		attacker = CombatImpl.elfList[attackPos]
 	end
 	if arg then
 		buffer.arg = arg
@@ -1630,10 +1645,12 @@ local function chixuHurtDel2(target,buffer)
 	local conf = GetBuffConfig(buffer.id)
 	local attackPos = buffer.attackPos
 	local attacker
-	if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
-		attacker = CombatImpl.helpList[attackPos]
-	else
+	if attackPos <= CombatDefine.COMBAT_HERO_ALL_CNT then
 		attacker = CombatImpl.objList[attackPos]
+	elseif attackPos > CombatDefine.COMBAT_HERO_ALL_CNT and attackPos < CombatDefine.COMBAT_HERO_ALL_CNT + CombatDefine.COMBAT_HELP_ALL_CNT then
+		attacker = CombatImpl.helpList[attackPos]
+	elseif attackPos >= CombatDefine.ELF_MIN_POS then
+		attacker = CombatImpl.elfList[attackPos]
 	end
 	local isAddHp = conf.cmd == "hp"
 	buffer.arg = CombatCalc.calcBufferHp(attacker,target,id,isAddHp)
@@ -2308,5 +2325,7 @@ function onExtraCombatRecord(pos,value,param)
 		obj.extraCombatRecord.chenshui = (obj.extraCombatRecord.chenshui or 0) + value
 	elseif param == "donghe" then
 		obj.extraCombatRecord.donghe = (obj.extraCombatRecord.donghe or 0) + value
+	elseif param == "gandian" then
+		obj.extraCombatRecord.gandian = (obj.extraCombatRecord.gandian or 0) + value
 	end
 end

+ 8 - 1
script/module/combat/CombatCalc.lua

@@ -433,7 +433,7 @@ local function getExtraHurt(attacker, defender, skillConfig)
 end
 
 function initAttacker(attacker)
-    if attacker.isPet then
+    if attacker.isPet or attacker.isElf then
         return
     end
     attacker.isBaoji = nil
@@ -684,6 +684,13 @@ function calcHurt(attacker, index, targets, skillConfig)
         return attacker.hurt or skillConfig.hurtRate[1], 0
     end
 
+    -- 精灵技能
+    if skillConfig.type == CombatDefine.SKILL_TYPE77 then
+        local atk = CombatObj.getValue(attacker, RoleDefine.ATK)
+        return atk * (skillConfig.hurtRate[1] / 10000), 0
+    end
+
+
     if not skillConfig.otherArgs.absoluteHit and isShanbi(attacker, index, targets) then
         local flag = 0
         flag = Util.setBit(flag, CombatDefine.FLAG_SHANBI)

+ 76 - 12
script/module/combat/CombatImpl.lua

@@ -18,6 +18,7 @@ local SkillExcel = require("excel.skill").skill
 
 objList 		= objList or {}
 helpList		= helpList or {}
+elfList			= elfList or {}
 attackOrder		= attackOrder or {}		-- 出手次序 [index]->pos
 round 			= round or 1 			-- 当前回合
 attackIndex 	= attackIndex or 1 		-- 当前进攻对象的index
@@ -61,6 +62,7 @@ useZhuijiObjList = {} --本场战斗使用过追击的英雄列表
 function init(type)
 	Util.initTable(objList)
 	Util.initTable(helpList)
+	Util.initTable(elfList)
 	Util.initTable(attackOrder)
 	Util.initTable(result)
 	Util.initTable(skillUseList)
@@ -222,6 +224,20 @@ function setHelp(side,helpType,help)
 	helpList[pos] = obj
 end
 
+function setElf(pos, elf)
+	local elfObj = CombatObj.elfs[pos]
+	CombatObj.initElf(elfObj)
+
+	elfObj.id = elf.id
+	elfObj.body = elf.body or 0
+	elfObj.head = elf.head or 0
+	elfObj.quality = elf.quality or 1
+	elfObj.skillList = elf.skillList or {}
+	elfObj.beSkillList = elf.beSkillList or {}
+	elfList[pos] = elfObj
+end
+
+
 function setMaxRound(value)
 	maxRound = value
 end
@@ -244,20 +260,40 @@ end
 
 local function cmp(a,b)
 	if a.helpType ~= CombatDefine.HELP_TYPE0 or b.helpType ~= CombatDefine.HELP_TYPE0 then
+		-- if a.helpType == CombatDefine.HELP_TYPE0 then
+		-- 	return false
+		-- elseif b.helpType == CombatDefine.HELP_TYPE0 then
+		-- 	return true
+		-- else
+        --     local aSpeed = a.speed or 0
+	    --     local bSpeed = b.speed or 0
+	    --     if aSpeed > bSpeed then
+	    --     	return true
+	    --     elseif aSpeed == bSpeed then
+	    --     	return a.pos < b.pos
+	    --     else
+	    --     	return false
+	    --     end 
+		-- end
+
 		if a.helpType == CombatDefine.HELP_TYPE0 then
 			return false
 		elseif b.helpType == CombatDefine.HELP_TYPE0 then
 			return true
+		elseif a.helpType == CombatDefine.HELP_TYPE1 and b.helpType == CombatDefine.HELP_TYPE2 then
+			return true
+		elseif a.helpType == CombatDefine.HELP_TYPE2 and b.helpType == CombatDefine.HELP_TYPE1 then
+			return false
 		else
             local aSpeed = a.speed or 0
-	        local bSpeed = b.speed or 0
-	        if aSpeed > bSpeed then
-	        	return true
-	        elseif aSpeed == bSpeed then
-	        	return a.pos < b.pos
-	        else
-	        	return false
-	        end 
+			local bSpeed = b.speed or 0
+			if aSpeed > bSpeed then
+				return true
+			elseif aSpeed == bSpeed then
+				return a.pos < b.pos
+			else
+				return false
+			end
 		end
 	end
 	local aSpeed = getValue(a, RoleDefine.SPEED)
@@ -297,7 +333,13 @@ local function canAttack(obj)
 	elseif obj.helpType == CombatDefine.HELP_TYPE1 then
 		return petCD == 0
 	elseif obj.helpType == CombatDefine.HELP_TYPE2 then
-
+		for i = 1,#obj.skillList do
+			local skill = obj.skillList[i]
+			if (skill[3] == 0 or (skill[2] - round) % skill[3] == 0) and Skill.SkillCondCheck(obj, skill[1]) then
+				return true
+			end
+		end
+		return false
 	elseif obj.helpType == CombatDefine.HELP_TYPE3 then
 
 	elseif obj.helpType == CombatDefine.HELP_TYPE4 then
@@ -332,11 +374,24 @@ function initAttackOrder()
 
             obj.speed = nil
             if obj.side == atkSide then
-               obj.speed = atkSpeed
+				obj.speed = atkSpeed
+            end
+		end
+	end
+
+	-- 精灵
+	for _,pos in ipairs(CombatDefine.SIDE2ELFPOS[0]) do
+		local elfObj = elfList[pos]
+		if elfObj and canAttack(elfObj) then
+			attackOrder[#attackOrder + 1] = elfObj
+
+            if elfObj.side == atkSide then
+				elfObj.speed = atkSpeed
             end
 		end
 	end
 
+
 	table.sort(attackOrder,cmp)
 	firstAttack = {true,true}
 end
@@ -550,8 +605,15 @@ function getSkillID(obj)
 				break
 			end
 		end
-	elseif obj.helpType == CombatDefine.HELP_TYPE2 then
-
+	elseif obj.helpType == CombatDefine.HELP_TYPE2 then -- 精灵
+		for i = 1,#obj.skillList do
+			local skill = obj.skillList[i]
+			if (skill[3] == 0 or (skill[2] - round) % skill[3] == 0) and  Skill.SkillCondCheck(obj, skill[1]) then
+				skillID = skill[1]
+				skill[2] = round + skill[3]
+				break
+			end
+		end
 	elseif obj.helpType == CombatDefine.HELP_TYPE3 then
 
 	elseif obj.helpType == CombatDefine.HELP_TYPE4 then
@@ -1082,6 +1144,8 @@ function setObjResult(pos,value)
 		obj = helpList[pos]
 	elseif pos == CombatDefine.PET_DEFPOS then
 		obj = helpList[pos]
+	elseif CombatDefine.ELF_MIN_POS <= pos and CombatDefine.ELF_MAX_POS >= pos then
+		obj = elfList[pos]
 	end
 	if not obj then
 		return

+ 189 - 13
script/module/combat/CombatLogic.lua

@@ -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)

+ 50 - 0
script/module/combat/CombatObj.lua

@@ -10,6 +10,7 @@ local CombatImpl = require("combat.CombatImpl")
 
 objs	= objs or {} 		-- [pos]->obj
 helps	= helps or {}
+elfs 	= elfs or {}	-- 精灵
 
 
 side2AddTimes = {}
@@ -97,6 +98,29 @@ function initAfterStart()
 		help.extraCombatRecord = nil --战斗中额外统计的数据
 		help.isPet = help.helpType == 1
 	end
+
+	local elfPosStartVal = CombatDefine.COMBAT_HERO_ALL_CNT + CombatDefine.COMBAT_HELP_ALL_CNT
+	for pos = 1,CombatDefine.COMBAT_ELF_ALL_CNT do
+		local elfObj = {}
+		elfObj.attr = {}
+		RoleAttr.initCombatAttr(elfObj.attr)
+		-- elfObj.replaceAttr = {}	-- 把replaceAttr中值>0的属性替换到attr中
+		-- RoleAttr.initCombatAttr(elfObj.replaceAttr)
+		elfObj.helpType		= CombatDefine.HELP_TYPE2   -- 辅助对象类型 武将/魔兽
+		elfObj.pos = pos + elfPosStartVal
+		elfObj.id = nil
+		elfObj.head = 0
+		elfObj.body = 0
+		elfObj.quality = 0
+		elfObj.side = pos > CombatDefine.COMBAT_ELF_CNT and CombatDefine.DEFEND_SIDE or CombatDefine.ATTACK_SIDE
+		elfObj.skillList = nil
+		elfObj.beSkillList = nil
+		elfObj.result = {0,0,0,0}		--战斗中输出和治疗 承受伤害 出手回合数 汇总
+		elfObj.combatResult = {0,0,{},0,{}}	--每次攻击受到的伤害和治疗
+		elfObj.extraCombatRecord = nil --战斗中额外统计的数据
+		elfObj.isElf = true
+		elfs[elfObj.pos] = elfObj
+	end
 end
 
 function getObjByPos(pos)
@@ -197,6 +221,32 @@ function initHelp(help)
 	RoleAttr.initCombatAttr(help.attr) 	
 end
 
+function initElf(elfObj)
+	elfObj.id = nil
+	elfObj.skillList = nil
+	elfObj.beSkillList = nil
+
+	elfObj.quality = 0
+	elfObj.head = 0
+	elfObj.body = 0
+    elfObj.icon = 0
+	elfObj.result[1] = 0
+	elfObj.result[2] = 0
+	elfObj.result[3] = 0
+	elfObj.result[4] = 0
+	elfObj.combatResult[1] = 0
+	elfObj.combatResult[2] = 0
+	for k in pairs(elfObj.combatResult[3]) do
+		elfObj.combatResult[3][k] = nil 
+	end
+	for k in pairs(elfObj.combatResult[5]) do
+		elfObj.combatResult[5][k] = nil 
+	end
+	elfObj.extraCombatRecord = nil
+	RoleAttr.initCombatAttr(elfObj.attr)
+end
+
+
 function setInitAttr(obj, attr)
 	local initAttr = obj.initAttr
 	for key in pairs(initAttr) do

+ 2 - 2
script/module/combat/CombatPosLogic.lua

@@ -888,7 +888,7 @@ function Elf_Pos_Query(human, combatType)
 	for i=1, CombatDefine.COMBAT_ELF_NOW_CNT do
 		msgElfPosArr[i].elfId = 0
 		msgElfPosArr[i].nowSkillDesc = ""
-		msgElfPosArr[i].nowSkillIcon = 0
+		msgElfPosArr[i].nowSkillIcon = ""
 
 		if elfList and elfList[i] then
 			local elfId = elfList[i]
@@ -913,7 +913,7 @@ function Elf_Pos_Update(human, combatType, elfIdArr)
 	local ElfEecordTb = {}
 	for _ ,elfId in ipairs(elfIdArr) do
 		if elfId > 0 then
-			if not IsActivateElf(human, elfId) then
+			if not ElfLogic.IsActivateElf(human, elfId) then
 				return Broadcast.sendErr(human, Lang.ELF_NOT_ACTIVATE)
 			end
 

+ 2 - 2
script/module/combat/Proto.lua

@@ -203,7 +203,7 @@ GC_COMBAT_BEGIN = {
 	{"combatType",		1,		"byte"}, -- 战斗类型
 	{"keepTime",		1,		"short"},-- 服务端经过了多少时间
 	{"heros",			12,		CombatHeroNet}, 	-- 对战英雄信息(站位)
-	{"helps",			10,		CombatHelpNet}, 	-- 对战辅助对象信息(站位)
+	{"helps",			10,		CombatHelpNet}, 	-- 对战辅助对象信息(站位), 精灵数据也放这里, 目前两方辅助之和最多2个,两方精灵之和最多8个
 	{"mapID",			1,		"int"},				-- 战斗场景
 	{"skillList",		60,	    CombatSkillConf},	-- 战斗中使用过的技能
 	{"cmdList",			16,		CombatCmdConf},	    -- 战斗中使用过的作用
@@ -449,7 +449,7 @@ GC_HERO_UPDATE_ZDL = {
 ELF_POS_INFO = {
 	{"elfId",			1,		"int"},      	-- 精灵Id
 	{"nowSkillDesc",	1,		"string"},  	-- 当前技能说明
-	{"nowSkillIcon",	1,		"int"},  		-- 当前技能Icon
+	{"nowSkillIcon",	1,		"string"},  		-- 当前技能Icon
 }
 
 

+ 1 - 1
script/module/combat/Skill.lua

@@ -943,7 +943,7 @@ end
 
 function CMD.fanji(obj,skillConfig,skillTargets)
 	if CombatImpl.isFanji or CombatImpl.comboType > 0 then return end
-	if CombatBuff.isStatus(obj,{"xuanyun","shihua","bingdong", "xuanyun2", "chenshui", "donghe"}) then return end
+	if CombatBuff.isStatus(obj,{"xuanyun","shihua","bingdong", "xuanyun2", "chenshui", "donghe", "gandian"}) then return end
 	if obj.side == skillTargets[1].side then
 		return
 	end