diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index eac075eb7..5da0d64b5 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -13,18 +13,20 @@ require("Modules.Battle.Logic.Misc.BattleObjectPool") require("Modules.Battle.Logic.Base.BattleEvent") require("Modules.Battle.Logic.Base.Random") -require("Modules.Battle.Logic.Base.RoleData") require("Modules.Battle.Logic.Base.Buff") -require("Modules.Battle.Logic.Base.Skill") require("Modules.Battle.Logic.Base.Passivity") +require("Modules.Battle.Logic.Role.RoleLogic") +require("Modules.Battle.Logic.Role.RoleData") +require("Modules.Battle.Logic.Role.RoleManager") +require("Modules.Battle.Logic.Role.Skill") + require("Modules.Battle.Logic.BattleLogic") -require("Modules.Battle.Logic.RoleLogic") require("Modules.Battle.Logic.SkillManager") -require("Modules.Battle.Logic.RoleManager") require("Modules.Battle.Logic.OutDataManager") require("Modules.Battle.Logic.BattleLogManager") +require("Modules.Battle.Logic.Monster.MonsterManager") local BattleMain = {} @@ -228,6 +230,23 @@ function BattleMain.Execute(args, fightData, optionData) end BattleLogic.StartOrder() + -- local startTime = os.clock() + -- local cor = coroutine.create(function() + -- while not BattleLogic.IsEnd do + -- print(os.clock()) + -- if os.clock() - startTime > 3 then + -- assert(false, "fight time out!!!") + -- break + -- end + -- end + -- end) + -- coroutine.resume(cor) + --debug.sethook( + -- function (event, line) + -- BattleLogManager.Log(debug.getinfo(2).short_src .. ":" .. line) + -- end + --, "l") + while not BattleLogic.IsEnd do BattleLogic.Update() end diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 5314aa125..8ac028d2d 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -2240,7 +2240,7 @@ local effectList = { --如果身上有不灭效果就不会加普攻,兼容金翅大鹏10星天赋 by:王振兴 if not BattleLogic.BuffMgr:HasBuff(caster,BuffName.NoDead) then BattleLogic.WaitForTrigger(0.5, function () - caster:InsertSkill(BattleSkillType.Normal, false, false, nil) + caster:InsertSkill(BattleSkillType.Normal, false, true, nil) end) end end, diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index 9ebeaf7e0..c109f86ed 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -2031,8 +2031,6 @@ local passivityList = { end) end, - - -- 直接伤害击杀目标回复自身[a]%的[b] -- a[float] [116] = function(role, args) @@ -2093,13 +2091,11 @@ local passivityList = { [118] = function(role, args) local f1 = args[1] local ct = args[2] - local af = 0 - local onSkillCast = function(skill) if skill.type == BattleSkillType.Normal and not skill.isAdd then af = 0 - elseif skill.type == BattleSkillType.Special then + elseif skill.type == BattleSkillType.Special then af = af + f1 end end @@ -2107,7 +2103,7 @@ local passivityList = { -- 如果是技能的伤害则判断加成 local onPassiveDamaging = function(func, target, damage, skill) - if skill and skill.type == BattleSkillType.Special then + if skill and (skill.type == BattleSkillType.Special or skill.type==BattleSkillType.Extra) then local dd = BattleUtil.CountValue(damage, af, ct) - damage if func then func(-floor(BattleUtil.ErrorCorrection(dd))) end end @@ -2384,7 +2380,7 @@ local passivityList = { -- 击杀数量累加 local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) if skill and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then - killNum = killNum + 1 + killNum = killNum + 1 end end role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit) @@ -2951,7 +2947,8 @@ local passivityList = { [156] = function(role, args) local i1 = args[1] local onBeSkillCastEnd = function(skill) - if skill.type == BattleSkillType.Normal then + --同阵营给自己普攻加血不扣除怒气 + if skill.owner.camp~=role.camp and skill.type == BattleSkillType.Normal then skill.owner:AddRage(i1, CountTypeName.Sub) end end @@ -3210,7 +3207,9 @@ local passivityList = { local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then local list = RoleManager.Query(function(v) return v.camp == role.camp end) - BattleUtil.SortByProp(list, RoleDataName.Hp, 1) + --生命最少改成生命百分比最少 2020/09/29 by:王振兴 + --BattleUtil.SortByProp(list, RoleDataName.Hp, 1) + BattleUtil.SortByHpFactor(list, 1) local index = 0 for i = 1, #list do if not list[i]:IsRealDead() and index < 2 then @@ -3620,7 +3619,8 @@ local passivityList = { -- 计算分摊伤害 local fenDamage = finalDamage * ff -- 需要分摊的总伤害 - list = BattleUtil.SortByProp(list, RoleDataName.Hp, 0) + --根据血量百分比排序 + BattleUtil.SortByHpFactor(list, 0) local targets = {role, list[1], list[2]} local fd = floor(BattleUtil.ErrorCorrection(fenDamage/#targets)) -- 每个人需要分摊的伤害 @@ -3632,7 +3632,8 @@ local passivityList = { -- 平分给别人 if fd > 0 then for i = 2, #targets do - BattleUtil.FinalDamage(skill, atkRole, targets[i], fd, nil, 0, dotType) + --不触发被动 + BattleUtil.FinalDamage(nil, atkRole, targets[i], fd, nil, 0, dotType) end end end @@ -3775,9 +3776,20 @@ local passivityList = { -- a[控制状态] [195] = function(role, args) local ctrl = args[1] - + local ctr2 = args[2] + local ctr3 = args[3] + local ctrls={} + if ctrl then + table.insert(ctrls,ctrl) + end + if ctr2 then + table.insert(ctrls,ctr2) + end + if ctr3 then + table.insert(ctrls,ctr3) + end local immune = function(buff) - return buff.type == BuffName.Control and (ctrl == 0 or buff.ctrlType == ctrl) + return buff.type == BuffName.Control and (BattleUtil.ChecklistIsContainValue(ctrls,buff.ctrlType)) end BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) @@ -3865,7 +3877,7 @@ local passivityList = { end end - role.Event:AddEvent(BattleEventName.FinalBeDamage, onFinalBeDamage) + role.Event:AddEvent(BattleEventName.FinalBeDamageEnd, onFinalBeDamage) end, @@ -3875,14 +3887,14 @@ local passivityList = { local f1 = args[1] local onFinalDamage = function(damagingFunc, atkRole, defRole, damage, skill, dotType, bCrit, damageType) - if skill and role.position ~= defRole.position and defRole.camp == role.camp and defRole.element == role.element then + if not role:IsDead() and skill and role.position ~= defRole.position and defRole.camp == role.camp and defRole.element == role.element then local shareDamage = floor(BattleUtil.ErrorCorrection(damage * f1)) -- 被攻击武将自身伤害 if damagingFunc then damagingFunc(shareDamage) end - -- 分担伤害 - BattleUtil.ApplyDamage(nil, atkRole, role, shareDamage) + -- 分担伤害 + BattleUtil.ApplyDamage(nil, atkRole, role, shareDamage,bCrit,damageType,dotType,true) end end BattleLogic.Event:AddEvent(BattleEventName.FinalDamage, onFinalDamage) @@ -4779,5 +4791,308 @@ local passivityList = { role.data.enemyType=f1 BattleUtil.CheckIsBoss(role) end, + -- (直接伤害(目前没有明确定义直接伤害))直接伤害击杀目标自身增加[a]点怒气 重写92被动效果 每次释放技能只触发一次 + -- a[int] + [245] = function(role, args) + local i1 = args[1] + local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,245) then + return + end + if skill and not skill.isAdd and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then + role:AddRage(i1, CountTypeName.Add) + if skill then + -- skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,245) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit) + end, + + -- 直接伤害每次击杀目标增加[a]%的[b]可叠加持续至战斗结束[c]改变 重写103效果 每次释放技能只触发一次 + -- a[float]b[属性]c[改变类型] + [246] = function(role, args) + local f1 = args[1] + local pro = args[2] + local ct = args[3] + -- 释放技能后 + local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,246) then + return + end + if defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then + local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, ct) + -- buff.cover = true + role:AddBuff(buff) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,246) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + -- 直接伤害击杀目标后追加[a]次普攻 重写114 一次技能只触发一次被动 + -- a[int] + [247] = function(role, args) + local i1 = args[1] + -- 释放技能后 + local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,247) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + for i = 1, i1 do + role:AddSkill(BattleSkillType.Normal, false, true, nil) + end + if skill then + -- skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,247) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 直接伤害击杀目标回复自身[a]%的[b] 重写116 一次技能只触发一次被动 + -- a[float] + [248] = function(role, args) + local f1 = args[1] + -- 释放技能后 + local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,248) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + local treat = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.MaxHp), f1)) + BattleUtil.CalTreat(role, role, treat) + if skill then + -- skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,248) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 直接伤害击杀目标下回合攻击[a]%暴击(TODO:目前为增加[a]%) 重写125 一次技能只触发一次被动 + -- a[float] + [249] = function(role, args) + local f1 = args[1] + -- 释放技能后 + local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,249) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + local buff = Buff.Create(role, BuffName.PropertyChange, 1, RoleDataName.Crit, f1, CountTypeName.Add) + role:AddBuff(buff) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,249) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 直接伤害每次击杀目标增加自身伤害[a]%,[b]改变,可叠加持续至战斗结束 重写132 一次技能只触发一次被动 + -- a[float]b[改变类型] + [250] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local killNum = 0 + local extra = 0 + + -- 击杀数量累加 + local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,250) then + return + end + if skill and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then + killNum = killNum + 1 + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,250) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit) + + + -- 释放技能时计算额外伤害 + local OnSkillCast = function(skill) + if skill then + extra = f1 * killNum + end + end + role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) + + + -- 造成伤害时判断额外伤害 + local passivityDamaging = function(func, caster, damage, skill) + if skill then + if func then + local dd = BattleUtil.CountValue(damage, extra, ct) - damage + func(-floor(BattleUtil.ErrorCorrection(dd))) + end + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging) + end, + + -- 直接伤害击杀[a]目标回复[b]%的最大生命 重写148 一次技能只触发一次被动 + -- a[持续伤害状态]b[float] + [251] = function(role, args) + local dot = args[1] + local f1 = args[2] + local function onHit(target, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,251) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + local maxHp = role:GetRoleData(RoleDataName.MaxHp) + local value = floor(BattleUtil.ErrorCorrection(maxHp* f1)) + BattleUtil.ApplyTreat(role, role, value) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,251) + end + end + role.Event:RemoveEvent(BattleEventName.RoleHit, onHit) + end + local onDamaging = function(func, target) + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then + role.Event:AddEvent(BattleEventName.RoleHit, onHit) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onDamaging) + end, + + -- 直接伤害击杀目标回复自身[a]点怒气 重写153 一次技能只触发一次被动 + -- a[int] + [252] = function(role, args) + local i1 = args[1] + local onHit = function(target, damage, bCrit, finalDmg,damageType,skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,252) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + role:AddRage(i1, CountTypeName.Add) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,252) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onHit) + end, + + -- 击杀目标后对敌方血量百分比最低两名角色造成[a]%[b]伤害 重写170 一次技能只触发一次被动 + -- a[float]b[伤害类型] + [253] = function(role, args) + local f1 = args[1] + local dt = args[2] + -- 直接伤害后 + local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,253) then + return + end + if skill and not skill.isAdd and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + local list = RoleManager.Query(function(v) return v.camp ~= role.camp end) + BattleUtil.SortByHpFactor(list, 1) + local index = 0 + for i = 1, #list do + if not list[i]:IsDead() and index < 2 then + index = index + 1 + BattleUtil.CalDamage(nil, role, list[i], dt, f1) + end + end + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,253) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 直接伤害击杀目标对仇恨目标造成[a]%物理伤害 重写185 一次技能只触发一次被动 + -- a[float] + [254] = function(role, args) + local f1 = args[1] + local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,254) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + local target = RoleManager.GetAliveAggro(role) + BattleUtil.CalDamage(nil, role, target, 1, f1) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,254) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 技能直接击杀敌方目标时有[a]%概率获得目标剩余所有怒气(输出武将佩戴)重写197 一次技能只触发一次被动 + -- a[float] + [255] = function(role, args) + local f1 = args[1] + local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,255) then + return + end + if skill and skill.type == BattleSkillType.Special and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + BattleUtil.RandomAction(f1, function() + role:AddRage(target.Rage, CountTypeName.Add) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,255) + end + end) + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 直接伤害击杀目标释放[a]技能。 重新243 一次技能只触发一次被动 + -- a[float] + [256] = function(role, args) + local f1 = args[1] + local f2=args[2] + local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,256) then + return + end + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) and not role:IsDead() then + -- local target = RoleManager.GetAliveAggro(role) + --BattleUtil.CalDamage(nil, role, target, 1, f1) + --加一个延时操作,防止有的英雄有死亡后再释放一次技能的被动 by:王振兴 + role:InsertExtraSkill(f1,f2) + if skill then + --skill.isTriggePassivity=true + table.insert(skill.triggerPassivityId,256) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, } return passivityList diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index 2159ee470..463217c5b 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -35,11 +35,12 @@ function Skill:Init(role, effectData, type, targets, isAdd, isRage) --type 0 异 self.hitTime = effectData[2] -- 效果命中需要的时间 self.continueTime = effectData[3] -- 命中后伤害持续时间 self.attackCount = effectData[4] -- 伤害持续时间内伤害次数 - + self.isTriggePassivity = false -- 是否一个技能只触发一次被动 true:每次释放技能只会触发一次 + self.triggerPassivityId={} self.targets = targets or {} self.isAdd = isAdd self.isRage = isRage - + self.isKill = false --是否技能击杀目标 for i=5, #effectData do local v = effectData[i] local effectGroup = effectGroupPool:Get() -- chooseId, {effect1, effect2, ...} @@ -120,6 +121,8 @@ function Skill:Cast(func) self.castDoneFunc = func self.effectTargets = {} self.targetIsHit = {} + self.isTriggePassivity=false + self.triggerPassivityId={} -- 先计算出技能的目标 for i=1, self.effectList.size do -- 是否重新选择目标 @@ -208,16 +211,18 @@ function Skill:Cast(func) --技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个 local duration = self.hitTime + self.continueTime -- 结算时间向后延长0.2秒,避免在效果结算完成前就结束了技能释放 - BattleLogic.WaitForTrigger(duration + 0.4, function() + BattleLogic.WaitForTrigger(duration + 0.8, function() self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) - + -- 只对效果1的目标发送事件,效果1是技能的直接伤害目标 for _, tr in ipairs(self.effectTargets[1]) do tr.Event:DispatchEvent(BattleEventName.BeSkillCastEnd, self) end -- 技能结束 self:EndSkill() + --技能消息发送完后 iskill 设置为false + self.isKill=false end) end @@ -257,6 +262,8 @@ function Skill:EndSkill() -- 技能结束后摇后结束技能释放 BattleLogic.WaitForTrigger(0.3, function() -- 结束回调 + self.isTriggePassivity=false + self.triggerPassivityId={} if self.castDoneFunc then self.castDoneFunc() end end) diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index 5f3f95232..3f44fff65 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -197,18 +197,25 @@ function BattleLogic.TurnRound(debugTurn) ) -- 轮数变化 BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound) + --轮数变化后延时0.2秒用于初始化监听回合数被动的初始化 + BattleLogic.WaitForTrigger(0.2,function() + BattleLogic.CheckBattleLogic() + end) else -- 切换阵营 CurCamp = (CurCamp + 1) % 2 + BattleLogic.CheckBattleLogic() end + +end +--检测战斗逻辑 +function BattleLogic.CheckBattleLogic() -- 这里再检测一次战斗结束 if CurRound > MaxRound then return end - - -- - BattleLogManager.Log( + BattleLogManager.Log( "Camp Change", "camp", CurCamp ) @@ -277,7 +284,6 @@ function BattleLogic.TurnRound(debugTurn) end) end - function BattleLogic.WaitForTrigger(delayTime, action) delayTime = BattleUtil.ErrorCorrection(delayTime) local delayFrame = floor(delayTime * BattleLogic.GameFrameRate + 0.5) diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 36ee4ce58..bf904b395 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -49,7 +49,7 @@ BattleEventName = { RoleRelive = indexAdd(), -- 角色复活了 FinalDamage = indexAdd(), FinalBeDamage = indexAdd(), - + FinalBeDamageEnd = indexAdd(), --最后被攻击结束 HitMiss = indexAdd(), BeHitMiss = indexAdd(), diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 925399e21..b3f5a4db0 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -323,7 +323,7 @@ function BattleUtil.Seckill(skill, atkRole, defRole) end -- 计算真实伤害 -function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) +function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) bCrit = bCrit or false damageType = damageType or 0 @@ -354,10 +354,11 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy end atkRole.Event:DispatchEvent(BattleEventName.FinalDamage, damagingFunc, defRole, damage, skill, dotType, bCrit, damageType) defRole.Event:DispatchEvent(BattleEventName.FinalBeDamage, damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType) + defRole.Event:DispatchEvent(BattleEventName.FinalBeDamageEnd, damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType) BattleLogic.Event:DispatchEvent(BattleEventName.FinalDamage, damagingFunc, atkRole, defRole, damage, skill, dotType, bCrit, damageType) -- - return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) + return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) end @@ -373,10 +374,8 @@ end function BattleUtil.ChecklistIsContainValue(_list,_value) if _list and _value then for key, value in pairs(_list) do - if value==_value then + if value ==_value then return true - else - return false end end end @@ -396,7 +395,7 @@ function BattleUtil.GetExtraSkillbyId(id) end end -function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) +function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) if damage < 0 then damage = 0 end local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage) if finalDmg >= 0 then @@ -419,6 +418,11 @@ function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageTy atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill) defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill) end + --如果不是技能带的伤害,并且是直接伤害就,,,,, + --用于处理不触发特性并且是直接伤害的伤害 isDirect 暂时先为bool值,后期可根据需求做修改扩展 by:王振兴 2020/10/12 16:18 + if isDirect and not skill then + atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill) + end end -- @@ -529,11 +533,26 @@ function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor) if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血 return end + -- 是否暴击: 暴击率 = 自身暴击率 - 对方抗暴率 + local bCrit = false + local critRandom = Random.Range01() + local critCondition = castRole:GetRoleData(RoleDataName.Crit) + bCrit = critRandom <= critCondition + bCrit = bCrit or targetRole.isFlagCrit == true -- 必定暴击 + -- 计算暴伤害系数 + local critDamageFactor = 1 + --计算暴击 + if bCrit then + --伤害有个+1.3 不知道干什么用的就给去了 by:wangxhenxing 2020/10/10 18:46 + critDamageFactor = 1.3 + castRole:GetRoleData(RoleDataName.CritDamageFactor) + end + -- 基础伤害增加系数 + local addDamageFactor = 1 + castRole:GetRoleData(RoleDataName.DamageBocusFactor) targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole) - BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) + BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor) end -function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) +function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor) if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血 return end @@ -550,7 +569,7 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) local factor = castRole.isTeam and 1 or castRole:GetRoleData(RoleDataName.TreatFacter) --释放者为team则不计算治疗加成属性 local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter) - local baseTreat = BattleUtil.FP_Mul(value, baseFactor, factor, factor2) + local baseTreat = BattleUtil.FP_Mul(value, baseFactor, factor, factor2,critDamageFactor,addDamageFactor) --加入被动效果 local cl = {} @@ -644,7 +663,7 @@ function BattleUtil.RandomDot(rand, dot, caster, target, round, interval, damage caster.Event:DispatchEvent(BattleEventName.PassiveRandomDot, _CallBack, dot) target.Event:DispatchEvent(BattleEventName.PassiveBeRandomDot, _CallBack, dot) rand = BattleUtil.CountChangeList(rand, cl) - damage = BattleUtil.CountChangeList(damage, dcl) + damage = floor(BattleUtil.CountChangeList(damage, dcl)) return BattleUtil.RandomAction(rand, function() local buff = Buff.Create(caster, BuffName.DOT, round, interval, dot, damage)