diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index d1229edf0..0860b251c 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -1915,7 +1915,7 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = skill:GetDirectTargets() + local list = skill:GetDirectTargetsNoMiss() if list then for i = 1, #list do list[i]:AddRage(i1, CountTypeName.Sub) @@ -2265,7 +2265,7 @@ local passivityList = { -- 普攻后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local list = skill:GetDirectTargets() + local list = skill:GetDirectTargetsNoMiss() if list then for _, r in ipairs(list) do r:AddRage(i1, CountTypeName.Sub) @@ -2467,7 +2467,7 @@ local passivityList = { -- 普攻后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local list = skill:GetDirectTargets() + local list = skill:GetDirectTargetsNoMiss() if list then local attack = role:GetRoleData(RoleDataName.Attack) local damage = floor(BattleUtil.ErrorCorrection(attack * 0.2)) @@ -2510,7 +2510,7 @@ local passivityList = { -- 技能后后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = skill:GetDirectTargets() + local list = skill:GetDirectTargetsNoMiss() if list then local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) for _, r in ipairs(list) do @@ -2533,7 +2533,7 @@ local passivityList = { -- 技能后后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local list = skill:GetDirectTargets() + local list = skill:GetDirectTargetsNoMiss() if list then local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) for _, r in ipairs(list) do @@ -2871,7 +2871,7 @@ local passivityList = { -- 技能后后 local onSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - local targets = skill:GetDirectTargets() + local targets = skill:GetDirectTargetsNoMiss() if targets then for _, r in ipairs(targets) do BattleUtil.RandomControl(f1, ctrl, role, r, i1) @@ -3416,7 +3416,7 @@ local passivityList = { local function onSkillCastEnd(skill) -- 对每个目标附加减伤盾 - local targets = skill:GetDirectTargets() + local targets = skill:GetDirectTargetsNoMiss() if targets and #targets == 1 then targets[1]:AddRage(i1, CountTypeName.Sub) end @@ -3523,7 +3523,7 @@ local passivityList = { local chooseId = effectGroup.chooseId local chooseLimit = floor(chooseId / 10000) % 10 if chooseLimit == 3 then -- 打纵列 - local targets = skill:GetDirectTargets() + local targets = skill:GetDirectTargetsNoMiss() if targets then for _, r in ipairs(targets) do r:AddRage(i1, CountTypeName.Sub) diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index c70d8b23e..9233ff7c5 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -10,7 +10,7 @@ local effectPool = BattleObjectPool.New(function () return { type = 0, args = {}} -- type, {args, ...} end) local effectGroupPool = BattleObjectPool.New(function () - return { chooseId = 0, duration = 0, effects = {}} -- chooseId, duration, {effect1, effect2, ...} + return { chooseId = 0, effects = {}} -- chooseId, {effect1, effect2, ...} end) Skill = {} @@ -25,31 +25,32 @@ end function Skill:Init(role, effectData, type, targets, isAdd, isRage) --type 0 异妖 1 点技 2 滑技 local isTeamSkill = type == 0 self.type = type - --skill = {技能ID, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...} + --skill = {技能ID, 命中时间, 持续时间, 伤害次数, {目标id1, 效果1, 效果2, ...},{目标id2, 效果3, 效果4, ...}, ...} --效果 = {效果类型id, 效果参数1, 效果参数2, ...} self.effectList:Clear() self.owner = role self.isTeamSkill = isTeamSkill self.teamSkillType = isTeamSkill and floor(effectData[1] / 100) or 0 self.id = effectData[1] -- 技能ID - -- self.EffectDuration = 0 -- 效果命中需要的时间 + self.hitTime = effectData[2] -- 效果命中需要的时间 + self.continueTime = effectData[3] -- 命中后伤害持续时间 + self.attackCount = effectData[4] -- 伤害持续时间内伤害次数 self.targets = targets or {} self.isAdd = isAdd self.isRage = isRage - for i=2, #effectData do + for i=5, #effectData do local v = effectData[i] - local effectGroup = effectGroupPool:Get() -- chooseId, duration, {effect1, effect2, ...} + local effectGroup = effectGroupPool:Get() -- chooseId, {effect1, effect2, ...} effectGroup.chooseId = v[1] --chooseId - effectGroup.duration = v[2] --duration - for j=3, #v do --effectList + for j=2, #v do -- effectList local effect = effectPool:Get() -- type, {args, ...} effect.type = v[j][1] for k=2, #v[j] do effect.args[k-1] = v[j][k] end - effectGroup.effects[j-2] = effect + effectGroup.effects[j-1] = effect end self.effectList:Add(effectGroup) end @@ -71,12 +72,11 @@ function Skill:Dispose() end end -local function takeEffect(caster, target, effects, duration, skill) - for k=1, #effects do +local function DoEffect(caster, target, eff, duration, skill) local e = {type = 0, args = {}} - e.type = effects[k].type - for i=1, #effects[k].args do - e.args[i] = effects[k].args[i] + e.type = eff.type + for i=1, #eff.args do + e.args[i] = eff.args[i] end -- 检测被动技能对技能参数的影响 @@ -100,6 +100,17 @@ local function takeEffect(caster, target, effects, duration, skill) ) end end +function Skill:takeEffect(caster, target, effects, effectIndex, duration, skill) + for k=1, #effects do + -- 如果不是第一个效果对列的第一个效果则判断是否命中 + if k ~= 1 and effectIndex == 1 then + if self:CheckTargetIsHit(target) then + DoEffect(caster, target, effects[k], duration, skill) + end + else + DoEffect(caster, target, effects[k], duration, skill) + end + end end -- 释放技能 @@ -107,7 +118,7 @@ end function Skill:Cast(func) self.castDoneFunc = func self.effectTargets = {} - + self.targetIsHit = {} -- 先计算出技能的目标 for i=1, self.effectList.size do -- 是否重新选择目标 @@ -153,7 +164,6 @@ function Skill:Cast(func) if arr and #arr > 0 then --效果延迟1帧生效 BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function() - local duration = effectGroup.duration local effects = effectGroup.effects local weight = floor(chooseId % 10000 / 100) local count = min(chooseId % 10, #arr) @@ -163,7 +173,20 @@ function Skill:Cast(func) -- 全部同时生效 for j=1, count do if arr[j] and not arr[j]:IsRealDead() then - takeEffect(self.owner, arr[j], effects, duration, self) + -- 检测是否命中 + if i == 1 then + self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.owner, arr[j]) + end + self:takeEffect(self.owner, arr[j], effects, i, self.hitTime, self) + -- if i == 1 then + -- self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.owner, arr[j]) + -- takeEffect(self.owner, arr[j], effects, self.hitTime, self) + -- else + -- -- 未命中的目标不会产生后续技能效果 + -- if self:CheckTargetIsHit(arr[j]) then + -- takeEffect(self.owner, arr[j], effects, self.hitTime, self) + -- end + -- end end end end) @@ -182,10 +205,7 @@ function Skill:Cast(func) tr.Event:DispatchEvent(BattleEventName.BeSkillCast, self) end --技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个 - local duration = 0 - for i=1, self.effectList.size do - duration = max(duration, self.effectList.buffer[i].duration) - end + local duration = self.hitTime + self.continueTime -- 结算时间向后延长0.2秒,避免在效果结算完成前就结束了技能释放 BattleLogic.WaitForTrigger(duration + 0.2, function() self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) @@ -202,10 +222,20 @@ function Skill:Cast(func) end --- 获取技能的直接目标,和策划规定第一个效果的目标为直接效果目标 +-- 获取技能的直接目标,和策划规定第一个效果的目标为直接效果目标,(包含miss的目标) function Skill:GetDirectTargets() return self.effectTargets[1] end +-- 获取直接目标,不包含miss的目标,可能为空 +function Skill:GetDirectTargetsNoMiss() + local list = {} + for _, role in ipairs(self.effectTargets[1]) do + if self.CheckTargetIsHit(role) then + table.insert(list, role) + end + end + return list +end -- 获取技能目标最大人数 function Skill:GetMaxTargetNum() local mainEffect = self.effectList.buffer[1] @@ -214,6 +244,10 @@ function Skill:GetMaxTargetNum() end return BattleUtil.GetMaxTargetNum(mainEffect.chooseId) end +-- 判断是否命中 +function Skill:CheckTargetIsHit(role) + return self.targetIsHit[role] +end -- 结束技能 function Skill:EndSkill() diff --git a/luafight/Modules/Battle/Logic/BattleLogManager.lua b/luafight/Modules/Battle/Logic/BattleLogManager.lua index 9abc0647f..a80a96dd4 100644 --- a/luafight/Modules/Battle/Logic/BattleLogManager.lua +++ b/luafight/Modules/Battle/Logic/BattleLogManager.lua @@ -1,6 +1,6 @@ BattleLogManager = {} local this = BattleLogManager -local isLog = true +local isLog = false local function pairsByKeys(t) local a = {} diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index 154311e79..bd991d9f8 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -210,10 +210,11 @@ function BattleLogic.TurnRound(debugTurn) "position", CurSkillPos[CurCamp] ) + -- buff计算 + BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 + BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) -- 如果角色无法释放技能 if not SkillRole:IsAvailable() then - BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 - BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 @@ -224,8 +225,8 @@ function BattleLogic.TurnRound(debugTurn) -- 行动 SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnStart, SkillRole) -- 开始行动 BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnStart, SkillRole) -- 开始行动 - BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 - BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) + -- BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 + -- BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) -- 释放技能后,递归交换阵营 SkillRole:CastSkill(function() BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 1e567782b..65b7122ec 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -50,6 +50,8 @@ BattleEventName = { FinalDamage = indexAdd(), FinalBeDamage = indexAdd(), + HitMiss = indexAdd(), + BeHitMiss = indexAdd(), CritDamageReduceFactor = indexAdd(), -- 暴击伤害减免系数 SkillCast = indexAdd(), -- 技能攻击前 diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 3d52d17cd..dec6fc17c 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -383,7 +383,15 @@ end --执行完整的命中,伤害,暴击计算,返回命中,暴击 --skill造成伤害的技能 atkRole攻击者 defRole受击者 damageType伤害类型 baseFactor伤害系数 ignoreDef无视防御参数 dotType是持续伤害类型 function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, ignoreDef, dotType) - if atkRole.isTeam and not defRole:IsDead() then --如果是队伍技能,计算真实伤害,则damageType为伤害值 + -- 判断是否命中 + if skill and not skill:CheckTargetIsHit(defRole) then + BattleLogic.Event:DispatchEvent(BattleEventName.HitMiss, atkRole, defRole, skill) + atkRole.Event:DispatchEvent(BattleEventName.HitMiss, defRole, skill) + defRole.Event:DispatchEvent(BattleEventName.BeHitMiss, atkRole, skill) + return 0 + end + -- 如果是队伍技能,计算真实伤害,则damageType为伤害值 + if atkRole.isTeam and not defRole:IsDead() then return BattleUtil.ApplyDamage(skill, atkRole, defRole, damageType), false end @@ -526,6 +534,15 @@ end +-- 检测命中 +function BattleUtil.CheckIsHit(atkRole, defRole) + -- 是否命中: 命中 = 自身命中率 - 对方闪避率 + local isHit = false + local hitRandom = Random.Range01() + local hitCondition = clamp(atkRole:GetRoleData(RoleDataName.Hit) - defRole:GetRoleData(RoleDataName.Dodge), 0, 1) + isHit = hitRandom <= hitCondition + return isHit +end function BattleUtil.RandomAction(rand, action) if Random.Range01() <= rand and action then