From 5d963ca40412efd8ef2b9161b723371439f06463 Mon Sep 17 00:00:00 2001 From: yuanshuai <243578945@qq.com> Date: Fri, 22 Oct 2021 16:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E6=88=98=E6=96=97=E7=9B=B8?= =?UTF-8?q?=E5=85=B3lua=E6=96=87=E4=BB=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luafight/Modules/Battle/Logic/Base/Buff.lua | 25 +- luafight/Modules/Battle/Logic/Base/Effect.lua | 77 +- .../Battle/Logic/Base/EffectCaster.lua | 28 +- .../Modules/Battle/Logic/Base/Passivity.lua | 892 +++++++++++++++--- luafight/Modules/Battle/Logic/BattleLogic.lua | 63 +- luafight/Modules/Battle/Logic/Buff/Blood.lua | 62 ++ luafight/Modules/Battle/Logic/Buff/DOT.lua | 13 +- luafight/Modules/Battle/Logic/Buff/HOT.lua | 23 +- luafight/Modules/Battle/Logic/Buff/Immune.lua | 15 +- .../Battle/Logic/Misc/BattleDefine.lua | 16 +- .../Modules/Battle/Logic/Misc/BattleUtil.lua | 244 ++++- .../Modules/Battle/Logic/Monster/Monster.lua | 14 +- .../Logic/Monster/MonsterSkill/MCondition.lua | 29 +- .../Logic/Monster/MonsterSkill/MSkill.lua | 9 +- .../Monster/MonsterSkill/MSkillGroup.lua | 14 +- .../Monster/MonsterSkill/MSkillManager.lua | 29 +- .../Logic/Monster/MonsterSkill/MTrigger.lua | 5 +- .../Modules/Battle/Logic/Role/RoleLogic.lua | 73 +- luafight/Modules/Battle/Logic/Role/Skill.lua | 6 +- .../Modules/Battle/Logic/SkillManager.lua | 27 +- 20 files changed, 1437 insertions(+), 227 deletions(-) create mode 100644 luafight/Modules/Battle/Logic/Buff/Blood.lua diff --git a/luafight/Modules/Battle/Logic/Base/Buff.lua b/luafight/Modules/Battle/Logic/Base/Buff.lua index 66ca401ff..0bd54efe8 100644 --- a/luafight/Modules/Battle/Logic/Base/Buff.lua +++ b/luafight/Modules/Battle/Logic/Base/Buff.lua @@ -15,6 +15,7 @@ local BuffRegister = { [BuffName.NoDead] = "NoDead", [BuffName.Aura] = "Aura", [BuffName.Brand] = "Brand", + [BuffName.Blood] = "Blood", } @@ -59,6 +60,9 @@ function Buff.Create(caster, type, duration, ...) buff.roundPass = 0 buff.startRound = BattleLogic.GetCurRound() + -- 重置buff状态 + buff.isBuff = nil + buff.isDeBuff = nil buff:SetData(...) return buff @@ -168,6 +172,7 @@ function BuffManager:AddBuff(target, buff) buff.roundDuration = buff.duration buff.roundInterval = buff.interval buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff) + buff.target.Event:DispatchEvent(BattleEventName.BuffBeAdd, buff) -- 用于记录统计 BattleLogic.Event:DispatchEvent(BattleEventName.RecordBuff, buff.caster, buff.target, buff) end @@ -323,6 +328,13 @@ function BuffManager:Update() -- end buffList:Add(buff) buff:OnStart() + + BattleLogManager.Log( + "Add Buff", + "camp", buff.caster.camp, + "position", buff.caster.position, + "id", buff.id, + "type", buff.type) buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) BattleLogic.Event:DispatchEvent(BattleEventName.BuffStart, buff) end @@ -367,9 +379,18 @@ function BuffManager:PassUpdate() -- 当前轮释放的buff不结算 if buff.startRound ~= BattleLogic.GetCurRound() then buff.roundPass = buff.roundPass + 1 - if buff.roundPass >= buff.roundDuration then - buff.disperse = true + --如果是Dot类的buff 判断触发次数;其他的还按照之前的逻辑判断 by:wangzhenxing 2021/08/27 + if buff.triggerTime then + --现在按照 每回合都会触发来处理的;如果存在4回合触发2次的还需处理 by:wangzhenxing 2021/08/27 + if buff.triggerTime==buff.roundDuration then + buff.disperse = true + end + else + if buff.roundPass >= buff.roundDuration then + buff.disperse = true + end end + buff.target.Event:DispatchEvent(BattleEventName.BuffRoundChange, buff) end end diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 3e200bc1f..9f2294ecb 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -200,7 +200,7 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local dmg = BattleUtil.CalDamage(skill, caster, target, dt, f1) - BattleUtil.CalTreat(caster, caster, floor(dmg * f2)) + BattleUtil.CalTreat(caster, caster, floor(dmg * f2),1,skill) end) end, --造成[a]%的[b]伤害,对[c]造成额外[d]%伤害 @@ -432,7 +432,7 @@ local effectList = { local f1 = args[2] BattleLogic.WaitForTrigger(interval, function () local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(BattlePropList[pro1]), f1)) - BattleUtil.CalTreat(caster, target, val) + BattleUtil.CalTreat(caster, target, val,1,skill) end) end, --对[a]的伤害[b]%,持续[c]秒 @@ -742,7 +742,7 @@ local effectList = { [43] = function(caster, target, args, interval, skill) local i1 = args[1] BattleLogic.WaitForTrigger(interval, function () - BattleUtil.CalTreat(caster, target, i1) + BattleUtil.CalTreat(caster, target, i1,1,skill) end) end, --造成[a]%的[b]伤害,计算伤害时额外计算[c]%的[d][e]和[f]%的[g][h] @@ -993,7 +993,7 @@ local effectList = { local count = min(#arr, i1) local heal = floor(damage / count) for i=1, count do - BattleUtil.CalTreat(caster, arr[i], heal) + BattleUtil.CalTreat(caster, arr[i], heal,1,skill) end end) end, @@ -1078,7 +1078,7 @@ local effectList = { if arr[1] ~= caster then caster.data:SubValue(RoleDataName.Hp, floor(caster:GetRoleData(RoleDataName.Hp) * f1)) end - BattleUtil.CalTreat(caster, arr[1], floor(caster:GetRoleData(RoleDataName.MaxHp) * f2)) + BattleUtil.CalTreat(caster, arr[1], floor(caster:GetRoleData(RoleDataName.MaxHp) * f2),1,skill) end end) end, @@ -1357,7 +1357,7 @@ local effectList = { BattleLogic.WaitForTrigger(interval, function () BattleUtil.RandomAction(f2, function () local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(BattlePropList[pro1]), f1)) - BattleUtil.CalTreat(caster, target, val) + BattleUtil.CalTreat(caster, target, val,1,skill) end) end) end, @@ -1509,7 +1509,7 @@ local effectList = { local OnBuffStart = function(buff) if buff.type == BuffName.Control then local val = floor(BattleUtil.FP_Mul(buff.target:GetRoleData(BattlePropList[pro1]), f2)) - BattleUtil.CalTreat(buff.caster, buff.target, val) + BattleUtil.CalTreat(buff.caster, buff.target, val,1,skill) end end caster.Event:AddEvent(BattleEventName.BuffStart, OnBuffStart) @@ -2285,7 +2285,7 @@ local effectList = { local f1 = args[2] BattleLogic.WaitForTrigger(interval, function () local val = floor(BattleUtil.FP_Mul(target:GetRoleData(BattlePropList[pro1]), f1)) - BattleUtil.CalTreat(caster, target, val) + BattleUtil.CalTreat(caster, target, val,1,skill) end) end, @@ -2399,6 +2399,67 @@ local effectList = { end) end) end, + + --造成主角战斗力[a]%+[b]的伤害 + --a[float],b[int] + [128] = function(caster, target, args, interval, skill) + local pro = args[1] + local round = args[2] + BattleLogic.WaitForTrigger(interval, function () + local damage=floor(caster.teamDamage*pro)+round + BattleUtil.FinalDamageCountShield(nil,caster, target,damage) + end) + end, + --回复目标主角战斗力[a]%+[b]的生命值,溢出部分转换为等量御甲值 + --a[float],b[int] + [129] = function(caster, target, args, interval, skill) + local pro = args[1] + local round = args[2] + BattleLogic.WaitForTrigger(interval, function () + local damage=floor(caster.teamDamage*pro)+round + local value=target:GetRoleData(RoleDataName.MaxHp)-target:GetRoleData(RoleDataName.Hp) + local yujia=0 + if value>0 then + BattleUtil.FinalTreat(caster, target,value,1,skill) + else + value=0 + end + if damage-value>0 then + if target.bloodShield then + target.bloodShield:AddValue(damage-value) + else + target:AddBuff(Buff.Create(caster,BuffName.Blood,0,damage-value)) + end + end + end) + + end, + --对目标造成流血状态,造成主角战斗力[a]%+[b]的间接伤害,持续[c]回合 + --a[float],b[int],c[int] + [130] = function(caster, target, args, interval, skill) + local f1 = args[1] + local v1 = args[2] + local round = args[3] + BattleLogic.WaitForTrigger(interval, function () + local damage=floor(caster.teamDamage*f1)+v1 + local buff=Buff.Create(caster, BuffName.DOT,round, 1,3,damage) + buff.isRealDamage=true + target:AddBuff(buff) + end) + end, + --对目标造成神佑状态,造成主角战斗力[a]%+[b]的血量,持续[c]回合,溢出部分转化为御甲 + --a[float],b[int],c[int] + [131] = function(caster, target, args, interval, skill) + local f1 = args[1] + local v1 = args[2] + local round = args[3] + BattleLogic.WaitForTrigger(interval, function () + local damage=floor(caster.teamDamage*f1)+v1 + local buff=Buff.Create(caster, BuffName.HOT,round,1,damage) + buff.hotType=2 + target:AddBuff(buff) + end) + end, } return effectList \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Base/EffectCaster.lua b/luafight/Modules/Battle/Logic/Base/EffectCaster.lua index cf225257b..e06f815f4 100644 --- a/luafight/Modules/Battle/Logic/Base/EffectCaster.lua +++ b/luafight/Modules/Battle/Logic/Base/EffectCaster.lua @@ -29,6 +29,14 @@ function EffectCaster:Init(skill, effects, targets) effect.args[k-1] = v[j][k] end effectGroup.effects[j-1] = effect + + BattleLogManager.Log( + "Init Effect", + "camp", skill.owner.camp, + "position", skill.owner.position, + "skillId", tostring(skill.id), + "effectType", tostring(effect.type) + ) end table.insert(self.effectList, effectGroup) end @@ -51,6 +59,15 @@ function EffectCaster:DoEffect(caster, target, eff, duration, skill) caster.Event:DispatchEvent(BattleEventName.SkillEffectBefore, skill, e, _PassiveCheck,target,eff) target.Event:DispatchEvent(BattleEventName.BeSkillEffectBefore, skill, e, _PassiveCheck) + BattleLogManager.Log( + "Do Effect", + "camp", caster.camp, + "position", caster.position, + "tcamp", target.camp, + "tposition", target.position, + "skillId", tostring(skill.id), + "effectType", tostring(e.type) + ) -- if Effect[e.type] then Effect[e.type](caster, target, e.args, duration, skill) @@ -188,7 +205,16 @@ function EffectCaster:GetDirectTargetsNoExile() return list end - +-- ȡֱĿûбĿ꣬Ϊ +function EffectCaster:GetDirectTargetsNoNODead() + local list = {} + for _, role in ipairs(self.effectTargets[1]) do + if not BattleLogic.BuffMgr:HasBuff(role,BuffName.NoDead) then + table.insert(list, role) + end + end + return list +end -- ȡĿ function EffectCaster:GetMaxTargetNum() diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index af5111787..4021db414 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -692,14 +692,17 @@ local passivityList = { end) end, - --进入战斗[a]秒后,免疫控制效果,持续[b]秒 - --a[int],b[int] + --进入战斗[a]秒后,免疫控制效果,持续[b]秒,免疫类型[c](c 不填默认为1 免疫控制) + --a[int],b[int],c[int] [37] = function(role, args) local f1 = args[1] local f2 = args[2] - + local type=1 + if args[3] then + type=args[3] + end BattleLogic.WaitForTrigger(f1, function () - role:AddBuff(Buff.Create(role, BuffName.Immune, f2, 1)) + role:AddBuff(Buff.Create(role, BuffName.Immune, f2,type)) end) end, @@ -1030,6 +1033,11 @@ local passivityList = { -- if lastTrigger > 1 then --加入限定避免循环触发 -- return -- end + --如果是boss 并且额外伤害是根据最大生命则返回 + local isBoss=BattleUtil.CheckIsBoss(defRole) + if isBoss then + return + end if skill and (skill.type==BattleSkillType.Special or skill.type==BattleSkillType.Extra or skill.type==BattleSkillType.DeadSkill ) then local ar1 = floor(BattleUtil.FP_Mul(defRole:GetRoleData(RoleDataName.MaxHp), f1)) --local ar2 = BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Attack), 2.5) @@ -1536,10 +1544,14 @@ local passivityList = { [91] = function(role, args,id,judge) local f1 = args[1] local ct = args[2] - local passivityDamaging = function(func, caster, damage,skill, dotType, bCrit) + local passivityDamaging = function(func, caster, damage,skill, dotType, bCrit,damageType) if skill and not skill.isTriggerJudge and judge==1 then return end + if damageType==3 then + return + end + --处理伏虎觉醒十星附加的额外技能,额外技能不触发这个特性 2020/11/17 wangzhenxing if skill and skill.type== BattleSkillType.Extra and skill.owner.roleId==10015 and judge==1 then return @@ -1597,7 +1609,7 @@ local passivityList = { if skill and not skill.isTriggerJudge and judge==1 then return end - if skill.type == BattleSkillType.Special then + if skill.type == BattleSkillType.Special or skill.type == BattleSkillType.DeadSkill then role.Event:AddEvent(BattleEventName.PassiveTreating, passiveTreating,nil,nil,role) end end @@ -1605,7 +1617,7 @@ local passivityList = { if skill and not skill.isTriggerJudge and judge==1 then return end - if skill.type == BattleSkillType.Special then + if skill.type == BattleSkillType.Special or skill.type == BattleSkillType.DeadSkill then role.Event:RemoveEvent(BattleEventName.PassiveTreating, passiveTreating) end end @@ -1737,7 +1749,7 @@ local passivityList = { end if skill.type == BattleSkillType.Special then role.Event:RemoveEvent(BattleEventName.RoleHit, OnHit) - local arr = RoleManager.Query(function (r) return r.camp == role.camp and r.deadFilter end) + local arr = RoleManager.NoOrder(function (r) return r.camp == role.camp and r.deadFilter end) BattleUtil.SortByHpFactor(arr, 1) -- 检测技能伤害���疗加成 local f = BattleUtil.CheckSkillDamageHeal(f1, role, arr[1]) @@ -2048,6 +2060,9 @@ local passivityList = { role.Event:RemoveEvent(BattleEventName.RoleDamageAfter, onRoleDamageAfter) end local function onRoleDamageBefore(target, factorFunc, damageType, skill) + if not skill then + return + end if skill and not skill.isTriggerJudge and judge==1 then return end @@ -2114,10 +2129,13 @@ local passivityList = { local ct = args[4] -- 如果是技能的伤害则判断加成 - local onPassiveDamaging = function(func, target, damage, skill) + local onPassiveDamaging = function(func, target, damage, skill,ditType,bCrit,damageType) if skill and not skill.isTriggerJudge and judge==1 then return end + if damageType==3 then + return + end --处理伏虎觉醒十星附加的额外技能,额外技能不触发这个特性 2020/11/17 wangzhenxing if skill and skill.type== BattleSkillType.Extra and skill.owner.roleId==10015 and judge==1 then return @@ -2144,6 +2162,7 @@ local passivityList = { -- a[float] [116] = function(role, args,id,judge) local f1 = args[1] + -- 释放技能后 local onRoleHit = function(target,damage,bCrit,finalDmg,damageType,skill) if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then @@ -2240,6 +2259,15 @@ local passivityList = { local i1 = args[4] -- 释放技能后 local onSkillEnd = function(skill) + BattleLogManager.Log( + "Passive 119", + "camp", role.camp, + "pos", role.position, + "isSkill", tostring(skill ~= nil), + "isTriggerJudge", tostring(skill.isTriggerJudge), + "type", tostring(skill.type), + "judge", tostring(judge) + ) if skill and not skill.isTriggerJudge and judge==1 then return end @@ -2693,7 +2721,7 @@ local passivityList = { return end if skill.type == BattleSkillType.Special then - local list = skill:GetDirectTargets() + local list = skill:GetDirectTargetsNoNoDead() if list then local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro]) * f1)) for _, r in ipairs(list) do @@ -2760,13 +2788,16 @@ local passivityList = { end, -- 受到[a]状态敌人攻击时受到伤害[b]改变[c]% - -- a[持续伤害状态]b[改变类型]c[float] + -- a[持续伤害状态]b[改变类型]c[float],d[int 1:直接伤害 ](d 不填/0不区别是否为直接伤害) [140] = function(role, args) local dot = args[1] local ct = args[2] local f1 = args[3] - - local onPassiveBeDamaging = function(func, caster, damage) + local type = args[4] + local onPassiveBeDamaging = function(func, caster, damage,skill) + if type==1 and not skill then + return + end if BattleLogic.BuffMgr:HasBuff(caster, BuffName.DOT, function(buff) return buff.damageType == dot end,role,dot) then local dmgDeduction = damage - floor(BattleUtil.ErrorCorrection(BattleUtil.CountValue(damage, f1, ct))) if func then func(dmgDeduction) end @@ -2780,23 +2811,23 @@ local passivityList = { -- a[int] [141] = function(role, args) local i1 = args[1] - local buff - BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) + local buff1=nil + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundStart, function(curRound) -- 第i1回合开始 if curRound == i1 then - buff = Buff.Create(role, BuffName.Shield, 0, ShieldTypeName.AllReduce, 0, 0) - buff.cover = false - buff.clear = false - role:AddBuff(buff) + buff1 = Buff.Create(role, BuffName.Shield, 0, ShieldTypeName.AllReduce, 0, 0) + buff1.cover = false + buff1.clear = false + role:AddBuff(buff1) end - if curRound == i1 + 1 then - if buff then - if buff.caster==role then - buff.disperse = true + if curRound == i1 + 1 then + if buff1 then + if buff1.caster==role then + buff1.disperse = true end end end - end,nil,nil,role) + end) end, @@ -2898,6 +2929,9 @@ local passivityList = { local index, tran local OnRoleDamageBefore = function(target, factorFunc, damageType, skill) + if not skill then + return + end if skill and not skill.isTriggerJudge and judge==1 then return end @@ -2907,6 +2941,9 @@ local passivityList = { end end local OnRoleDamageAfter = function(defRole,damageFunc,fixDamage,skill) + if not skill then + return + end if skill and not skill.isTriggerJudge and judge==1 then return end @@ -3298,7 +3335,7 @@ local passivityList = { local f1 = args[1] local dot = args[2] local f2 = args[3] - local i1 = args[3] + local i1 = args[4] -- 技能后后 local onBeSkillCastEnd = function(skill) @@ -3311,25 +3348,25 @@ local passivityList = { role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd,nil,nil,role) end, - -- 攻击目标时目标身上每有1种异常状态(包括麻痹、眩晕、沉默、灼烧、中毒)都会使对其造成的直接伤害提高,异常状态数量乘以[a]%。 - -- a[float] + -- 攻击目标时目标身上每有1种异常状态(包括麻痹、眩晕、沉默、灼烧、中毒)都会使对其造成的直接伤害提高,异常状态数量乘以[a]%。,[b]是否包含dot类buff(b 不填/0为包含 ) + -- a[float],b[int 1:不包含] [161] = function(role, args,id,judge) local f1 = args[1] - + local isDot = args[2] + if not isDot then + isDot=0 + end --之前为根据异常效果的数量改为根据异常效果的类型 by:王振兴 local function onPassiveDamaging(damagingFunc, target, damage,skill) if skill and not skill.isTriggerJudge and judge==1 then return end - --local list = BattleLogic.BuffMgr:GetBuff(target, function(buff) - --return buff.type == BuffName.DOT or buff.type == BuffName.Control - --end) local dotList={} local controlList={} local list=BattleLogic.BuffMgr:GetBuff(target) for i = 1, #list do local buff=list[i] - if buff.type== BuffName.DOT and buff.damageType and dotList and not BattleUtil.ChecklistIsContainValue(dotList,buff.damageType) then + if isDot==0 and buff.type== BuffName.DOT and buff.damageType and dotList and not BattleUtil.ChecklistIsContainValue(dotList,buff.damageType) then table.insert(dotList,buff.damageType) end @@ -3931,8 +3968,8 @@ local passivityList = { table.insert(cl, {v, ct}) end end - role.Event:DispatchEvent(BattleEventName.PassiveDamageShare, _CallBack,skill) - atkRole.Event:DispatchEvent(BattleEventName.PassiveDamageBeShare, _CallBack,skill) + role.Event:DispatchEvent(BattleEventName.PassiveDamageShare, _CallBack,skill,atkRole) + atkRole.Event:DispatchEvent(BattleEventName.PassiveDamageBeShare, _CallBack,skill,role) ff = BattleUtil.CountChangeList(ff, cl) -- 计算分摊伤害 @@ -4078,17 +4115,21 @@ local passivityList = { if maxNum and maxNum > 0 then cf = cf/maxNum end - - local targets = skill:GetDirectTargets() - if not targets or #targets == 0 then return end - - for _, target in ipairs(targets) do - BattleUtil.RandomAction(cf, function() - BattleLogic.BuffMgr:ClearBuff(target, function(buff) - return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce - end) + BattleUtil.RandomAction(cf, function() + BattleLogic.BuffMgr:ClearBuff(defRole, function(buff) + return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce end) - end + end) + --local targets = skill:GetDirectTargets() + --if not targets or #targets == 0 then return end + -- for _, target in ipairs(targets) do + -- LogError("11111111111") + -- BattleUtil.RandomAction(cf, function() + -- BattleLogic.BuffMgr:ClearBuff(target, function(buff) + -- return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce + -- end) + -- end) + -- end end end role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore,nil,nil,role) @@ -4136,18 +4177,22 @@ local passivityList = { end end - end,nil,nil,role) + end) end, - -- 对敌方造成伤害如被分摊其分摊比降低[a]% - -- a[float] + -- 对敌方造成伤害如被分摊其分摊比降低[a]%,判断类型[b](b:1 普攻 2 技能 3 所有 4:燃烧目标 技能 ) + -- a[float],b[int] [196] = function(role, args,id,judge) local f1 = args[1] local type = args[2] - local onDamageBeShare = function(func,skill) + local onDamageBeShare = function(func,skill,target) if skill and not skill.isTriggerJudge and judge==1 then return - end + end + if type==4 and (not BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return buff.type== BuffName.DOT and buff.damageType==1 end,role,1) + or (skill and (skill.type==BattleSkillType.Normal or skill.type==BattleSkillType.ChaosNormal))) then + return + end --普攻不会被降低分摊 2020/11/17 wangzhenxing lihaiyang if type==1 and skill and skill.type~=BattleSkillType.Normal then return @@ -4197,14 +4242,21 @@ local passivityList = { end, - --每回合最多受到自身生命上限[a]%的伤害(该伤害为来自武将的直接伤害) + --每回合最多受到自身生命上限[a]%的伤害(该伤害为来自武将的直接伤害,血量最多扣到50%) --a[float] [199] = function(role, args) local f1 = args[1] - local curDamage = 0 + local maxPro=0 local function onRoundChange() curDamage = 0 + --本回合最多能扣到多少比例的血条 + maxPro=(role:GetRoleData(RoleDataName.Hp)/role:GetRoleData(RoleDataName.MaxHp))-f1 + if maxPro<0 then + maxPro=0 + end + --LogError("本回合最多能扣到的比例=="..maxPro) + end BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange,nil,nil,role) @@ -4215,8 +4267,12 @@ local passivityList = { return end -- - local maxDamage = role:GetRoleData(RoleDataName.MaxHp) * f1 - curDamage = curDamage + damage + --local maxDamage = role:GetRoleData(RoleDataName.MaxHp) * f1 + --curDamage = curDamage + damage + --判断伤害是否能超出能扣除的最大伤害 + local maxDamage =floor(role:GetRoleData(RoleDataName.Hp)-(role:GetRoleData(RoleDataName.MaxHp) * maxPro)) + --LogError("本次能扣的最大伤害=="..maxDamage.." 本次伤害=="..damage) + curDamage=damage if curDamage > maxDamage then -- 计算免除的伤害值 local md = curDamage - maxDamage @@ -4227,7 +4283,7 @@ local passivityList = { end end - role.Event:AddEvent(BattleEventName.FinalBeDamageEnd, onFinalBeDamage,nil,nil,role) + role.Event:AddEvent(BattleEventName.CheckLiZhanZhiQu, onFinalBeDamage,nil,nil,role) end, @@ -4258,8 +4314,8 @@ local passivityList = { table.insert(cl, {v, ct}) end end - role.Event:DispatchEvent(BattleEventName.PassiveDamageShare, _CallBack,skill) - atkRole.Event:DispatchEvent(BattleEventName.PassiveDamageBeShare, _CallBack,skill) + role.Event:DispatchEvent(BattleEventName.PassiveDamageShare, _CallBack,skill,atkRole) + atkRole.Event:DispatchEvent(BattleEventName.PassiveDamageBeShare, _CallBack,skill,defRole) ff = BattleUtil.CountChangeList(ff, cl) local shareDamage = floor(BattleUtil.ErrorCorrection(damage * f1*ff)) -- 被攻击武将自身伤害 @@ -5382,38 +5438,40 @@ local passivityList = { -- 击杀数量累加 local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) --如果是技能并且这个被动已经被触发过 return - if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,id) then + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,id) then return end if skill and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then - killNum = killNum + 1 + --killNum = killNum + 1 if skill then --skill.isTriggePassivity=true table.insert(skill.triggerPassivityId,id) end + local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[5], f1, ct) + role:AddBuff(buff) end end role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit,nil,nil,role) -- 释放技能时计算额外伤害 - local OnSkillCast = function(skill) - if skill then - extra = f1 * killNum - end - end - role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast,nil,nil,role) + -- local OnSkillCast = function(skill) + -- if skill then + -- extra = f1 * killNum + -- end + -- end + -- role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast,nil,nil,role) - -- 造成伤害时判断额外伤害 - 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,nil,nil,role) + -- -- 造成伤害时判断额外伤害 + -- 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,nil,nil,role) end, -- 直接伤害击杀[a]目标回复[b]%的最大生命 重写148 一次技能只触发一次被动 @@ -5618,9 +5676,15 @@ local passivityList = { return end local val = -floor(BattleUtil.FP_Mul(dt, defRole:GetRoleData(BattlePropList[f1]))) - if func then - func(val) + if f1==12 or f1==13 then + BattleUtil.FinalDamage(nil,role,defRole,-val) + else + if func then + func(val) + end end + + end end role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging,nil,nil,role) @@ -5671,11 +5735,12 @@ local passivityList = { end role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging,nil,nil,role) end, - --本次技能中如果有[a]目标,额外回复[b]点怒气 - -- a[持续伤害状态],b[int] + --本次技能中如果有[a]目标,额外回复[b]点怒气,[c]buff的类型(a 填效果类型里面的具体类型; c 不填/1为dot, 2为controll ) + -- a[持续伤害状态],b[int],c[int ] [261]=function(role,args,id,judge) local dot=args[1] - local i1 = args[2]--defRole, damage, bCrit, finalDmg, damageType, skill + local i1 = args[2] + local type = args[3] local OnRoleHit = function(skill) -- if skill and skill.owner==role and (skill.type==BattleSkillType.Special or skill.type==BattleSkillType.Extra) and role.camp~=defRole.camp and defRole and BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT, function(buff) return buff.damageType == dot end) then -- role:AddRage(i1, CountTypeName.Add) @@ -5689,8 +5754,18 @@ local passivityList = { return end local num=0 + local buffName=BuffName.DOT + if type then + if type==1 then + buffName=BuffName.DOT + elseif type==2 then + buffName=BuffName.Control + end + end for key, value in pairs(list) do - local isHave=BattleLogic.BuffMgr:HasBuff(value, BuffName.DOT, function(buff) return buff.damageType == dot and buff.caster==role and buff.startRound == BattleLogic.GetCurRound() end,role,dot) + local isHave=BattleLogic.BuffMgr:HasBuff(value, buffName,function(buff) return + (buffName==BuffName.DOT and buff.damageType==dot or buff.ctrlType==dot) and buff.caster==role and buff.startRound == BattleLogic.GetCurRound() + end,role,dot) if isHave then num=num+1 end @@ -5735,6 +5810,9 @@ local passivityList = { local round=args[1] local pro=args[2] local onRoleDamageBefore=function(defRole, factorFunc, damageType, skill) + if not skill then + return + end if skill and not skill.isTriggerJudge and judge==1 then return end @@ -5742,7 +5820,7 @@ local passivityList = { if BattleLogic.GetCurRound() ~= round then return end - if defRole and defRole.camp~=role.camp and skill.owner==role and (skill.type==BattleSkillType.Special or skill.type==BattleSkillType.Extra) then + if defRole and defRole.camp~=role.camp and skill and skill.owner==role and (skill.type==BattleSkillType.Special or skill.type==BattleSkillType.Extra) then BattleUtil.RandomAction(pro, function() BattleLogic.BuffMgr:ClearBuff(defRole, function(buff) --之前写的 buff.immuneType == 2 不知道为什么清除免疫燃烧 改成==1 了 by:王振兴 2021/06/09 @@ -5906,6 +5984,9 @@ local passivityList = { local curBuff=nil local onRoleDamageBefore=function(atkRole, factorFunc, damageType, skill) + if not skill then + return + end if atkRole.camp~= role.camp and BattleLogic.BuffMgr:HasBuff(skill.owner, BuffName.DOT, function (buff) return buff.damageType == sta1 end,role,sta1) then --curBuff=Buff.Create(role, BuffName.Immune, 1,4,immune) -- role:AddBuff(curBuff) @@ -6049,6 +6130,9 @@ local passivityList = { local curBuff=nil local immuneState=false local onRoleDamageBefore=function(atkRole, factorFunc, damageType, skill) + if not skill then + return + end if atkRole.camp~= role.camp and BattleLogic.BuffMgr:HasBuff(skill.owner, BuffName.DOT, function (buff) return buff.damageType == sta1 end,role,sta1) then --curBuff=Buff.Create(role, BuffName.Immune, 1,4,immune) -- role:AddBuff(curBuff) @@ -6243,7 +6327,7 @@ local passivityList = { if num>=0 then --精卫转移怒气不算减怒 role.Rage=role.Rage-lessRage - BattleUtil.CalRage(role,caster,lessRage,CountTypeName.Add) + BattleUtil.CalRage(role,caster,lessRage,CountTypeName.Add,true) -- 用于记录统计 BattleLogic.Event:DispatchEvent(BattleEventName.RecordTransRage, role, caster, lessRage) end @@ -6321,11 +6405,12 @@ local passivityList = { fireNum=fireNum+1 end end + num=fireNum end list=BattleUtil.SortByRage(list,0) for i = 1, #list do - if i<=fireNum then + if i<=num then BattleUtil.CalRage(role, list[i], v1, ct) end end @@ -6958,18 +7043,16 @@ local passivityList = { if role:IsDead() then return end - -- if skill and not skill.isTriggerJudge and judge==1 then - -- return - -- end - -- LogYellow("307 1") - if skill and (skill.type==BattleSkillType.Special or skill.type== BattleSkillType.Extra or skill.type== BattleSkillType.Monster) then --技能造成的直接伤害 - local list = RoleManager.Query(function(v) return v.camp == role.camp end) + if skill and (skill.type==BattleSkillType.Special or skill.type== BattleSkillType.Extra or skill.type== BattleSkillType.DeadSkill) then --技能造成的直接伤害 + local list = RoleManager.NoOrder(function(v) return v.camp == role.camp end) BattleUtil.SortByHpFactor(list, 1) - -- LogYellow("307 2") if list[1] then - -- LogYellow("307 3") local val = floor(BattleUtil.FP_Mul(f1, list[1]:GetRoleData(BattlePropList[pro]))) - BattleUtil.CalTreat(role, list[1], val) + if pro==12 then + BattleUtil.FinalTreat(role, list[1], val) + else + BattleUtil.CalTreat(role, list[1], val) + end end end end @@ -7024,11 +7107,26 @@ local passivityList = { local ctr2 = args[3] local ctr3 = args[4] local ctr4 = args[5] - local SkillCast = function(damagingFunc, defRole, damage, skill) + 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 SkillCast = function(skill) + if not skill then + return + end + if skill.type ~= BattleSkillType.Special and skill.type ~= BattleSkillType.Extra and skill.type ~= BattleSkillType.DeadSkill then + return + end local list = RoleManager.Query(function(v) return v.camp == role.camp end) BattleUtil.SortByHpFactor(list, 1) local target = nil - -- LogYellow("309 1: "..#list) for i = 1, #list do if not list[i]:IsRealDead() then target = list[i] @@ -7036,10 +7134,8 @@ local passivityList = { end end if target and target.roleData.element==ele then - -- LogYellow("309 2") BattleLogic.BuffMgr:ClearBuff(target, function(buff) - -- LogYellow("309 3: "..buff.type.." "..buff.ctrlType) - return buff.type == BuffName.Control and (buff.ctrlType == ctrl or buff.immuneType == ctr2 or buff.immuneType == ctr3 or buff.immuneType == ctr4) + return buff.type == BuffName.Control and BattleUtil.ChecklistIsContainValue(ctrls,buff.ctrlType) end) end end @@ -7064,13 +7160,13 @@ local passivityList = { -- LogYellow("310 2 周围的目标造成[a]%的[b]属性伤害 value:"..value.position) local val = floor(BattleUtil.FP_Mul(f1, role:GetRoleData(BattlePropList[pro]))) -- LogYellow("310 end pro: "..pro.." val: "..val) - BattleUtil.FinalDamage(role, value, val) + BattleUtil.FinalDamage(nil,role, value, val) end end end end end - role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit,nil,nil,role) + role.Event:AddEvent(BattleEventName.Seckill, onRoleHit,nil,nil,role) end, -- 触发追击技能时,该追击技能的伤害[a]% 提高[b]改变类型 -- a[float] b[int,改变类型] @@ -7096,31 +7192,51 @@ local passivityList = { [312] = function(role, args) local n1 = args[1] local curRoundAddValue = 0--当前回合加的所有怒气点数 - local onRecordRageChange = function(caster, target, deltaRage,countType,value) + local onRecordRageChange = function(caster, target, deltaRage,countType,value,lastRage,isBorrow) + --如果是精卫借的怒气 2021/10/09 wangzhenxing + if isBorrow then + return + end + + if curRoundAddValue > n1 then + return + end + + if target.camp==role.camp then + return + end + -- LogYellow("312 1") if countType == CountTypeName.Add then -- LogYellow("312 2") local list=BattleLogic.BuffMgr:GetBuff(target) + local endAddNum=0 + local isHave=false for i = 1, #list do local buff=list[i] -- 有连接符 - if BattleLogic.BuffMgr:HasBuff(target, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end) then - -- LogYellow("312 3") - if curRoundAddValue <= n1 then - local endAddNum = value - if (curRoundAddValue + endAddNum) > n1 then - endAddNum = n1 - curRoundAddValue + if not isHave then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end) then + -- LogYellow("312 3") + if curRoundAddValue <= n1 then + endAddNum = value + if (curRoundAddValue + endAddNum) > n1 then + endAddNum = n1 - curRoundAddValue + end + -- LogYellow("312 4 endAddNum: "..endAddNum) + isHave=true end - -- LogYellow("312 4 endAddNum: "..endAddNum) - curRoundAddValue = curRoundAddValue + endAddNum - BattleUtil.CalRage(role,role,endAddNum,CountTypeName.Add) - return - end + end end end + if isHave and endAddNum>0 then + curRoundAddValue = curRoundAddValue + endAddNum + BattleUtil.CalRage(role,role,endAddNum,CountTypeName.Add) + end end end BattleLogic.Event:AddEvent(BattleEventName.RecordRageChange, onRecordRageChange,nil,nil,role) + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) -- LogYellow("312 5 curRoundAddValue = 0") curRoundAddValue = 0 @@ -7239,7 +7355,7 @@ local passivityList = { end, -- 技能施加控制状态失败,回复自身[a]点怒气() -- a[int] - [318] = function(role, args) + [318] = function(role, args,id,judge) local f1 = args[1] local ctrlNum=0 @@ -7428,7 +7544,7 @@ local passivityList = { end, --释放技能怒气不足时,损失自身([a]-我方活着的[b]系神将数)%生命*不足怒气数 后释放技能 --a[int],b[int] - [324]=function(role,args) + [324]=function(role,args,id,judge) local max=args[1] local ele=args[2] local onRoleCastSkillBrfore=function(caster) @@ -7455,7 +7571,7 @@ local passivityList = { end, -- 被自身控制[a]的敌方目标,己方[b]阵营神将对其造成伤害增加[c]% -- a[int 控制状态] b[int] c[float] - [325] = function(role, args) + [325] = function(role, args,id,judge) local f1 = args[1] local ele = args[2] local f2 = args[3] @@ -7564,17 +7680,19 @@ local passivityList = { if deadRole~=role then return end - BattleUtil.RandomAction(p1, function () - local list = RoleManager.Query(function(r) - return r.camp ~= role.camp + BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime,function() + BattleUtil.RandomAction(p1, function () + local list = RoleManager.Query(function(r) + return r.camp ~= role.camp + end) + if #list < 1 then return end + local index = Random.RangeInt(1, #list) + local target = list[index] + BattleUtil.Seckill(nil,role,target) end) - if #list < 1 then return end - local index = Random.RangeInt(1, #list) - local target = list[index] - BattleUtil.Seckill(nil,role,target) end) end - BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, onRoleRealDead,nil,nil,role) + role.Event:AddEvent(BattleEventName.RoleRealDead, onRoleRealDead,nil,nil,role) end, --行动后,每剩余1点怒气对[a]自己造成伤害[b][c]%的伤害 --a[int 1:自己],b[int],c[float] @@ -7743,7 +7861,7 @@ local passivityList = { end, -- 武将怒气为[a]点时即可释放技能,释放技能消耗当前所有怒气 超过[c]点的怒气部分 每消耗1点怒气技能伤害为[b]%(c不填默认为4) -- a[int]b[float],c[int] - [336] = function(role, args) + [336] = function(role, args,id,judge) local i1 = args[1] local f1 = args[2] local num = args[3] @@ -7776,7 +7894,16 @@ local passivityList = { end end role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging,nil,nil,role) - + + local onPassiveTreat=function(treatFactorFunc, targetRole,skill) + if skill and skill.type == BattleSkillType.Special then + local deltaRage = allRage - num + if deltaRage > 0 then + treatFactorFunc(1-f1*deltaRage,CountTypeName.Sub) + end + end + end + role.Event:AddEvent(BattleEventName.PassiveTreatingFactor,onPassiveTreat,nil,nil,role) end, -- 直接伤害击杀目标后下回合必定暴击 -- a[int] @@ -7811,6 +7938,9 @@ local passivityList = { end end local function onRoleDamageBefore(skill) + if not skill then + return + end if skill and not skill.isTriggerJudge and judge==1 then return end @@ -7844,8 +7974,522 @@ local passivityList = { end BattleLogic.Event:AddEvent(BattleEventName.BattleRoundStart, onRoundStart,nil,nil,role) + end, + -- 受到直接伤害的[a]%转换为护甲 + -- a[float] + [338] = function(role, args,id,judge) + local f1 = args[1] + local onBeHit = function(caster, damage, bCrit, finalDmg, damageType, skill,isDirect) + if finalDmg<=0 then + return + end + --如果角色死亡就不会反弹伤害 + if role:IsDead() then + return + end + --不是真实伤害 + if not skill and not isDirect then + return + end + local rDamage =floor(f1 * damage) + + if role.bloodShield then + role.bloodShield:AddValue(rDamage) + else + role:AddBuff(Buff.Create(role, BuffName.Blood,0, rDamage)) + end + + end + role.Event:AddEvent(BattleEventName.RoleBeHit, onBeHit,nil,nil,role) + end, + --每次行动未造成击杀,则该行动主目标造成其[a][b]%的间接伤害 + --a[int 属性],b[float] + [339] = function(role, args,id,judge) + local p1 = args[1] + local v1 = args[2] + local isNoDie=true + --获取主目标 + local onSkillCast = function(skill) + if not skill then + return + end + if skill and not skill.isTriggerJudge and judge==1 then + return + end + local list=skill:GetDirectTargets() + local target=RoleManager.GetAggroHero(role,list) + if target and BattleUtil.LengthOfTable(target)>0 then + role.curMainTarget=target[1] + end + end + role.Event:AddEvent(BattleEventName.SkillCastBefore, onSkillCast,nil,nil,role) + + local onRoleKill=function(defRole,skill) + isNoDie=false + end + local onTurnStar=function(role) + role.Event:AddEvent(BattleEventName.RoleKill,onRoleKill,nil,nil,role) + end + role.Event:AddEvent(BattleEventName.RoleTurnStart, onTurnStar,nil,nil,role) + local onTurnEnd=function(role) + role.Event:RemoveEvent(BattleEventName.RoleKill,onRoleKill,nil,nil,role) + if isNoDie then + local damage=floor(BattleUtil.FP_Mul(role.curMainTarget:GetRoleData(BattlePropList[p1]),v1)) + BattleUtil.FinalDamage(nil,role,role.curMainTarget,damage) + end + isNoDie=true + end + role.Event:AddEvent(BattleEventName.RoleTurnEnd, onTurnEnd,nil,nil,role) + end, + -- 为己方单位恢复怒气是,为主目标添加[a] 属性[b] [c]%的效果,持续[d]回合,每回合最多生效一次 + -- a[int 改变类型] b[int] c[float] d[int] + [340] = function(role, args,id,judge) + local ct = args[1] + local p1 = args[2] + local v1=args[3] + local round=args[4] + local isTurn=false + local onRoleHit = function(caster, target, deltaRage, countType, value) + if not isTurn then + return + end + + if caster~=role then + return + end + if target.camp~=role.camp or countType~=CountTypeName.Add then + return + end + target:AddBuff(Buff.Create(role, BuffName.PropertyChange,round, BattlePropList[p1],v1, ct)) + isTurn=false + end + BattleLogic.Event:AddEvent(BattleEventName.RecordRageChange, onRoleHit,nil,nil,role) + + + local onRoleTurnStart=function() + isTurn=true + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundStart,onRoleTurnStart,nil,nil,role) + end, + -- 造成直接伤害时,自身每有[a]点怒气,造成的伤害增加[b]%,最高为[c]% + -- a[int],b[float],c[float] + [341] = function(role, args,id,judge) + local num = args[1] + local f1 = args[2] + local f2 = args[3] + + local count=0 + local OnSkillCast=function(skill) + count=floor(role.Rage/num) + end + role.Event:AddEvent(BattleEventName.ActionOperateAngerBefore,OnSkillCast,nil,nil,role) + local OnPassiveDamaging = function(damagingFunc, target, damage,skill) + if not skill then + return + end + + local add=count*f1 + if add>f2 then + add=f2 + end + + damagingFunc(-floor(BattleUtil.FP_Mul(add,damage))) + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging,nil,nil,role) + end, + --回合行动形成追击时,每次追击造成的伤害增加[a]% + --a[float] + [342] = function(role, args,id,judge) + local p1 = args[1] + local isTurn=false + + -- 如果是行动回合追加的技能的伤害 + local onPassiveDamaging = function(func, target, damage, skill) + + if not skill then + return + end + + if not skill.isAdd then + return + end + if isTurn==false then + return + end + if not skill.isTriggerJudge and judge==1 then + return + end + + if skill.type==BattleSkillType.Special or skill.type==BattleSkillType.Extra or skill.type==BattleSkillType.Normal then + func(-floor(BattleUtil.FP_Mul(p1,damage))) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging,nil,nil,role) + + local onTurnStar=function(role) + isTurn=true + end + role.Event:AddEvent(BattleEventName.RoleTurnStart, onTurnStar,nil,nil,role) + + local onTurnEnd=function(role) + isTurn=false + end + role.Event:AddEvent(BattleEventName.RoleTurnEnd, onTurnEnd,nil,nil,role) + end, + --回合结束时,与自己怒气相同的己方单位同时回复[a]点怒气 + --a[int] + [343]=function(role,args,id,judge) + local num=args[1] + local onRoundChange=function(round) + if round==0 then + return + end + local list = RoleManager.Query(function(v) return role.camp == v.camp end) + for _, r in pairs(list) do + if r.Rage==role.Rage and r~=role then + BattleUtil.CalRage(role,r,num,CountTypeName.Add) + end + end + BattleUtil.CalRage(role,role,num,CountTypeName.Add) + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundEnd, onRoundChange,nil,nil,role) + end, + --释放技能时,对控制成功的目标,技能的直接伤害增加[a]%;失败使目标 属性[b] 改变[c] [d]% 持续[e]回合 + --a[float],b[int 属性id],c[int 改变类型],d[float],e[int] + [344]=function(role,args,id,judge) + local p1=args[1] + local pro = args[2] + local ct = args[3] + local v1 = args[4] + local round = args[5] + local curSkill=nil + --添加buff成功 + local OnBuffBeAdd=function(buff) + if not buff or buff.caster~=role or buff.type~=BuffName.Control then + return + end + --添加技能额外伤害 + if curSkill then + local finalDamage=floor(role.superSkillDamage*p1) + BattleUtil.ApplyDamageNoPassive(curSkill,role,buff.target,finalDamage) + end + end + --添加buff失败 + local OnBuffAddFail=function(buff) + if not buff or buff.caster~=role or buff.type~=BuffName.Control then + return + end + if buff.target then + buff.target:AddBuff(Buff.Create(role, BuffName.PropertyChange, round, BattlePropList[pro],v1, ct)) + end + end + + local OnSkillCast=function(skill) + if skill.type~=BattleSkillType.Special then + return + end + curSkill=skill + BattleLogic.Event:AddEvent(BattleEventName.RoleAddBuffFail,OnBuffAddFail,nil,nil,role) + role.Event:AddEvent(BattleEventName.BuffCaster,OnBuffBeAdd,nil,nil,role) + end + role.Event:AddEvent(BattleEventName.SkillCast,OnSkillCast,nil,nil,role) + + local OnSkillCastEnd=function(skill) + if skill.type~=BattleSkillType.Special then + return + end + curSkill=nil + BattleLogic.Event:RemoveEvent(BattleEventName.RoleAddBuffFail,OnBuffAddFail,nil,nil,role) + role.Event:RemoveEvent(BattleEventName.BuffCaster,OnBuffBeAdd,nil,nil,role) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd,OnSkillCastEnd,nil,nil,role) + end, + --持续伤害效果[a]结算时,对目标造成其[b][c]%的伤害 + -- a[int dot类型id] b[int 属性id],c[float] + [345]=function(role,args) + local type=args[1] + local pro=args[2] + local v1=args[3] + local OnBuffEnd=function(buff) + if buff and buff.caster==role and buff.damageType==type then + local val = floor(BattleUtil.FP_Mul(v1, buff.target:GetRoleData(BattlePropList[pro]))) + BattleUtil.FinalDamage(nil,role,buff.target, val) + end + end + BattleLogic.Event:AddEvent(BattleEventName.DotBuffEnd, OnBuffEnd,nil,nil,role) + end, + --技能对[a]阵营/职业目标 伤害[b]改变[c]% ,[d]类型(1:阵营 2:职业) + -- a[int] b[int],c[float],d[int] + [346]=function(role,args,id,judge) + local v1=args[1] + local ct=args[2] + local v2=args[3] + local type=args[4] + local OnPassiveDamaging = function(damagingFunc, defRole, damage,skill) + if skill and not skill.isTriggerJudge and judge==1 then + return + end + if not defRole then + return + end + if defRole.camp==role.camp then + return + end + --如果不是限定阵营 + if type==1 and defRole.element~=v1 then + return + end + --如果不是限定职业 + if type==2 and defRole.professionId~=v1 then + return + end + damagingFunc(-floor(v2 * damage)) + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging,nil,nil,role) + end, + --敌方单位死亡立即回复满血(没有表现) + [347]=function(role,args,id,judge) + + local onRoleHit = function(deadRole) + if deadRole.camp==role.camp then + return + end + --BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () + local addHp=role:GetRoleData(RoleDataName.MaxHp) - role:GetRoleData(RoleDataName.Hp) + role.data:AddValue(RoleDataName.Hp,addHp) + --end) + end + BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, onRoleHit,nil,nil,role) + end, + --第[a]回合结束后,自身血量未降低到[b]%,[c]属性[d]改变 [e]% 持续[f]回合,[g]属性[h]改变 [i]% 持续[j]回合(g,h,i,j任一参数不填都不会生效) + --a[int],b[float],c[int 属性],d[int 改变类型],e[float],f[int], g[int 属性],h[int,改变类型],i[float],j[int] + [348]=function(role,args,id,judge) + local round = args[1] + local prop = args[2] + local pro1 = args[3] + local ct1 = args[4] + local v1 = args[5] + local r1 = args[6] + local pro2 = args[7] + local ct2 = args[8] + local v2 = args[9] + local r2 = args[10] + local OnRoundEnd=function(curRound) + if curRound~= round then + return + end + local curProp=BattleUtil.GetHPPencent(role) + if curProp<=prop then + return + end + + if r1 and pro1 and v1 and ct1 then + role:AddBuff(Buff.Create(role,BuffName.PropertyChange, r1, BattlePropList[pro1], v1, ct1)) + end + + if r2 and pro2 and v2 and ct2 then + role:AddBuff(Buff.Create(role,BuffName.PropertyChange, r2, BattlePropList[pro2], v2, ct2)) + end + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundEnd,OnRoundEnd) + end, + --每回合最多减少[a]点怒气(不受放逐影响) + --a[int] + [349]=function(role,args,id,judge) + local maxNum=args[1] + role.RoundMaxSubRage=maxNum + local OnRoundEnd=function(curRound) + role.AllSubRage=0 + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundEnd,OnRoundEnd) + end, + -- 第[a]回合中,敌人受到的任何伤害会对其他敌人造成该伤害[b]%的间接伤害 + -- a[int],b[float] + [350] = function(role, args,id,judge) + + local i1 = args[1] + local f1 = args[2] + + local function OnDamage(func, atkRole, defRole, damage, skill, dotType, bCrit, damageType) + if skill==nil then + return + end + if skill and not skill.isTriggerJudge and judge==1 then + return + end + if defRole.camp ~= role.camp then + if skill or dotType then + local list = RoleManager.Query(function(r) return r.camp == defRole.camp and r ~= defRole end) + for _, r in ipairs(list) do + local dd = floor(BattleUtil.ErrorCorrection(damage* f1)) + BattleUtil.FinalDamage(nil, atkRole, r, dd) + end + end + end + end + + local function onRoundChange(curRound) + if curRound == i1 then + BattleLogic.Event:AddEvent(BattleEventName.FinalDamage, OnDamage) + elseif curRound == i1 + 1 then + BattleLogic.Event:RemoveEvent(BattleEventName.FinalDamage, OnDamage) + end + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange) end, + + --自身行动回合开始前,为自己添加[a][b]%的御甲 + --a[int],b[float] + [351] = function(role, args,id,judge) + local pro = args[1] + local v1 = args[2] + local onRoundChange=function(curRound) + local val = floor(BattleUtil.FP_Mul(v1, role:GetRoleData(BattlePropList[pro]))) + --如果身上有御甲就添加御甲的值 + if role.bloodShield then + role.bloodShield:AddValue(val) + else--没有就上御甲buff + role:AddBuff(Buff.Create(role, BuffName.Blood,0, val)) + end + end + role.Event:AddEvent(BattleEventName.RoleTurnStart, onRoundChange,nil,nil,role) + end, + -- 行动击杀目标,追加[a]次普攻 + -- a[int] + [352] = function(role, args,id,judge) + local i1 = args[1] + local isTurn=false + local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) + if not skill then + return + end + --改为一次行动只触发一次,不管这次行动追加多少次技能,击杀多少次,都只触发一次 by:wangzhenxing dengdan 2021/7/16 + if not isTurn then + return + end + if skill.isNotLoop then + return + end + --如果是技能并且这个被动已经被触发过 return + if skill and BattleUtil.ChecklistIsContainValue(skill.triggerPassivityId,id) then + return + end + + if target:IsDead() and not BattleUtil.CheckIsNoDead(target) and not role:IsDead() then + for i = 1, i1 do + role:AddSkill(BattleSkillType.Normal, false, true, nil,true,true) + end + isTurn=false + if skill then + table.insert(skill.triggerPassivityId,id) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit,nil,nil,role) + + + local onRoleTurnStart=function() + isTurn=true + end + role.Event:AddEvent(BattleEventName.RoleTurnStart,onRoleTurnStart,nil,nil,role) + end, + --直接伤害击杀目标溢出伤害的[a]%将对当前生命绝对值[b]的目标造成伤害 + -- a[float],b[int] + [353]=function(role,args,id,judge) + local f1 = args[1] + local type = args[2] or 0 + local allDamage = 0 + -- 伤害清空 + local onSkillCastBefore=function (skill) + if not skill then + return + end + allDamage = 0 + end + role.Event:AddEvent(BattleEventName.SkillCastBefore,onSkillCastBefore,nil,nil,role) + -- 直接伤害后 + local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) + if skill and not skill.isTriggerJudge and judge==1 then + return + end + if skill and skill.owner==role and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then + local dmg= floor(BattleUtil.ErrorCorrection((damage-finalDmg)*f1)) + allDamage = allDamage + dmg + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit,nil,nil,role) + -- 技能释放结束 + local onSkillCastEnd=function (skill) + if not skill then + return + end + if allDamage > 0 then + local list = RoleManager.Query(function(v) return v.camp ~= role.camp end) + list = BattleUtil.SortByProp(list, RoleDataName.Hp,type) + if list and list[1] then + BattleUtil.ApplyDamage(nil, role, list[1], allDamage) + allDamage = 0 + end + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd,onSkillCastEnd,nil,nil,role) + end, + --回合开始前给自身增加[a][b]%的御甲,每场战斗触发[c]次 + --a[int 属性id], b[flaot], c[int] + [354]=function(role,args,id,judge) + local pro = args[1] + local v1 = args[2] + local num = args[3] + local time=0 + local onRoundStart= function(round) + if time>=num then + return + end + local val = floor(BattleUtil.FP_Mul(v1, role:GetRoleData(BattlePropList[pro]))) + --如果身上有御甲就添加御甲的值 + if role.bloodShield then + role.bloodShield:AddValue(val) + else--没有就上御甲buff + role:AddBuff(Buff.Create(role, BuffName.Blood,0, val)) + end + time=time+1 + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundStart,onRoundStart,nil,nil,role) + end, + + --[a]数回合,自身释放技能,己方全体神将 [b]属性[c]改变[d]%,持续[e]回合(e:0为永久) + --a[int 1:奇数 0:偶数 ] b[int 属性id], c[int 改变类型], d[float],e[int] + [355]=function(role,args,id,judge) + local type = args[1] + local pro = args[2] + local ct = args[3] + local v1 = args[4] + local round = args[5] + + local onSkillCast = function(skill) + if not skill then + return + end + local r=BattleLogic.GetCurRound() + if r%2~=type then + return + end + if skill and not skill.isTriggerJudge and judge==1 then + return + end + if skill.type==BattleSkillType.Special + or skill.type==BattleSkillType.Extra + or skill.type==BattleSkillType.DeadSkill then + local list = RoleManager.Query(function(v) return role.camp == v.camp end) + for _, r in pairs(list) do + r:AddBuff(Buff.Create(role, BuffName.PropertyChange, round, BattlePropList[pro],v1, ct)) + end + end + end + role.Event:AddEvent(BattleEventName.SkillCastBefore,onSkillCast,nil,nil,role) + end, + } return passivityList diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index e541652f4..57c61bd70 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -234,8 +234,12 @@ function BattleLogic.TurnRound(debugTurn) -- 第一次进入 或者 本轮结束 初始化流程状态 if CurRound == 0 or (CurSkillPos[0] == 6 and CurSkillPos[1] == 6) then if CurRound ~= 0 then - -- 上一轮结束 - BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundEnd, CurRound) + if BattleLogic.CheckHaveInsertRole() then + return + else + -- 上一轮结束 + BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundEnd, CurRound) + end end -- 检测一次灵兽技能 SkillManager.CheckMonsterSkill(function() @@ -378,6 +382,61 @@ function BattleLogic.CheckBattleLogic() SkillRole:CastSkill() end +--检测是否有插入得英雄 +function BattleLogic.CheckHaveInsertRole() + if insertSkillRole then + local SkillRole=insertSkillRole + insertSkillRole=nil + -- 如果找不到下一个人,直接交换阵营 + if not SkillRole then + BattleLogManager.Log( "No Skill Position" ) + BattleLogic.TurnRoundNextFrame() + return + end + -- + BattleLogManager.Log( + "Position Change", + "position", CurSkillPos[CurCamp] + ) + + -- 行动 + SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnStart, SkillRole) -- 开始行动 + BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnStart, SkillRole) -- 开始行动 + -- buff计算 + BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 + BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) + -- 设置行动完成回调 + SkillManager.SetTurnRoundFunc(function() + BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) + BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff + BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 + BattleLogic.BuffMgr:PassUpdateNoDead() -- 计算buff不灭 + SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 行动结束 + BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 开始行动 + BattleLogic.TurnRoundNextFrame() + end) + + -- 如果角色无法释放技能 + if not SkillRole:IsAvailable() -- 角色不能释放技能 + or (SkillRole:IsDead() -- 将死状态 + and not BattleLogic.BuffMgr:HasBuff(SkillRole,BuffName.NoDead) --将死但没有不死buff + and not SkillManager.HaveMySkill(SkillRole)) -- 也没有要释放的技能 + then + SkillManager.CheckTurnRound() + return + end + + -- 释放技能后,递归交换阵营 + SkillRole:CastSkill() + return true + else + return false + 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/Buff/Blood.lua b/luafight/Modules/Battle/Logic/Buff/Blood.lua new file mode 100644 index 000000000..abfc17338 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Buff/Blood.lua @@ -0,0 +1,62 @@ +Blood = Buff:New() + +--初始化Buff,通过传入一些自定义参数控制成长相关的数值 +function Blood:SetData(...) + + -- 刷新排序等级 + self.bloodValue=... + self.sort = 4 + +end + +function Blood:AddValue(value) + self.bloodValue=self.bloodValue+value + self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),1,value) +end + + + +--初始化后调用一次 +function Blood:OnStart() + self.target.bloodShield = self + self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),1,self.bloodValue) +end +function Blood:GetCurValue() + return self.bloodValue +end + +--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd +function Blood:OnTrigger() + return true +end + +--效果结束时调用一次 +function Blood:OnEnd() + self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,0) + self.target.bloodShield = nil + self.bloodValue=0 +end +--计算血甲 +function Blood:CountBloodValue(damage) + local finalDamage=0 + self.bloodValue=self.bloodValue-damage + if self.bloodValue<=0 then + self.disperse=true + finalDamage=self.bloodValue + end + local value=0 + if self.bloodValue<=0 then + value=0 + end + self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp)) + return finalDamage +end + + + +--只有当cover字段为true时触发,返回true则被新效果覆盖 +function Blood:OnCover(newBuff) + return true +end + +return Blood \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Buff/DOT.lua b/luafight/Modules/Battle/Logic/Buff/DOT.lua index 53e28442c..97ce4d19e 100644 --- a/luafight/Modules/Battle/Logic/Buff/DOT.lua +++ b/luafight/Modules/Battle/Logic/Buff/DOT.lua @@ -8,6 +8,7 @@ function DOT:SetData(...) self.damagePro, --1 物理 2 魔法 (真实伤害时 为伤害值) self.damageFactor = ... --伤害系数 self.isRealDamage = false + self.triggerTime=0 --if self.damageType == 2 then -- self.cover = true -- self.layer = 1 @@ -18,14 +19,14 @@ function DOT:SetData(...) -- 刷新排序等级 self.sort = 2 - if self.damageType == 3 then -- 流血buff在行动之后刷新 - self.sort = 3 - end + -- if self.damageType == 3 then -- 流血buff在行动之后刷新 + -- self.sort = 3 + -- end end --初始化后调用一次 function DOT:OnStart() - if self.caster.isTeam then + if self.caster.isTeam or self.caster.type == BattleUnitType.Player then self.isRealDamage = true end end @@ -38,12 +39,14 @@ function DOT:OnTrigger() else BattleUtil.CalDamage(nil, self.caster, self.target, self.damagePro, self.damageFactor, 0, self.damageType) end + self.triggerTime=self.triggerTime+1 return true end --效果结束时调用一次 function DOT:OnEnd() - + BattleLogic.Event:DispatchEvent(BattleEventName.DotBuffEnd, self) + self.triggerTime=0 end --只有当cover字段为true时触发,返回true则被新效果覆盖 diff --git a/luafight/Modules/Battle/Logic/Buff/HOT.lua b/luafight/Modules/Battle/Logic/Buff/HOT.lua index fea844dc4..a26f690aa 100644 --- a/luafight/Modules/Battle/Logic/Buff/HOT.lua +++ b/luafight/Modules/Battle/Logic/Buff/HOT.lua @@ -5,7 +5,7 @@ function HOT:SetData(...) self.interval, self.healValue = ... - + self.hotType=1 -- 1:治愈 2.神佑 -- 刷新排序等级 self.sort = 1 -- 最先计算回血 end @@ -19,7 +19,7 @@ end --修改持续加血效果的加血值 function HOT:ChangeHealValue(newValue) - if newValue then + if newValue and self.hotType~=2 then self.healValue=newValue end end @@ -28,7 +28,24 @@ end function HOT:OnTrigger() if not self.target.ctrl_noheal or self.target:IsDead() then --禁疗和死亡无法加血 - BattleUtil.ApplyTreat(self.caster, self.target, self.healValue) + if self.hotType==2 then + local value=self.target:GetRoleData(RoleDataName.MaxHp)-self.target:GetRoleData(RoleDataName.Hp) + local yujia=0 + if value>0 then + BattleUtil.FinalTreat(self.caster, self.target,value,1,nil) + else + value=0 + end + if self.healValue-value>0 then + if self.target.bloodShield then + self.target.bloodShield:AddValue(self.healValue-value) + else + self.target:AddBuff(Buff.Create(self.caster,BuffName.Blood,0,self.healValue-value)) + end + end + else + BattleUtil.ApplyTreat(self.caster, self.target, self.healValue) + end end return true end diff --git a/luafight/Modules/Battle/Logic/Buff/Immune.lua b/luafight/Modules/Battle/Logic/Buff/Immune.lua index da5f2e820..dc3e282da 100644 --- a/luafight/Modules/Battle/Logic/Buff/Immune.lua +++ b/luafight/Modules/Battle/Logic/Buff/Immune.lua @@ -14,6 +14,13 @@ local immune3 = function(buff) return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce end +--免疫控制不免疫禁疗 +local immune5 = function(buff) + return buff.type == BuffName.Control and buff.ctrlType and buff.ctrlType~=4 +end + + + --初始化Buff,通过传入一些自定义参数控制成长相关的数值 function Immune:SetData(type,func) self.immuneType = type @@ -38,11 +45,11 @@ function Immune:OnStart() elseif self.immuneType==4 then--自定义免疫 if self.immune4 then self.target.buffFilter:Add(self.immune4) - end - end - if condition then - -- body + end + elseif self.immuneType==5 then--免疫控制 不免疫禁疗 + self.target.buffFilter:Add(immune5) end + end --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 712759327..b5dc394e9 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -131,6 +131,7 @@ BattleEventName = { BuffStart = indexAdd(), BuffDodge = indexAdd(), BuffTrigger = indexAdd(), + BuffBeAdd=indexAdd(), BuffEnd = indexAdd(), BuffCountChange = indexAdd(), BuffCover = indexAdd(), @@ -153,9 +154,10 @@ BattleEventName = { RoleCastSkillBefore = indexAdd(), --护盾buff消失以后 ShieldBuffEnd=indexAdd(), - --治疗效果导入 + --治疗效果结束 HotBuffEnd=indexAdd(), - + --dot buff结束 + DotBuffEnd=indexAdd(), -- 战斗记录用 RecordDamage = indexAdd(), -- 伤害 RecordTreat = indexAdd(), -- 治疗 @@ -170,6 +172,9 @@ BattleEventName = { RecordRageChange = indexAdd(), -- 怒气改变时 ActionOperateAngerAfter =indexAdd(),--角色行动操作怒气后 HitRoleInBurn = indexAdd(), --击中在燃烧状态得敌人 + ActionOperateAngerBefore =indexAdd(),--角色行动操作怒气前 + BloodValueChange = indexAdd(), --御甲只发发生改变 + CheckLiZhanZhiQu = indexAdd(),--检测历战之躯 } BattleMaxFrame = 1000000 @@ -203,6 +208,7 @@ RoleDataName = { DarkDamageReduceFactor = indexAdd(), --暗系伤害减免系数(%) ElementDamageBocusFactor = indexAdd(), --属性伤害加成系数(%) InitRage = indexAdd(), --初始怒气值 + } BuffName = { @@ -218,13 +224,14 @@ BuffName = { NoDead = 10, Aura = 11, Brand = 12, + Blood = 13, } DotType = { All = 0, Burn = 1, Poison = 2, - Blooding = 3, + Blooding = 3, } ControlType = { @@ -322,7 +329,8 @@ OutDataName = { BattleUnitType = { Role = 1, - Monster = 2 + Monster = 2, + Player = 3, } BattleRoleElementType = { diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 87b5d7024..96907c8e5 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -8,6 +8,23 @@ local min = math.min --local BattleEventName = BattleEventName BattleUtil.Passivity = require("Modules/Battle/Logic/Base/Passivity") +local function table_removebyvalue(array, value, removeall) + local c, i, max = 0, 1, #array + while i <= max do + if array[i] == value then + table.remove(array, i) + c = c + 1 + i = i - 1 + max = max - 1 + if not removeall then + break + end + end + i = i + 1 + end + return c +end + local function clamp(v, minValue, maxValue) if v < minValue then return minValue @@ -202,6 +219,16 @@ function BattleUtil.SortByHpFactorAndHp(arr, sort) end) return arr end + +--移除队列有不灭的单位 +function BattleUtil.RemoveNoDeadRole(arr) + for i = 1, #arr do + local role=arr[i] + if BattleLogic.BuffMgr:HasBuff(role,BuffName.NoDead) then + table_removebyvalue(arr,role) + end + end +end --按怒气排序 function BattleUtil.SortByRage(arr, sort) BattleUtil.Sort(arr, function(a, b) @@ -352,6 +379,8 @@ function BattleUtil.ChooseTarget(role, chooseId) BattleUtil.SortByProp(arr, RoleDataName.Hp, sort) elseif chooseWeight == 2 then -- 血量百分比 BattleUtil.SortByHpFactor(arr, sort) + --选血量百分比最低的 不选择有不灭的,如果伤害要选有不灭的 需处理 + BattleUtil.RemoveNoDeadRole(arr) elseif chooseWeight == 3 then -- 攻击力 BattleUtil.SortByProp(arr, RoleDataName.Attack, sort) elseif chooseWeight == 4 then -- 防御 @@ -508,7 +537,7 @@ end -- 秒杀 function BattleUtil.Seckill(skill, atkRole, defRole) -- 灵兽无效 - if defRole.type == BattleUnitType.Monster then + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then return end local damage = defRole:GetRoleData(RoleDataName.Hp) @@ -520,7 +549,7 @@ function BattleUtil.Seckill(skill, atkRole, defRole) atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole,skill) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole) - atkRole.Event:DispatchEvent(BattleEventName.Seckill, defRole) + atkRole.Event:DispatchEvent(BattleEventName.Seckill, defRole,damage,nil,finalDmg) defRole.Event:DispatchEvent(BattleEventName.BeSeckill, atkRole) BattleLogic.Event:DispatchEvent(BattleEventName.Seckill, atkRole, defRole) end @@ -540,7 +569,7 @@ end -- 秒杀定额血量 function BattleUtil.SeckillHP(skill, atkRole, defRole, pro) -- 灵兽无效 - if defRole.type == BattleUnitType.Monster then + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then return end local damage = floor(BattleUtil.FP_Mul(defRole:GetRoleData(RoleDataName.MaxHp),pro)) @@ -551,7 +580,7 @@ function BattleUtil.SeckillHP(skill, atkRole, defRole, pro) defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole) atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole,skill) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole) - atkRole.Event:DispatchEvent(BattleEventName.Seckill, defRole) + atkRole.Event:DispatchEvent(BattleEventName.Seckill, defRole,damage,nil,finalDmg) defRole.Event:DispatchEvent(BattleEventName.BeSeckill, atkRole) BattleLogic.Event:DispatchEvent(BattleEventName.Seckill, atkRole, defRole) end @@ -571,7 +600,7 @@ end -- 计算真实伤害 function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) -- 灵兽无效 - if defRole.type == BattleUnitType.Monster then + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then return end @@ -613,9 +642,31 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) end +-- 计算真实伤害(没有被动增伤) +function BattleUtil.ApplyDamageNoPassive(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) + -- 灵兽无效 + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then + return + end + -- 计算护盾减伤 + damage = BattleUtil.CalShield(atkRole, defRole, damage,skill) + -- 造成的最终伤害 + local damagingFunc = function(dmgDeduction) + damage = damage - dmgDeduction + end + + defRole.Event:DispatchEvent(BattleEventName.FinalBeDamageEnd, damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType,isDirect) + BattleLogic.Event:DispatchEvent(BattleEventName.FinalDamage, damagingFunc, atkRole, defRole, damage, skill, dotType, bCrit, damageType) + + -- + return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) +end + + + -- 怒气计算 -function BattleUtil.CalRage(caster, target, value, countType) +function BattleUtil.CalRage(caster, target, value, countType,isBorrow) -- 角色身上有无敌盾,不扣除怒气 by:wangzhenxing 2020/08/10 14:56 if (countType==3 or countType==4) -- 降怒 @@ -625,9 +676,21 @@ function BattleUtil.CalRage(caster, target, value, countType) return end local lastRage=target.Rage + --如果每回合减的怒气超过了每回合上限就不再减怒 + if (countType==3 or countType==4) and target.RoundMaxSubRage~=0 and target.RoundMaxSubRage<=target.AllSubRage then + return + end + --这个减的怒气+已经间的怒气> 怒气限制 + if (countType==3 or countType==4) and target.RoundMaxSubRage~=0 and value+target.AllSubRage>target.RoundMaxSubRage then + value=target.RoundMaxSubRage-target.AllSubRage + end -- 操作怒气 local deltaRage = target:AddRage(value, countType) - BattleLogic.Event:DispatchEvent(BattleEventName.RecordRageChange, caster, target, deltaRage,countType,value,lastRage) + if (countType==3 or countType==4) and target.RoundMaxSubRage~=0 then + target.AllSubRage=target.AllSubRage-deltaRage + end + + BattleLogic.Event:DispatchEvent(BattleEventName.RecordRageChange, caster, target, deltaRage,countType,value,lastRage,isBorrow) -- 用于记录统计 BattleLogic.Event:DispatchEvent(BattleEventName.RecordRage, caster, target, deltaRage) end @@ -672,11 +735,30 @@ end function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) -- 灵兽无效 - if defRole.type == BattleUnitType.Monster then + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then return end if damage < 0 then damage = 0 end - local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage) + + if skill and skill.type==BattleSkillType.Special then + skill.owner.superSkillDamage=damage + end + --计算血量防护 + local realDamage=damage + --血量防护只会防直接伤害 + if defRole.bloodShield and skill then + realDamage=math.abs(defRole.bloodShield:CountBloodValue(damage)) + -- damage=realDamage + end + --检测历战之躯 + -- 造成的最终伤害 + local damagingFunc = function(dmgDeduction) + realDamage = realDamage - dmgDeduction + damage=realDamage + end + defRole.Event:DispatchEvent(BattleEventName.CheckLiZhanZhiQu, damagingFunc, atkRole, realDamage, skill, dotType, bCrit, damageType,isDirect) + --御甲过滤后的伤害只会处理扣血 by: wangzhenxing shihongyi 2021/09/27 + local finalDmg = defRole.data:SubValue(RoleDataName.Hp,realDamage) if finalDmg >= 0 then if defRole:GetRoleData(RoleDataName.Hp) <= 0 and not defRole:IsDead() then defRole:SetDead(damage) @@ -726,15 +808,98 @@ function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageTy return finalDmg end +--计算盾的最终伤害 +function BattleUtil.FinalDamageCountShield(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect) + -- 灵兽无效 + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then + return + end + -- 计算护盾减伤 + damage = BattleUtil.CalShield(atkRole, defRole, damage,skill) + + if damage < 0 then damage = 0 end + if skill and skill.type==BattleSkillType.Special then + skill.owner.superSkillDamage=damage + end + --计算血量防护 + local realDamage=damage + --血量防护只会防直接伤害 + if defRole.bloodShield and skill then + realDamage=math.abs(defRole.bloodShield:CountBloodValue(damage)) + -- damage=realDamage + end + --检测历战之躯 + -- 造成的最终伤害 + local damagingFunc = function(dmgDeduction) + realDamage = realDamage - dmgDeduction + damage=realDamage + end + defRole.Event:DispatchEvent(BattleEventName.CheckLiZhanZhiQu, damagingFunc, atkRole, realDamage, skill, dotType, bCrit, damageType,isDirect) + --LogError("最后扣除伤害=="..realDamage) + --御甲过滤后的伤害只会处理扣血 by: wangzhenxing shihongyi 2021/09/27 + local finalDmg = defRole.data:SubValue(RoleDataName.Hp,realDamage) + if finalDmg >= 0 then + if defRole:GetRoleData(RoleDataName.Hp) <= 0 and not defRole:IsDead() then + defRole:SetDead(damage) + defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole) + atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole,skill) + BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole,skill,dotType) + end + + atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType, dotType, skill) + defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType, dotType, skill) + BattleLogic.Event:DispatchEvent(BattleEventName.RoleDamage, atkRole, defRole, damage, bCrit, finalDmg, damageType, dotType, skill) + BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeDamaged, defRole, atkRole, damage, bCrit, finalDmg, damageType, dotType, skill) + if bCrit then + atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole, damage, bCrit, finalDmg, damageType, skill) + defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole, damage, bCrit, finalDmg, damageType, skill) + end + if skill then + atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill,isDirect) + defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill,isDirect) + --如果目标是主燃烧目标 or 目标身上有燃烧效果 + if atkRole.curMainTarget==defRole or BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT,function(buff) return buff.damageType == 1 end) then + atkRole.Event:DispatchEvent(BattleEventName.HitRoleInBurn,skill,defRole) + end + 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,isDirect) + defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill,isDirect) + end + + end + + -- 战斗记录用 + BattleLogic.Event:DispatchEvent(BattleEventName.RecordDamage, atkRole, defRole, damage) + -- + BattleLogManager.Log( + "Final Damage", + "acamp", atkRole.camp, + "apos", atkRole.position, + "tcamp", defRole.camp, + "tpos", defRole.position, + "damage", damage, + "dotType", tostring(dotType) + ) + + return finalDmg +end + + + + + --执行完整的命中,伤害,暴击计算,返回命中,暴击 --skill造成伤害的技能 atkRole攻击者 defRole受击者 damageType伤害类型 baseFactor伤害系数 ignoreDef无视防御参数 dotType是持续伤害类型 function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, ignoreDef, dotType) -- 灵兽无效 - if defRole.type == BattleUnitType.Monster then + if defRole.type == BattleUnitType.Monster or defRole.type == BattleUnitType.Player then return end -- 判断是否命中 - if skill and not skill:CheckTargetIsHit(defRole) then + if skill and not skill:CheckTargetIsHit(defRole) and atkRole.type==BattleUnitType.Role then BattleLogic.Event:DispatchEvent(BattleEventName.HitMiss, atkRole, defRole, skill) atkRole.Event:DispatchEvent(BattleEventName.HitMiss, defRole, skill) defRole.Event:DispatchEvent(BattleEventName.BeHitMiss, atkRole, skill) @@ -764,7 +929,7 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i -- 无视防御系数 ignoreDef = 1 - (ignoreDef or 0) -- 基础伤害 = 攻击力 - 防御力 - baseDamage = max(attack - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0) + baseDamage = max(attack - BattleUtil.FP_Mul(defence, ignoreDef), 0) -- 基础伤害增加系数 local addDamageFactor = 1 + atkRole:GetRoleData(RoleDataName.DamageBocusFactor) - defRole:GetRoleData(RoleDataName.DamageReduceFactor) @@ -822,9 +987,9 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i return finalDmg, bCrit end -function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor) +function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor,skill) -- 灵兽无效 - if targetRole.type == BattleUnitType.Monster then + if targetRole.type == BattleUnitType.Monster or targetRole.type == BattleUnitType.Player then return end BattleLogic.Event:DispatchEvent(BattleEventName.DisposeRoleCtrl_noheal, castRole,targetRole) @@ -851,10 +1016,54 @@ function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor) -- 基础伤害增加系数 local addDamageFactor = 1 + castRole:GetRoleData(RoleDataName.DamageBocusFactor) targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole) - BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor) + BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor,skill) +end +function BattleUtil.FinalTreat(castRole, targetRole, value, baseFactor,skill) + -- 灵兽无效 + if targetRole.type == BattleUnitType.Monster or targetRole.type == BattleUnitType.Player then + return + end + BattleLogic.Event:DispatchEvent(BattleEventName.DisposeRoleCtrl_noheal, castRole,targetRole) + if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血 + --禁疗并且没有死亡的单位显示血量+0 不走后面代码,防止触发后面的被动 by:王振兴 2021/1/27 + if targetRole.ctrl_noheal and not targetRole:IsDead() then + targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, 0, 0) + end + return + end + targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole) + local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp) + local hp = targetRole:GetRoleData(RoleDataName.Hp) + baseFactor = baseFactor or 1 + local baseTreat = BattleUtil.FP_Mul(value, baseFactor) + + --baseTreat = BattleUtil.CountChangeList(baseTreat, cl) + -- 取整 + local baseTreat = floor(baseTreat + 0.5) + + local treat = min(baseTreat, maxHp - hp) + if treat > 0 then + targetRole.data:AddValue(RoleDataName.Hp, treat) + end + + castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat, baseTreat) + targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat) + --添加发送到battleLogic的治疗消息,用于计算总的战斗伤害值 + BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat) + -- 战斗记录用 + BattleLogic.Event:DispatchEvent(BattleEventName.RecordTreat, castRole, targetRole, baseTreat) + BattleLogManager.Log( + "Final Treat", + "acamp", castRole.camp, + "apos", castRole.position, + "tcamp", targetRole.camp, + "tpos", targetRole.position, + "value", value + ) end -function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor) + +function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor,skill) -- 灵兽无效 if targetRole.type == BattleUnitType.Monster then return @@ -875,7 +1084,7 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamag local treatFactorFunc = function(df, dt) baseFactor = BattleUtil.CountValue(baseFactor, df, dt) end - castRole.Event:DispatchEvent(BattleEventName.PassiveTreatingFactor, treatFactorFunc, targetRole) + castRole.Event:DispatchEvent(BattleEventName.PassiveTreatingFactor, treatFactorFunc, targetRole,skill) targetRole.Event:DispatchEvent(BattleEventName.PassiveBeTreatedFactor, treatFactorFunc, castRole) local factor = castRole.isTeam and 1 or castRole:GetRoleData(RoleDataName.TreatFacter) --释放者为team则不计算治疗加成属性 @@ -973,6 +1182,7 @@ function BattleUtil.RandomControl(rand, ctrl, caster, target, round) target:AddBuff(buff) end) if not isAdd then + buff.target=target BattleLogic.Event:DispatchEvent(BattleEventName.RoleAddBuffFail,buff) end return isAdd diff --git a/luafight/Modules/Battle/Logic/Monster/Monster.lua b/luafight/Modules/Battle/Logic/Monster/Monster.lua index d257857a2..a44c90523 100644 --- a/luafight/Modules/Battle/Logic/Monster/Monster.lua +++ b/luafight/Modules/Battle/Logic/Monster/Monster.lua @@ -16,15 +16,27 @@ end function Monster:Init(data) self.type = BattleUnitType.Monster self.camp = data.camp + -- if data.position==10 then + -- self.type = BattleUnitType.Player + -- end self.position = data.position self.star = data.star self.uid= data.id + self.teamDamage=data.teamDamage self.roleData = data self.data:Init(self, data.property) self.buffFilter:Clear() --buff屏蔽列表 self.Event:ClearEvent() self.exileTargets={}--已经被放逐过的目标 - self.skillGroup = MSkillManager.CreateMSkillGroup(self, data.skill) + -- self.skillGroup = MSkillManager.CreateMSkillGroup(self, data.skill) + + -- self.skillList=data.skill + self.skillGroupList = {} + for i = 1, #data.skill do + -- LogError("---------------------"..data.skill[i].skillData.effect[1]) + --LogError("monster skill id=="..data.skill[i]) + self.skillGroupList[i] = MSkillManager.CreateMSkillGroup(self, i, data.skill[i]) + end end diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua index 1664b31b3..7feb4d77f 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua @@ -1,7 +1,7 @@ MCondition = {} local this = MCondition - +local skillRound={} local _ConditionConfig = { [0] = function(skill, condition) --0:无限制条件 return true @@ -134,6 +134,26 @@ local _ConditionConfig = { end return false end, + [8] = function(skill, condition) --6:回合cd数限制 + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + + -- 获取当前回合 + + --return true + local curRound = BattleLogic.GetCurRound() + if not skillRound[skill.id] then + skillRound[skill.id]=curRound + return true + else + if curRound==skillRound[skill.id]+comValue then + skillRound[skill.id]=curRound + return true + end + end + return false + end, } -- 条件检测 @@ -147,5 +167,12 @@ function MCondition.CheckCondition(skill, condition) return _ConditionConfig[conId](skill, condition) end +-- 清除缓存 +function MCondition.ClearCache() + if skillRound then + skillRound={} + end +end + return MCondition \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua index daaf6af28..5dda34c92 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua @@ -19,14 +19,15 @@ function MSkill:Init(owner, group, index, skillData) self.curCastCount = 0 self.maxCastCount = self.skillData.maxCount - + -- LogError("monster skill id=="..skillData.effect[1]) self.curRoundCount = 0 self.maxRoundCount = self.skillData.maxRoundCount - -- 将技能加入触发检测 - MTrigger.AddSkill(self.skillData.triggerId, self.skillData.triggerCondition, self) - + + --MTrigger.AddSkill(self.skillData, self.skillData.triggerCondition, self) local effectData = self.skillData.effect self.id = effectData[1] -- 技能ID + -- 将技能加入触发检测 + MTrigger.AddSkill(self.skillData.triggerId, self.skillData.triggerCondition, self) self.hitTime = effectData[2] -- 效果命中需要的时间 self.continueTime = effectData[3] -- 命中后伤害持续时间 self.attackCount = effectData[4] -- 伤害持续时间内伤害次数 diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillGroup.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillGroup.lua index fa01a5641..42baced7b 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillGroup.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillGroup.lua @@ -8,13 +8,21 @@ function MSkillGroup:New() end -- 初始化数据 -function MSkillGroup:Init(monster, groupData) +function MSkillGroup:Init(monster, groupIndex, groupData) self.owner = monster + self.groupIndex = groupIndex self.skillGroupData = groupData -- 创建技能 self.skillList = {} - for index, data in ipairs(self.skillGroupData) do - self.skillList[index] = MSkillManager.CreateMSkill(monster, self, index, data) + local num=0 + -- for index, data in ipairs(self.skillGroupData) do + -- LogError("careat skill=="..index.." data=="..data.effect[1]) + -- num=num+1 + -- self.skillList[num] = MSkillManager.CreateMSkill(monster, self, num, data) + + -- end + for i = 1, #self.skillGroupData do + self.skillList[i] = MSkillManager.CreateMSkill(monster, self, i, self.skillGroupData[i]) end end diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillManager.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillManager.lua index 42deeef8d..d6c457e1a 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillManager.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MSkillManager.lua @@ -12,31 +12,38 @@ function this.Init() end -- 创建一个技能组 -function this.CreateMSkillGroup(monster, skillGroupData) - local index = monster:GetCamp() * 6 + monster:GetPosition() +function this.CreateMSkillGroup(monster, groupIndex, skillGroupData) + local position = monster:GetCamp() * 6 + monster:GetPosition() if not this.MSkillGroupList then this.MSkillGroupList = {} end - if not this.MSkillGroupList[index] then - this.MSkillGroupList[index] = MSkillGroup:New() + if not this.MSkillGroupList[position] then + this.MSkillGroupList[position] = MSkillGroup:New() end - this.MSkillGroupList[index]:Init(monster, skillGroupData) + this.MSkillGroupList[position]:Init(monster, groupIndex, skillGroupData) + return this.MSkillGroupList[position] end -- 创建一个技能 function this.CreateMSkill(monster, group, index, skilldata) local owner = group:GetOwner() - local m_index = owner:GetCamp() * 6 + owner:GetPosition() + local groupIndex = group.groupIndex + local position = owner:GetCamp() * 6 + owner:GetPosition() if not this.MSkillList then this.MSkillList = {} end - if not this.MSkillList[m_index] then - this.MSkillList[m_index] = {} + if not this.MSkillList[position] then + this.MSkillList[position] = {} end - if not this.MSkillList[m_index][index] then - this.MSkillList[m_index][index] = MSkill:New() + if not this.MSkillList[position][groupIndex] then + this.MSkillList[position][groupIndex] = {} end - this.MSkillList[m_index][index]:Init(monster, group, index, skilldata) + if not this.MSkillList[position][groupIndex][index] then + this.MSkillList[position][groupIndex][index] = MSkill:New() + end + this.MSkillList[position][groupIndex][index]:Init(monster, group, index, skilldata) + + return this.MSkillList[position][groupIndex][index] end return MSkillManager \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua index eebb84f5f..4a0f578ff 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua @@ -102,11 +102,14 @@ end -- 初始化事件监听 function this.InitListener() + --每次初始化时间监听前 清除下缓存数据 + MCondition.ClearCache() for triggerId, config in pairs(_TriggerConfig) do BattleLogic.Event:AddEvent(config.event, function(...) -- 用于排序 local sortList = {} -- 判断是否有需要触发的技能 + local triggerSkill = this.TriggerList[triggerId] if not triggerSkill then return @@ -154,7 +157,7 @@ function MTrigger.AddSkill(triggerId, condition, skill) if not this.TriggerList[triggerId] then this.TriggerList[triggerId] = {} end - table.insert(this.TriggerList[triggerId], {condition = condition, skill = skill}) + table.insert(this.TriggerList[triggerId], {condition = condition, skill = skill,trigger= triggerId}) end return MTrigger \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Role/RoleLogic.lua b/luafight/Modules/Battle/Logic/Role/RoleLogic.lua index 0cfdc3ed6..5f2b36c7f 100644 --- a/luafight/Modules/Battle/Logic/Role/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/Role/RoleLogic.lua @@ -29,6 +29,9 @@ function RoleLogic:Init(uid, data, position) self.isDead = self:GetRoleData(RoleDataName.Hp) <= 0 self.isRealDead = self.isDead self.killDamage = 0 --致死伤害 + self.teamDamage = data.teamDamage --最高战斗力 + self.superSkillDamage = 0 --技能伤害 + self.killRole=nil --击杀英雄 self.camp = data.camp --阵营 0:我方 1:敌方 self.name = data.name self.element = data.element @@ -60,7 +63,8 @@ function RoleLogic:Init(uid, data, position) self.aiOrder = data.ai self.aiIndex = 1 self.aiTempCount = 0 - + self.RoundMaxSubRage=0 --每回合最多减少怒气 + self.AllSubRage =0 -- 每回合减少的怒气 self.IsDebug = false self.enemyType = EnemyType.normal self.lockTarget = nil --嘲讽 @@ -75,7 +79,7 @@ function RoleLogic:Init(uid, data, position) self.reliveFilter = true -- 控制复活的标志位,置为false角色将不再享受复活效果 self.reliveHPF = 1 self.reliveCaster = nil - + self.bloodShield = nil self.IsCanAddSkill = true -- 是否可以追加技能 self.mustHit=false --必定命中 self.mustCrit=false --必定暴击 @@ -98,6 +102,14 @@ function RoleLogic:Init(uid, data, position) end if BattleUtil.Passivity[id] then BattleUtil.Passivity[id](self, args,passivityId,judge) + BattleLogManager.Log( + "Add Passive", + "id", tostring(id), + "camp", tostring(self.camp), + "pos", tostring(self.position), + "passivityId", tostring(passivityId), + "judge", tostring(judge) + ) -- 加入被动列表 table.insert(self.passiveList, {id, args,passivityId}) end @@ -290,10 +302,19 @@ function RoleLogic:AddBuff(buff) BattleLogic.Event:DispatchEvent(BattleEventName.RoleAddBuffMiss, _CallBack, self, buff) missF = BattleUtil.CountChangeList(missF, cl) + BattleLogManager.Log( + "Add Buff random", + "missF", missF) -- 如果概率为0 或者没有miss if missF == 0 or not BattleUtil.RandomAction(missF, function() BattleLogic.BuffMgr:PutBuff(buff) end) then for i=1, self.buffFilter.size do if self.buffFilter.buffer[i](buff,self) then + BattleLogManager.Log( + "Buff Filter", + "camp", buff.caster.camp, + "position", buff.caster.position, + "id", buff.id, + "type", buff.type) BattleLogic.BuffMgr:PutBuff(buff) BattleLogic.Event:DispatchEvent(BattleEventName.RoleAddBuffFail,buff,self) return @@ -302,7 +323,7 @@ function RoleLogic:AddBuff(buff) BattleLogic.BuffMgr:AddBuff(self, buff) end end - + function RoleLogic:Dispose() end @@ -310,6 +331,15 @@ end -- 判断角色是否可以释放技能 function RoleLogic:IsAvailable(skill) + if skill and skill.effectCaster then + --放技能前判断是否有目标,没有就不会放技能,直接执行技能回调 by 王振兴 2021/09/17 + --为解决攻击目标只剩被放逐的单位导致我方不放技能扣除怒气 + skill.effectCaster:ChooseTarget() + local targets=BattleUtil.LengthOfTable(skill.effectCaster:GetDirectTargetsNoExile()) + if targets==0 then + return false + end + end --角色没有真正死亡 在 被眩晕/沉默的 情况下 任然能释放死亡技能 if (self.ctrl_dizzy or self.ctrl_slient) and self:IsDead() and skill and skill.type==BattleSkillType.DeadSkill then return true @@ -344,7 +374,7 @@ function RoleLogic:SkillCast(skill, func) _CastDone() return end - + self.Event:DispatchEvent(BattleEventName.ActionOperateAngerBefore,self) -- 没有麻痹,释放普通攻击 if (skill.type == BattleSkillType.Normal or skill.type ==BattleSkillType.ChaosNormal) and not self.ctrl_palsy then @@ -411,28 +441,22 @@ end -- targets 指定目标 -- isAdd 是否是追加技能 -- isRage 是否正常操作怒气值 -function RoleLogic:AddSkill(type, isRage, isAdd, targets) +function RoleLogic:AddSkill(type, isRage, isAdd, targets,isTrigger,isLoop) if not self.IsCanAddSkill and isAdd then return end local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill --角色被混乱后 local isTriggerJudge=true + if isTrigger~=nil then + isTriggerJudge=isTrigger + end if self.ctrl_chaos then type=BattleSkillType.ChaosNormal --混乱普攻使用普攻特效 effectData={self.skill[1],self.skill[2],self.skill[3],self.skill[4],{100001,{1,1,1}}} isTriggerJudge=false end - SkillManager.AddSkill(self, effectData, type, targets, isAdd, isRage,isTriggerJudge) + SkillManager.AddSkill(self, effectData, type, targets, isAdd, isRage,isTriggerJudge,isLoop) -- - BattleLogManager.Log( - "Add Skill", - "camp", self.camp, - "pos", self.position, - "type", type, - "isRage", tostring(isRage), - "isAdd", tostring(isAdd), - "targets", targets and #targets or "0" - ) end --加入额外技能,用于额外释放技能 by:王振兴 @@ -450,15 +474,6 @@ function RoleLogic:InsertExtraSkill(id,type) end --和老史,佳琦确认果 附加技能算绝技 被沉默无法释放 可以套娃 递归触发 by:王振兴 SkillManager.InsertSkill(self, effectData, skillType, nil, true, false,isTrigger) - BattleLogManager.Log( - "Insert Extra Skill", - "camp", self.camp, - "pos", self.position, - "type", skillType, - "isRage", tostring(false), - "isAdd", tostring(true), - "targets", targets and #targets or "0" - ) end end @@ -468,16 +483,6 @@ function RoleLogic:InsertSkill(type, isRage, isAdd, targets) if not self.IsCanAddSkill and isAdd then return end local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill SkillManager.InsertSkill(self, effectData, type, targets, isAdd, isRage) - -- - BattleLogManager.Log( - "Insert Skill", - "camp", self.camp, - "pos", self.position, - "type", type, - "isRage", tostring(isRage), - "isAdd", tostring(isAdd), - "targets", targets and #targets or "0" - ) end -- 设置是否可以追加技能 function RoleLogic:SetIsCanAddSkill(isCan) diff --git a/luafight/Modules/Battle/Logic/Role/Skill.lua b/luafight/Modules/Battle/Logic/Role/Skill.lua index dde4102de..68a8958b3 100644 --- a/luafight/Modules/Battle/Logic/Role/Skill.lua +++ b/luafight/Modules/Battle/Logic/Role/Skill.lua @@ -62,7 +62,6 @@ function Skill:Cast(func) self.castDoneFunc = func self.isTriggePassivity=false self.triggerPassivityId={} - -- 技能效果生效 if self.effectCaster then --放技能前判断是否有目标,没有就不会放技能,直接执行技能回调 by 王振兴 2021/03/26 @@ -126,6 +125,11 @@ end function Skill:GetDirectTargetsNoExile() return self.effectCaster:GetDirectTargetsNoExile() end + +-- 获取直接目标,不包含触发不灭的目标,可能为空 +function Skill:GetDirectTargetsNoNoDead() + return self.effectCaster:GetDirectTargetsNoNODead() +end -- 获取技能目标最大人数 function Skill:GetMaxTargetNum() return self.effectCaster:GetMaxTargetNum() diff --git a/luafight/Modules/Battle/Logic/SkillManager.lua b/luafight/Modules/Battle/Logic/SkillManager.lua index 243949d49..2373f00a7 100644 --- a/luafight/Modules/Battle/Logic/SkillManager.lua +++ b/luafight/Modules/Battle/Logic/SkillManager.lua @@ -44,13 +44,26 @@ end -- 向技能列表中追加技能 -function this.AddSkill(caster, effectData, type, targets, isAdd, isRage,isTriggerJudge) +function this.AddSkill(caster, effectData, type, targets, isAdd, isRage,isTriggerJudge,isloop) -- 如果超出最大限制则不再追加技能 if not this.CheckMaxCount() then return end + BattleLogManager.Log( + "Add Skill", + "camp", caster.camp, + "pos", caster.position, + "type", type, + "isRage", tostring(isRage), + "isAdd", tostring(isAdd), + "isTriggerJudge", tostring(isTriggerJudge), + "targets", targets and #targets or "0" + ) local skill = skillPool:Get() skill:Init(caster, effectData, type, targets, isAdd, isRage,isTriggerJudge) + if isloop then + skill.isNotLoop=isloop + end if type == BattleSkillType.DeadSkill then -- 死亡技能加入单独的对列 table.insert(this.DeadSkillList, skill) else @@ -64,6 +77,18 @@ function this.InsertSkill(caster, effectData, type, targets, isAdd, isRage,isTri if not this.CheckMaxCount() then return end + BattleLogManager.Log( + "Insert Skill", + "camp", caster.camp, + "pos", caster.position, + "type", type, + "isRage", tostring(isRage), + "isAdd", tostring(isAdd), + "isTriggerJudge", tostring(isTriggerJudge), + "isLoop", tostring(isLoop), + "targets", targets and #targets or "0" + ) + local skill = skillPool:Get() --角色被混乱后