From c7e7ef4f3d5502479fb639253960ab3a2ae3c284 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Wed, 6 May 2020 15:54:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8A=80=E8=83=BD=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ljsd/jieling/logic/family/GuildLogic.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java index 221b51d36..5ace2c74b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java @@ -1225,13 +1225,16 @@ public class GuildLogic { } int percent = SSpecialConfig.getIntegerValue(SSpecialConfig.GUILD_TECHNOLOGY_RETURN_PERCENT); int[][] dropArray = consume.toArray(new int[consume.size()][]); + int[][] dropArrayReally =new int[dropArray.length][]; for(int i = 0;i Date: Wed, 6 May 2020 16:49:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=88=98=E6=96=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/BattleMain.lua | 6 +- luafight/BattleMain.lua | 3 +- luafight/Modules/Battle/Logic/Base/Buff.lua | 14 +- luafight/Modules/Battle/Logic/Base/Effect.lua | 93 +- .../Modules/Battle/Logic/Base/Passivity.lua | 862 +++++++++++++++--- luafight/Modules/Battle/Logic/Base/Skill.lua | 15 +- luafight/Modules/Battle/Logic/BattleLogic.lua | 633 +++---------- luafight/Modules/Battle/Logic/Buff/DOT.lua | 4 +- luafight/Modules/Battle/Logic/Buff/HOT.lua | 2 +- luafight/Modules/Battle/Logic/Buff/Immune.lua | 7 + luafight/Modules/Battle/Logic/Buff/NoDead.lua | 53 ++ luafight/Modules/Battle/Logic/Buff/Shield.lua | 6 +- .../Battle/Logic/Misc/BattleDefine.lua | 31 + .../Modules/Battle/Logic/Misc/BattleUtil.lua | 201 +++- luafight/Modules/Battle/Logic/RoleLogic.lua | 135 ++- luafight/Modules/Battle/Logic/RoleManager.lua | 279 ++++++ .../Modules/Battle/Logic/SkillManager.lua | 14 +- 17 files changed, 1596 insertions(+), 762 deletions(-) create mode 100644 luafight/Modules/Battle/Logic/Buff/NoDead.lua create mode 100644 luafight/Modules/Battle/Logic/RoleManager.lua diff --git a/conf/BattleMain.lua b/conf/BattleMain.lua index 1ea152578..ef25971c5 100644 --- a/conf/BattleMain.lua +++ b/conf/BattleMain.lua @@ -1,5 +1,6 @@ +package.path = package.path ..';luafight/?.lua'; -- linux -package.path = package.path ..';../luafight/?.lua'; +-- package.path = package.path ..';../luafight/?.lua'; require("Modules.Battle.Logic.Misc.BattleDefine") require("Modules.Battle.Logic.Misc.BattleUtil") @@ -228,7 +229,7 @@ function BattleMain.Execute(args, fightData, optionData) end) then local resultList = {} if BattleLogic.Result == 1 then --胜利记录我方剩余血量 - local arr = BattleLogic.Query(function (r) return r.camp == 0 end, true) + local arr = RoleManager.Query(function (r) return r.camp == 0 end, true) for i=1, #arr do resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp) end @@ -304,4 +305,5 @@ function BattleMain.Execute(args, fightData, optionData) end return { result = -1 } end + return BattleMain \ No newline at end of file diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index 00c87a744..ef25971c5 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -229,7 +229,7 @@ function BattleMain.Execute(args, fightData, optionData) end) then local resultList = {} if BattleLogic.Result == 1 then --胜利记录我方剩余血量 - local arr = BattleLogic.Query(function (r) return r.camp == 0 end, true) + local arr = RoleManager.Query(function (r) return r.camp == 0 end, true) for i=1, #arr do resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp) end @@ -305,4 +305,5 @@ function BattleMain.Execute(args, fightData, optionData) end return { result = -1 } end + return BattleMain \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Base/Buff.lua b/luafight/Modules/Battle/Logic/Base/Buff.lua index 03aa33d3e..bd79e0dec 100644 --- a/luafight/Modules/Battle/Logic/Base/Buff.lua +++ b/luafight/Modules/Battle/Logic/Base/Buff.lua @@ -31,7 +31,7 @@ end function Buff.Create(caster, type, duration, ...) local buff = getBuff(type) buff.type = type - buff.id = BattleLogic.GenerateBuffId() + buff.id = BuffManager.GenerateBuffId() buff.caster = caster buff.disperse = false --该值为true时,buff在下一帧被清除 buff.cover = false --该值为true时,同类型新buff会覆盖旧buff @@ -88,6 +88,8 @@ end BuffManager = {} BuffManager.__index = BuffManager +local curBuffId + function BuffManager.New() local instance = {owner=0, buffQueue = BattleQueue.New(), buffDic = BattleDictionary.New()} setmetatable(instance, BuffManager) @@ -102,6 +104,7 @@ function BuffManager.GetLevelByType(type) end + function BuffManager:Init() while self.buffQueue.size > 0 do putBuff(self.buffQueue:Dequeue()) @@ -115,8 +118,17 @@ function BuffManager:Init() buffListPool:Put(list) end self.buffDic:Clear() + + curBuffId = 0 end +function BuffManager.GenerateBuffId() + if not curBuffId then + curBuffId = 0 + end + curBuffId = curBuffId + 1 + return curBuffId +end function BuffManager:AddBuff(target, buff) buff.target = target self.buffQueue:Enqueue(buff) diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index a7df15ce2..4578faa63 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -101,7 +101,7 @@ local effectList = { local cb1 = args[2] local f2 = args[3] BattleLogic.WaitForTrigger(interval, function () - buffRandomAction(f1, target, Buff.Create(caster, BuffName.Control, f2, cb1)) + BattleUtil.RandomControl(f1, cb1, caster, target, f2) end) end, --[d]改变[a]属性[b]%,持续[c]秒 @@ -277,8 +277,8 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local dmg, crit = BattleUtil.CalDamage(skill, caster, target, dt, f1) - if target.isDead then - local arr = BattleLogic.Query(function (r) return r.camp ~= caster.camp and r.uid ~= target.uid end) + if target:IsDead() then + local arr = RoleManager.Query(function (r) return r.camp ~= caster.camp and r.uid ~= target.uid end) for i=1, #arr do BattleUtil.ApplyDamage(skill, caster, arr[i], floor(dmg * f2)) end @@ -392,7 +392,7 @@ local effectList = { BattleLogic.WaitForTrigger(interval, function () BattleUtil.CalDamage(skill, caster, target, dt, f1) if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f3, ct)) + BattleUtil.RandomControl(f1, ct, caster, target, f3) end end) end, @@ -463,7 +463,7 @@ local effectList = { [26] = function(caster, target, args, interval, skill) local d = args[1] BattleLogic.WaitForTrigger(interval, function () - if not target.isDead then + if not target:IsRealDead() then BattleUtil.ApplyDamage(skill, caster, target, d) end end) @@ -664,7 +664,7 @@ local effectList = { local d = args[1] caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () - if not target.isDead then + if not target:IsRealDead() then BattleUtil.ApplyDamage(skill, caster, target, d) end end) @@ -705,7 +705,7 @@ local effectList = { f1 = f1 + f3 end) BattleUtil.CalDamage(skill, caster, target, dt, f1) - if target.isDead then + if target:IsDead() then BattleUtil.RandomAction(f4, function () caster:AddSkillCD(0) end) @@ -725,12 +725,12 @@ local effectList = { brand.exDmg = brand.exDmg + (oldBuff.exDmg or 0) end local trigger = function(atkRole, damagingFunc, damageType) - BattleUtil.RandomAction(f1, function () + BattleUtil.RandomAction(f1, function() damagingFunc(brand.exDmg) end) end target.Event:AddEvent(BattleEventName.RoleBeDamagedBefore, trigger) - brand.endFunc = function () + brand.endFunc = function() brand.exDmg = nil target.Event:RemoveEvent(BattleEventName.RoleBeDamagedBefore, trigger) end @@ -791,7 +791,7 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local dmg, crit = BattleUtil.CalDamage(skill, caster, target, dt, f1) - if target.isDead then + if target:IsDead() then local buff = Buff.Create(caster, BuffName.PropertyChange, 0, BattlePropList[pro1], f2, 2) buff.cover = true buff.maxLayer = i1 @@ -953,7 +953,7 @@ local effectList = { local f3 = args[4] BattleLogic.WaitForTrigger(interval, function () if BattleUtil.GetHPPencent(target) < f1 then - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f3, ct)) + BattleUtil.RandomControl(f2, ct, caster, target, f3) end end) end, @@ -1095,7 +1095,7 @@ local effectList = { local delayDmgTrigger delayDmgTrigger = function(less, d) if less > 0 then - local role = target.isDead and BattleUtil.ChooseTarget(caster, 20110)[1] or target + local role = target:IsRealDead() and BattleUtil.ChooseTarget(caster, 20110)[1] or target if role then caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, role, d) BattleLogic.WaitForTrigger(d, function () @@ -1116,12 +1116,12 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () BattleUtil.CalDamage(skill, caster, target, dt, f1) - if target.isDead then - BattleUtil.RandomAction(f2, function () - if caster.superSkill then - caster.superSkill:Cast() - end - end) + if target:IsDead() then + -- BattleUtil.RandomAction(f2, function () + -- if caster.superSkill then + -- caster.superSkill:Cast() + -- end + -- end) end end) end, @@ -1164,7 +1164,7 @@ local effectList = { -- 伤害 BattleUtil.CalDamage(skill, caster, target, dt, f1) -- 控制未命中则施加增伤印记 - if not buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f3, 1)) then + if not BattleUtil.RandomControl(f2, 1, caster, target, f3) then local brand = Buff.Create(caster, BuffName.Brand, 0, "zengshang") brand.maxLayer = i1 brand.clear = false @@ -1308,7 +1308,7 @@ local effectList = { else BattleUtil.CalDamage(skill, caster, target, dt, f1) end - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f4, c1)) + BattleUtil.RandomControl(f2, c1, caster, target, f4) end) end) end @@ -1340,7 +1340,7 @@ local effectList = { if buff.caster and not buff.caster.isTeam then local trigger = function(defRole, damageFunc, damage) damageFunc(damage * remainCount) end buff.caster.Event:AddEvent(BattleEventName.RoleDamageAfter, trigger) - BattleUtil.CalDamage(skill, buff.caster, buff.target, buff.damagePro, buff.damageFactor,0, true) + BattleUtil.CalDamage(skill, buff.caster, buff.target, buff.damagePro, buff.damageFactor,0, buff.damageType) buff.caster.Event:RemoveEvent(BattleEventName.RoleDamageAfter, trigger) end end @@ -1376,7 +1376,7 @@ local effectList = { caster.proTranList:Add(proTran) BattleUtil.CalDamage(skill, caster, target, dt, f1) caster.proTranList:Remove(caster.proTranList.size) - if target.isDead then + if target:IsDead() then BattleUtil.RandomAction(f3, function () caster:AddSkillCD(0) end) @@ -1408,9 +1408,9 @@ local effectList = { local arr = BattleUtil.ChooseTarget(caster, 20000) for i=1, #arr do if arr[i] == target then - buffRandomAction(f1+f3, arr[i], Buff.Create(caster, BuffName.Control, f2, cb1)) + BattleUtil.RandomControl(f1+f3, cb1, caster, arr[i], f2) else - buffRandomAction(f1, arr[i], Buff.Create(caster, BuffName.Control, f2, cb1)) + BattleUtil.RandomControl(f1, cb1, caster, arr[i], f2) end end end) @@ -1464,7 +1464,7 @@ local effectList = { end return b end) - buffRandomAction(f1+f3*layer, target, Buff.Create(caster, BuffName.Control, f2, ct)) + BattleUtil.RandomControl(f1+f3*layer, ct, caster, target, f2) end) end, --添加[a]的[b]%护盾,持续[c]秒。为自身挂护盾印记,每层额外增加护盾值[d]%,印记最多[e]层。印记不显示。(增益印记,不可驱散) @@ -1533,13 +1533,13 @@ local effectList = { if lastTrigger > 1 then --加入限定避免循环触发 return end - if not target.isDead then + if not target:IsDead() then damagingFunc(floor(damage * f1)) BattleUtil.ApplyDamage(skill, atkRole, target, BattleUtil.CalShield(atkRole, target, floor(damage * f1))) end lastTrigger = 0 end - local list = BattleLogic.GetNeighbor(target, 1) + local list = RoleManager.GetNeighbor(target, 1) for i=1, #list do if list[i] ~= target then list[i].Event:AddEvent(BattleEventName.PassiveBeDamaging, OnPassiveDamaging) @@ -1675,7 +1675,7 @@ local effectList = { end end) if hasBuff then - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f3, ct)) + BattleUtil.RandomControl(f2, ct, caster, target, f3) end end) end, @@ -1697,7 +1697,7 @@ local effectList = { end end) if hasBuff then - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f3, ct)) + BattleUtil.RandomControl(f2, ct, caster, target, f3) end end) end, @@ -1723,8 +1723,8 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType) - if target.isDead then - local arr = BattleLogic.Query(function (r) return r.camp == target.camp and r.uid ~= target.uid end) + if target:IsDead() then + local arr = RoleManager.Query(function (r) return r.camp == target.camp and r.uid ~= target.uid end) for i=1, #arr do BattleUtil.ApplyDamage(skill, caster, arr[i], floor((damage-finalDmg)*f2)) end @@ -1891,7 +1891,7 @@ local effectList = { else BattleUtil.CalDamage(skill, caster, target, dt, f1) end - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f4, c1)) + BattleUtil.RandomControl(f2, c1, caster, target, f4) end) end) end @@ -1975,8 +1975,10 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType) - local arr = BattleLogic.Query(function (r) return r.camp == caster.camp end) + local arr = RoleManager.Query(function (r) return r.camp == caster.camp end) BattleUtil.SortByHpFactor(arr, 1) + -- 检测技能伤害治疗加成 + f2 = BattleUtil.CheckSkillDamageHeal(f2, caster, arr[1]) -- 治疗血量最低队友实际伤害的f2% BattleUtil.ApplyTreat(caster, arr[1], floor(finalDmg*f2)) end @@ -1993,6 +1995,18 @@ local effectList = { local i1 = args[2] caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () + + + local cl = {} + local function _CallBack(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + caster.Event:DispatchEvent(BattleEventName.PassiveShield, _CallBack, ShieldTypeName.RateReduce) + target.Event:DispatchEvent(BattleEventName.PassiveBeShield, _CallBack, ShieldTypeName.RateReduce) + f1 = BattleUtil.CountChangeList(f1, cl) + target:AddBuff(Buff.Create(caster, BuffName.Shield, i1, ShieldTypeName.RateReduce, f1, 0)) end) end, @@ -2053,7 +2067,7 @@ local effectList = { BattleLogic.WaitForTrigger(interval, function () local OnBeHit = function() - if not target.isDead and BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + if not target:IsDead() and BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then local ft = target:GetRoleData(RoleDataName.Hp)/target:GetRoleData(RoleDataName.MaxHp) if ft < f2 then BattleUtil.RandomAction(f3, function() @@ -2083,7 +2097,7 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType) - if target.isDead then + if target:IsDead() then caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, 0, BattlePropList[pro1], f2, ct)) end end @@ -2106,10 +2120,7 @@ local effectList = { caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () local damage = BattleUtil.ErrorCorrection(f2 * caster:GetRoleData(BattlePropList[pro])) - - local buff = Buff.Create(caster, BuffName.DOT, i1, 1, dot, damage) - buff.isRealDamage = true - buffRandomAction(f1, target, buff) + BattleUtil.RandomDot(f1, dot, caster, target, i1, 1, damage) end) end, @@ -2136,11 +2147,11 @@ local effectList = { local f2 = args[4] local ct = args[5] local f3 = args[6] - caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) + -- caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () BattleUtil.CalDamage(skill, caster, target, dt, f1) if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then - buffRandomAction(f2, target, Buff.Create(caster, BuffName.Control, f3, ct)) + BattleUtil.RandomControl(f2, ct, caster, target, f3) end end) end, diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index 1373d893a..77bfd8f02 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -148,7 +148,7 @@ local passivityList = { local OnPassiveTreating = function(treatingFunc) BattleUtil.RandomAction(f1, function () - treatingFunc(f2) + treatingFunc(f2, CountTypeName.AddPencent) end) end role.Event:AddEvent(BattleEventName.PassiveTreating, OnPassiveTreating) @@ -607,12 +607,10 @@ local passivityList = { local f2 = args[2] local OnSkillCastEnd = function(skill) - BattleUtil.RandomAction(f1, function () - local arr = BattleUtil.ChooseTarget(role, 20001) - if arr[1] then - arr[1]:AddBuff(Buff.Create(role, BuffName.Control, f2, 1)) - end - end) + local arr = BattleUtil.ChooseTarget(role, 20001) + if arr[1] then + BattleUtil.RandomControl(f1, 1, role, arr[1], f2) + end end role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) end, @@ -970,7 +968,7 @@ local passivityList = { local OnPassiveTreating = function(treatingFunc) BattleUtil.RandomAction(role:GetRoleData(RoleDataName.Crit), function () - treatingFunc(f1) + treatingFunc(f1, CountTypeName.AddPencent) end) end role.Event:AddEvent(BattleEventName.PassiveTreating, OnPassiveTreating) @@ -984,9 +982,7 @@ local passivityList = { if atkRole.isTeam then return end - BattleUtil.RandomAction(f1, function () - atkRole:AddBuff(Buff.Create(role, BuffName.Control, f2, 1)) - end) + BattleUtil.RandomControl(f1, 1, role, atkRole, f2) end role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit) end, @@ -1070,7 +1066,7 @@ local passivityList = { local OnSkillCastEnd = function(skill) local arr = BattleUtil.ChooseTarget(role, 20000) for i=1, #arr do - BattleUtil.RandomAction(f1, function () + BattleUtil.RandomAction(f1, function ()-- arr[i]:AddBuff(Buff.Create(role, BuffName.DOT, f3, 1, d1, dt, f2)) end) end @@ -1108,8 +1104,8 @@ local passivityList = { local f4 = args[6] local triggerUid = {} - BattleLogic.Event:AddEvent(BattleEventName.RoleBeDamaged, function (defRole, atkRole, damage, bCrit, finalDmg, damageType, isDot) - if atkRole.isTeam or role.isDead or isDot then + BattleLogic.Event:AddEvent(BattleEventName.RoleBeDamaged, function (defRole, atkRole, damage, bCrit, finalDmg, damageType, dotType) + if atkRole.isTeam or role:IsDead() or dotType then return end if triggerUid[atkRole.uid] then --加入限定避免循环触发 @@ -1126,7 +1122,7 @@ local passivityList = { end end if defRole == target then - BattleUtil.RandomAction(f1, function () + BattleUtil.RandomAction(f1, function ()-- role.Event:DispatchEvent(BattleEventName.RoleViewBullet, f4, atkRole) BattleLogic.WaitForTrigger(f4, function () triggerUid[atkRole.uid] = atkRole.uid @@ -1165,7 +1161,7 @@ local passivityList = { local OnSkillCastEnd = function(skill) BattleUtil.RandomAction(f1, function () - local list = BattleLogic.GetNeighbor(role, 1) + local list = RoleManager.GetNeighbor(role, 1) for i=1, #list do local val = floor(BattleUtil.FP_Mul(role:GetRoleData(BattlePropList[pro]), f2)) list[i]:AddBuff(Buff.Create(role, BuffName.Shield, f3, ShieldTypeName.NormalReduce, val, 0)) @@ -1212,7 +1208,7 @@ local passivityList = { local f2 = args[3] BattleLogic.Event:AddEvent(BattleEventName.BattleRoleDead, function (defRole, atkRole) - if role.isDead or atkRole.isTeam then + if role:IsDead() or atkRole.isTeam then return end if defRole.camp == role.camp then @@ -1238,13 +1234,13 @@ local passivityList = { local count = 0 BattleLogic.Event:AddEvent(BattleEventName.SkillCast, function (skill) - if skill.owner.isTeam or role.isDead then + if skill.owner.isTeam or role:IsDead() then return end if skill.owner.camp ~= role.camp then count = count + 1 if count == i1 then - BattleUtil.RandomAction(f1, function () + BattleUtil.RandomAction(f1, function ()-- role.Event:DispatchEvent(BattleEventName.AOE, 1-role.camp) BattleLogic.WaitForTrigger(f3, function () local arr = BattleUtil.ChooseTarget(role, 20000) @@ -1553,7 +1549,7 @@ local passivityList = { -- buff.cover = true -- 可以叠加 -- buff.clear = false -- 不可驱散 -- role:AddBuff(buff) - if defRole.isDead then + if defRole:IsDead() then role:AddRage(i1, CountTypeName.Add) end end @@ -1565,7 +1561,7 @@ local passivityList = { [93] = function(role, args) local f1 = args[1] local passiveTreating = function(func, caster) - if func then func(f1) end + if func then func(f1, CountTypeName.AddPencent) end end local OnSkillCast = function(skill) if skill.type == BattleSkillType.Special then @@ -1588,7 +1584,7 @@ local passivityList = { local f1 = args[1] local pro = args[2] local ct = args[3] - local list = BattleLogic.Query(function(v) return role.camp == v.camp end) + local list = RoleManager.Query(function(v) return role.camp == v.camp end) for _, r in pairs(list) do r.data:CountValue(BattlePropList[pro], f1, ct) end @@ -1641,7 +1637,7 @@ local passivityList = { local onSkillEnd = function(skill) BattleUtil.RandomAction(f1, function() BattleLogic.WaitForTrigger(0.1, function() - local list = BattleLogic.Query(function(v) + local list = RoleManager.Query(function(v) return v.camp == (role.camp + 1) % 2 end) for _, r in ipairs(list) do @@ -1672,10 +1668,12 @@ local passivityList = { [99] = function(role, args) local f1 = args[1] local OnHit = function(atkRole, damage, bCrit, finalDmg, damageType) - local arr = BattleLogic.Query(function (r) return r.camp == role.camp end) + local arr = RoleManager.Query(function (r) return r.camp == role.camp end) BattleUtil.SortByHpFactor(arr, 1) + -- 检测技能伤害治疗加成 + local f = BattleUtil.CheckSkillDamageHeal(f1, role, arr[1]) -- 治疗血量最低队友实际伤害的f1% - BattleUtil.ApplyTreat(role, arr[1], floor(BattleUtil.ErrorCorrection(finalDmg*f1))) + BattleUtil.ApplyTreat(role, arr[1], floor(BattleUtil.ErrorCorrection(finalDmg*f))) end role.Event:AddEvent(BattleEventName.RoleHit, OnHit) end, @@ -1704,20 +1702,19 @@ local passivityList = { local ct = args[2] local f1 = args[3] - local onSkillControl = function(target, buff, rate, func) - if buff.type == BuffName.Control and buff.ctrlType == ctl then - local finalRate = BattleUtil.CountValue(rate, f1, ct) - if func then func(finalRate) end + local onSkillControl = function(func, ctrl) + if ctrl == ctl then + if func then func(f1, ct) end end end local onSkillCast = function(skill) if skill.type == BattleSkillType.Special then - role.Event:AddEvent(BattleEventName.SkillRandomBuff, onSkillControl) + role.Event:AddEvent(BattleEventName.PassiveRandomControl, onSkillControl) end end local onSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - role.Event:RemoveEvent(BattleEventName.SkillRandomBuff, onSkillControl) + role.Event:RemoveEvent(BattleEventName.PassiveRandomControl, onSkillControl) end end role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) @@ -1748,7 +1745,7 @@ local passivityList = { local ct = args[3] -- 释放技能后 local onRoleHit = function(defRole) - if defRole.isDead then + if defRole:IsDead() then local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, ct) -- buff.cover = true role:AddBuff(buff) @@ -1766,11 +1763,11 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.camp == role.camp end) + local list = RoleManager.Query(function(v) return v.camp == role.camp end) BattleUtil.SortByHpFactor(list, 1) local target = nil for i = 1, #list do - if not list[i].isDead and list[i] ~= role then + if not list[i]:IsRealDead() and list[i] ~= role then target = list[i] break end @@ -1792,7 +1789,7 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.camp == role.camp end) + local list = RoleManager.Query(function(v) return v.camp == role.camp end) for i = 1, #list do local r = list[i] r:AddRage(i1, CountTypeName.Add) @@ -1811,11 +1808,11 @@ local passivityList = { local i1 = args[3] local onBeHit = function(caster, damage) - local list = BattleLogic.Query(function(v) return v.camp == role.camp end) + local list = RoleManager.Query(function(v) return v.camp == role.camp end) list = BattleUtil.SortByProp(list, BattlePropList[pro], 1) for i = 1, i1 do local r = list[i] - if r and not r.isDead then + if r and not r:IsRealDead() then local treatValue = floor(BattleUtil.ErrorCorrection(f1 * damage)) BattleUtil.ApplyTreat(role, r, treatValue) end @@ -1843,7 +1840,19 @@ local passivityList = { local f1 = args[1] local onBeHit = function(caster, damage, bCrit, finalDmg, damageType, skill) if skill then --技能造成的直接伤害 - local rDamage = floor(BattleUtil.ErrorCorrection(f1 * damage)) + local rDamage = f1 * damage + + -- 计算被动技能额外加乘 + local cl = {} + local function _CallBack(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + caster.Event:DispatchEvent(BattleEventName.PassiveRebackDamage, _CallBack) + rDamage = floor(BattleUtil.ErrorCorrection(BattleUtil.CountChangeList(rDamage, cl))) + + BattleUtil.ApplyDamage(nil, role, caster, rDamage) end end @@ -1886,11 +1895,9 @@ local passivityList = { local f1 = args[1] local ctl = args[2] local i1 = args[3] - local onRoleBeDamaged = function(caster, damage, bCrit, finalDmg, damageType, isDot, skill) - if role.isDead and skill then - BattleUtil.RandomAction(f1, function() - caster:AddBuff(Buff.Create(role, BuffName.Control, i1, ctl)) - end) + local onRoleBeDamaged = function(caster, damage, bCrit, finalDmg, damageType, dotType, skill) + if role:IsDead() and skill then + BattleUtil.RandomControl(f1, ctl, role, caster, i1) end end role.Event:AddEvent(BattleEventName.RoleBeDamaged, onRoleBeDamaged) @@ -1940,7 +1947,7 @@ local passivityList = { local i1 = args[1] -- 释放技能后 local onRoleHit = function(target) - if target.isDead then + if target:IsDead() then for i = 1, i1 do role:AddSkill(BattleSkillType.Normal, false, true, nil) end @@ -1986,7 +1993,7 @@ local passivityList = { local f1 = args[1] -- 释放技能后 local onRoleHit = function(target) - if target.isDead then + if target:IsDead() then local treat = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.MaxHp), f1)) BattleUtil.CalTreat(role, role, treat) end @@ -2008,7 +2015,7 @@ local passivityList = { local onSkillCast = function(skill) extra = 0 if skill and skill.type == BattleSkillType.Special then - -- local roleList =BattleLogic.Query(function (r) return r.camp ~= role.camp end) + -- local roleList =RoleManager.Query(function (r) return r.camp ~= role.camp end) -- local deadNum = 6 - #roleList -- local level = math.floor(deadNum/i1) -- extra = BattleUtil.ErrorCorrection(level * f1) @@ -2084,10 +2091,10 @@ local passivityList = { local f1 = args[1] local onBeHit = function(caster, damage) - local list = BattleLogic.Query(function(v) return v.camp == role.camp end) + local list = RoleManager.Query(function(v) return v.camp == role.camp end) for i = 1, #list do local r = list[i] - if r and not r.isDead then + if r and not r:IsDead() then local treatValue = floor(BattleUtil.ErrorCorrection(f1 * damage)) BattleUtil.ApplyTreat(role, r, treatValue) end @@ -2119,7 +2126,7 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.camp == role.camp and v.position <= 3 end) + local list = RoleManager.Query(function(v) return v.camp == role.camp and v.position <= 3 end) for _, role in ipairs(list) do BattleLogic.BuffMgr:QueryBuff(role, function(buff) if buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.RateReduce then @@ -2142,7 +2149,7 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.camp == role.camp and v.position <= 3 end) + local list = RoleManager.Query(function(v) return v.camp == role.camp and v.position <= 3 end) for _, role in ipairs(list) do BattleLogic.BuffMgr:QueryBuff(role, function(buff) if buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.RateReduce then @@ -2162,7 +2169,7 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.position > 3 end) + local list = RoleManager.Query(function(v) return v.position > 3 end) for _, r in ipairs(list) do r:AddRage(i1, CountTypeName.Add) end @@ -2177,7 +2184,7 @@ local passivityList = { local f1 = args[1] -- 释放技能后 local onRoleHit = function(target) - if target.isDead then + if target:IsDead() then local buff = Buff.Create(role, BuffName.PropertyChange, 1, RoleDataName.Crit, f1, CountTypeName.Add) role:AddBuff(buff) end @@ -2239,10 +2246,48 @@ local passivityList = { -- [129] = {}, - -- TODO - -- 死亡后持续战斗两回合期间受伤不致死,[a]回合后自动死亡。期间技能伤害降低[b]%无法触发追击效果且死后无法被复活。 - -- a[int]b[float] - -- [130] = {}, + -- 死亡后持续战斗两回合期间受伤不致死,[a]回合后自动死亡。期间技能伤害降低[b]%无法触发追击效果且死后无法被复活。受到伤害[c]改变 + -- a[int]b[float]c[改变类型] + [130] = function(role, args) + local i1 = args[1] + local f1 = args[2] + local ct = args[3] + + -- 角色死亡时 + local onRoleDead = function() + -- -- 暂时不能死 + -- role:SetDeadFilter(false) + + -- -- 伤害降低 + -- local function onPassiveDamaging(func, target, damage, skill) + -- if skill and skill.type == BattleSkillType.Special then + -- local dd = BattleUtil.CountValue(damage, f1, 4) - damage + -- if func then func(-floor(BattleUtil.ErrorCorrection(dd))) end + -- end + -- end + -- role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + + -- -- 自动死亡 + -- local counter = 0 + -- local function onRoleTurnEnd() + -- counter = counter + 1 + -- if counter == i1 then + -- -- 可以去死了 + -- role:SetDeadFilter(true) + -- -- 但是不能复活了 + -- role:SetReliveFilter(false) + -- -- 移除事件 + -- role.Event:RemoveEvent(BattleEventName.RoleTurnEnd, onRoleTurnEnd) + -- role.Event:RemoveEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + -- end + -- end + -- role.Event:AddEvent(BattleEventName.RoleTurnEnd, onRoleTurnEnd) + + local buff = Buff.Create(role, BuffName.NoDead, i1, f1, ct, false) + BattleLogic.BuffMgr:AddBuff(role, buff) + end + role.Event:AddEvent(BattleEventName.RoleDead, onRoleDead) + end, -- 敌方每[a]改变[b]人自身伤害就[d]改变[e]% (敌方每死亡i1个则自身属性改变) @@ -2291,7 +2336,7 @@ local passivityList = { -- 击杀数量累加 local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) - if skill and defRole.isDead then + if skill and defRole:IsDead() then killNum = killNum + 1 end end @@ -2354,21 +2399,20 @@ local passivityList = { local ct = args[2] local f1 = args[3] - local onSkillControl = function(target, buff, rate, func) - if buff.type == BuffName.DOT and buff.damageType == dot then - local finalRate = BattleUtil.CountValue(rate, f1, ct) - if func then func(finalRate) end + local onSkillControl = function(func, dotType) + if dotType == dot then + if func then func(f1, ct) end end end local onSkillCast = function(skill) if skill.type == BattleSkillType.Special then - role.Event:AddEvent(BattleEventName.SkillRandomBuff, onSkillControl) + role.Event:AddEvent(BattleEventName.PassiveRandomDot, onSkillControl) end end -- 技能后后 local onSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - role.Event:RemoveEvent(BattleEventName.SkillRandomBuff, onSkillControl) + role.Event:RemoveEvent(BattleEventName.PassiveRandomDot, onSkillControl) end end role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) @@ -2390,11 +2434,7 @@ local passivityList = { local attack = role:GetRoleData(RoleDataName.Attack) local damage = floor(BattleUtil.ErrorCorrection(attack * 0.2)) for _, r in ipairs(list) do - BattleUtil.RandomAction(f1, function() - local buff = Buff.Create(role, BuffName.DOT, i1, 1, dot, damage) - buff.isRealDamage = true - r:AddBuff(buff) - end) + BattleUtil.RandomDot(f1, dot, role, r, i1, 1, damage) end end end @@ -2414,13 +2454,9 @@ local passivityList = { local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then local caster = skill.owner - BattleUtil.RandomAction(f1, function() - local attack = role:GetRoleData(RoleDataName.Attack) - local damage = floor(BattleUtil.ErrorCorrection(attack * 0.2)) - local buff = Buff.Create(role, BuffName.DOT, i1, 1, dot, damage) - buff.isRealDamage = true - caster:AddBuff(buff) - end) + local attack = role:GetRoleData(RoleDataName.Attack) + local damage = floor(BattleUtil.ErrorCorrection(attack * 0.2)) + BattleUtil.RandomDot(f1, dot, role, caster, i1, 1, damage) end end role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onSkillEnd) @@ -2566,33 +2602,41 @@ local passivityList = { local ct = args[3] local f1 = args[4] - local onSkillControl = function(target, buff, rate, func) - if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(b) return b.damageType == dot end) then - if buff.type == BuffName.Control and buff.ctrlType == ctrl then - local finalRate = BattleUtil.CountValue(rate, f1, ct) - if func then func(finalRate) end + local onSkillControl = function(func, ctrl2, target) + if ctrl2 == ctrl then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(b) return b.damageType == dot end) then + if func then func(f1, ct) end end end end local onSkillCast = function(skill) if skill.type == BattleSkillType.Special then - role.Event:AddEvent(BattleEventName.SkillRandomBuff, onSkillControl) + role.Event:AddEvent(BattleEventName.PassiveRandomControl, onSkillControl) end end -- 技能后后 local onSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - role.Event:RemoveEvent(BattleEventName.SkillRandomBuff, onSkillControl) + role.Event:RemoveEvent(BattleEventName.PassiveRandomControl, onSkillControl) end end role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) end, - -- TODO -- 死亡时释放[a]次技能 -- a[int] - -- [144] = + [144] = function(role, args) + local i1 = args[1] + + local function onRoleDead() + for i = 1, i1 do + -- 插入一个技能,该技能优先级较高 + role:InsertSkill(BattleSkillType.Special, false, true, nil) + end + end + role.Event:AddEvent(BattleEventName.RoleDead, onRoleDead) + end, -- 技能对[a]目标[b]额外提升[c]%(当次),[d]改变 @@ -2657,13 +2701,9 @@ local passivityList = { -- 技能后后 local onRoleBeHit = function(caster) - BattleUtil.RandomAction(f1, function() - local attack = role:GetRoleData(RoleDataName.Attack) - local damage = floor(BattleUtil.ErrorCorrection(attack * 0.2)) - local buff = Buff.Create(role, BuffName.DOT, i1, 1, dot, damage) - buff.isRealDamage = true - caster:AddBuff(buff) - end) + local attack = role:GetRoleData(RoleDataName.Attack) + local damage = floor(BattleUtil.ErrorCorrection(attack * 0.2)) + BattleUtil.RandomDot(f1, dot, role, caster, i1, 1, damage) end role.Event:AddEvent(BattleEventName.RoleBeHit, onRoleBeHit) end, @@ -2675,7 +2715,7 @@ local passivityList = { local dot = args[1] local f1 = args[2] local function onHit(target) - if target.isDead then + if target:IsDead() then local maxHp = role:GetRoleData(RoleDataName.MaxHp) local value = floor(BattleUtil.ErrorCorrection(maxHp* f1)) BattleUtil.ApplyTreat(role, role, value) @@ -2691,10 +2731,41 @@ local passivityList = { end, - -- TODO - -- 技能攻击的目标如本回合直接攻击过自己则对其造成伤害增加[a]%(如目标[b]则伤害增加[c]%) - -- a[float]b[持续伤害状态]c[float] - -- [149] + -- 技能攻击的目标如本回合直接攻击过自己则对其造成伤害增加[a]%(如目标[b]则伤害增加[c]%)[d]改变 + -- a[float]b[持续伤害状态]c[float]d[改变类型] + [149] = function(role, args) + local f1 = args[1] + local dot = args[2] + local f2 = args[3] + local ct = args[4] + + local attor = {} + local onRoleBeHit = function(caster) + if not attor[caster.position] then + attor[caster.position] = 1 + end + end + role.Event:AddEvent(BattleEventName.RoleBeHit, onRoleBeHit) + + local onBattleRoundChange = function(func, caster) + attor = {} + end + role.Event:AddEvent(BattleEventName.BattleRoundChange, onBattleRoundChange) + + -- 被动技能加伤害 + local onDamaging = function(func, target, damage, skill) + if attor[target.position] and skill and func then + local df = f1 + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then + df = df + f2 + end + local dd = BattleUtil.CountValue(damage, df, ct) - damage + func(-floor(BattleUtil.ErrorCorrection(dd))) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onDamaging) + + end, -- 技能对[a]目标当次伤害提升[b]%,[c]改变 -- a[持续伤害状态]b[flaot]c[改变类型] @@ -2762,10 +2833,7 @@ local passivityList = { local targets = skill:GetDirectTargets() if targets then for _, r in ipairs(targets) do - BattleUtil.RandomAction(f1, function() - local buff = Buff.Create(role, BuffName.Control, i1, ctrl) - r:AddBuff(buff) - end) + BattleUtil.RandomControl(f1, ctrl, role, r, i1) end end end @@ -2779,17 +2847,31 @@ local passivityList = { local i1 = args[1] local onHit = function(target, damage, bCrit, finalDmg) - if target.isDead then + if target:IsDead() then role:AddRage(i1, CountTypeName.Add) end end role.Event:AddEvent(BattleEventName.RoleHit, onHit) end, - -- TODO -- 复活友方第[a]位阵亡的英雄并回复其[b]%的生命每场战斗触发[c]次 -- a[int]b[float]c[int] - -- [154] + [154] = function(role, args) + local i1 = args[1] + local f1 = args[2] + local i2 = args[3]-- 无意义(第几个死亡的人只能有一个) + + local counter = 0 + local onRoleRealDead = function(deadRole) + if deadRole.camp == role.camp then + counter = counter + 1 + if counter == i1 then + deadRole:SetRelive(f1) + end + end + end + BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, onRoleRealDead) + end, -- 目标血量每降低[c]%(只看当前血量),对其治疗量就[e]改变[f]% -- c[float]e[改变类型]f[float] @@ -2841,12 +2923,12 @@ local passivityList = { local i1 = args[1] local onSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.camp == role.camp end) + local list = RoleManager.Query(function(v) return v.camp == role.camp end) table.sort(list, function(a, b) return a.position < b.position end) for i= 1, #list do - if list[i] and not list[i].isDead then + if list[i] and not list[i]:IsRealDead() then list[i]:AddRage(i1, CountTypeName.Add) break end @@ -2891,13 +2973,9 @@ local passivityList = { -- 技能后后 local onBeSkillCastEnd = function(skill) if skill.type == BattleSkillType.Normal then - BattleUtil.RandomAction(f1, function() - local attack = role:GetRoleData(RoleDataName.Attack) - local damage = floor(BattleUtil.ErrorCorrection(attack * f2)) - local buff = Buff.Create(role, BuffName.DOT, i1, 1, dot, damage) - buff.isRealDamage = true - skill.owner:AddBuff(buff) - end) + local attack = role:GetRoleData(RoleDataName.Attack) + local damage = floor(BattleUtil.ErrorCorrection(attack * f2)) + BattleUtil.RandomDot(f1, dot, role, skill.owner, i1, 1, damage) end end role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd) @@ -2973,11 +3051,11 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = BattleLogic.Query(function(v) return v.camp == role.camp end) + local list = RoleManager.Query(function(v) return v.camp == role.camp end) BattleUtil.SortByHpFactor(list, 1) - local index = 0 + local index = 0 for i = 1, #list do - if not list[i].isDead and index < 2 then + if not list[i]:IsRealDead() and index < 2 then index = index + 1 -- 吸血率%25 策划说写死 list[i]:AddBuff(Buff.Create(role, BuffName.Shield, i1, ShieldTypeName.AllReduce, 0.25, 0)) @@ -3011,12 +3089,12 @@ local passivityList = { local dt = args[2] -- 直接伤害后 local onRoleHit = function(target) - if target.isDead then - local list = BattleLogic.Query(function(v) return v.camp ~= role.camp end) + if target:IsDead() 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 + if not list[i]:IsDead() and index < 2 then index = index + 1 BattleUtil.CalDamage(nil, role, list[i], dt, f1) end @@ -3026,6 +3104,552 @@ local passivityList = { role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) end, + -- 攻击目标越少[a]对每个目标提升概率越高,提升概率为[b]%除以被击者的总数,提升为[c]改变 + -- a[控制状态]b[float]c[改变类型] + [172] = function(role, args) + local ctrl = args[1] + local f1 = args[2] + local ct = args[3] + + local af = 0 + local onSkillCast = function(skill) + local targets = skill:GetDirectTargets() + if targets and #targets > 0 then + af = BattleUtil.ErrorCorrection(f1/#targets) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + local onPassiveRandomControl = function(func, ctrl2) + if ctrl == ctrl2 then + if func then func(af, ct) end + end + end + role.Event:AddEvent(BattleEventName.PassiveRandomControl, onPassiveRandomControl) + end, + + -- 反弹伤害增加[a]%,[b]改变 + -- a[float]b[改变类型] + [173] = function(role, args) + local f1 = args[1] + local ct = args[2] + local onPassiveRebackDamage = function(func) + if func then func(f1, ct) end + end + role.Event:AddEvent(BattleEventName.PassiveRebackDamage, onPassiveRebackDamage) + end, + + -- 技能直接伤害治疗生命最少队友治疗量提升[a]%,[b]改变 + -- a[float]b[改变类型] + [174] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local PassiveSkillDamageHeal = function(func) + if func then func(f1, ct) end + end + role.Event:AddEvent(BattleEventName.PassiveSkillDamageHeal, onPassiveSkillDamageHeal) + end, + + -- 释放技能时,对己方生命最少武将治疗效果额外提升[a],[b]改变 + -- a[float]b[改变类型] + [175] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local onPassiveTreatingFactor = function(func, target) + local arr = RoleManager.Query(function (r) return r.camp == role.camp end) + BattleUtil.SortByHpFactor(arr, 1) + if arr and arr[1] and arr[1] == target then + if func then func(f1, ct) end + end + end + + local function onSkillCast(skill) + if skill.type == BattleSkillType.Special then + role.Event:AddEvent(BattleEventName.PassiveTreatingFactor, onPassiveTreatingFactor) + end + end + local function onSkillCastEnd(skill) + if skill.type == BattleSkillType.Special then + role.Event:RemoveEvent(BattleEventName.PassiveTreatingFactor, onPassiveTreatingFactor) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + end, + + -- 减伤盾抵抗效果提升[a]%,抵抗效果[b]增加,提升效果由所有受益目标平分。 + -- a[float]b[改变类型] + [176] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local af = 0 + local onSkillCast = function(skill) + local targets = skill.effectTargets[2] + if targets and #targets > 0 then + af = BattleUtil.ErrorCorrection(f1/#targets) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + + local onPassiveRandomDot = function(func, dot2) + if dot == dot2 then + if func then func(af, ct) end + end + end + role.Event:AddEvent(BattleEventName.PassiveRandomDot, onPassiveRandomDot) + end, + + -- 技能治疗效果提升[a]%, 同时为每个技能目标附加减伤盾,减伤效果[b]%,持续[c]回合 + -- a[float]b[float]c[int] + [177] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local i1 = args[3] + + local onPassiveTreatingFactor = function(func, target) + if func then func(f1, 1) end + end + + local function onSkillCast(skill) + if skill.type == BattleSkillType.Special then + role.Event:AddEvent(BattleEventName.PassiveTreatingFactor, onPassiveTreatingFactor) + end + end + local function onSkillCastEnd(skill) + if skill.type == BattleSkillType.Special then + role.Event:RemoveEvent(BattleEventName.PassiveTreatingFactor, onPassiveTreatingFactor) + -- 对每个目标附加减伤盾 + local targets = skill:GetDirectTargets() + for _, target in ipairs(targets) do + target:AddBuff(Buff.Create(role, BuffName.Shield, i1, ShieldTypeName.RateReduce, f2, 0)) + end + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + end, + + + -- 攻击目标越少[a]对每个目标提升概率越高,提升率等于[b]%除以被攻击者的总数,[c]改变 + -- a[持续伤害状态]b[float]c[改变类型] + [178] = function(role, args) + local dot = args[1] + local f1 = args[2] + local ct = args[3] + + local af = 0 + local onSkillCast = function(skill) + local targets = skill:GetDirectTargets() + if targets and #targets > 0 then + af = BattleUtil.ErrorCorrection(f1/#targets) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + local onPassiveShield = function(func, shieldType) + if shieldType == ShieldTypeName.RateReduce then + if func then func(af, ct) end + end + end + role.Event:AddEvent(BattleEventName.PassiveShield, onPassiveShield) + end, + + -- 对别人造成的中毒伤害的[a]%用于治疗自己 + -- a[float] + [179] = function(role, args) + local f1 = args[1] + local dot = DotType.Poison + + local onRoleDamage = function(defRole, damage, bCrit, finalDmg, damageType, dotType, skill) + if dotType == dot then + BattleUtil.ApplyTreat(role, role, floor(BattleUtil.ErrorCorrection(finalDmg * f1))) + end + end + role.Event:AddEvent(BattleEventName.RoleDamage, onRoleDamage) + end, + + + -- 受到[a]效果概率降低[b]%,[c]改变 + -- a[控制状态]b[float]c[改变类型] + [180] = function(role, args) + local ctrl = args[1] + local f1 = args[2] + local ct = args[3] + + local onPassiveBeRandomControl = function(func, ctrl2, target) + if ctrl == ctrl2 then + if func then func(f1, ct) end + end + end + role.Event:AddEvent(BattleEventName.PassiveBeRandomControl, onPassiveBeRandomControl) + end, + + + -- 攻击单体目标时额外降低目标[a]点怒气 + -- a[int] + [181] = function(role, args) + local i1 = args[1] + + local function onSkillCastEnd(skill) + -- 对每个目标附加减伤盾 + local targets = skill:GetDirectTargets() + if targets and #targets == 1 then + targets[1]:AddRage(i1, CountTypeName.Sub) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + end, + + + -- 攻击目标越少[a]对每个目标的伤害越高,伤害提升量等于[b]%除以由于自身攻击受到该效果的敌人的总数,[c]改变 + -- a[持续伤害状态]b[float]c[改变类型] + [182] = function(role, args) + local dot = args[1] + local f1 = args[2] + local ct = args[3] + + local af = 0 + local onSkillCast = function(skill) + local targets = skill:GetDirectTargets() + if targets and #targets > 0 then + af = BattleUtil.ErrorCorrection(f1/#targets) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + local onPassiveRandomDot = function(func, dot2, damage) + if dot == dot2 then + if func then func(nil, nil, af, ct) end + end + end + role.Event:AddEvent(BattleEventName.PassiveRandomDot, onPassiveRandomDot) + end, + + -- 有该技能角色,释放技能造成的[a]效果附加封治疗效果,该状态武将无法回复生命 + -- a[持续伤害状态] + [183] = function(role, args) + local dot = args[1] + + local onBuffCaster = function(buff) + if buff.type == BuffName.DOT and buff.dotType == dot then + role:AddBuff(Buff.Create(role, BuffName.Control, buff.duration, ControlType.NoHeal)) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, onBuffCaster) + end, + + -- [a]状态延长[b]回合 + -- a[持续伤害状态]b[int] + [184] = function(role, args) + local dot = args[1] + local i1 = args[2] + + local onBuffCaster = function(buff) + if buff.type == BuffName.DOT and buff.dotType == dot then + buff:ChangeBuffDuration(CountTypeName.Add, i1) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, onBuffCaster) + end, + + + -- 直接伤害击杀目标对仇恨目标造成[a]%物理伤害 + -- a[float] + [185] = function(role, args) + local f1 = args[1] + + local onRoleHit = function(target) + if target:IsDead() then + local target = RoleManager.GetAggro(role) + BattleUtil.CalDamage(nil, role, target, 1, f1) + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + end, + + + -- 攻击纵排目标时额外降低目标[a]点怒气 + -- a[int] + [186] = function(role, args) + local i1 = args[1] + + local onSkillCastEnd = function(skill) + local effectGroup = skill.effectList.buffer[1] + local chooseId = effectGroup.chooseId + local chooseLimit = floor(chooseId / 10000) % 10 + if chooseLimit == 3 then -- 打纵列 + local targets = skill:GetDirectTargets() + if targets then + for _, r in ipairs(targets) do + r:AddRage(i1, CountTypeName.Sub) + end + end + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + end, + + -- 普攻[a]%概率暴击 + -- a[float] + [187] = function(role, args) + local f1 = args[1] + local function onSkillCast(skill) + if skill.type == BattleSkillType.Normal then + role.data:AddValue(RoleDataName.Crit, f1) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + local function onSkillCastEnd(skill) + if skill.type == BattleSkillType.Normal then + role.data:SubValue(RoleDataName.Crit, f1) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + end, + + -- 受到伤害降低[a]%(与减伤盾同效果)并且将自身受到非致命伤害平分给自身及己方当前生命最高的两名武将(被平摊武将有无敌也会受到伤害)降低伤害[b]改变 + -- a[float]b[改变类型] + [188] = function(role, args) + local f1 = args[1] + local ct = args[2] + + + local onFinalBeDamage = function(damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType) + -- 伤害降低 + local finalDamage = BattleUtil.CountValue(damage, f1, ct) + local curHp = role:GetRoleData(RoleDataName.Hp) + -- 不是致死伤害 + if finalDamage < curHp then + -- 找到除自身外的血量最高的两人 + local list = RoleManager.Query(function(v) + return v.camp == role.camp and v.position ~= role.position + end) + local ff = 1 -- 分摊比 + -- 检测被动对分摊比的影响 + local cl = {} + local function _CallBack(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + role.Event:DispatchEvent(BattleEventName.PassiveDamageShare, _CallBack) + atkRole.Event:DispatchEvent(BattleEventName.PassiveDamageBeShare, _CallBack) + ff = BattleUtil.CountChangeList(ff, cl) + + -- 计算分摊伤害 + local fenDamage = finalDamage * ff -- 需要分摊的总伤害 + list = BattleUtil.SortByProp(list, RoleDataName.Hp, 0) + local targets = {role, list[1], list[2]} + local fd = floor(BattleUtil.ErrorCorrection(fenDamage/#targets)) -- 每个人需要分摊的伤害 + + -- 自身伤害 + if damagingFunc then + local unFenDamage = floor(BattleUtil.ErrorCorrection(finalDamage * (1 - ff))) -- 不被分摊的伤害 + damagingFunc(floor(BattleUtil.ErrorCorrection(damage - (unFenDamage + fd)))) + end + -- 平分给别人 + for i = 2, #targets do + BattleUtil.FinalDamage(skill, atkRole, targets[i], fd, nil, 0, dotType) + end + end + end + role.Event:AddEvent(BattleEventName.FinalBeDamage, onFinalBeDamage) + + end, + + -- 有该技能角色,造成的[a]效果会使目标无法获得无敌盾和无敌吸血盾效果 + -- a[持续伤害状态] + [189] = function(role, args) + local dot = args[1] + + local onBuffCaster = function(buff) + if buff.type == BuffName.DOT and buff.dotType == dot then + role:AddBuff(Buff.Create(role, BuffName.Immune, buff.duration, 4)) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, onBuffCaster) + end, + + -- 技能直接伤害[a]%转化为生命治疗自己 + -- a[float] + [191] = function(role, args) + local f1 = args[1] + + local onHit = function(target, damage, bCrit, finalDmg, dtype, skill) + if skill and skill.type == BattleSkillType.Special then + -- 检测技能伤害治疗加成 + local f = BattleUtil.CheckSkillDamageHeal(f1, role, target) + -- 治疗自己 + BattleUtil.ApplyTreat(role, role, floor(BattleUtil.ErrorCorrection(finalDmg * f))) + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onHit) + end, + -- 武将怒气小于[a]点时不会释放技能,释放技能消耗当前所有怒气超过4怒气部分每额外消耗1点怒气技能伤害增加[b]% + -- a[int]b[float] + [192] = function(role, args) + local i1 = args[1] + local f1 = args[2] + + -- 提高技能释放怒气值 + role.SuperSkillRage = i1 + + -- + local allRage = 0 + local function onRoleRageCost(rage, rate, func) + allRage = role.Rage + local deltaRage = allRage - role.SuperSkillRage + if func then + func(0, deltaRage) + end + end + role.Event:AddEvent(BattleEventName.RoleRageCost, onRoleRageCost) + + + -- 释放技能后 + local onPassiveDamaging = function(damagingFunc, defRole, damage, skill, dotType) + if skill and skill.type == BattleSkillType.Special then + local deltaRage = allRage - 4 + if deltaRage > 0 then + local dd = BattleUtil.CountValue(damage, f1 * deltaRage, 2) - damage + damagingFunc(-floor(BattleUtil.ErrorCorrection(dd))) + end + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + + end, + + -- 对己方生命最少的三个武将治疗效果额外提升治疗武将攻击的[a]%,提升为[b]改变 + -- a[float]b[改变类型] + [193] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local OnPassiveTreating = function(treatingFunc, target) + local arr = RoleManager.Query(function (r) return r.camp == role.camp end) + BattleUtil.SortByHpFactor(arr, 1) + if not arr then return end + for i = 1, 3 do + if arr[i] and arr[i] == target then + treatingFunc(f1, ct) + end + end + end + role.Event:AddEvent(BattleEventName.PassiveTreating, OnPassiveTreating) + end, + + + -- 攻击有概率清除敌方武将无敌盾和无敌吸血盾,攻击目标越少,清除概率越高,对每个受击者清除概率等于[a]%除以受击者的总数 + -- a[float] + [194] = function(role, args) + local f1 = args[1] + + local OnSkillCastEnd = function(skill) + local targets = skill:GetDirectTargets() + if not targets or #targets == 0 then return end + local cf = f1/#targets + 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) + end) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + -- 首回合免疫[a]效果 + -- a[控制状态] + [195] = function(role, args) + local dot = args[1] + + local immune = function(buff) + return buff.type == BuffName.DOT and (dot == 0 or buff.dotType == dot) + end + + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) + -- 第i1回合开始 + if curRound == 1 then + role.buffFilter:Add(immune) + end + -- 第i1+i2回合结束 + if curRound == 2 then + for i = 1, role.buffFilter.size do + if role.buffFilter.buffer[i] == immune then + role.buffFilter:Remove(i) + break + end + end + end + end) + end, + + -- 对敌方造成伤害如被分摊其分摊比降低[a]% + -- a[float] + [196] = function(role, args) + local f1 = args[1] + local onDamageBeShare = function(func) + if func then func(f1, CountTypeName.Sub) end + end + role.Event:DispatchEvent(BattleEventName.PassiveDamageBeShare, onDamageBeShare) + end, + + -- 技能直接击杀敌方目标时有[a]%概率获得目标剩余所有怒气(输出武将佩戴) + -- a[float] + [197] = function(role, args) + local f1 = args[1] + local onRoleHit = function(target) + if target:IsDead() then + BattleUtil.RandomAction(f1, function() + role:AddRage(target.rage, CountTypeName.Add) + end) + end + end + role.Event:DispatchEvent(BattleEventName.RoleHit, onRoleHit) + end, + + -- 受到的[a]效果伤害降低[b]%(与减伤盾原理相同)[c]改变 + -- a[持续伤害状态]b[float]c[改变类型] + [198] = function(role, args) + local dot = args[1] + local f1 = args[2] + local ct = args[3] + + -- 释放技能后 + local onPassiveDamaging = function(damagingFunc, defRole, damage, skill, dotType) + if dotType and (dotType == dot or dot == 0) then + local dd = damage - BattleUtil.CountValue(damage, f1, ct) + damagingFunc(floor(BattleUtil.ErrorCorrection(dd))) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + + end, + + + + + -- 伤害增加[a]%,[b]改变 + -- a[float]b[改变类型] + [205] = function(role, args) + local f1 = args[1] + local ct = args[2] + local passivityDamaging = function(func, caster, damage, skill) + if skill and func then + local dd = BattleUtil.CountValue(damage, f1, ct) - damage + func(-floor(BattleUtil.ErrorCorrection(dd))) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging) + end, + --技能治疗系数[a]改变[b]%(作用于主动技能效果103) @@ -3059,7 +3683,7 @@ local passivityList = { if skill.type == BattleSkillType.Special then BattleUtil.RandomAction(f1, function() BattleLogic.WaitForTrigger(0.1, function() - local list = BattleLogic.Query(function(v) + local list = RoleManager.Query(function(v) return v.camp == (role.camp + 1) % 2 and v.position > 3 end) for _, r in ipairs(list) do diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index ec3288ab5..ca855dbcf 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -89,9 +89,11 @@ local function takeEffect(caster, target, effects, duration, skill) target.Event:DispatchEvent(BattleEventName.BeSkillEffectBefore, skill, e, _PassiveCheck) -- - effect[e.type](caster, target, e.args, duration, skill) - if BattleLogic.IsOpenBattleRecord then - BattleLogic.RecordEffect(caster, target, e.type, e.args, duration) + if effect[e.type] then + effect[e.type](caster, target, e.args, duration, skill) + if BattleLogic.IsOpenBattleRecord then + BattleLogic.RecordEffect(caster, target, e.type, e.args, duration) + end end end end @@ -110,7 +112,7 @@ function Skill:Cast(func) self.effectTargets[i] = self.targets[i] -- 判断是否有有效目标 for _, role in ipairs(self.effectTargets[i]) do - if not role.isDead then + if not role:IsRealDead() then isReTarget = false end end @@ -140,7 +142,7 @@ function Skill:Cast(func) end -- 全部同时生效 for j=1, count do - if arr[j] and not arr[j].isDead then + if arr[j] and not arr[j]:IsRealDead() then takeEffect(self.owner, arr[j], effects, duration, self) end end @@ -159,8 +161,6 @@ function Skill:Cast(func) for _, tr in ipairs(self.effectTargets[1]) do tr.Event:DispatchEvent(BattleEventName.BeSkillCast, self) end - - BattleLogic.SetSkillUsable(self.owner.camp, false) --技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个 local duration = 0 for i=1, self.effectList.size do @@ -168,7 +168,6 @@ function Skill:Cast(func) end -- 结算时间向后延长0.2秒,避免在效果结算完成前就结束了技能释放 BattleLogic.WaitForTrigger(duration + 0.2, function() - BattleLogic.SetSkillUsable(self.owner.camp, true) self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index d2013d237..e48684962 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -1,3 +1,9 @@ + +require("Modules.Battle.Logic.SkillManager") +require("Modules.Battle.Logic.RoleManager") + + + BattleLogic = {} local floor = math.floor @@ -11,30 +17,16 @@ local CurCamp = 0 local CurSkillPos = {} local PosList = {} -local curUid -local curBuffId local curFrame -local playerSkillUsable -local enemySkillUsable - -local bMyAllDead -local bEnemyAllDead - BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 8 兽潮 9巅峰战 BattleLogic.IsEnd = false BattleLogic.Result = -1 BattleLogic.Event = BattleEvent.New() BattleLogic.BuffMgr = BuffManager.New() -local playerTeamDummyRole = {camp = 0, Event = BattleEvent.New(), isTeam = true, curSkill = nil, isDebug = false} -local enemyTeamDummyRole = {camp = 1, Event = BattleEvent.New(), isTeam = true, curSkill = nil, isDebug = false} -local playerTeamSkillList = {} -local enemyTeamSkillList = {} - local _IsDebug - local fightData local record local optionRecord @@ -49,11 +41,6 @@ BattleLogic.TotalOrder = 0 --当前波次 BattleLogic.CurOrder = 0 -local teamSkillCastRound = {2, 4, 6} -local MyTeamSkillCastIndex -local EnemyTeamSkillCastIndex - - local actionPool = BattleObjectPool.New(function () return { 0, 0 } @@ -84,29 +71,18 @@ function BattleLogic.Init(data, optionData) BattleLogic.Clear() - curUid = 0 - curBuffId = 0 curFrame = 0 CurRound = 0 _IsDebug = false - playerTeamDummyRole.isDebug = false - playerTeamDummyRole.Event:ClearEvent() - enemyTeamDummyRole.isDebug = false - enemyTeamDummyRole.Event:ClearEvent() - - playerSkillUsable = true - enemySkillUsable = true - - bMyAllDead = false - bEnemyAllDead = false BattleLogic.Event:ClearEvent() BattleLogic.BuffMgr:Init() BattleLogic.IsEnd = false BattleLogic.Result = -1 + RoleManager.Init() SkillManager.Init() end @@ -114,89 +90,20 @@ function BattleLogic.StartOrder() -- BattleLogic.CurOrder = BattleLogic.CurOrder + 1 if BattleLogic.CurOrder == 1 then - MyTeamSkillCastIndex = 1 - EnemyTeamSkillCastIndex = 1 - local playerData = fightData.playerData local enemyData = fightData.enemyData[BattleLogic.CurOrder] for i=1, #playerData do - BattleLogic.AddRole(playerData[i], playerData[i].position) + RoleManager.AddRole(playerData[i], playerData[i].position) end for i=1, #enemyData do - BattleLogic.AddRole(enemyData[i], enemyData[i].position) + RoleManager.AddRole(enemyData[i], enemyData[i].position) end - for i=1,3 do - if playerTeamSkillList[i] then - skillPool:Put(playerTeamSkillList[i]) - playerTeamSkillList[i]=nil - end - end - for i=1, #playerData.teamSkill do - local skill = skillPool:Get() - skill:Init(playerTeamDummyRole, playerData.teamSkill[i], 0) - playerTeamSkillList[i] = skill - end - for i=1, #playerData.teamPassive do - for j=1, #playerData.teamPassive[i] do - local v = playerData.teamPassive[i][j] - local id = v[1] - local args = {} - for k = 2, #v do - args[k-1] = v[k] - end - BattleLogic.TakeTeamPassivity(playerTeamDummyRole, id, args) - end - end - - for i=1,3 do - if enemyTeamSkillList[i] then - skillPool:Put(enemyTeamSkillList[i]) - enemyTeamSkillList[i]=nil - end - end - for i=1, #enemyData.teamSkill do - local skill = skillPool:Get() - skill:Init(enemyTeamDummyRole, enemyData.teamSkill[i], 0) - enemyTeamSkillList[i] = skill - end - for i=1, #enemyData.teamPassive do - for j=1, #enemyData.teamPassive[i] do - local v = enemyData.teamPassive[i][j] - local id = v[1] - local args = {} - for k = 2, #v do - args[k-1] = v[k] - end - BattleLogic.TakeTeamPassivity(enemyTeamDummyRole, id, args) - end - end else - BattleLogic.ClearOrder() + RoleManager.ClearEnemy() local orderList = fightData.enemyData[BattleLogic.CurOrder] for i=1, #orderList do - BattleLogic.AddRole(orderList[i], orderList[i].position) - end - - for i=1, #enemyTeamSkillList do - skillPool:Put(enemyTeamSkillList[i]) - enemyTeamSkillList[i]=nil - end - for i=1, #orderList.teamSkill do - local skill = skillPool:Get() - skill:Init(enemyTeamDummyRole, orderList.teamSkill[i], 0) - enemyTeamSkillList[i] = skill - end - for i=1, #orderList.teamPassive do - for j=1, #orderList.teamPassive[i] do - local v = orderList.teamPassive[i][j] - local id = v[1] - local args = {} - for k = 2, #v do - args[k-1] = v[k] - end - BattleLogic.TakeTeamPassivity(enemyTeamDummyRole, id, args) - end + RoleManager.AddRole(orderList[i], orderList[i].position) end end @@ -224,13 +131,23 @@ function BattleLogic.GetIsDebug() return _IsDebug end - -- 下一帧开始下一轮 +local _TurnRoundFlag = 0 function BattleLogic.TurnRoundNextFrame() - BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function() - BattleLogic.TurnRound() - end) + _TurnRoundFlag = 0 end + +-- 检测是否要轮转 +function BattleLogic.CheckTurnRound() + if _TurnRoundFlag == 2 then + return + end + _TurnRoundFlag = _TurnRoundFlag + 1 + if _TurnRoundFlag == 2 then + BattleLogic.TurnRound() + end +end + -- 开始轮转 -- debugTurn 用于判断是否是debug轮转的参数 function BattleLogic.TurnRound(debugTurn) @@ -242,8 +159,8 @@ function BattleLogic.TurnRound(debugTurn) if CurRound == 0 or (CurSkillPos[0] == 6 and CurSkillPos[1] == 6) then CurRound = CurRound + 1 CurCamp = 0 - CurSkillPos[0] = -1 -- 先从异妖开始检测 - CurSkillPos[1] = -1 + CurSkillPos[0] = 0 + CurSkillPos[1] = 0 -- 轮数变化 BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound) else @@ -253,188 +170,58 @@ function BattleLogic.TurnRound(debugTurn) -- 当前阵营下一释放技能的位置 local cpos = CurSkillPos[CurCamp] + 1 - if cpos == 0 then - -- 保存当前释放技能的位置 - CurSkillPos[CurCamp] = cpos - -- 刷新异妖buff轮数(暂时不用) - -- BattleLogic.BuffMgr:PassUpdate() - -- 检测异妖技能释放 - BattleLogic.CheckTeamSkillCast(CurCamp) - else - -- 找到下一个释放技能的人 - local SkillRole - for p = cpos, 6 do - -- 保存当前位置 - CurSkillPos[CurCamp] = p - -- 自己阵营中的位置 + 自己阵营的ID * 6 = 自己在PosList中的位置 - local role = PosList[p + (CurCamp * 6)] - if role and not role.isDead then - SkillRole = role - break - end - - -- 如果当前位置不能释放技能也需要走buff轮转 - BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 - BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) - BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) - BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff - BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 - end - -- 如果找不到下一个人,直接交换阵营 - if not SkillRole then - BattleLogic.TurnRoundNextFrame() - return + -- 找到下一个释放技能的人 + local SkillRole + for p = cpos, 6 do + -- 保存当前位置 + CurSkillPos[CurCamp] = p + -- 自己阵营中的位置 + 自己阵营的ID * 6 = 自己在PosList中的位置 + local role = RoleManager.GetRole(CurCamp, p) --PosList[p + (CurCamp * 6)] + if role and not role:IsRealDead() then + SkillRole = role + break end - - -- 如果角色无法释放技能 - if not SkillRole:IsAvailable() then - BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 - BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) - BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) - BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff - BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 - BattleLogic.TurnRoundNextFrame() -- 下一个 - return - end - - -- 行动 - SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnStart) -- 开始行动 + -- 如果当前位置不能释放技能也需要走buff轮转 BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) - -- 释放技能后,递归交换阵营 - SkillRole:CastSkill(function() - BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) - BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff - BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 - SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd) -- 行动结束 - BattleLogic.TurnRoundNextFrame() - end) + BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) + BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff + BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 end + -- 如果找不到下一个人,直接交换阵营 + if not SkillRole then + BattleLogic.TurnRoundNextFrame() + return + end + + + -- 如果角色无法释放技能 + if not SkillRole:IsAvailable() then + BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 + BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) + BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) + BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff + BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 + BattleLogic.TurnRoundNextFrame() -- 下一个 + return + end + + -- 行动 + SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnStart) -- 开始行动 + BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量 + BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血) + -- 释放技能后,递归交换阵营 + SkillRole:CastSkill(function() + BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) + BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff + BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 + SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd) -- 行动结束 + BattleLogic.TurnRoundNextFrame() + end) end - --- 触发异妖被动 -function BattleLogic.TakeTeamPassivity(teamCaster, id, args) - for _, v in pairs(PosList) do - BattleUtil.Passivity[id](v, args) - end - -- objList:Foreach(function(k, v) - -- BattleUtil.Passivity[id](v, args) - -- end) -end - --- 获取当前等待释放技能的异妖的序号 -function BattleLogic.GetTeamSkillCastIndex(camp) - -- body - if camp == 0 then - return MyTeamSkillCastIndex - else - return EnemyTeamSkillCastIndex - end -end - --- 获取异妖 -function BattleLogic.GetTeamSkill(camp, pos) - if camp == 0 then - return playerTeamSkillList[pos] - else - return enemyTeamSkillList[pos] - end -end - --- 获取异妖技能CD -function BattleLogic.GetTeamSkillCastSlider(camp) - local teamSkillCastIndex = BattleLogic.GetTeamSkillCastIndex(camp) - if playerTeamDummyRole.isDebug or teamSkillCastIndex > #teamSkillCastRound then - return 0 - end - local slider = 0 - if teamSkillCastIndex == 1 then - slider = CurRound / teamSkillCastRound[teamSkillCastIndex] - else - slider = (CurRound - teamSkillCastRound[teamSkillCastIndex - 1]) / (teamSkillCastRound[teamSkillCastIndex] - teamSkillCastRound[teamSkillCastIndex - 1]) - end - return slider -end - --- 检测异妖技能是否可以释放 -function BattleLogic.CheckTeamSkillCast(camp) - local teamSkillCastIndex = BattleLogic.GetTeamSkillCastIndex(camp) - local teamSkillList = camp == 0 and playerTeamSkillList or enemyTeamSkillList - if teamSkillList[teamSkillCastIndex] then - if teamSkillCastIndex <= #teamSkillCastRound and CurRound >= teamSkillCastRound[teamSkillCastIndex] then - teamSkillList[teamSkillCastIndex]:Cast(BattleLogic.TurnRoundNextFrame) - if camp == 0 then - MyTeamSkillCastIndex = MyTeamSkillCastIndex + 1 - else - EnemyTeamSkillCastIndex = EnemyTeamSkillCastIndex + 1 - end - return - end - end - -- 没有要释放技能的异妖,切换阵营 - BattleLogic.TurnRoundNextFrame() -end - - -function BattleLogic.GenerateBuffId() - if not curBuffId then - curBuffId = 0 - end - curBuffId = curBuffId + 1 - return curBuffId -end - --- 角色数据添加 -function BattleLogic.AddRole(roleData, position) - if not curUid then - curUid = 0 - end - curUid = curUid + 1 - local role = rolePool:Get() - role:Init(curUid, roleData, position) - -- objList:Add(curUid, role) - if roleData.camp == 0 then - PosList[position] = role -- 1-6 我方英雄 - else - PosList[position + 6] = role-- 7-12 敌方英雄 - end - if not role.isDead then - BattleLogic.Event:DispatchEvent(BattleEventName.AddRole, role) - end -end --- 获取角色数据 -function BattleLogic.GetRole(camp, pos) - return PosList[pos + camp*6] -end --- 获取某阵营所有角色 -function BattleLogic.GetRoleByCamp(camp) - local list = {} - for i = 1, 6 do - list[i] = PosList[i + camp * 6] - end - return list -end - - -function BattleLogic.SetSkillUsable(camp, value) - if camp == 0 then - playerSkillUsable = value - else - enemySkillUsable = value - end -end - -function BattleLogic.GetSkillUsable(camp) - if camp == 0 then - return playerSkillUsable - else - return enemySkillUsable - end -end - function BattleLogic.WaitForTrigger(delayTime, action) delayTime = BattleUtil.ErrorCorrection(delayTime) local delayFrame = floor(delayTime * BattleLogic.GameFrameRate + 0.5) @@ -451,96 +238,15 @@ function BattleLogic.WaitForTrigger(delayTime, action) end end -function BattleLogic.AddOption(opType, opArg) - table.insert(optionRecord, {curFrame + 1, opType, opArg}) -end - -function BattleLogic.GetTeamSkillCaster(camp) - return camp == 0 and playerTeamDummyRole or enemyTeamDummyRole -end function BattleLogic.CurFrame() return curFrame end -function BattleLogic.Query(func, inCludeDeadRole) - local list = {} - local index = 1 - if func then - for pos, v in pairs(PosList) do - if func(v) and (inCludeDeadRole or not v.isDead) then - list[index] = v - index = index + 1 - end - end - -- objList:Foreach(function(k, v) - -- if func(v) and (inCludeDeadRole or not v.isDead) then - -- list[index] = v - -- index = index + 1 - -- end - -- end) - end - return list -end - -function BattleLogic.BattleEnd(result) - BattleLogic.IsEnd = true - BattleLogic.Result = result - BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result) -end - -function BattleLogic.Clear() - -- while objList.size > 0 do - -- objList.vList[objList.size]:Dispose() - -- removeObjList:Add(objList.vList[objList.size]) - -- objList:Remove(objList.vList[objList.size].uid) - -- end - for _, obj in pairs(PosList) do - obj:Dispose() - removeObjList:Add(obj) - end - PosList = {} - - while removeObjList.size > 0 do - rolePool:Put(removeObjList.buffer[removeObjList.size]) - removeObjList:Remove(removeObjList.size) - end - while tbActionList.size > 0 do - actionPool:Put(tbActionList.buffer[tbActionList.size]) - tbActionList:Remove(tbActionList.size) - end -end - -function BattleLogic.ClearOrder() - local removePos = {} - for pos, obj in pairs(PosList) do - if obj.camp == 1 then - removePos[pos] = 1 - BattleLogic.Event:DispatchEvent(BattleEventName.RemoveRole, obj) - obj:Dispose() - removeObjList:Add(obj) - end - end - for pos, _ in pairs(removePos) do - PosList[pos] = nil - end - - -- local index = 1 - -- while index <= objList.size do - -- if objList.vList[index].camp == 1 then - -- BattleLogic.Event:DispatchEvent(BattleEventName.RemoveRole, objList.vList[index]) - -- objList.vList[index]:Dispose() - -- removeObjList:Add(objList.vList[index]) - -- objList:Remove(objList.vList[index].uid) - -- else - -- index = index + 1 - -- end - -- end -end - function BattleLogic.Update() curFrame = curFrame + 1 - if bMyAllDead then + local roleResult = RoleManager.GetResult() + if roleResult == 0 then BattleLogic.BattleEnd(0) return end @@ -548,7 +254,7 @@ function BattleLogic.Update() BattleLogic.BattleEnd(0) return end - if bEnemyAllDead then + if roleResult == 1 then if BattleLogic.CurOrder == BattleLogic.TotalOrder then BattleLogic.BattleEnd(1) else @@ -557,6 +263,7 @@ function BattleLogic.Update() end end + -- 检测帧事件(技能命中,伤害计算,buff生成) local index = 1 while index <= tbActionList.size do local action = tbActionList.buffer[index] @@ -568,164 +275,62 @@ function BattleLogic.Update() index = index + 1 end end - + -- 检测buff BattleLogic.BuffMgr:Update() + --- + -- 检测角色状态 + RoleManager.Update() + + -- 检测死亡 + if RoleManager.CheckDead() then -- 单独用一帧执行死亡 + return + end + -- 检测复活 + if RoleManager.CheckRelive() then -- 单独用一帧执行复活 + return + end + + -- 检测技能释放 + -- 检测轮转 + BattleLogic.CheckTurnRound() + -- 技能 SkillManager.Update() - bMyAllDead = true - bEnemyAllDead = true - for _, v in pairs(PosList) do - if not v.isDead then - v:Update() - if v.camp == 0 then - bMyAllDead = false - else - bEnemyAllDead = false - end - end - end - -- objList:Foreach(function(k, v) - -- if not v.isDead then - -- v:Update() - -- if v.camp == 0 then - -- bMyAllDead = false - -- else - -- bEnemyAllDead = false - -- end - -- end - -- end) - if bEnemyAllDead then - BattleLogic.Event:DispatchEvent(BattleEventName.BattleOrderEnd, BattleLogic.CurOrder) +end + +-- 战斗结束 +function BattleLogic.BattleEnd(result) + BattleLogic.IsEnd = true + BattleLogic.Result = result + BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result) +end +-- +function BattleLogic.Clear() + -- 清空角色 + RoleManager.Clear() + -- 清空事件 + while tbActionList.size > 0 do + actionPool:Put(tbActionList.buffer[tbActionList.size]) + tbActionList:Remove(tbActionList.size) end end ---对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的 -function BattleLogic.GetAggro(role) - -- 计算开始位置 - local startPos = role.position - startPos = startPos > 3 and startPos - 3 or startPos - local target - local enemyCamp = role.camp == 0 and 1 or 0 - -- c=0 前排 c=1 后排 - for c = 0, 1 do - startPos = startPos + c*3 - -- 向左 - for i = startPos, c*3+1, -1 do - local pos = i + enemyCamp * 6 - if PosList[pos] and not PosList[pos].isDead then - target = PosList[pos] - break - end - end - if target then return target end - -- 向右 - for i = startPos + 1, c*3+3 do - local pos = i + enemyCamp * 6 - if PosList[pos] and not PosList[pos].isDead then - target = PosList[pos] - break - end - end - if target then return target end - end -end ---对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的 -function BattleLogic.GetArrAggroList(role, arr) - -- 重构数据 - local plist = {} - for _, role in ipairs(arr) do - plist[role.position] = role - end - -- 计算开始位置 - local startPos = role.position - startPos = startPos > 3 and startPos - 3 or startPos - local targetList = {} - -- c=0 前排 c=1 后排 - for c = 0, 1 do - startPos = startPos + c*3 - -- 向左 - for i = startPos, c*3+1, -1 do - local pos = i - if plist[pos] and not plist[pos].isDead then - table.insert(targetList, plist[pos]) - end - end - -- 向右 - for i = startPos + 1, c*3+3 do - local pos = i - if plist[pos] and not plist[pos].isDead then - table.insert(targetList, plist[pos]) - end - end - end - return targetList -end ---获取对位相邻站位的人 chooseType 1 我方 2 敌方(对位的敌人受到嘲讽的影响,若对位的敌人死亡,则选取相邻最近的作为目标) -function BattleLogic.GetNeighbor(role, chooseType) - local posList = {} - local target - if chooseType == 1 then - target = role - else - if role.lockTarget and not role.lockTarget.isDead then - target = role.lockTarget - else - target = BattleLogic.GetAggro(role) - end - end - if target then - local list = BattleLogic.Query(function (r) return r.camp == target.camp end) - for i=1, #list do - if not list[i].isDead then - if list[i].position == target.position + 3 -- 后排的人 - or list[i].position == target.position - 3 -- 前排的人 - or (math.abs(target.position - list[i].position) <= 1 and floor((target.position-1)/3) == floor((list[i].position-1)/3)) then -- 旁边的人和自己 - table.insert(posList, list[i]) - end - end - end - end - return posList -end -function BattleLogic.CastTeamSkill(camp) - if camp == 0 then - local teamSkill = playerTeamSkillList[MyTeamSkillCastIndex] - if teamSkill then - teamSkill:Cast() - end - else - local teamSkill = enemyTeamSkillList[EnemyTeamSkillCastIndex] - if teamSkill then - teamSkill:Cast() - end - end -end ---Debug专用 --- function BattleLogic.SetDebug() --- objList:Foreach(function(k, v) --- v.IsDebug = not v.IsDebug --- end) --- playerTeamDummyRole.isDebug = not playerTeamDummyRole.isDebug --- enemyTeamDummyRole.isDebug = not enemyTeamDummyRole.isDebug --- end ---Debug专用 --- function BattleLogic.SetRoleValue(uid, name, value) --- if objList.kvList[uid] then --- objList.kvList[uid].data:SetValue(name, value) --- end --- end --- --Debug专用 --- function BattleLogic.SetRoleDebug(uid, isDebug) --- if objList.kvList[uid] then --- objList.kvList[uid].IsDebug = isDebug --- end --- end + + + + + + + + + +-------++++++++++++++++++++++++++++ 战斗记录相关 --Record专用 function BattleLogic.GetRecord() return record diff --git a/luafight/Modules/Battle/Logic/Buff/DOT.lua b/luafight/Modules/Battle/Logic/Buff/DOT.lua index 8bfdde234..53e28442c 100644 --- a/luafight/Modules/Battle/Logic/Buff/DOT.lua +++ b/luafight/Modules/Battle/Logic/Buff/DOT.lua @@ -34,9 +34,9 @@ end function DOT:OnTrigger() if self.isRealDamage then - BattleUtil.ApplyDamage(nil, self.caster, self.target, self.damagePro) + BattleUtil.ApplyDamage(nil, self.caster, self.target, self.damagePro, nil, nil, self.damageType) else - BattleUtil.CalDamage(nil, self.caster, self.target, self.damagePro, self.damageFactor,0, true) + BattleUtil.CalDamage(nil, self.caster, self.target, self.damagePro, self.damageFactor, 0, self.damageType) end return true end diff --git a/luafight/Modules/Battle/Logic/Buff/HOT.lua b/luafight/Modules/Battle/Logic/Buff/HOT.lua index 202d039c9..505cdf71d 100644 --- a/luafight/Modules/Battle/Logic/Buff/HOT.lua +++ b/luafight/Modules/Battle/Logic/Buff/HOT.lua @@ -19,7 +19,7 @@ end --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd function HOT:OnTrigger() - if not self.target.ctrl_noheal or self.target.isDead then --禁疗和死亡无法加血 + if not self.target.ctrl_noheal or self.target:IsDead() then --禁疗和死亡无法加血 BattleUtil.ApplyTreat(self.caster, self.target, self.healValue) end return true diff --git a/luafight/Modules/Battle/Logic/Buff/Immune.lua b/luafight/Modules/Battle/Logic/Buff/Immune.lua index 0504e3e9f..f16fe510a 100644 --- a/luafight/Modules/Battle/Logic/Buff/Immune.lua +++ b/luafight/Modules/Battle/Logic/Buff/Immune.lua @@ -10,6 +10,9 @@ end local immune2 = function(buff) return buff.type == BuffName.DOT end +local immune3 = function(buff) + return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce +end --初始化Buff,通过传入一些自定义参数控制成长相关的数值 function Immune:SetData(...) @@ -30,6 +33,8 @@ function Immune:OnStart() self.target.buffFilter:Add(immune1) elseif self.immuneType == 2 then --免疫dot self.target.buffFilter:Add(immune2) + elseif self.immuneType == 3 then --免疫无敌盾 + self.target.buffFilter:Add(immune3) end end @@ -49,6 +54,8 @@ function Immune:OnEnd() immune = immune1 elseif self.immuneType == 2 then --免疫dot immune = immune2 + elseif self.immuneType == 3 then --免疫无敌盾 + immune = immune3 end for i = 1, self.target.buffFilter.size do if self.target.buffFilter.buffer[i] == immune then diff --git a/luafight/Modules/Battle/Logic/Buff/NoDead.lua b/luafight/Modules/Battle/Logic/Buff/NoDead.lua new file mode 100644 index 000000000..a92b4e777 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Buff/NoDead.lua @@ -0,0 +1,53 @@ +NoDead = Buff:New() + +--初始化Buff,通过传入一些自定义参数控制成长相关的数值 +function NoDead:SetData(...) + self.damageFactor, + self.factorCT, + self.isCanRelive = ... -- buff期间的增伤系数 + self.cover = true --控制效果可被覆盖 + -- 刷新排序等级 + self.sort = 4 +end + +-- 伤害降低 +function NoDead:onPassiveDamaging(func, target, damage, skill) + if skill and skill.type == BattleSkillType.Special then + local dd = BattleUtil.CountValue(damage, self.damageFactor, self.factorCT) - damage + if func then func(-math.floor(BattleUtil.ErrorCorrection(dd))) end + end +end + +--初始化后调用一次 +function NoDead:OnStart() + -- + self.target.Event:AddEvent(BattleEventName.PassiveDamaging, self.onPassiveDamaging, self) + self.target:SetDeadFilter(false) + + self.target:SetReliveFilter(self.isCanRelive) +end + +--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd +function NoDead:OnTrigger() + return true +end + +--效果结束时调用一次 +function NoDead:OnEnd() + self.target.Event:AddEvent(BattleEventName.PassiveDamaging, self.onPassiveDamaging, self) + self.target:SetDeadFilter(true) +end + +--只有当cover字段为true时触发,返回true则被新效果覆盖 +function NoDead:OnCover(newBuff) + + return true +end + +-- 比较buff +function NoDead:OnCompare(buff) + return true +end + + +return NoDead diff --git a/luafight/Modules/Battle/Logic/Buff/Shield.lua b/luafight/Modules/Battle/Logic/Buff/Shield.lua index ad599bc20..c827c98d8 100644 --- a/luafight/Modules/Battle/Logic/Buff/Shield.lua +++ b/luafight/Modules/Battle/Logic/Buff/Shield.lua @@ -24,6 +24,10 @@ function Shield:OnStart() self.target.shield:Add(self) if self.shieldType == ShieldTypeName.AllReduce then self.target.buffFilter:Add(immune0) + -- 清除所有负面buff + BattleLogic.BuffMgr:ClearBuff(self.target, function (buff) + return buff.type == BuffName.Control or buff.type == BuffName.Dot + end) end end @@ -82,7 +86,7 @@ function Shield:OnEnd() if self.shieldType == ShieldTypeName.NormalReduce then for i = 1, self.target.shield.size do if self.target.shield.buffer[i] == self then - local arr = BattleLogic.Query(function (r) return r.camp ~= self.target.camp end) + local arr = RoleManager.Query(function (r) return r.camp ~= self.target.camp end) for j = 1, #arr do BattleUtil.ApplyDamage(nil, self.target, arr[j], math.floor(self.dmgReboundFactor * self.damageSum)) end diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 122d1be64..a181ac542 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -44,6 +44,10 @@ BattleEventName = { RoleRageChange = indexAdd(), -- 角色怒气变化 RoleControl = indexAdd(), -- 角色释放控制技能 RoleBeControl = indexAdd(), -- 角色被控制 + RoleRealDead = indexAdd(), -- 角色真死了 + RoleRelive = indexAdd(), -- 角色复活了 + FinalDamage = indexAdd(), + FinalBeDamage = indexAdd(), SkillCast = indexAdd(), -- 技能攻击前 SkillCastEnd = indexAdd(), -- 技能攻击结束 @@ -60,6 +64,22 @@ BattleEventName = { PassiveCriting = indexAdd(), PassiveTreatingFactor = indexAdd(), PassiveBeTreatedFactor = indexAdd(), + PassiveRandomControl = indexAdd(), + PassiveBeRandomControl = indexAdd(), + PassiveRandomDot = indexAdd(), + PassiveBeRandomDot = indexAdd(), + + PassiveRebackDamage = indexAdd(), + + PassiveSkillDamageHeal = indexAdd(), + PassiveBeSkillDamageHeal = indexAdd(), + + PassiveDamageShare = indexAdd(), + PassiveDamageBeShare = indexAdd(), + + PassiveShield = indexAdd(), + PassiveBeShield = indexAdd(), + AOE = indexAdd(), @@ -121,6 +141,7 @@ BuffName = { Brand = "Brand", Shield = "Shield", Immune = "Immune", + NoDead = "NoDead", } DotType = { @@ -130,6 +151,16 @@ DotType = { Blooding = 3, } +ControlType = { + Dizzy = 1, + Slient = 2, + LockTarget = 3, + NoHeal = 4, + Blind = 5, + + Palsy = 7, +} + BattleSkillType = { Monster = 0, Normal = 1, diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 3774bdd87..954586b7a 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -37,7 +37,7 @@ end function BattleUtil.ChooseFRow(arr) local tempArr = {} for _, r in ipairs(arr) do - if r.position <= 3 and not r.isDead then + if r.position <= 3 and not r:IsRealDead() then table.insert(tempArr, r) end end @@ -50,7 +50,7 @@ end function BattleUtil.ChooseBRow(arr) local tempArr = {} for _, r in ipairs(arr) do - if r.position > 3 and not r.isDead then + if r.position > 3 and not r:IsRealDead() then table.insert(tempArr, r) end end @@ -133,31 +133,31 @@ function BattleUtil.ChooseTarget(role, chooseId) local arr -- 选择类型 if chooseType == 1 then - arr = BattleLogic.Query(function (r) return r.camp == role.camp end) + arr = RoleManager.Query(function (r) return r.camp == role.camp end) elseif chooseType == 2 then - if role.lockTarget and not role.lockTarget.isDead and num == 1 then --嘲讽时对单个敌军生效 + if role.lockTarget and not role.lockTarget:IsRealDead() and num == 1 then --嘲讽时对单个敌军生效 return {role.lockTarget} end - arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end) + arr = RoleManager.Query(function (r) return r.camp ~= role.camp end) elseif chooseType == 3 then if role.ctrl_blind then --致盲时自身变随机友军 - arr = BattleLogic.Query(function (r) return r.camp == role.camp end) + arr = RoleManager.Query(function (r) return r.camp == role.camp end) BattleUtil.RandomList(arr) return {arr[1]} end return {role} elseif chooseType == 4 then - if role.lockTarget and not role.lockTarget.isDead then --嘲讽时对仇恨目标生效 + if role.lockTarget and not role.lockTarget:IsRealDead() then --嘲讽时对仇恨目标生效 return {role.lockTarget} end if role.ctrl_blind then --致盲时仇恨目标变随机 - arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end) + arr = RoleManager.Query(function (r) return r.camp ~= role.camp end) BattleUtil.RandomList(arr) return {arr[1]} end - return {BattleLogic.GetAggro(role)} + return {RoleManager.GetAggro(role)} else - arr = BattleLogic.Query() + arr = RoleManager.Query() end --选择范围 @@ -206,9 +206,9 @@ function BattleUtil.ChooseTarget(role, chooseId) elseif chooseWeight == 6 then -- 魔抗 BattleUtil.SortByProp(arr, RoleDataName.MagicDefence, sort) elseif chooseWeight == 7 then -- 对位及其相邻目标 - arr = BattleLogic.GetNeighbor(role, chooseType) + arr = RoleManager.GetNeighbor(role, chooseType) elseif chooseWeight == 8 then -- 对位 - arr = BattleLogic.GetArrAggroList(role, arr) + arr = RoleManager.GetArrAggroList(role, arr) -- elseif chooseWeight == 9 then -- 展位距离 -- BattleUtil.Sort(arr, function(a, b) -- local r1 = math.abs(role.position - a.position) * 10 + a.position @@ -283,9 +283,8 @@ function BattleUtil.Seckill(skill, atkRole, defRole) local damage = defRole:GetRoleData(RoleDataName.Hp) local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage) if finalDmg >= 0 then - if defRole:GetRoleData(RoleDataName.Hp) <= 0 then - defRole.isDead = true - BattleLogic.BuffMgr:ClearBuff(defRole) + if defRole:GetRoleData(RoleDataName.Hp) <= 0 and not defRole:IsDead() then + defRole:SetDead() defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole) atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole) @@ -298,14 +297,13 @@ function BattleUtil.Seckill(skill, atkRole, defRole) end -- 计算真实伤害 -function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, isDot) +function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) bCrit = bCrit or false damageType = damageType or 0 - isDot = isDot or false -- if atkRole.isTeam then -- --max(技能基础伤害*(1+已方异妖伤害加成-目标异妖伤害减免),30%×技能基础伤害) - -- local arr = BattleLogic.Query(function (r) return r.camp == atkRole.camp end) + -- local arr = RoleManager.Query(function (r) return r.camp == atkRole.camp end) -- local n = 0 -- for i=1, #arr do -- n = n + arr[i]:GetRoleData(RoleDataName.TeamDamageBocusFactor) @@ -314,33 +312,47 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy -- end --加入被动效果 - local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end - atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill) - defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill) + local damagingFunc = function(dmgDeduction) + damage = damage - dmgDeduction + end + atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill, dotType) + defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill, dotType) -- 计算护盾减伤 damage = BattleUtil.CalShield(atkRole, defRole, damage) + + -- 造成的最终伤害 + local damagingFunc = function(dmgDeduction) + damage = damage - dmgDeduction + 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) + + -- + return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) +end + +function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) if damage >= 0 then local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage) if finalDmg >= 0 then - if defRole:GetRoleData(RoleDataName.Hp) <= 0 then - defRole.isDead = true - BattleLogic.BuffMgr:ClearBuff(defRole) + if defRole:GetRoleData(RoleDataName.Hp) <= 0 and not defRole:IsDead() then + defRole:SetDead() defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole) atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole) end - atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType, isDot, skill) - defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType, isDot, skill) - BattleLogic.Event:DispatchEvent(BattleEventName.RoleDamage, atkRole, defRole, damage, bCrit, finalDmg, damageType, isDot, skill) - BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeDamaged, defRole, atkRole, damage, bCrit, finalDmg, damageType, isDot, skill) + 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 not isDot then + if not dotType then atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill) defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill) end @@ -352,9 +364,9 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy end --执行完整的命中,伤害,暴击计算,返回命中,暴击 ---skill造成伤害的技能 atkRole攻击者 defRole受击者 damageType伤害类型 baseFactor伤害系数 ignoreDef无视防御参数 isDot是否是dot -function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, ignoreDef, isDot) - if atkRole.isTeam and not defRole.isDead then --如果是队伍技能,计算真实伤害,则damageType为伤害值 +--skill造成伤害的技能 atkRole攻击者 defRole受击者 damageType伤害类型 baseFactor伤害系数 ignoreDef无视防御参数 dotType是持续伤害类型 +function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, ignoreDef, dotType) + if atkRole.isTeam and not defRole:IsDead() then --如果是队伍技能,计算真实伤害,则damageType为伤害值 return BattleUtil.ApplyDamage(skill, atkRole, defRole, damageType), false end @@ -443,14 +455,14 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedAfter, atkRole, damageFunc, baseDamage) local finalDmg = 0 --计算实际造成的扣血 - if not defRole.isDead then - finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, baseDamage, bCrit, damageType, isDot) + if not defRole:IsRealDead() then + finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, baseDamage, bCrit, damageType, dotType) end return finalDmg, bCrit end function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor) - if targetRole.ctrl_noheal or targetRole.isDead then --禁疗和死亡无法加血 + if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血 return end targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole) @@ -458,6 +470,9 @@ function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor) end function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) + if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血 + return + end baseFactor = baseFactor or 1 local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp) local hp = targetRole:GetRoleData(RoleDataName.Hp) @@ -474,9 +489,20 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) local baseTreat = floor(BattleUtil.FP_Mul(value, baseFactor, factor, factor2) + 0.5) --加入被动效果 - local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end + local cl = {} + local function treatingFunc(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + -- local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end castRole.Event:DispatchEvent(BattleEventName.PassiveTreating, treatingFunc, targetRole) targetRole.Event:DispatchEvent(BattleEventName.PassiveBeTreated, treatingFunc, castRole) + baseTreat = BattleUtil.CountChangeList(baseTreat, cl) + + + + local treat = min(baseTreat, maxHp - hp) if treat > 0 then targetRole.data:AddValue(RoleDataName.Hp, treat) @@ -485,12 +511,62 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat) end + + + function BattleUtil.RandomAction(rand, action) if Random.Range01() <= rand and action then action() + return true end + return false end +-- +function BattleUtil.RandomControl(rand, ctrl, caster, target, round) + + local cl = {} + local function _CallBack(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + caster.Event:DispatchEvent(BattleEventName.PassiveRandomControl, _CallBack, ctrl, target) + target.Event:DispatchEvent(BattleEventName.PassiveBeRandomControl, _CallBack, ctrl, target) + rand = BattleUtil.CountChangeList(rand, cl) + + return BattleUtil.RandomAction(rand, function() + local buff = Buff.Create(caster, BuffName.Control, round, ctrl) + target:AddBuff(buff) + end) +end + +-- +function BattleUtil.RandomDot(rand, dot, caster, target, round, interval, damage) + + local cl = {} + local dcl = {} + local function _CallBack(v, ct, dv, dct) + if v then + table.insert(cl, {v, ct}) + end + if dv then + table.insert(dcl, {dv, dct}) + end + end + caster.Event:DispatchEvent(BattleEventName.PassiveRandomDot, _CallBack, dot) + target.Event:DispatchEvent(BattleEventName.PassiveBeRandomDot, _CallBack, dot) + rand = BattleUtil.CountChangeList(rand, cl) + damage = BattleUtil.CountChangeList(damage, dcl) + + return BattleUtil.RandomAction(rand, function() + local buff = Buff.Create(caster, BuffName.DOT, round, interval, dot, damage) + buff.isRealDamage = true + target:AddBuff(buff) + end) +end + + function BattleUtil.RandomList(arr) if #arr <= 1 then return end local index @@ -553,4 +629,55 @@ function BattleUtil.CountValue(v1, v2, ct) -- 做一个正确性检测 -- v = BattleUtil.ErrorCorrection(v) return v -end \ No newline at end of file +end + +-- 计算数值改变 +function BattleUtil.CountChangeList(v, changeList) + local aplist = {} + local splist = {} + local fv = v + -- 先算绝对值 + for _, change in ipairs(changeList) do + local cv = change[1] + local ct = change[2] + if ct then + if ct == 1 or ct == 3 then + fv = BattleUtil.CountValue(fv, cv, ct) + elseif ct == 2 then + table.insert(aplist, change) + elseif ct == 4 then + table.insert(splist, change) + end + end + end + -- 加乘(对基数进行加乘) + for _, change in ipairs(aplist) do + local cv = change[1] + local ct = change[2] + fv = fv + (BattleUtil.CountValue(v, cv, ct) - v) + end + -- 减乘(对最终数值进行减乘算) + for _, change in ipairs(splist) do + local cv = change[1] + local ct = change[2] + fv = BattleUtil.CountValue(fv, cv, ct) + end + + return fv +end + +-- 检测技能伤害治疗加乘 +function BattleUtil.CheckSkillDamageHeal(f, caster, target) + + local cl = {} + local function _CallBack(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + caster.Event:DispatchEvent(BattleEventName.PassiveSkillDamageHeal, _CallBack) + target.Event:DispatchEvent(BattleEventName.PassiveBeSkillDamageHeal, _CallBack) + f = BattleUtil.CountChangeList(f, cl) + + return f +end diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index b1c9428bd..cfccbd94f 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -1,6 +1,4 @@ -require("Modules.Battle.Logic.SkillManager") - RoleLogic = {} RoleLogic.__index = RoleLogic --local RoleLogic = RoleLogic @@ -33,6 +31,7 @@ function RoleLogic:Init(uid, data, position) self.data:Init(self, data.property) self.isDead = self:GetRoleData(RoleDataName.Hp) <= 0 + self.isRealDead = self.isDead self.camp = data.camp --阵营 0:我方 1:敌方 self.name = data.name @@ -53,6 +52,13 @@ function RoleLogic:Init(uid, data, position) local time = self:GetRoleData(RoleDataName.Speed)/(20*(self:GetRoleData(RoleDataName.Level)+10)) self.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate) + + -- 初始化怒气值(默认2) + self.Rage = 2 + self:GetRoleData(RoleDataName.InitRage)-- 当前怒气值 + self.RageGrow = 2 -- 普通技能怒气成长 + self.SuperSkillRage = 4 -- 技能需要释放的怒气值,默认为4 + self.NoRageRate = 0 -- 不消耗怒气值的概率 + -- self.passiveList = {} if data.passivity and #data.passivity > 0 then @@ -68,18 +74,11 @@ function RoleLogic:Init(uid, data, position) -- 加入被动列表 table.insert(self.passiveList, {id, args}) else - print("被动技能"..id.."不存在") + --print("被动技能"..id.."不存在") end end end - -- 初始化怒气值(默认2) - self.Rage = 2 + self:GetRoleData(RoleDataName.InitRage)-- 当前怒气值 - self.RageGrow = 2 -- 普通技能怒气成长 - self.SuperSkillRage = 4 -- 技能需要释放的怒气值 - self.NoRageRate = 0 -- 不消耗怒气值的概率 - - self.aiOrder = data.ai self.aiIndex = 1 self.aiTempCount = 0 @@ -92,6 +91,11 @@ function RoleLogic:Init(uid, data, position) self.ctrl_palsy = false --麻痹 只能2技能 self.ctrl_noheal = false --禁疗 self.ctrl_blind = false --致盲 + + self.deadFilter = true -- 控制死亡,置为false则角色暂时无法死亡 + + self.reliveFilter = true -- 控制复活的标志位,置为false角色将不再享受复活效果 + self.reliveHPF = 1 end -- 添加一个被动技能 @@ -112,7 +116,7 @@ function RoleLogic:AddPassive(id, args, isRepeat) end -- function RoleLogic:CanCastSkill() - return self.sp >= self.spPass and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp) + return self.sp >= self.spPass and not self.IsDebug end -- 废弃的方法 @@ -213,7 +217,7 @@ end function RoleLogic:AddBuff(buff) - if self.isDead then + if self:IsRealDead() then BattleLogic.BuffMgr:PutBuff(buff) return end @@ -234,7 +238,7 @@ end -- 判断角色是否可以释放技能 function RoleLogic:IsAvailable() -- 眩晕 -- 死亡 - if self.ctrl_dizzy or self.isDead then + if self.ctrl_dizzy or self:IsRealDead() then return false end -- 沉默麻痹同时存在 @@ -327,15 +331,14 @@ end -- isAdd 是否是追加技能 -- isRage 是否正常操作怒气值 function RoleLogic:AddSkill(type, isRage, isAdd, targets) - if not self.SkillNum then - self.SkillNum = 0 - end - self.SkillNum = self.SkillNum + 1 - local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill SkillManager.AddSkill(self, effectData, type, targets, isAdd, isRage) end - +-- 插入一个技能 +function RoleLogic:InsertSkill(type, isRage, isAdd, targets) + local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill + SkillManager.InsertSkill(self, effectData, type, targets, isAdd, isRage) +end -- 正常触发技能 @@ -381,21 +384,89 @@ function RoleLogic:ForceCastSkill(type, targets, func) end --- 设置我被杀死时的信息 -function RoleLogic:SetkillMeInfo(caster, skill) - self.killCaster = caster - self.killSkill = skill +-- 判断是否可以去死了 +function RoleLogic:IsCanDead() + -- 暂时不能死 + if not self.deadFilter then + return false + end + -- 还有我的技能没有释放,不能死啊 + if SkillManager.HaveMySkill(self) then + return false + end + return true end +-- 真的去死 +function RoleLogic:GoDead() + if self:IsCanDead() then + self.isRealDead = true + self.Event:DispatchEvent(BattleEventName.RoleRealDead, self) + BattleLogic.Event:DispatchEvent(BattleEventName.RoleRealDead, self) + return true + end + return false +end + +-- 设置是否可以死亡 +function RoleLogic:SetDeadFilter(filter) + self.deadFilter = filter +end +-- 要死了 +function RoleLogic:SetDead() + self.isDead = true + BattleLogic.BuffMgr:ClearBuff(self) + RoleManager.AddDeadRole(self) +end +-- 判断是否死亡 +function RoleLogic:IsDead() + return self.isDead +end +function RoleLogic:IsRealDead() + return self.isRealDead +end + + +-- 是否可以复活 +function RoleLogic:IsCanRelive() + if not self.reliveFilter then + return false + end + if not self.isRealDead then + return false + end + return true +end +-- 复活吧, 真的去世后才能复活 +function RoleLogic:Relive() + if self:IsCanRelive() then + -- 没有指定血量则满血 + self.isDead = false + self.isRealDead = false + local maxHp = self.data:GetData(RoleDataName.MaxHp) + self.data:SetValue(RoleDataName.Hp, floor(self.reliveHPF * maxHp)) + -- 发送复活事件 + self.Event:DispatchEvent(BattleEventName.RoleRelive, self) + BattleLogic.Event:DispatchEvent(BattleEventName.RoleRelive, self) + return true + end + return false +end +-- 设置是否可以死亡 +function RoleLogic:SetReliveFilter(filter) + self.reliveFilter = filter +end +--,hpf 复活时拥有的血量的百分比 +function RoleLogic:SetRelive(hpf) + -- 判断是否可以复活 + if self:IsCanRelive() then + self.reliveHPF = hpf or 1 + RoleManager.AddReliveRole(self) + end + return false +end + + function RoleLogic:Update() - - if self:GetRoleData(RoleDataName.Hp) <= 0 then - self.isDead = true - BattleLogic.BuffMgr:ClearBuff(self) - self.Event:DispatchEvent(BattleEventName.RoleDead, self.killCaster) - self.killCaster.Event:DispatchEvent(BattleEventName.RoleKill, self) - BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, self, self.killCaster) - end - end diff --git a/luafight/Modules/Battle/Logic/RoleManager.lua b/luafight/Modules/Battle/Logic/RoleManager.lua new file mode 100644 index 000000000..e3f2cf977 --- /dev/null +++ b/luafight/Modules/Battle/Logic/RoleManager.lua @@ -0,0 +1,279 @@ +RoleManager = {} +local this = RoleManager + +-- 将死之人 +local _DeadRoleList = {} +-- 重生之人 +local _ReliveRoleList = {} +-- 所有角色 +local PosList = {} +-- 删除节点 +local removeObjList = BattleList.New() +-- 角色对象池 +local rolePool = BattleObjectPool.New(function () + return RoleLogic.New() +end) + + +local bMyAllDead +local bEnemyAllDead + +-- 初始化 +function this.Init() + + bMyAllDead = false + bEnemyAllDead = false + + this.Clear() +end + + +-- 角色数据添加 +local curUid +function this.AddRole(roleData, position) + if not curUid then + curUid = 0 + end + curUid = curUid + 1 + local role = rolePool:Get() + role:Init(curUid, roleData, position) + -- objList:Add(curUid, role) + if roleData.camp == 0 then + PosList[position] = role -- 1-6 我方英雄 + else + PosList[position + 6] = role-- 7-12 敌方英雄 + end + if not role:IsRealDead() then + BattleLogic.Event:DispatchEvent(BattleEventName.AddRole, role) + end +end + + +-- +function this.Update() + + bMyAllDead = true + bEnemyAllDead = true + for _, v in pairs(PosList) do + if not v:IsRealDead() then + v:Update() + if v.camp == 0 then + bMyAllDead = false + else + bEnemyAllDead = false + end + end + end + if bEnemyAllDead then + BattleLogic.Event:DispatchEvent(BattleEventName.BattleOrderEnd, BattleLogic.CurOrder) + end +end + +-- 获取结果 +function this.GetResult() + if bMyAllDead then + return 0 + end + if bEnemyAllDead then + return 1 + end +end + +-- 加入将死的人 +function this.AddDeadRole(role) + _DeadRoleList[role.position + role.camp * 6] = role +end +-- 检测是有人将死 +function this.CheckDead() + local isDeadFrame = false + local removePos = {} + for pos, role in pairs(_DeadRoleList) do + if role:GoDead() then + isDeadFrame = true + table.insert(removePos, pos) + end + end + for _, pos in ipairs(removePos) do + _DeadRoleList[pos] = nil + end + return isDeadFrame +end + +-- 加入复活之人 +function this.AddReliveRole(role) + _ReliveRoleList[role.position + role.camp * 6] = role +end +-- 检测是否有人复活 +function this.CheckRelive() + local isReliveFrame = false + local removePos = {} + for pos, role in pairs(_ReliveRoleList) do + if role:Relive() then + isReliveFrame = true + table.insert(removePos, pos) + end + end + for _, pos in ipairs(removePos) do + _ReliveRoleList[pos] = nil + end + return isReliveFrame +end + + + + + +-- 获取角色数据 +function this.GetRole(camp, pos) + return PosList[pos + camp*6] +end + +-- 获取某阵营所有角色 +function this.GetRoleByCamp(camp) + local list = {} + for i = 1, 6 do + list[i] = PosList[i + camp * 6] + end + return list +end + +-- 查找角色 +function RoleManager.Query(func, inCludeDeadRole) + local list = {} + local index = 1 + if func then + for pos, v in pairs(PosList) do + if func(v) and (inCludeDeadRole or not v:IsRealDead()) then + list[index] = v + index = index + 1 + end + end + end + return list +end + + +--对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的 +function this.GetAggro(role) + -- 计算开始位置 + local startPos = role.position + startPos = startPos > 3 and startPos - 3 or startPos + local target + local enemyCamp = role.camp == 0 and 1 or 0 + + -- c=0 前排 c=1 后排 + for c = 0, 1 do + startPos = startPos + c*3 + -- 向左 + for i = startPos, c*3+1, -1 do + local pos = i + enemyCamp * 6 + if PosList[pos] and not PosList[pos]:IsRealDead() then + target = PosList[pos] + break + end + end + if target then return target end + -- 向右 + for i = startPos + 1, c*3+3 do + local pos = i + enemyCamp * 6 + if PosList[pos] and not PosList[pos]:IsRealDead() then + target = PosList[pos] + break + end + end + if target then return target end + end +end +--对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的 +function this.GetArrAggroList(role, arr) + -- 重构数据 + local plist = {} + for _, role in ipairs(arr) do + plist[role.position] = role + end + -- 计算开始位置 + local startPos = role.position + startPos = startPos > 3 and startPos - 3 or startPos + local targetList = {} + -- c=0 前排 c=1 后排 + for c = 0, 1 do + startPos = startPos + c*3 + -- 向左 + for i = startPos, c*3+1, -1 do + local pos = i + if plist[pos] and not plist[pos]:IsRealDead() then + table.insert(targetList, plist[pos]) + end + end + -- 向右 + for i = startPos + 1, c*3+3 do + local pos = i + if plist[pos] and not plist[pos]:IsRealDead() then + table.insert(targetList, plist[pos]) + end + end + end + return targetList +end +--获取对位相邻站位的人 chooseType 1 我方 2 敌方(对位的敌人受到嘲讽的影响,若对位的敌人死亡,则选取相邻最近的作为目标) +function this.GetNeighbor(role, chooseType) + local posList = {} + local target + if chooseType == 1 then + target = role + else + if role.lockTarget and not role.lockTarget:IsRealDead() then + target = role.lockTarget + else + target = this.GetAggro(role) + end + end + if target then + local list = this.Query(function (r) return r.camp == target.camp end) + for i=1, #list do + if not list[i]:IsRealDead() then + if list[i].position == target.position + 3 -- 后排的人 + or list[i].position == target.position - 3 -- 前排的人 + or (math.abs(target.position - list[i].position) <= 1 and floor((target.position-1)/3) == floor((list[i].position-1)/3)) then -- 旁边的人和自己 + table.insert(posList, list[i]) + end + end + end + end + return posList +end + + +function this.Clear() + + for _, obj in pairs(PosList) do + obj:Dispose() + removeObjList:Add(obj) + end + PosList = {} + + while removeObjList.size > 0 do + rolePool:Put(removeObjList.buffer[removeObjList.size]) + removeObjList:Remove(removeObjList.size) + end + + _DeadRoleList = {} + _ReliveRoleList = {} +end + +-- 多波 +function this.ClearEnemy() + local removePos = {} + for pos, obj in pairs(PosList) do + if obj.camp == 1 then + removePos[pos] = 1 + BattleLogic.Event:DispatchEvent(BattleEventName.RemoveRole, obj) + obj:Dispose() + removeObjList:Add(obj) + end + end + for pos, _ in pairs(removePos) do + PosList[pos] = nil + end +end +return this \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/SkillManager.lua b/luafight/Modules/Battle/Logic/SkillManager.lua index 69ac996fd..df2764a65 100644 --- a/luafight/Modules/Battle/Logic/SkillManager.lua +++ b/luafight/Modules/Battle/Logic/SkillManager.lua @@ -24,10 +24,18 @@ end function this.InsertSkill(caster, effectData, type, targets, isAdd, isRage) local skill = skillPool:Get() skill:Init(caster, effectData, type, targets, isAdd, isRage) - table.insert(this.SkillList, skill, 1) + table.insert(this.SkillList, 1, skill) return skill end - +-- 获取是否拥有我的技能未释放 +function this.HaveMySkill(role) + for _, skill in ipairs(this.SkillList) do + if skill.owner == role then + return true + end + end + return false +end -- 设置用于轮转的方法 @@ -43,7 +51,7 @@ function this.CheckTurnRound() end -- 没有技能释放的时候才轮转 if this.TurnRoundFunc then - BattleLogic.WaitForTrigger(1, function() + BattleLogic.WaitForTrigger(0.3, function() this.TurnRoundFunc() this.TurnRoundFunc = nil end) From 824c8239c5686e41749b4f661f7dfcb2656af61c Mon Sep 17 00:00:00 2001 From: lvxinran Date: Wed, 6 May 2020 19:51:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=88=98=E6=96=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/BattleMain.lua | 5 +- luafight/BattleMain.lua | 5 +- luafight/Modules/Battle/Logic/Base/Effect.lua | 3 + .../Modules/Battle/Logic/Base/Passivity.lua | 122 +++++++++++++++++- .../Battle/Logic/Misc/BattleDefine.lua | 6 + .../Modules/Battle/Logic/Misc/BattleUtil.lua | 43 +++++- 6 files changed, 173 insertions(+), 11 deletions(-) diff --git a/conf/BattleMain.lua b/conf/BattleMain.lua index ef25971c5..4bd546033 100644 --- a/conf/BattleMain.lua +++ b/conf/BattleMain.lua @@ -200,7 +200,6 @@ local function AddRecord(fightData) end end function BattleMain.Execute(args, fightData, optionData) - print("trfghjdfgucvhbjnfdcgvj") _seed = args.seed _type = args.type _fightData = fightData @@ -234,7 +233,7 @@ function BattleMain.Execute(args, fightData, optionData) resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp) end elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量 - local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true) + local arr = RoleManager.Query(function (r) return r.camp == 1 end, true) for i=1, #arr do resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp) end @@ -250,7 +249,7 @@ function BattleMain.Execute(args, fightData, optionData) -- print("hp:"..resultList[i]) --end --print("最终运行帧数:"..BattleLogic.CurFrame()) - local curRound, maxRound = BattleLogic.GetCurRound() + local curRound, maxRound = BattleLogic.GetCurRound() if curRound > maxRound and _type == 9 then local playerDamage=0 local enemyDamage=0 diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index ef25971c5..4bd546033 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -200,7 +200,6 @@ local function AddRecord(fightData) end end function BattleMain.Execute(args, fightData, optionData) - print("trfghjdfgucvhbjnfdcgvj") _seed = args.seed _type = args.type _fightData = fightData @@ -234,7 +233,7 @@ function BattleMain.Execute(args, fightData, optionData) resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp) end elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量 - local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true) + local arr = RoleManager.Query(function (r) return r.camp == 1 end, true) for i=1, #arr do resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp) end @@ -250,7 +249,7 @@ function BattleMain.Execute(args, fightData, optionData) -- print("hp:"..resultList[i]) --end --print("最终运行帧数:"..BattleLogic.CurFrame()) - local curRound, maxRound = BattleLogic.GetCurRound() + local curRound, maxRound = BattleLogic.GetCurRound() if curRound > maxRound and _type == 9 then local playerDamage=0 local enemyDamage=0 diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 4578faa63..7fb0b3660 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -2068,6 +2068,9 @@ local effectList = { local OnBeHit = function() if not target:IsDead() and BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + -- 检测被动技能对秒杀参数得影响 + f2, f3 = BattleUtil.CheckSeckill(f2, f3, caster, target) + -- local ft = target:GetRoleData(RoleDataName.Hp)/target:GetRoleData(RoleDataName.MaxHp) if ft < f2 then BattleUtil.RandomAction(f3, function() diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index 77bfd8f02..002634f48 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -2807,9 +2807,12 @@ local passivityList = { local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) if skill and skill.type == BattleSkillType.Normal then if BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + -- 检测被动技能对秒杀参数得影响 + local bf, kf = BattleUtil.CheckSeckill(f1, f2, caster, target) + -- local ft = defRole:GetRoleData(RoleDataName.Hp)/defRole:GetRoleData(RoleDataName.MaxHp) - if ft < f1 then - BattleUtil.RandomAction(f2, function() + if ft < bf then + BattleUtil.RandomAction(kf, function() -- 秒杀 BattleUtil.Seckill(skill, role, defRole) end) @@ -2981,8 +2984,39 @@ local passivityList = { role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd) end, + -- 攻击目标时目标身上每有1种异常状态(包括麻痹、眩晕、沉默、灼烧、中毒)都会使对其造成的直接伤害提高,异常状态数量乘以[a]%。 + -- a[float] + [161] = function(role, args) + local f1 = args[1] + local function onPassiveDamaging(damagingFunc, target, damage) + local list = BattleLogic.BuffMgr:QueryBuff(target, function(buff) + return buff.type == BuffName.DOT or buff.type == BuffName.Control + end) + if list and damagingFunc then + local num = #list + local dd = BattleUtil.CountValue(damage, f1 * num, CountTypeName.AddPencent) - damage + damagingFunc(-floor(BattleUtil.ErrorCorrection(dd))) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + end, + -- 爆伤减免增加[a]%,[b]改变 + -- a[float]b[改变类型] + [164] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local function onPassiveBeDamaging(damagingFunc, target, damage, skill, dotType, bCrit) + if bCrit then + local dd = damage - BattleUtil.CountValue(damage, f1, CountTypeName.SubPencent) + damagingFunc(floor(BattleUtil.ErrorCorrection(dd))) + end + end + role.Event:AddEvent(BattleEventName.PassiveBeDamaging, onPassiveBeDamaging) + end, + -- 战斗中生命每减少[a]%,自身伤害就[b]改变[c]%,减少为[d]改变 -- a[float]b[改变类型]c[float]d[改变类型] [165] = function(role, args) @@ -3634,6 +3668,90 @@ local passivityList = { end, + --每回合最多受到自身生命上限[a]%的伤害(该伤害为来自武将的直接伤害) + --a[float] + [199] = function(role, args) + local f1 = args[1] + + local curDamage = 0 + local function onBattleRoundChange() + curDamage = 0 + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onBattleRoundChange) + + + local function onFinalBeDamage(damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType) + local maxDamage = role:GetRoleData(RoleDataName.MaxHp) * f1 + curDamage = curDamage + damage + if curDamage < maxDamage then + if damagingFunc then damagingFunc(damage) end + else + -- 计算免除的伤害值 + local md = curDamage - maxDamage + if md > damage then + md = damage + end + if damagingFunc then damagingFunc(md) end + end + + end + role.Event:AddEvent(BattleEventName.FinalBeDamage, onFinalBeDamage) + end, + + + -- 初始怒气增加[a]点并且目标血量低于[b]%时即有概率秒杀(对应秒杀技能) + -- a[int]b[float] + [200] = function(role, args) + local i1 = args[1] + local f1 = args[2] + role.data:CountValue(RoleDataName.InitRage, i1, CountTypeName.Add) + + local function onPassiveSeckill(func) + if func then func(f1, CountTypeName.Cover) end + end + role.Event:AddEvent(BattleEventName.PassiveSeckill, onPassiveSeckill) + end, + + -- 秒杀概率增加[a]%直接伤害击杀的[b]目标有[c]%概率无法复活触发秒杀的目标[d]%无法复活,秒杀概率[e]改变 + -- a[float]b[持续伤害状态]c[float]d[float]e[改变类型] + [201] = function(role, args) + local f1 = args[1] + local dot = args[2] + local f2 = args[3] + local f3 = args[4] + local ct = args[5] + + -- 秒杀概率增加 + local function onPassiveSeckill(func) + if func then func(nil, nil, f1, ct) end + end + role.Event:AddEvent(BattleEventName.PassiveSeckill, onPassiveSeckill) + + -- 直接伤害概率无法复活 + local function onRoleHit(target) + if target:IsDead() then + if not BattleLogic.BuffMgr:HasBuff(role, BuffName.DOT, function (buff) return buff.dotType == dot or dot == 0 end) then + BattleUtil.RandomAction(f2, function() + target:SetReliveFilter(false) + end) + end + end + end + role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) + + + + -- 秒杀概率无法复活 + local function onSecKill(target) + BattleUtil.RandomAction(f3, function() + target:SetReliveFilter(false) + end) + end + role.Event:AddEvent(BattleEventName.Seckill, onSecKill) + + end, + + -- 伤害增加[a]%,[b]改变 diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index a181ac542..eeffe57ce 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -74,6 +74,11 @@ BattleEventName = { PassiveSkillDamageHeal = indexAdd(), PassiveBeSkillDamageHeal = indexAdd(), + PassiveSeckill = indexAdd(), + PassiveBeSeckill = indexAdd(), + Seckill = indexAdd(), + BeSeckill = indexAdd(), + PassiveDamageShare = indexAdd(), PassiveDamageBeShare = indexAdd(), @@ -172,6 +177,7 @@ CountTypeName = { AddPencent = 2, Sub = 3, SubPencent = 4, + Cover = 5, } ShieldTypeName = { diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 954586b7a..0e5630fd5 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -288,6 +288,10 @@ function BattleUtil.Seckill(skill, atkRole, defRole) defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole) atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole) + + atkRole.Event:DispatchEvent(BattleEventName.SecKill, defRole) + defRole.Event:DispatchEvent(BattleEventName.BeSecKill, atkRole) + BattleLogic.Event:DispatchEvent(BattleEventName.SecKill, atkRole, defRole) end atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, false, finalDmg, 0, false, skill) defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, false, finalDmg, 0, false, skill) @@ -315,8 +319,8 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end - atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill, dotType) - defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill, dotType) + atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill, dotType, bCrit) + defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill, dotType, bCrit) -- 计算护盾减伤 damage = BattleUtil.CalShield(atkRole, defRole, damage) @@ -625,6 +629,8 @@ function BattleUtil.CountValue(v1, v2, ct) v = v - v2 elseif ct == 4 then --乘减算(百分比属性减算) v = v * (1 - v2) + elseif ct == 5 then -- 覆盖 + v = v2 end -- 做一个正确性检测 -- v = BattleUtil.ErrorCorrection(v) @@ -635,6 +641,7 @@ end function BattleUtil.CountChangeList(v, changeList) local aplist = {} local splist = {} + local cplist = {} local fv = v -- 先算绝对值 for _, change in ipairs(changeList) do @@ -647,6 +654,8 @@ function BattleUtil.CountChangeList(v, changeList) table.insert(aplist, change) elseif ct == 4 then table.insert(splist, change) + elseif ct == 5 then + table.insert(cplist, change) end end end @@ -662,7 +671,12 @@ function BattleUtil.CountChangeList(v, changeList) local ct = change[2] fv = BattleUtil.CountValue(fv, cv, ct) end - + -- 覆盖 + for _, change in ipairs(cplist) do + local cv = change[1] + local ct = change[2] + fv = BattleUtil.CountValue(fv, cv, ct) + end return fv end @@ -681,3 +695,26 @@ function BattleUtil.CheckSkillDamageHeal(f, caster, target) return f end + +-- 检测技能伤害治疗加乘 +function BattleUtil.CheckSeckill(bf, kf, caster, target) + + local bcl = {} + local kcl = {} + local function _CallBack(bv, bct, kv, kct) + if v then + if bv and bct then + table.insert(bcl, {bv, bct}) + end + if kv and kct then + table.insert(kcl, {kv, kct}) + end + end + end + caster.Event:DispatchEvent(BattleEventName.PassiveSeckill, _CallBack) + target.Event:DispatchEvent(BattleEventName.PassiveBeSeckill, _CallBack) + bf = BattleUtil.CountChangeList(bf, bcl) + kf = BattleUtil.CountChangeList(kf, kcl) + + return bf, kf +end From 8abd2af09c1c470dab3b346209e2f502b04fe5c2 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Thu, 7 May 2020 15:53:26 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=88=98=E6=96=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luafight/Modules/Battle/Logic/Base/Effect.lua | 23 +++++++ luafight/Modules/Battle/Logic/BattleLogic.lua | 5 +- luafight/Modules/Battle/Logic/Buff/Curse.lua | 62 +++++++++++++++++++ .../Battle/Logic/Misc/BattleDefine.lua | 5 ++ .../Modules/Battle/Logic/Misc/BattleUtil.lua | 1 + luafight/Modules/Battle/Logic/RoleManager.lua | 2 +- 6 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 luafight/Modules/Battle/Logic/Buff/Curse.lua diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 7fb0b3660..4ab7f8b07 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -2110,6 +2110,19 @@ local effectList = { end) end, + + -- 给目标附加一个印记,印记效果是己方武将直接攻击敌方非该印记状态的目标时所造成的伤害的[a]会额外再平分给敌方所有处于该印记状态的目标,持续[b]回合 + -- a[float]b[int] + [110] = function(caster, target, args, interval, skill) + local f1 = args[1] + local i1 = args[2] + BattleLogic.WaitForTrigger(interval, function () + local buff = Buff.Create(caster, BuffName.Curse, i1, CurseTypeName.ShareDamage, f1) + target:AddBuff(buff) + end) + end, + + -- [a]%概率造成[b],每回合造成[c]%自身[d]的伤害,持续[e]回合 -- a[float]b[持续伤害状态].c[float],d[属性]e[int] @@ -2178,6 +2191,16 @@ local effectList = { end end) end, + + -- 回复自身最大生命值的[a]% + -- a[float] + [115] = function(caster, target, args, interval, skill) + local f1 = args[1] + BattleLogic.WaitForTrigger(interval, function () + local v = floor(BattleUtil.ErrorCorrection(target:GetRoleData(RoleDataName.MaxHp)*f1)) + BattleUtil.ApplyTreat(caster, target, v) + end) + end, } return effectList \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index e48684962..b4a6a1b74 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -54,7 +54,7 @@ local rolePool = BattleObjectPool.New(function () return RoleLogic.New() end) -function BattleLogic.Init(data, optionData) +function BattleLogic.Init(data, optionData, maxRound) if BattleLogic.IsOpenBattleRecord then record = {} end @@ -74,6 +74,7 @@ function BattleLogic.Init(data, optionData) curFrame = 0 CurRound = 0 + MaxRound = maxRound or 20 _IsDebug = false @@ -250,7 +251,7 @@ function BattleLogic.Update() BattleLogic.BattleEnd(0) return end - if CurRound > 20 then + if CurRound > MaxRound then BattleLogic.BattleEnd(0) return end diff --git a/luafight/Modules/Battle/Logic/Buff/Curse.lua b/luafight/Modules/Battle/Logic/Buff/Curse.lua new file mode 100644 index 000000000..c9ee203e0 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Buff/Curse.lua @@ -0,0 +1,62 @@ +Curse = Buff:New() + + +--初始化Buff,通过传入一些自定义参数控制成长相关的数值 +function Curse:SetData(curseType, ...) + self.curseType = curseType + self.args = {...} --标记,结束回调 + self.cover = true + + -- 刷新排序等级 + self.sort = 4 +end +-- +function Curse:ShareDamageTrigger(atkRole, defRole, damage, skill, dotType, bCrit, damageType) + if skill and defRole.camp == self.target.camp then + -- 没有此印记的队友收到伤害 + if not BattleLogic.BuffMgr:HasBuff(defRole, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end) then + -- 计算拥有此印记人的数量 + local sdList = RoleManager.Query(function(role) + return role.camp == self.target.camp and BattleLogic.BuffMgr:HasBuff(role, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end) + end) + if sdList and #sdList ~= 0 then + -- 计算收到的伤害 + local f1 = self.args[1] --平分伤害的百分比 + local sd = math.floor(BattleUtil.ErrorCorrection(damage * f1 / #sdList)) + BattleUtil.ApplyDamage(nil, atkRole, self.target, sd) + end + end + end +end + + +--初始化后调用一次 +function Curse:OnStart() + if self.curseType == CurseTypeName.ShareDamage then + BattleLogic.Event:AddEvent(BattleEventName.FinalDamage, self.ShareDamageTrigger, self) + end +end + + +--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd +function Curse:OnTrigger() + return true +end + +--效果结束时调用一次 +function Curse:OnEnd() + if self.curseType == CurseTypeName.ShareDamage then + BattleLogic.Event:RemoveEvent(BattleEventName.FinalDamage, self.ShareDamageTrigger, self) + end +end + +--只有当cover字段为true时触发,返回true则被新效果覆盖 +function Curse:OnCover(newBuff) + return self.curseType == newBuff.curseType +end + +-- 比较buff +function Curse:OnCompare(buff) + return self.curseType == newBuff.curseType +end +return Curse diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index eeffe57ce..bb4b011d0 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -147,6 +147,7 @@ BuffName = { Shield = "Shield", Immune = "Immune", NoDead = "NoDead", + Curse = "Curse", } DotType = { @@ -205,4 +206,8 @@ BattlePropList = { RoleDataName.CureFacter, RoleDataName.Tenacity, RoleDataName.InitRage, +} + +CurseTypeName = { + ShareDamage = 1, } \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 0e5630fd5..4bc053dc3 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -332,6 +332,7 @@ 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) + BattleLogic.Event:DispatchEvent(BattleEventName.FinalDamage, atkRole, defRole, damage, skill, dotType, bCrit, damageType) -- return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) diff --git a/luafight/Modules/Battle/Logic/RoleManager.lua b/luafight/Modules/Battle/Logic/RoleManager.lua index e3f2cf977..48a3064ee 100644 --- a/luafight/Modules/Battle/Logic/RoleManager.lua +++ b/luafight/Modules/Battle/Logic/RoleManager.lua @@ -234,7 +234,7 @@ function this.GetNeighbor(role, chooseType) if not list[i]:IsRealDead() then if list[i].position == target.position + 3 -- 后排的人 or list[i].position == target.position - 3 -- 前排的人 - or (math.abs(target.position - list[i].position) <= 1 and floor((target.position-1)/3) == floor((list[i].position-1)/3)) then -- 旁边的人和自己 + or (math.abs(target.position - list[i].position) <= 1 and math.floor((target.position-1)/3) == math.floor((list[i].position-1)/3)) then -- 旁边的人和自己 table.insert(posList, list[i]) end end