Ver Fonte

添加注释和新增两个选取操作

mafei há 1 ano atrás
pai
commit
a4feddaf3c

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

@@ -19,7 +19,7 @@ local HeroDefine = require("hero.HeroDefine")
 
 local tbFuwenSkillGroupID = {}
 local posSortBySpeed = posSortBySpeed or {}
-
+-- beskill 阵法技能和符文相关 @mafei
 function initBeSkill(obj)
 	obj.beSkillList = {}
 	obj.beSkillListTemp = {}

+ 9 - 0
script/module/combat/CombatImpl.lua

@@ -36,6 +36,12 @@ isFanji			= false
 comboType       = 0
 isPVP           = 0
 comboHurtRate   = 0
+--[[
+	commonArgs = {
+		type -- 战斗类型
+		hpLimit -- 血量上限,默认为角色HP,对应特定关卡
+	}
+]]
 commonArgs		= commonArgs or {}
 comboList       = comboList or {}
 beSkillPosUseList = beSkillPosUseList or {}	--友军技能使用列表
@@ -386,6 +392,7 @@ function onRoundBegin()
 	beforeCombat()
 	BeSkill.onRoundBegin(round)
 	initAttackOrder()
+	--每回合开始处理buff
 	if #frameBufferList > 0 or #frameSayList > 0 then
 		addFrame()
 		mergeFrameBuffer()
@@ -674,6 +681,7 @@ local function afterCombo()
 end
 
 function calcFrame()
+	-- 没有能出手的人,开始下一个回合
 	if not attackOrder[1] then
 		onRoundBegin()
 	end
@@ -692,6 +700,7 @@ function calcFrame()
 	beforeCombat()
 	local attacker = attackOrder[1]
 	if attacker then
+		-- 目前mpAtkRate 永远为nil
 		local skillID,mpAtkRate = getSkillID(attacker)
     	-- buff作用效果
         --skillID = 10131

+ 17 - 4
script/module/combat/CombatLogic.lua

@@ -160,9 +160,10 @@ function getCombatObjList(human, side, combatType, args)
 			end
 		end
 	end
+	-- 获取战斗模块组件
 	local moduleFn = getModule(combatType)
 	if not moduleFn then return end
-
+	-- 模块有对应获取战斗对象的方法 ,有则调用
 	if moduleFn.getCombatObjList then
 		local objList, helpList, rolebase, formation,jiban = moduleFn.getCombatObjList(human, side, args, combatType)
 		if objList then 
@@ -170,6 +171,7 @@ function getCombatObjList(human, side, combatType, args)
 		end
 	end
 
+
 	local monsterOutID, zhandouli = getCombatMonsterOutID(human, side, combatType, args)
 	if monsterOutID then
 		local objList, helpList, rolebase, formation, jiban = getMonsterObjList(monsterOutID, nil, args)
@@ -1184,7 +1186,7 @@ end
 
 --[[
 	@param1 : agent
-	@param2 : mapID //地图ID
+	@param2 : mapID 目前看来已经被遗弃了
 	@oaram3 : 对应参数
 	@param4 : 战斗类型
 ]]
@@ -1196,9 +1198,12 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
 		return
 	end
 
-    -- 获得地图ID
+    -- 初始化战斗实现类
     CombatImpl.init(combatType)
+	-- 获得地图ID
     mapID = getMapID(human, combatType, param)
+
+	-- 获取上阵列表
 	local defender, defHelp, defRBase,defFormation,defJiban = getCombatObjList(human, CombatDefine.DEFEND_SIDE, combatType, param)
 	local attacker, atkHelp, atkRBase, atkFormation,atkJiban
 	if defender then
@@ -1224,8 +1229,10 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
  	combatInfo.defHelp = defHelp or {}
  	combatInfo.defFormation = defFormation
 	combatInfo.defJiban = defJiban
+	-- 代码看来,种族属性功能还未实现 @mafei
 	combatInfo.posAttr[CombatDefine.ATTACK_SIDE] = CombatPosLogic.getPosAttr(attacker)
 	combatInfo.posAttr[CombatDefine.DEFEND_SIDE] = CombatPosLogic.getPosAttr(defender) 
+	-- 获取英雄列表的羁绊
 	combatInfo.jiban[CombatDefine.ATTACK_SIDE] = JibanLogic.getJiban(attacker,atkJiban)
 	combatInfo.jiban[CombatDefine.DEFEND_SIDE] = JibanLogic.getJiban(defender,defJiban) 
 	combatInfo.maxRound = getMaxRound(human,combatType)
@@ -1237,7 +1244,7 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
 	JibanLogic.setBeSkill(attacker,combatInfo.jiban[CombatDefine.ATTACK_SIDE])
 	JibanLogic.setBeSkill(defender,combatInfo.jiban[CombatDefine.DEFEND_SIDE])
 
-	
+	-- 遗迹五号位?
     local changePos = nil
     if combatType == CombatDefine.COMBAT_TYPE10 then
         for k,v in pairs(attacker) do
@@ -1247,11 +1254,15 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
             break
         end
     end
+	-- 将符合阵法的战斗对象封装到objList里面? 其他对象如何处理?
 	setCombatInfo(atkFormation, attacker, CombatDefine.ATTACK_SIDE)
 	setCombatInfo(defFormation, defender, CombatDefine.DEFEND_SIDE)
+	-- 设置援军
 	setHelp(atkHelp, CombatDefine.ATTACK_SIDE)
 	setHelp(defHelp, CombatDefine.DEFEND_SIDE)
+	-- 设置最大回合数
 	CombatImpl.setMaxRound(combatInfo.maxRound)
+	-- 设置战斗模式
 	CombatImpl.setFightMode(combatInfo.fightMode)
 	--需要对技能特殊处理的(比如不重置cd)
 	setSkillAndBeskill(human,combatInfo)
@@ -1262,9 +1273,11 @@ function combatBegin(human, mapID, param, combatType, cbParam, isSaodang)
         tempParam.cbParam = cbParam
         tempParam.changePos = changePos
     end
+	-- 战前准备(种族 阵法等开战触发),同步属性
 	onFightBegin(human, combatType, tempParam, param)
 	makeAttrLogStr(human)
 
+	-- 战斗开始
 	while CombatImpl.calcFrame() do end    
     copyToCombatInfo(combatInfo)
 

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

@@ -391,6 +391,7 @@ function getPosAttr(objList)
 end
 
 function onFightBegin(human)
+	-- 获取进攻方种族属性
 	local attrs1 = human.combat.posAttr[1]
 	if attrs1 then
 		for k,v in pairs(attrs1) do
@@ -404,6 +405,7 @@ function onFightBegin(human)
 		end
 	end
 	
+	-- 获取防御方种族属性
 	local attrs2 = human.combat.posAttr[2]
 	if attrs2 then
 		for k, v in pairs(attrs2) do

+ 14 - 1
script/module/combat/JibanLogic.lua

@@ -42,8 +42,21 @@ local function fontJibanInfo(net,id)
 end
 
 function initAfterHot()
-	FATHER2ID = {}
+	-- 同一father下的羁绊互斥
+	--[[
+		FATHER2ID = {
+			[jibanCfg.father] = {
+				jibanCfg.id,
+			} -- array
+		}
+	]]
+	FATHER2ID = {} 
 	HERO2ID = {}
+	--[[
+		temp = {
+			{jibanCfg.quality,jibanCfg.id},
+		} -- array
+	]]
 	local temp = {}
 
 

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

@@ -155,6 +155,7 @@ function attack(obj, targets, skillConfig)
     local totalHurt = 0 
     local limitHurt = 0
     local fenTanHurt = 0
+	-- 分摊技能操作
     if  skillConfig.otherArgs and skillConfig.otherArgs.hurtFenTan and skillConfig.otherArgs.hurtFenTan[1] == 1  then
         for index = 1, #targets do
 		   local target = targets[index]

+ 70 - 29
script/module/combat/TargetMode.lua

@@ -36,7 +36,7 @@ local function canTarget(obj)
 	end
 end
 
-function getObj(pos)
+local function getObj(pos)
     -- 不能直接取 援军对象
     if pos == CombatDefine.BACKUP_POS[1] or  pos == CombatDefine.BACKUP_POS[2] then return end
 
@@ -102,31 +102,15 @@ function getTargets(attacker, targetMode, skillTargets, cmdTargets, checkChaofen
     return ret
 end
 
-
-
--- 全体目标
---[[
-	@param2 = {
-		handlerID,
-		side    0: 全部双方  1:敌方 2: 己方
-		isSkillTarget  1:非 2:是;默认1
-		exclude        1: 否 2:是 和isSkillTarget关联,是skillTarget还是取非skillTarget	
-	}
-	@param3 = targetObjList 技能目标(所有目标)
-]]
-local function handler2(attacker,targetMode,skillTargets)
-	local targetSide = getTargetSide(attacker,targetMode)
-	-- 如果传入有skillTarget 优先使用技能所带的target集合
-	local isSkillTarget = targetMode[3] or 1
-	local exclude = targetMode[4] or 1
+local function getTargetList(side,isSkillTarget,exclude,skillTargets)
 	local targetList = {}
-	for _,pos in ipairs(CombatDefine.DEFAULT_TARGET_POS3[targetSide]) do
+	for _,pos in ipairs(CombatDefine.DEFAULT_TARGET_POS3[side]) do
 		local obj = getObj(pos)
 		if canTarget(obj) then 
 			targetList[#targetList+1] = obj
 		end
 	end
-	if isSkillTarget ~= 1 then
+	if isSkillTarget ~= 1 then 
 		local skillTargetList = {}
 		for _,obj in ipairs(skillTargets) do 
 			skillTargetList[#skillTargetList + 1] = obj
@@ -145,6 +129,25 @@ local function handler2(attacker,targetMode,skillTargets)
 			end
 		end
 	end
+	return targetList
+end
+
+-- 全体目标
+--[[
+	@param2 = {
+		handlerID,
+		side    0: 全部双方  1:敌方 2: 己方
+		isSkillTarget  1:非 2:是;默认1
+		exclude        1: 否 2:是 和isSkillTarget关联,是skillTarget还是取非skillTarget	
+	}
+	@param3 = targetObjList 技能目标(所有目标)
+]]
+local function handler2(attacker,targetMode,skillTargets)
+	local targetSide = getTargetSide(attacker,targetMode)
+	-- 如果传入有skillTarget 优先使用技能所带的target集合
+	local isSkillTarget = targetMode[3] or 1
+	local exclude = targetMode[4] or 1
+	local targetList = getTargetList(targetSide,isSkillTarget,exclude,skillTargets)
 	-- 转化为目标target
 	for _,obj in ipairs (targetList) do 
 		targets[#targets + 1] = obj
@@ -445,11 +448,7 @@ local function handler33(attacker,targetMode)
 
 end
 
-
-
------------------------------------- 未实现功能 分界线   ------------------------------------
-
--- 根据指定buff层数选择x个目标
+-- 根据自身指定buff层数选择x个目标
 --[[
 	@param2 = {
 		handlerID,
@@ -457,27 +456,69 @@ end
 		buffID    buff ID
 		count,    buff层数 默认为1
 		cnt,      选择几个目标 默认为1
+		isSkillTarget  1:非 2:是;默认1
+		exclude        1: 否 2:是 和isSkillTarget关联,是skillTarget还是取非skillTarget	
 	}
 ]]
 local function handler32(attacker, targetMode, skillTargets)
+	local buffID = assert(targetMode[3],"invalid config")
     local targetSide = getTargetSide(attacker,targetMode)
-
+	local isSkillTarget = targetMode[6] or 1
+	local exclude = targetMode[7] or 1
+	local targetList = getTargetList(targetSide,isSkillTarget,exclude,skillTargets)
+	local exist,buffLayer =  CombatBuff.isStatus(attacker,buffID)
+	if not exist then 
+		return
+	end
+	local count = buffLayer // (targetMode[4] or 1 )
+	local maxHit = targetMode[5] or 1
+	local hitObjMap = {}
+	-- 打乱targetList表
+	table.shuffle(targetList)
+	-- 筛选targets
+	while true do 
+		if #targetList <= 0 or count <= 0 then 
+			break	
+		end
+		local r = math.random(#targetList)
+		local obj = targetList[r]
+		hitObjMap[obj.pos] = hitObjMap[obj.pos] or 0
+		-- 如果有重复的obj应该也删除
+		if hitObjMap[obj.pos] >= maxHit then 
+			table.remove(targetList,r)
+		else 
+			hitObjMap[obj.pos] = hitObjMap[obj.pos] + 1
+			targets[#targets+1] = obj
+			count = count - 1
+		end
+	end
 end
 
 -- 复活x个单位
 --[[
-	@param = {
+	@param2 = {
 		handlerID,
 		side,
 		cnt,   选择复活的数量 默认为1
 	}
 ]]
-function handler21(attacker,targetMode)
+local function handler21(attacker,targetMode)
 	local cnt = targetMode[3] or 1
 	local targetSide = getTargetSide(attacker,targetMode)
-	
+	local targetList = getTargetList(targetSide,1)
+	table.shuffle(targetList)
+	for _,obj in ipairs(targetList) do 
+		-- 判断能否复活
+		if CombatBuff.canRevive(obj) then 
+			targets[#targets+1] = obj
+		end
+		if #targets >= cnt then 
+			break
+		end
+	end
 end
 
+------------------------------------ 未实现功能 分界线   ------------------------------------
 --技能目标(所有目标)
 function handler11(attacker,targetMode,skillTargets)
 	-- abandon

+ 6 - 0
script/module/friend/FriendLogic.lua

@@ -440,6 +440,12 @@ function getCombatObjList(human, side, args)
 end
 
 -- 好友切磋
+--[[
+	@param2 = {
+		uuid -- 目标角色uuid 
+		......
+	}
+]]
 function fight(human, args)
 	if not checkCombatPos(human, args) then
 		return