diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 66786574f..16643b06e 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -84,7 +84,11 @@ local effectList = { local f2 = args[3] local ct = args[4] BattleLogic.WaitForTrigger(interval, function () - target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct)) + local buff = Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct) + if f2 == 0 then + buff.cover = true + end + target:AddBuff(buff) end) end, --持续恢复[a]*[b]%生命,持续[c]秒 @@ -181,7 +185,7 @@ local effectList = { local f2 = args[4] casterBulletEffect(caster, target, interval) BattleLogic.WaitForTrigger(interval, function () - if target.professionId == i1 then + if target.roleData.professionId == i1 then f1 = f1 + f2 end BattleUtil.CalDamage(caster, target, dt, f1) @@ -282,7 +286,7 @@ local effectList = { casterBulletEffect(caster, target, interval) BattleLogic.WaitForTrigger(interval, function () local dmg = floor(caster:GetRoleData(propertyList[dt]) * f1) - if target.professionId == i1 then + if target.roleData.professionId == i1 then BattleUtil.RandomAction(f2, function () target.isFlagCrit = true BattleUtil.CalDamage(caster, target, dmg) @@ -485,7 +489,7 @@ local effectList = { BattleLogic.WaitForTrigger(d * (i-1), function () caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, d, target) BattleLogic.WaitForTrigger(d, function () - if target.professionId == pt then + if target.roleData.professionId == pt then f1 = f1 + f2 end BattleUtil.CalDamage(caster, target, dt, f1) @@ -579,7 +583,7 @@ local effectList = { local f2 = args[4] local ct = args[5] BattleLogic.WaitForTrigger(interval, function () - if target.professionId == pt then + if target.roleData.professionId == pt then target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct)) end end) @@ -695,15 +699,22 @@ local effectList = { local f2 = args[2] local f3 = args[3] BattleLogic.WaitForTrigger(interval, function () + local brand = Buff.Create(caster, BuffName.Brand, f3, "weak") + brand.exDmg = f2 + brand.coverFunc = function (oldBuff) + brand.exDmg = brand.exDmg + oldBuff.exDmg + end local trigger = function(atkRole, damagingFunc, damageType) BattleUtil.RandomAction(f1, function () - damagingFunc(f2) + damagingFunc(brand.exDmg) end) end target.Event:AddEvent(BattleEventName.RoleBeDamagedBefore, trigger) - target:AddBuff(Buff.Create(caster, BuffName.Brand, f3, "weak", function () + brand.endFunc = function () + brand.exDmg = nil target.Event:RemoveEvent(BattleEventName.RoleBeDamagedBefore, trigger) - end)) + end + target:AddBuff(brand) end) end, --瞬间恢复[a]的生命 @@ -714,20 +725,22 @@ local effectList = { BattleUtil.CalTreat(caster, target, i1) end) end, - --造成[a]%的[b]伤害,计算伤害时,额外计算[c]%的[d]和[e]%的[f] - --a[float],b[伤害类型],c[float],d[属性],e[float],f[属性] + --造成[a]%的[b]伤害,计算伤害时额外计算[c]%的[d][e]和[f]%的[g][h] + --a[float],b[伤害类型],c[float],d[属性],e[改变类型],f[float],g[属性],h[改变类型] [44] = function(caster, target, args, interval) local f1 = args[1] local dt = args[2] local f2 = args[3] local pro1 = args[4] - local f3 = args[5] - local pro2 = args[6] + local ct1 = args[5] + local f3 = args[6] + local pro2 = args[7] + local ct2 = args[8] casterBulletEffect(caster, target, interval) BattleLogic.WaitForTrigger(interval, function () - local proTran1 = {proName = propertyList[pro1], tranProName = propertyList[pro1], tranFactor = f2} - local proTran2 = {proName = propertyList[pro2], tranProName = propertyList[pro2], tranFactor = f3} + local proTran1 = {proName = propertyList[pro1], tranProName = propertyList[pro1], tranFactor = f2, changeType = ct1} + local proTran2 = {proName = propertyList[pro2], tranProName = propertyList[pro2], tranFactor = f3, changeType = ct2} caster.proTranList:Add(proTran1) caster.proTranList:Add(proTran2) BattleUtil.CalDamage(caster, target, dt, f1) @@ -776,7 +789,7 @@ local effectList = { local f3 = args[5] casterBulletEffect(caster, target, interval) BattleLogic.WaitForTrigger(interval, function () - if target.professionId == pt then + if target.roleData.professionId == pt then BattleUtil.CalDamage(caster, target, dt, f1+f3, f2) else BattleUtil.CalDamage(caster, target, dt, f1) @@ -807,15 +820,17 @@ local effectList = { end local OnSkillCast, OnSkillCastEnd OnSkillCast = function(skill) - caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) caster.Event:RemoveEvent(BattleEventName.SkillCast, OnSkillCast) + caster.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) end OnSkillCastEnd = function(skill) - caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) - caster.Event:RemoveEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () --延迟一帧移除事件,防止触发帧和结束帧为同一帧时,被动未移除 + caster.Event:RemoveEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) + end) end caster.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) - caster.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) end) end, --造成[a]%的[b]伤害,如果目标受到此次伤害前,生命低于最大生命[c]%,则直接击杀。 @@ -833,38 +848,47 @@ local effectList = { end end) end, - --增加[c]层缚灵印记,每层印记[f]改变[d]属性[e]%,[i]改变[g]属性[h]%,最大[j]层(0为无限) - --c[int],d[属性],e[float],f[改变类型],g[属性],h[float],i[改变类型],j[int] + --增加[c]层缚灵印记,每层使受到的伤害增加[d],减少[e]%的受治疗效果,最大[f]层(0为无限) + --c[int],d[float],e[float],f[int] [51] = function(caster, target, args, interval) local i1 = args[1] - local pro1 = args[2] - local f2 = args[3] - local ct1 = args[4] - local pro2 = args[5] - local f3 = args[6] - local ct2 = args[7] - local i2 = args[8] + local f2 = args[2] + local f3 = args[3] + local i2 = args[4] local flag = "fuling"..caster.uid BattleLogic.WaitForTrigger(interval, function () - local changeBuff1 = Buff.Create(target, BuffName.PropertyChange, 0, propertyList[pro1], f2*i1, ct1) - changeBuff1.cover = true - changeBuff1.maxLayer = i2 + for i=1, i1 do + local brand + brand = Buff.Create(caster, BuffName.Brand, 0, flag) + brand.exDmg = f2 + brand.exHeal = f3 + brand.maxLayer = i2 + brand.coverFunc = function (oldBuff) + if i2 == 0 or oldBuff.layer < i2 then + brand.exDmg = brand.exDmg + oldBuff.exDmg + brand.exHeal = brand.exHeal + oldBuff.exHeal + else + brand.exDmg = oldBuff.exDmg + brand.exHeal = oldBuff.exHeal + end + end + local trigger = function(atkRole, damagingFunc, damageType) + damagingFunc(brand.exDmg) + end + local OnPassiveBeTreated = function(treatingFunc) + treatingFunc(-brand.exHeal) + end - local changeBuff2 = Buff.Create(target, BuffName.PropertyChange, 0, propertyList[pro2], f3*i1, ct2) - changeBuff2.cover = true - changeBuff2.maxLayer = i2 - - target:AddBuff(changeBuff1) - target:AddBuff(changeBuff2) - - local brandBuff - brandBuff = Buff.Create(caster, BuffName.Brand, 0, flag, function () - brandBuff.linkBuff1 = nil - brandBuff.linkBuff2 = nil - end) - brandBuff.linkBuff1 = changeBuff1 - brandBuff.linkBuff2 = changeBuff2 - target:AddBuff(brandBuff) + target.Event:AddEvent(BattleEventName.RoleBeDamagedBefore, trigger) + target.Event:AddEvent(BattleEventName.PassiveBeTreated, OnPassiveBeTreated) + brand.endFunc = function () + brand.exDmg = nil + brand.exHeal = nil + target.Event:RemoveEvent(BattleEventName.RoleBeDamagedBefore, trigger) + target.Event:RemoveEvent(BattleEventName.PassiveBeTreated, OnPassiveBeTreated) + end + target:AddBuff(brand) + end end) end, --造成[a]%的[b]伤害,引爆目标身上所有缚灵印记,每层造成攻击*[c]的真实伤害。 @@ -910,7 +934,7 @@ local effectList = { end end) end, - --[e]改变[a]属性[b]%的[c],持续[d]秒 + --[e]改变[a]属性*[b]%的[c],持续[d]秒 --a[属性],b[float],c[属性],d[int],e[改变类型] [54] = function(caster, target, args, interval) local pro1 = args[1] @@ -919,7 +943,7 @@ local effectList = { local f2 = args[4] local ct = args[5] BattleLogic.WaitForTrigger(interval, function () - target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro1], floor(caster:GetRoleData(propertyList[pro2]) * f1), ct)) + target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro2], floor(caster:GetRoleData(propertyList[pro1]) * f1), ct)) end) end, --清除[a]状态 @@ -957,9 +981,9 @@ local effectList = { local i1 = args[2] casterBulletEffect(caster, target, interval) BattleLogic.WaitForTrigger(interval, function () - local damage = BattleUtil.ApplyDamage(caster, target, floor(caster:GetRoleData(RoleDataName.Hp) * f1)) + local damage = BattleUtil.ApplyDamage(caster, target, floor(target:GetRoleData(RoleDataName.Hp) * f1)) local arr = BattleUtil.ChooseTarget(caster, 10110) - local count = math.min(#arr, i1) + local count = min(#arr, i1) local heal = floor(damage / count) for i=1, count do BattleUtil.CalTreat(caster, arr[i], heal) diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index b35f98d37..e784b363a 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -41,7 +41,7 @@ local passivityList = { for i=1, skill.effectList.size do duration = max(duration, skill.effectList.buffer[i].duration) end - role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], duration + BattleLogic.GameDeltaTime * 2) + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], 2, duration + BattleLogic.GameDeltaTime * 2) end) end role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) @@ -203,7 +203,7 @@ local passivityList = { local OnRoleBeDamagedBefore = function(atkRole, func, damageType) if damageType == dt then BattleUtil.RandomAction(f1, function () - role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], BattleLogic.GameDeltaTime) + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], 2, BattleLogic.GameDeltaTime) end) end end @@ -292,7 +292,7 @@ local passivityList = { local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType) if damageType == dt then BattleUtil.RandomAction(f1, function () - role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], f3) + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], 2, f3) end) end end @@ -331,7 +331,7 @@ local passivityList = { local OnSkillCastEnd = function(skill) BattleUtil.RandomAction(f1, function () - role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], f3) + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], 2, f3) end) end role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) @@ -375,7 +375,6 @@ local passivityList = { --a[float] [19] = function(role, args) local f1 = args[1] - role.data:AddValue(RoleDataName.CureFacter, f1) end, @@ -733,7 +732,7 @@ local passivityList = { local f1 = args[2] local OnBeHit = function(atkRole) - if atkRole.professionId == i1 then + if atkRole.roleData.professionId == i1 then BattleUtil.CalTreat(role, role, f1) end end diff --git a/luafight/Modules/Battle/Logic/Buff/Brand.lua b/luafight/Modules/Battle/Logic/Buff/Brand.lua index 17ba16659..b88973adc 100644 --- a/luafight/Modules/Battle/Logic/Buff/Brand.lua +++ b/luafight/Modules/Battle/Logic/Buff/Brand.lua @@ -26,7 +26,9 @@ function Brand:OnEnd() --log("Brand:OnEnd") if self.endFunc then self.endFunc() + self.endFunc = nil end + self.coverFunc = nil end --只有当cover字段为true时触发,返回true则被新效果覆盖 @@ -40,6 +42,9 @@ function Brand:OnCover(newBuff) newBuff.layer = math.min(self.layer + 1, newBuff.maxLayer) end end + if newBuff.coverFunc then + newBuff.coverFunc(self) + end return b end diff --git a/luafight/Modules/Battle/Logic/Buff/Shield.lua b/luafight/Modules/Battle/Logic/Buff/Shield.lua index 66b57bc91..6f7986256 100644 --- a/luafight/Modules/Battle/Logic/Buff/Shield.lua +++ b/luafight/Modules/Battle/Logic/Buff/Shield.lua @@ -7,6 +7,7 @@ function Shield:SetData(...) self.shieldValue, --护盾值 self.dmgReboundFactor = ... --伤害反弹系数 self.damageSum = 0 --记录承受的伤害 + self.isBuff = true end --初始化后调用一次 diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 83a894f0d..461c52189 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -37,6 +37,7 @@ BattleEventName = { SkillCastEnd = indexAdd(), PassiveTreating = indexAdd(), + PassiveBeTreated = indexAdd(), PassiveBeDamaging = indexAdd(), PassiveDamaging = indexAdd(), PassiveCriting = indexAdd(), diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 70c28912f..61848666f 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -295,7 +295,8 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) --加入被动效果 local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end - castRole.Event:DispatchEvent(BattleEventName.PassiveTreating, treatingFunc) + castRole.Event:DispatchEvent(BattleEventName.PassiveTreating, treatingFunc, targetRole) + targetRole.Event:DispatchEvent(BattleEventName.PassiveBeTreated, treatingFunc, castRole) local treat = min(baseTreat, maxHp - hp) if treat > 0 then diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index bc0ff269f..e40e0cbc6 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -235,7 +235,17 @@ function RoleLogic:GetRoleData(property) for i=1, self.proTranList.size do item = self.proTranList.buffer[i] if item.proName == property then - tarPro = tarPro + BattleUtil.ErrorCorrection(self.data:GetData(item.tranProName) * item.tranFactor) + local value + if item.changeType == 1 then --加算 + value = item.tranFactor + elseif item.changeType == 2 then --乘加算(百分比属性加算) + value = BattleUtil.ErrorCorrection(self.data:GetData(item.tranProName) * item.tranFactor) + elseif item.changeType == 3 then --减算 + value = -item.tranFactor + elseif item.changeType == 4 then --乘减算(百分比属性减算) + value = -BattleUtil.ErrorCorrection(self.data:GetData(item.tranProName) * item.tranFactor) + end + tarPro = tarPro + value end end return tarPro @@ -243,8 +253,8 @@ end --proA替换的属性,factor系数,proB被替换的属性, duration持续时间 --读取proB属性时,得到的值为proB + proA * factor -function RoleLogic:AddPropertyTransfer(proA, factor, proB, duration) - local proTran = {proName = proB, tranProName = proA, tranFactor = factor} +function RoleLogic:AddPropertyTransfer(proA, factor, proB, ct, duration) + local proTran = {proName = proB, tranProName = proA, tranFactor = factor, changeType = ct} self.proTranList:Add(proTran) local index = self.proTranList.size BattleLogic.WaitForTrigger(duration, function ()