From 9c7377e3d6a006d5dc1054a668580e4e7a7d4a49 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Fri, 3 Jul 2020 18:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E5=91=BD=E4=B8=AD=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Battle/Logic/Base/Passivity.lua | 16 ++-- .../~Lua/Modules/Battle/Logic/Base/Skill.lua | 85 +++++++++++++------ .../Battle/Logic/Misc/BattleDefine.lua | 3 + .../Modules/Battle/Logic/Misc/BattleUtil.lua | 11 ++- .../~Lua/Modules/Battle/View/RoleView.lua | 5 ++ 5 files changed, 83 insertions(+), 37 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Passivity.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Passivity.lua index 2ba9250d9e..00e8f3eaea 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Passivity.lua +++ b/Assets/ManagedResources/~Lua/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/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Skill.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Skill.lua index 4ec4e22a3c..a35a592b93 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Skill.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Skill.lua @@ -72,33 +72,45 @@ function Skill:Dispose() end end -local function takeEffect(caster, target, effects, duration, skill) +local function DoEffect(caster, target, eff, duration, skill) + local e = {type = 0, args = {}} + e.type = eff.type + for i=1, #eff.args do + e.args[i] = eff.args[i] + end + + -- 检测被动技能对技能参数的影响 + local function _PassiveCheck(pe) + if pe then + e = pe + end + end + caster.Event:DispatchEvent(BattleEventName.SkillEffectBefore, skill, e, _PassiveCheck) + target.Event:DispatchEvent(BattleEventName.BeSkillEffectBefore, skill, e, _PassiveCheck) + + -- + if effect[e.type] then + effect[e.type](caster, target, e.args, duration, skill) + + BattleLogManager.Log( + "Take Effect", + "tcamp", target.camp, + "tpos", target.position, + "type", e.type + ) + end +end +local function takeEffect(caster, target, effects, effectIndex, duration, skill) + + for k=1, #effects do - local e = {type = 0, args = {}} - e.type = effects[k].type - for i=1, #effects[k].args do - e.args[i] = effects[k].args[i] - end - - -- 检测被动技能对技能参数的影响 - local function _PassiveCheck(pe) - if pe then - e = pe + -- 如果不是第一个效果对列的第一个效果则判断是否命中 + if k ~= 1 and effectIndex == 1 then + if self:CheckTargetIsHit(target) then + DoEffect(caster, target, effects[k], duration, skill) end - end - caster.Event:DispatchEvent(BattleEventName.SkillEffectBefore, skill, e, _PassiveCheck) - target.Event:DispatchEvent(BattleEventName.BeSkillEffectBefore, skill, e, _PassiveCheck) - - -- - if effect[e.type] then - effect[e.type](caster, target, e.args, duration, skill) - - BattleLogManager.Log( - "Take Effect", - "tcamp", target.camp, - "tpos", target.position, - "type", e.type - ) + else + DoEffect(caster, target, effects[k], duration, skill) end end end @@ -167,7 +179,16 @@ function Skill:Cast(func) if i == 1 then self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.owner, arr[j]) end - takeEffect(self.owner, arr[j], effects, self.hitTime, 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) @@ -203,10 +224,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] diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleDefine.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleDefine.lua index b5ec718ef9..d7c4e7eb01 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -50,6 +50,9 @@ BattleEventName = { FinalDamage = indexAdd(), FinalBeDamage = indexAdd(), + HitMiss = indexAdd(), + BeHitMiss = indexAdd(), + CritDamageReduceFactor = indexAdd(), -- 暴击伤害减免系数 SkillCast = indexAdd(), -- 技能攻击前 diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua index 7456a3d3ec..b5b6a62057 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -383,10 +383,17 @@ 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 + end + -- 如果是队伍技能,计算真实伤害,则damageType为伤害值 + if atkRole.isTeam and not defRole:IsDead() then return BattleUtil.ApplyDamage(skill, atkRole, defRole, damageType), false end - -- 计算技能额外伤害系数加成 baseFactor = baseFactor or 1 local factorFunc = function(exFactor) baseFactor = baseFactor + exFactor end diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/RoleView.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/RoleView.lua index 65843e542e..1ff034fcb0 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/RoleView.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/RoleView.lua @@ -48,6 +48,7 @@ function RoleView.New(go, role, position, root) BattleLogic.Event:AddEvent(BattleEventName.BattleEnd, instance.OnEnd, instance) BattleLogic.Event:AddEvent(BattleEventName.BattleOrderChange, instance.OnEnd, instance) + role.Event:AddEvent(BattleEventName.BeHitMiss, instance.OnBeHitMiss, instance) role.Event:AddEvent(BattleEventName.RoleBeDamaged, instance.OnDamaged, instance) role.Event:AddEvent(BattleEventName.RoleBeTreated, instance.OnTreated, instance) role.Event:AddEvent(BattleEventName.RoleBeHealed, instance.OnHealed, instance) @@ -1167,6 +1168,10 @@ function RoleView:OnShieldTrigger(shield) end end +-- 哈哈,没打着 +function RoleView:OnBeHitMiss(atkRole, skill) + self:TextBuffFloating(TextFloatingColor.Blue, "未命中") +end local DotTypeTip = { [0] = Language[10276],