From 9fb69b69bfc0a41aeab36f87061aa1b20a0f304f Mon Sep 17 00:00:00 2001 From: lvxinran Date: Thu, 16 Apr 2020 15:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luafight/Modules/Battle/Logic/Base/Buff.lua | 4 +- luafight/Modules/Battle/Logic/Base/Effect.lua | 101 ++-- .../Modules/Battle/Logic/Base/Passivity.lua | 474 +++++++++++------- .../Modules/Battle/Logic/Base/RoleData.lua | 19 +- luafight/Modules/Battle/Logic/Base/Skill.lua | 143 ++---- luafight/Modules/Battle/Logic/BattleLogic.lua | 236 ++++++--- .../Modules/Battle/Logic/Buff/Control.lua | 4 +- .../Battle/Logic/Buff/PropertyChange.lua | 2 +- luafight/Modules/Battle/Logic/Buff/Shield.lua | 25 +- luafight/Modules/Battle/Logic/RoleLogic.lua | 117 +++-- .../com/ljsd/jieling/exception/ErrorCode.java | 3 +- 11 files changed, 696 insertions(+), 432 deletions(-) diff --git a/luafight/Modules/Battle/Logic/Base/Buff.lua b/luafight/Modules/Battle/Logic/Base/Buff.lua index c3502f85e..1dcb00f77 100644 --- a/luafight/Modules/Battle/Logic/Base/Buff.lua +++ b/luafight/Modules/Battle/Logic/Base/Buff.lua @@ -270,7 +270,7 @@ function BuffManager:TurnUpdate(sort) buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff) end elseif buff.roundInterval < 0 then - if buff.roundPass > buff.roundDuration then + if buff.roundPass >= buff.roundDuration then buff.disperse = true end else @@ -280,7 +280,7 @@ function BuffManager:TurnUpdate(sort) end buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff) end - if buff.roundPass > buff.roundDuration then + if buff.roundPass >= buff.roundDuration then buff.disperse = true end end diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 39f4d8a4c..fb6fb01e5 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -1903,13 +1903,22 @@ local effectList = { local dt = args[2] local i1 = args[3] local f2 = args[4] + + local roleList =BattleLogic.Query(function (r) return r.camp == target.camp end) + local deadNum = 6 - #roleList + local level = math.floor(deadNum/i1) + local extra = level * f2 + 1 + caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () - local roleList =BattleLogic.Query(function (r) return r.camp == target.camp and r.isDead end, true) - local deadNum = #roleList - local level = math.floor(deadNum/i1) - local extra = (level * f2 + 1) * f1 - BattleUtil.CalDamage(skill, caster, target, dt, extra) + local OnPassiveDamaging = function(damagingFunc, defRole, damage) + if damagingFunc then + damagingFunc(-floor(damage * extra)) + end + end + caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) + BattleUtil.CalDamage(skill, caster, target, dt, f1) + caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) end) end, @@ -1919,25 +1928,23 @@ local effectList = { [100] = function(caster, target, args, interval, skill) local ct = args[1] local i1 = args[2] - caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) + -- caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () target:AddRage(i1, ct) end) end, - - -- 造成[a]%的[b]伤害,然后对仇恨目标追加一次1技能(追加的1技能不回怒气)【aoe】 + -- 组合技能 + -- 对仇恨目标追加一次1技能(追加的1技能不回怒气) -- a[float],b[伤害类型] [101] = function(caster, target, args, interval, skill) - local f1 = args[1] - local dt = args[2] - -- caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) + local i1 = args[1] BattleLogic.WaitForTrigger(interval, function () - BattleUtil.CalDamage(skill, caster, target, dt, f1) + -- 对仇恨目标追加一次技能 + for i = 1, i1 do + caster:AddSkill(BattleSkillType.Normal, false, true, {{target}}) + end end) - - -- 对仇恨目标追加一次技能 - caster:AddSkill(BattleSkillType.Normal, false, true, {target}) end, -- 造成[a]%的[b]伤害,如果目标数量大于[c]个,增加自身[d]点怒气(主动 + 被动167联合实现) @@ -1967,7 +1974,7 @@ local effectList = { BattleLogic.WaitForTrigger(interval, function () local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType) local arr = BattleLogic.Query(function (r) return r.camp == caster.camp end) - arr = BattleUtil.SortByProp(arr, RoleDataName.Hp, 0) + arr = BattleUtil.SortByProp(arr, RoleDataName.Hp, 1) -- 治疗血量最低队友实际伤害的f2% BattleUtil.ApplyTreat(caster, arr[1], floor(finalDmg*f2)) end @@ -1988,22 +1995,25 @@ local effectList = { end) end, - --造成[a]%的[b]伤害如目标[c]则[d]改变自身[e]%的[f] - -- a[float]b[伤害类型]c[持续伤害状态]d[改变类型]e[float]f[属性] + -- 造成[a]%的[b]伤害如目标[c]则本次技能造成伤害增加[d]% + -- a[float]b[伤害类型]c[持续伤害状态]d[float] [105] = function(caster, target, args, interval, skill) local f1 = args[1] local dt = args[2] local dot = args[3] - local ct = args[4] - local f2 = args[5] - local pro1 = args[6] + local f2 = args[4] caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) BattleLogic.WaitForTrigger(interval, function () - if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then - caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, 0, propertyList[pro1], f2, ct)) + local OnPassiveDamaging = function(damagingFunc, defRole, damage) + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + if damagingFunc then + damagingFunc(-floor(damage * f2)) + end + end end - + caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) BattleUtil.CalDamage(skill, caster, target, dt, f1) + caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) end) end, @@ -2103,19 +2113,20 @@ local effectList = { - -- 造成[a]%的[b]伤害,然后对仇恨目标追加一次1技能(追加的1技能不回怒气)技能101的弹道特效版 + -- 造成[a]%的[b]伤害,然后对仇恨目标追加一次1技能(追加的1技能不回怒气)技能101的弹道特效版(删除) -- a[float],b[伤害类型] - [112] = function(caster, target, args, interval, skill) - local f1 = args[1] - local dt = args[2] - caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) - BattleLogic.WaitForTrigger(interval, function () - BattleUtil.CalDamage(skill, caster, target, dt, f1) - end) + -- [112] = function(caster, target, args, interval, skill) + -- local f1 = args[1] + -- local dt = args[2] + -- caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) + -- BattleLogic.WaitForTrigger(interval, function () + -- BattleUtil.CalDamage(skill, caster, target, dt, f1) + -- end) + + -- -- 对仇恨目标追加一次技能 + -- caster:AddSkill(BattleSkillType.Normal, false, true, {{target}}) + -- end, - -- 对仇恨目标追加一次技能 - caster:AddSkill(BattleSkillType.Normal, false, true, {target}) - end, --造成[a]%的[b]伤害,对[c]有[d]%造成[e],持续[f]秒 技能21的弹道特效版 --a[float],b[伤害类型,]c[持续伤害状态],d[float],e[控制状态],f[int] [113] = function(caster, target, args, interval, skill) @@ -2133,6 +2144,26 @@ local effectList = { end end) end, + + -- 造成[a]%的[b]伤害如目标[c]则本次技能暴击率提高[d]% + -- a[float]b[伤害类型]c[持续伤害状态]d[float] + [114] = function(caster, target, args, interval, skill) + local f1 = args[1] + local dt = args[2] + local dot = args[3] + local f2 = args[4] + caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) + BattleLogic.WaitForTrigger(interval, function () + local index, tran + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then + index, tran = caster:AddPropertyTransfer(RoleDataName.Crit, f2, RoleDataName.Crit, 1) + end + BattleUtil.CalDamage(skill, caster, target, dt, f1) + if index and tran then + caster:RemovePropertyTransfer(index, tran) + end + end) + end, } return effectList \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index f7b594286..a8b87c6f6 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -1509,12 +1509,13 @@ local passivityList = { end, - -- [a]增加[b] + -- [a]增加[b], [c]改变 -- a[属性]b[float] [90] = function(role, args) local pro = args[1] local f1 = args[2] - role.data:AddValue(propertyList[pro], f1) + local ct = args[3] + role.data:CountValue(propertyList[pro], f1, ct) end, -- 技能伤害增加[a] @@ -1528,31 +1529,33 @@ local passivityList = { end local OnSkillCast = function(skill) if skill.type == BattleSkillType.Special then - role.Event:AddEvent(RoleDataName.PassiveDamaging, passivityDamaging) + role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging) end end local OnSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - role.Event:RemoveEvent(RoleDataName.PassiveDamaging, passivityDamaging) + role.Event:RemoveEvent(BattleEventName.PassiveDamaging, passivityDamaging) end end - role.Event:AddEvent(RoleDataName.OnSkillCast, OnSkillCast) - role.Event:AddEvent(RoleDataName.OnSkillCastEnd, OnSkillCastEnd) + role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) end, - -- (直接伤害(目前没有明确定义直接伤害))击杀目标自身增加[a][b] - -- a[int]b[属性] + -- (直接伤害(目前没有明确定义直接伤害))直接伤害击杀目标自身增加[a]点怒气 + -- a[int] [92] = function(role, args) local i1 = args[1] - local pro = args[2] - local OnKill = function(defRole) - local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], i1, 1) - buff.cover = true -- 可以叠加 - buff.clear = false -- 不可驱散 - role:AddBuff(buff) + local OnRoleHit = function(defRole) + -- local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], i1, 1) + -- buff.cover = true -- 可以叠加 + -- buff.clear = false -- 不可驱散 + -- role:AddBuff(buff) + if defRole.isDead then + role:AddRage(i1, CountTypeName.Add) + end end - role.Event:AddEvent(BattleEventName.RoleKill, OnKill) + role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit) end, -- 技能治疗量增加[a] @@ -1564,27 +1567,28 @@ local passivityList = { end local OnSkillCast = function(skill) if skill.type == BattleSkillType.Special then - role.Event:AddEvent(RoleDataName.PassiveTreating, passiveTreating) + role.Event:AddEvent(BattleEventName.PassiveTreating, passiveTreating) end end local OnSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - role.Event:RemoveEvent(RoleDataName.PassiveTreating, passiveTreating) + role.Event:RemoveEvent(BattleEventName.PassiveTreating, passiveTreating) end end - role.Event:AddEvent(RoleDataName.OnSkillCast, OnSkillCast) - role.Event:AddEvent(RoleDataName.OnSkillCastEnd, OnSkillCastEnd) + role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) end, - -- 全体上阵武将增加[a][b] - -- a[float]b[属性] + -- 全体上阵武将增加[a][b] [c]改变 + -- a[float]b[属性]c[改变类型] [94] = function(role, args) local f1 = args[1] local pro = args[2] + local ct = args[3] local list = BattleLogic.Query(function(v) return role.camp == v.camp end) for _, r in pairs(list) do - role.data:AddPencentValue(propertyList[pro], f1) + r.data:CountValue(propertyList[pro], f1, ct) end end, @@ -1610,16 +1614,16 @@ local passivityList = { end local OnSkillCast = function(skill) if skill.type == BattleSkillType.Normal then - role.Event:AddEvent(RoleDataName.PassiveDamaging, passivityDamaging) + role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging) end end local OnSkillCastEnd = function(skill) if skill.type == BattleSkillType.Normal then - role.Event:RemoveEvent(RoleDataName.PassiveDamaging, passivityDamaging) + role.Event:RemoveEvent(BattleEventName.PassiveDamaging, passivityDamaging) end end - role.Event:AddEvent(RoleDataName.OnSkillCast, OnSkillCast) - role.Event:AddEvent(RoleDataName.OnSkillCastEnd, OnSkillCastEnd) + role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) end, @@ -1645,16 +1649,15 @@ local passivityList = { role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd) end, - -- 释放技能[a]概率不消耗[b] - -- a[float]b[属性] + -- 释放技能[a]概率不消耗怒气 + -- a[float] [98] = function(role, args) local f1 = args[1] - local prop = args[2] -- 目前只是怒气 local onRageCost = function(noCostRate, costRage, func) - local finalRate = f1 - local finalCost = costRage - if func then func(finalRate, finalCost) end + local dRate = f1 + local dCost = 0 + if func then func(dRate, dCost) end end role.Event:AddEvent(BattleEventName.RoleRageCost, onRageCost) end, @@ -1666,7 +1669,7 @@ local passivityList = { local f1 = args[1] local OnHit = function(atkRole, damage, bCrit, finalDmg, damageType) local arr = BattleLogic.Query(function (r) return r.camp == role.camp end) - arr = BattleUtil.SortByProp(arr, RoleDataName.Hp, 0) + arr = BattleUtil.SortByProp(arr, RoleDataName.Hp, 1) -- 治疗血量最低队友实际伤害的f1% BattleUtil.ApplyTreat(role, arr[1], floor(BattleUtil.ErrorCorrection(finalDmg*f1))) end @@ -1681,9 +1684,10 @@ local passivityList = { local f1 = args[2] local onRageCost = function(noCostRate, costRage, func) - local finalRate = BattleUtil.CountValue(noCostRate, f1, ct) - local finalCost = costRage - if func then func(finalRate, finalCost) end + local dRate = BattleUtil.CountValue(noCostRate, f1, ct) - noCostRate + dRate = BattleUtil.ErrorCorrection(dRate) + local dCost = 0 + if func then func(dRate, dCost) end end role.Event:AddEvent(BattleEventName.RoleRageCost, onRageCost) end, @@ -1740,8 +1744,8 @@ local passivityList = { -- 释放技能后 local onRoleHit = function(defRole) if defRole.isDead then - local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], CountTypeName.AddPencent, f1) - buff.cover = true + local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, CountTypeName.AddPencent) + -- buff.cover = true role:AddBuff(buff) end end @@ -1758,7 +1762,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) - list = BattleUtil.SortByProp(list, RoleDataName.Hp, 0) + list = BattleUtil.SortByProp(list, RoleDataName.Hp, 1) local target = nil for i = 1, #list do if not list[i].isDead and list[i] ~= role then @@ -1803,7 +1807,7 @@ local passivityList = { local onBeHit = function(caster, damage) local list = BattleLogic.Query(function(v) return v.camp == role.camp end) - list = BattleUtil.SortByProp(list, propertyList[pro], 0) + list = BattleUtil.SortByProp(list, propertyList[pro], 1) for i = 1, i1 do local r = list[i] if r and not r.isDead then @@ -1832,9 +1836,11 @@ local passivityList = { -- a[float] [108] = function(role, args) local f1 = args[1] - local onBeHit = function(caster, damage) - local rDamage = floor(BattleUtil.ErrorCorrection(f1 * damage)) - BattleUtil.ApplyDamage(nil, role, caster, rDamage) + local onBeHit = function(caster, damage, bCrit, finalDmg, damageType, skill) + if skill then --技能造成的直接伤害 + local rDamage = floor(BattleUtil.ErrorCorrection(f1 * damage)) + BattleUtil.ApplyDamage(nil, role, caster, rDamage) + end end role.Event:AddEvent(BattleEventName.RoleBeHit, onBeHit) end, @@ -1858,9 +1864,11 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - for i = 1, #skill.effectTargets do - local r = skill.effectTargets[i] - r:AddRage(i1, CountTypeName.Sub) + local list = skill:GetDirectTargets() + if list then + for i = 1, #list do + list[i]:AddRage(i1, CountTypeName.Sub) + end end end end @@ -1888,32 +1896,38 @@ local passivityList = { -- a[int] [112] = function(role, args) local i1 = args[1] - - BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) - local onRoleDamageBefore = function(target) + local function onRoleDamageAfter(target) + target.isFlagCrit = false + role.Event:RemoveEvent(BattleEventName.RoleDamageAfter, onRoleDamageAfter) + end + local function onRoleDamageBefore(target) + if BattleLogic.GetCurRound() == i1 then target.isFlagCrit = true + role.Event:AddEvent(BattleEventName.RoleDamageAfter, onRoleDamageAfter) end - local onRoleDamageAfter = function(target) - target.isFlagCrit = false - end - -- 在第 i1 回合必定暴击 - if curRound == i1 then - role.Event:AddEvent(BattleEventName.RoleDamageBefore, onRoleDamageBefore) - role.Event:AddEvent(BattleEventName.onRoleDamageAfter, onRoleDamageAfter) - else - role.Event:RemoveEvent(BattleEventName.RoleDamageBefore, onRoleDamageBefore) - role.Event:RemoveEvent(BattleEventName.onRoleDamageAfter, onRoleDamageAfter) - end - end) + end + role.Event:AddEvent(BattleEventName.RoleDamageBefore, onRoleDamageBefore) end, - - - --TODO -- 追加的普攻[a]%概率暴击 -- a[float] - -- [113] = {}, + [113] = function(role, args) + local f1 = args[1] + local function onSkillCast(skill) + if skill.type == BattleSkillType.Normal and skill.isAdd then + role.data:AddValue(RoleDataName.Crit, f1) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + local function onSkillCastEnd(skill) + if skill.type == BattleSkillType.Normal and skill.isAdd then + role.data:SubValue(RoleDataName.Crit, f1) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + end, -- 直接伤害击杀目标后追加[a]次普攻 -- a[int] @@ -1969,16 +1983,28 @@ local passivityList = { local ct = args[1] -- 对方阵营中死亡数量 local i1 = args[2] local f1 = args[3] - - -- - local onRoleDamageBefore = function(target, func) - local roleList =BattleLogic.Query(function (r) return r.camp == target.camp and r.isDead end, true) - local deadNum = #roleList - local level = math.floor(deadNum/i1) - local extra = BattleUtil.ErrorCorrection(level * f1) - if func then func(extra) end + + + -- 每次释放技能时提前计算额外加成的伤害 + local extra = 0 + 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 deadNum = 6 - #roleList + local level = math.floor(deadNum/i1) + extra = BattleUtil.ErrorCorrection(level * f1) + end end - role.Event:AddEvent(BattleEventName.RoleDamageBefore, onRoleDamageBefore) + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) + + -- 如果是技能的伤害则判断加成 + local onPassiveDamaging = function(func, target, damage, skill) + if skill and skill.type == BattleSkillType.Special then + if func then func(-floor(BattleUtil.ErrorCorrection(extra*damage))) end + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) end, @@ -2021,7 +2047,7 @@ local passivityList = { -- 释放技能后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local buff = Buff.Create(role, BuffName.PropertyChange, i1, propertyList[pro], ct, f1) + local buff = Buff.Create(role, BuffName.PropertyChange, i1, propertyList[pro], f1, ct) buff.cover = true role:AddBuff(buff) end @@ -2094,7 +2120,7 @@ local passivityList = { if skill.type == BattleSkillType.Special then local list = BattleLogic.Query(function(v) return v.camp == role.camp and v.position <= 3 end) for _, role in ipairs(list) do - BuffManager:QueryBuff(role, function(buff) + BattleLogic.BuffMgr:QueryBuff(role, function(buff) if buff.type == BuffName.Shield and buff.ShieldType == ShieldTypeName.RateReduce then buff:ChangeShieldValue(ct, f1) end @@ -2128,7 +2154,7 @@ local passivityList = { -- 释放技能后 local onRoleHit = function(target) if target.isDead then - local buff = Buff.Create(role, BuffName.PropertyChange, 1, propertyList[RoleDataName.Crit], CountTypeName.Add, f1) + local buff = Buff.Create(role, BuffName.PropertyChange, 1, RoleDataName.Crit, f1, CountTypeName.Add) role:AddBuff(buff) end end @@ -2136,9 +2162,27 @@ local passivityList = { end, -- TODO - -- 战斗中自身[a]每[b]改变[c]%,[d]就[e]改变[f]% - -- a[属性]b[改变类型]c[float]d[属性]e[改变类型]f[float] - [126] = {}, + -- 战斗中生命每减少[c]%,[d]就[e]改变[f]% + -- c[float]d[属性]e[改变类型]f[float] + [126] = function(role, args) + local f1 = args[1] + local pro = args[2] + local dt = args[3] + local f2 = args[4] + + local levelDamage = floor(role:GetRoleData(RoleDataName.MaxHp)*f1) + local curDamage = 0 + -- 释放技能后 + local onRoleBeDamaged = function(caster, damage) + curDamage = curDamage + damage + if curDamage >= levelDamage then + curDamage = curDamage - levelDamage + local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f2, dt) + role:AddBuff(buff) + end + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, onRoleBeDamaged) + end, -- 与48相同 @@ -2151,9 +2195,11 @@ local passivityList = { -- 普攻后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local list = skill.effectTargets - for _, r in ipairs(list) do - r:AddRage(i1, CountTypeName.Sub) + local list = skill:GetDirectTargets() + if list then + for _, r in ipairs(list) do + r:AddRage(i1, CountTypeName.Sub) + end end end end @@ -2174,7 +2220,7 @@ local passivityList = { -- [130] = {}, - -- 敌方每[a]改变[b]人自身[c]就[d]改变[e]% + -- 敌方每[a]改变[b]人自身[c]就[d]改变[e]% (敌方每死亡i1个则自身属性改变) -- a[改变类型]b[int]c[属性]d[改变类型]e[float] [131] = function(role, args) local ct1 = args[1] @@ -2190,7 +2236,7 @@ local passivityList = { deadNum = deadNum + 1 if deadNum >= i1 then deadNum = 0 - local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], ct2, f1) + local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, ct2) role:AddBuff(buff) end end @@ -2202,7 +2248,7 @@ local passivityList = { -- [132] = {}, - -- 攻击时若目标[a]则[b],[c]改变[d]% + -- 攻击时若目标[a]则当次攻击自身[b],[c]改变[d]% -- a[持续伤害状态]b[属性]c[改变类型]d[float} [133] = function(role, args) local dot = args[1] @@ -2210,14 +2256,20 @@ local passivityList = { local ct = args[3] local f1 = args[4] + + local index, tran local OnRoleDamageBefore = function(target) if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then - local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], ct, f1) - role:AddBuff(buff) + index, tran = role:AddPropertyTransfer(propertyList[pro], f1, propertyList[pro], ct) end end - - BattleLogic.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore) + local OnRoleDamageAfter = function() + if index and tran then + role:RemovePropertyTransfer(index, tran) + end + end + role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore) + role.Event:AddEvent(BattleEventName.RoleDamageAfter, OnRoleDamageAfter) end, @@ -2259,15 +2311,17 @@ local passivityList = { -- 普攻后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local list = skill.effectTargets - 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) + local list = skill:GetDirectTargets() + if list then + 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) + end end end end @@ -2308,14 +2362,16 @@ local passivityList = { -- 技能后后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = skill.effectTargets - local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) - for _, r in ipairs(list) do - local auraBuff = Buff.Create(role, BuffName.Aura, i1, function (tr) - BattleUtil.CalTreat(tr, tr, tv) - end) - auraBuff.interval = 1 - r:AddBuff(auraBuff) + local list = skill:GetDirectTargets() + if list then + local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) + for _, r in ipairs(list) do + local auraBuff = Buff.Create(role, BuffName.Aura, i1, function (tr) + BattleUtil.CalTreat(tr, tr, tv) + end) + auraBuff.interval = 1 + r:AddBuff(auraBuff) + end end end end @@ -2331,14 +2387,16 @@ local passivityList = { -- 技能后后 local onSkillEnd = function(skill) if skill.type == BattleSkillType.Normal then - local list = skill.effectTargets - local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) - for _, r in ipairs(list) do - local auraBuff = Buff.Create(role, BuffName.Aura, i1, function (tr) - BattleUtil.CalTreat(tr, tr, tv) - end) - auraBuff.interval = 1 - r:AddBuff(auraBuff) + local list = skill:GetDirectTargets() + if list then + local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) + for _, r in ipairs(list) do + local auraBuff = Buff.Create(role, BuffName.Aura, i1, function (tr) + BattleUtil.CalTreat(tr, tr, tv) + end) + auraBuff.interval = 1 + r:AddBuff(auraBuff) + end end end end @@ -2348,7 +2406,23 @@ local passivityList = { -- TODO -- 释放技能后给目标附加治疗效果[a]改变[b]% -- a[改变类型]b[float] - -- [139] = {}, + [139] = function(role, args) + local dt = args[1] + local f1 = args[2] + local tFactor = function(factorFunc) + factorFunc(dt, f1) + end + role.Event:AddEvent(BattleEventName.SkillCast, function(skill) + if skill.type == BattleSkillType.Special then + role.Event:AddEvent(BattleEventName.PassiveTreatingFactor, tFactor) + end + end) + role.Event:AddEvent(BattleEventName.SkillCastEnd, function(skill) + if skill.type == BattleSkillType.Special then + role.Event:RemoveEvent(BattleEventName.PassiveTreatingFactor, tFactor) + end + end) + end, -- 受到[a]状态敌人攻击时受到伤害[b]改变[c]% -- a[持续伤害状态]b[改变类型]c[float] @@ -2408,7 +2482,6 @@ local passivityList = { 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 @@ -2436,46 +2509,53 @@ local passivityList = { -- [144] = - -- 技能对[a]目标[b]额外提升[c]% - -- a[持续伤害状态]b[属性]c[float] + -- 技能对[a]目标[b]额外提升[c]%(当次),[d]改变 + -- a[持续伤害状态]b[属性]c[float]d[改变类型] [145] = function(role, args) local dot = args[1] local pro = args[2] local f1 = args[3] + local ct = args[4] - -- 技能后后 - local onSkillCastEnd = function(skill) - if skill.type == BattleSkillType.Special then - local list = skill.effectTargets - for _, target in ipairs(list) do - if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(b) return b.damageType == dot end) then - local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, CountTypeName.AddPencent) - end - end + local index, tran + local OnRoleDamageBefore = function(target, factorFunc, damageType, skill) + if skill.type == BattleSkillType.Special and + BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then + index, tran = role:AddPropertyTransfer(propertyList[pro], f1, propertyList[pro], ct) end end - role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + local OnRoleDamageAfter = function() + if index and tran then + role:RemovePropertyTransfer(index, tran) + end + end + role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore) + role.Event:AddEvent(BattleEventName.RoleDamageAfter, OnRoleDamageAfter) end, - -- 普攻对[a]目标[b]额外提升[c]% - -- a[持续伤害状态]b[属性]c[float] + -- 普攻对[a]目标伤害额外增加[b]%(当次),[c]改变 + -- a[持续伤害状态]b[float]c[改变类型] [146] = function(role, args) local dot = args[1] - local pro = args[2] - local f1 = args[3] + local f1 = args[2] + local ct = args[3] - -- 技能后后 - local onSkillCastEnd = function(skill) - if skill.type == BattleSkillType.Normal then - local list = skill.effectTargets - for _, target in ipairs(list) do - if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(b) return b.damageType == dot end) then - local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, CountTypeName.AddPencent) - target:AddBuff(buff) - end - end + local onPassiveDamaging = function(damagingFunc, defRole, damage) + if damagingFunc then + damagingFunc(-floor(BattleUtil.FP_Mul(f1, damage))) end end + local onSkillCast = function(skill) + if skill.type == BattleSkillType.Special then + role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + end + end + local onSkillCastEnd = function(skill) + if skill.type == BattleSkillType.Special then + role.Event:RemoveEvent(BattleEventName.PassiveDamaging, onPassiveDamaging) + end + end + role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast) role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) end, @@ -2500,10 +2580,26 @@ local passivityList = { end, - -- TODO -- 直接伤害击杀[a]目标回复[b]%的最大生命 -- a[持续伤害状态]b[float] - -- [148] + [148] = function(role, args) + local dot = args[1] + local f1 = args[2] + local function onHit(target) + if target.isDead then + local maxHp = role:GetRoleData(RoleDataName.MaxHp) + local value = floor(BattleUtil.ErrorCorrection(maxHp* f1)) + BattleUtil.ApplyTreat(role, role, value) + end + role.Event:RemoveEvent(BattleEventName.RoleHit, onHit) + end + local onDamaging = function(func, target) + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then + role.Event:AddEvent(BattleEventName.RoleHit, onHit) + end + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, onDamaging) + end, -- TODO @@ -2529,34 +2625,54 @@ local passivityList = { -- 技能后后 local onSkillCastEnd = function(skill) if skill.type == BattleSkillType.Special then - local list = skill.effectTargets - for _, r in ipairs(list) do - BattleUtil.RandomAction(f1, function() - local buff = Buff.Create(role, BuffName.Control, i1, ctrl) - r:AddBuff(buff) - end) + 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) + end end end end role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) end, - - - -- TODO -- 直接伤害击杀目标回复自身[a]点怒气 -- a[int] - -- [153] + [153] = function(role, args) + local i1 = args[1] + + local onHit = function(target, damage, bCrit, finalDmg) + 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] - -- TODO - -- 目标[a]每[b]改变[c]%,对其[d]就[e]改变[f]% - -- a[属性]b[改变类型]c[float]d[属性]e[改变类型]f[float] - -- [155] + -- 目标血量每降低[c]%(只看当前血量),对其治疗量就[e]改变[f]% + -- c[float]e[改变类型]f[float] + [155] = function(role, args) + local f1 = args[1] + local ct = args[2] + local f2 = args[3] + local function onPassiveTreatingFactor(treatFactorFunc, targetRole) + local lf = targetRole:GetRoleData(RoleDataName.Hp)/targetRole:GetRoleData(RoleDataName.MaxHp) + local df = 1 - lf -- 血量降低百分比 = 1 - 当前血量百分比 + local level = floor(df/f1) + if treatFactorFunc then + treatFactorFunc(ct, BattleUtil.ErrorCorrection(level*f2)) + end + end + role.Event:AddEvent(BattleEventName.PassiveTreatingFactor, onPassiveTreatingFactor) + end, -- 受到普攻后降低攻击自己武将的[c]点怒气 -- c[int] @@ -2564,17 +2680,26 @@ local passivityList = { local i1 = args[1] local onBeSkillCastEnd = function(skill) if skill.type == BattleSkillType.Normal then - skill.ower:AddRage(i1, CountTypeName.Sub) + skill.owner:AddRage(i1, CountTypeName.Sub) end end - role.Event:AddEvent(RoleDataName.BeSkillCastEnd, onBeSkillCastEnd) + role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd) end, - -- TODO 奸商盾 -- 减伤盾减伤比例[a]改变[b]% -- a[改变类型]b[float] - -- [157] + [157] = function(role, args) + local ct = args[1] + local f1 = args[2] + + local OnBuffCaster = function(buff) + if buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.RateReduce then + buff:ChangeShieldValue(ct, f1) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) + end, -- 释放技能后回复当前本方阵容最靠前武将[a]点怒气 -- a[int] @@ -2586,12 +2711,15 @@ local passivityList = { list = table.sort(list, function(a, b) return a.position < b.position end) - if list[1] and list[1].isDead then - list[1]:AddRage(i1, CountTypeName.Add) + for i= 1, #list do + if list[i] and not list[i].isDead then + list[i]:AddRage(i1, CountTypeName.Add) + break + end end end end - role.Event:AddEvent(RoleDataName.SkillCastEnd, onSkillCastEnd) + role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) end, @@ -2611,18 +2739,18 @@ local passivityList = { local i1 = args[3] -- 技能后后 - local onSkillCastEnd = function(skill) + 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 - caster:AddBuff(buff) + skill.owner:AddBuff(buff) end) end end - role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd) + role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd) end, @@ -2662,14 +2790,14 @@ local passivityList = { local i2 = args[2] -- 释放技能后 local onSkillEnd = function(skill) - if #skill.effectTargets > i1 then + local targets = skill:GetDirectTargets() + if targets and #targets > i1 then role:AddRage(i2, 1) end end role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd) end, - -- TODO 无敌吸血盾 -- 释放技能后给当前血量最少的2名队友附加无敌吸血盾持续[a]回合 -- a[int] [168] = function(role, args) @@ -2678,10 +2806,10 @@ local passivityList = { local onSkillEnd = function(skill) if skill.type == BattleSkillType.Special then local list = BattleLogic.Query(function(v) return v.camp == role.camp end) - list = BattleUtil.SortByProp(list, RoleDataName.Hp, 0) + list = BattleUtil.SortByProp(list, RoleDataName.Hp, 1) local index = 0 for i = 1, #list do - if not list[i].isDead and list[i] ~= role and index < 2 then + if not list[i].isDead and index < 2 then index = index + 1 -- 吸血率%25 策划说写死 list[i]:AddBuff(Buff.Create(role, BuffName.Shield, i1, ShieldTypeName.AllReduce, 0.25, 0)) diff --git a/luafight/Modules/Battle/Logic/Base/RoleData.lua b/luafight/Modules/Battle/Logic/Base/RoleData.lua index 2b46ce607..ca16319b0 100644 --- a/luafight/Modules/Battle/Logic/Base/RoleData.lua +++ b/luafight/Modules/Battle/Logic/Base/RoleData.lua @@ -15,9 +15,10 @@ end function RoleData:Init(role, data) self.role = role - for i=1, #data do - self.data[i] = BattleUtil.ErrorCorrection(data[i]) - self.orginData[i] = BattleUtil.ErrorCorrection(data[i]) + local max = max(#data, #self.data) + for i=1, max do + self.data[i] = BattleUtil.ErrorCorrection(data[i] or 0) + self.orginData[i] = BattleUtil.ErrorCorrection(data[i] or 0) end end @@ -101,6 +102,18 @@ function RoleData:SubPencentValue(name, pencent) return 0 end +function RoleData:CountValue(name, value, ct) + if ct == 1 then + self:AddValue(name, value) + elseif ct == 2 then + self:AddPencentValue(name, value) + elseif ct == 3 then + self:SubValue(name, value) + elseif ct == 4 then + self:SubPencentValue(name, value) + end +end + --Debug function RoleData:Foreach(func) for k,v in ipairs(self.data) do diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index 7a96288dd..471718308 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -86,11 +86,35 @@ function Skill:Cast(func, targets, isAdd) self.castDoneFunc = func self.effectTargets = {} self.isAdd = isAdd + + + -- 先计算出技能的目标 + for i=1, self.effectList.size do + -- 是否重新选择目标 + local isReTarget = true + if targets and targets[i] then + self.effectTargets[i] = targets[i] + -- 判断是否有有效目标 + for _, role in ipairs(self.effectTargets[i]) do + if not role.isDead then + isReTarget = false + end + end + end + -- 重新选择目标 + if isReTarget then + local effectGroup = self.effectList.buffer[i] + local chooseId = effectGroup.chooseId + self.effectTargets[i] = BattleUtil.ChooseTarget(self.owner, chooseId) + end + end + + -- 对目标造成相应的效果 for i=1, self.effectList.size do local effectGroup = self.effectList.buffer[i] local chooseId = effectGroup.chooseId - local arr = targets or BattleUtil.ChooseTarget(self.owner, chooseId) - if #arr > 0 then + local arr = self.effectTargets[i] + if arr and #arr > 0 then --效果延迟1帧生效 BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function() local duration = effectGroup.duration @@ -100,111 +124,42 @@ function Skill:Cast(func, targets, isAdd) if count == 0 then count = #arr end - -- 全部同时生效 for j=1, count do if arr[j] and not arr[j].isDead then takeEffect(self.owner, arr[j], effects, duration, self) - -- 加入目标列表 - table.insert(self.effectTargets, arr[j]) end end - - -- if chooseId == 100000 or chooseId == 200000 then --10000 我方aoe 20000 敌方aoe - -- local camp = chooseId == 100000 and self.owner.camp or 1 - self.owner.camp - -- self.owner.Event:DispatchEvent(BattleEventName.AOE, camp) - -- for j=1, count do - -- takeEffect(self.owner, arr[j], effects, duration, self) - -- -- 加入目标列表 - -- table.insert(self.effectTargets, arr[j]) - -- end - -- elseif weight == 7 then --对位相邻的目标同时触发效果 - -- for j=1, count do - -- takeEffect(self.owner, arr[j], effects, duration, self) - -- -- 加入目标列表 - -- table.insert(self.effectTargets, arr[j]) - -- end - -- else - -- for j = 1, count do - -- local index = j - -- local r = arr[index] - -- -- if not r or r.isDead then --当被选取的目标已经死亡或者没有,则重新选取,若重新选取的目标也死亡或者没有,则从之前的目标中选取第一个不死亡的 - -- -- if not targets then -- 如果是指定目标释放的则不再选取目标 - -- -- arr = BattleUtil.ChooseTarget(self.owner, chooseId) - -- -- r = arr[index] - -- -- if not r then --当没有新增的被选取目标时,可能为空 - -- -- for i=1, #arr do - -- -- if not arr[i].isDead then - -- -- r = arr[i] - -- -- break - -- -- end - -- -- end - -- -- end - -- -- end - -- -- end - -- -- - -- if r and not r.isDead then - -- takeEffect(self.owner, r, effects, duration, self) - -- -- 加入目标列表 - -- table.insert(self.effectTargets, r) - -- end - -- end - -- end end) end end - -- 计算技能CD的没有用了 - -- if not self.isTeamSkill then - -- local type = BattleLogic.Type - -- local isPVEMonster = self.owner.camp == 1 and (type == 1 or type == 2 or type == 4 or type == 5 or type == 8) - -- local time = 0 - -- if isPVEMonster then - -- if self.owner.superSkill == self then - -- --怪物绝技读条时间=max(10-速度/(8*(等级+10)),2) - -- time = max(10-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 2) - -- else - -- --怪物普技读条时间==max(9-速度/(8*(等级+10)),1) - -- time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1) - -- end - -- else - -- if self.owner.superSkill == self then - -- --绝技读条时间=max(9-速度/(8*(等级+10)),3) - -- time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 3) - -- else - -- --普技读条时间=max(7-速度/(8*(等级+10)),1.5) - -- time = max(7-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5) - -- end - -- end - -- self.owner.sp = 0 - -- self.owner.spPass = floor(BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate) - -- else - -- self.owner.curSkill = self - -- end - -- if self.isTeamSkill then self.owner.curSkill = self end - -- 延时一帧执行,避免战斗还没开始就释放了技能 - -- BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function() - self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self) - BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self) - -- end) - + -- 释放技能开始 + self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self) + BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self) + -- 只对效果1的目标发送事件,效果1是技能的直接伤害目标 + 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 duration = max(duration, self.effectList.buffer[i].duration) end - - BattleLogic.SetSkillUsable(self.owner.camp, false) - BattleLogic.WaitForTrigger(duration, function() + -- 结算时间向后延长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) - for _, tr in ipairs(self.effectTargets) do + + -- 只对效果1的目标发送事件,效果1是技能的直接伤害目标 + for _, tr in ipairs(self.effectTargets[1]) do tr.Event:DispatchEvent(BattleEventName.BeSkillCastEnd, self) end -- 技能结束 @@ -213,17 +168,21 @@ function Skill:Cast(func, targets, isAdd) end + +-- 获取技能的直接目标,和策划规定第一个效果的目标为直接效果目标 +function Skill:GetDirectTargets() + return self.effectTargets[1] +end + -- 结束技能 function Skill:EndSkill() + -- 技能后摇 -- 技能结束后摇后结束技能释放 - -- if self.isAdd then - -- if self.castDoneFunc then self.castDoneFunc() end - -- else - -- 非追加技能加入技能后摇 - BattleLogic.WaitForTrigger(0.5, function() - if self.castDoneFunc then self.castDoneFunc() end - end) - -- end + BattleLogic.WaitForTrigger(0.3, function() + -- 结束回调 + if self.castDoneFunc then self.castDoneFunc() end + + end) -- self.effectTargets = {} self.isAdd = nil diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index fc2234dd2..75b0f19d6 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -2,7 +2,7 @@ BattleLogic = {} local floor = math.floor local min = math.min -local objList = BattleDictionary.New() +-- local objList = BattleDictionary.New() local removeObjList = BattleList.New() local MaxRound = 20 @@ -117,11 +117,13 @@ function BattleLogic.StartOrder() MyTeamSkillCastIndex = 1 EnemyTeamSkillCastIndex = 1 - for i=1, #fightData.playerData do - BattleLogic.AddRole(fightData.playerData[i], i) + local playerData = fightData.playerData + local enemyData = fightData.enemyData[BattleLogic.CurOrder] + for i=1, #playerData do + BattleLogic.AddRole(playerData[i], playerData[i].position) end - for i=1, #fightData.enemyData[BattleLogic.CurOrder] do - BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i], i) + for i=1, #enemyData do + BattleLogic.AddRole(enemyData[i], enemyData[i].position) end for i=1,3 do @@ -130,14 +132,14 @@ function BattleLogic.StartOrder() playerTeamSkillList[i]=nil end end - for i=1, #fightData.playerData.teamSkill do + for i=1, #playerData.teamSkill do local skill = skillPool:Get() - skill:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i], 0) + skill:Init(playerTeamDummyRole, playerData.teamSkill[i], 0) playerTeamSkillList[i] = skill end - for i=1, #fightData.playerData.teamPassive do - for j=1, #fightData.playerData.teamPassive[i] do - local v = fightData.playerData.teamPassive[i][j] + 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 @@ -153,14 +155,14 @@ function BattleLogic.StartOrder() enemyTeamSkillList[i]=nil end end - for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do + for i=1, #enemyData.teamSkill do local skill = skillPool:Get() - skill:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], 0) + skill:Init(enemyTeamDummyRole, enemyData.teamSkill[i], 0) enemyTeamSkillList[i] = skill end - for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do - for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do - local v = fightData.enemyData[BattleLogic.CurOrder].teamPassive[i][j] + 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 @@ -171,22 +173,23 @@ function BattleLogic.StartOrder() end else BattleLogic.ClearOrder() - for i=1, #fightData.enemyData[BattleLogic.CurOrder] do - BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i], i) + 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, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do + for i=1, #orderList.teamSkill do local skill = skillPool:Get() - skill:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], 0) + skill:Init(enemyTeamDummyRole, orderList.teamSkill[i], 0) enemyTeamSkillList[i] = skill end - for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do - for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do - local v = fightData.enemyData[BattleLogic.CurOrder].teamPassive[i][j] + 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 @@ -294,9 +297,12 @@ end -- 触发异妖被动 function BattleLogic.TakeTeamPassivity(teamCaster, id, args) - objList:Foreach(function(k, v) + for _, v in pairs(PosList) do BattleUtil.Passivity[id](v, args) - end) + end + -- objList:Foreach(function(k, v) + -- BattleUtil.Passivity[id](v, args) + -- end) end -- 获取当前等待释放技能的异妖的序号 @@ -369,7 +375,7 @@ function BattleLogic.AddRole(roleData, position) curUid = curUid + 1 local role = rolePool:Get() role:Init(curUid, roleData, position) - objList:Add(curUid, role) + -- objList:Add(curUid, role) if roleData.camp == 0 then PosList[position] = role -- 1-6 我方英雄 else @@ -433,10 +439,6 @@ function BattleLogic.GetTeamSkillCaster(camp) return camp == 0 and playerTeamDummyRole or enemyTeamDummyRole end -function BattleLogic.HasObj(obj) - return obj and objList:Get(obj.uid) -end - function BattleLogic.CurFrame() return curFrame end @@ -445,12 +447,18 @@ function BattleLogic.Query(func, inCludeDeadRole) local list = {} local index = 1 if func then - objList:Foreach(function(k, v) + 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) + 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 @@ -462,11 +470,17 @@ function BattleLogic.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) + -- 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) @@ -478,17 +492,30 @@ function BattleLogic.Clear() end function BattleLogic.ClearOrder() - 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 + 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() @@ -530,7 +557,7 @@ function BattleLogic.Update() bMyAllDead = true bEnemyAllDead = true - objList:Foreach(function(k, v) + for _, v in pairs(PosList) do if not v.isDead then v:Update() if v.camp == 0 then @@ -539,7 +566,17 @@ function BattleLogic.Update() bEnemyAllDead = false end 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 @@ -547,32 +584,65 @@ end --对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的 function BattleLogic.GetAggro(role) - local minNeighbor = 100 - local index = 100 + -- 计算开始位置 + local startPos = role.position + startPos = startPos > 3 and startPos - 3 or startPos local target local enemyCamp = role.camp == 0 and 1 or 0 - objList:Foreach(function(k, v) - if v.camp == enemyCamp and not v.isDead then - if role.position == v.position then - minNeighbor = 0 - index = v.position - target = v - return "break" --终止foreach - else - local neighbor = math.abs(role.position - v.position) - if neighbor < minNeighbor then - minNeighbor = neighbor - index = v.position - target = v - elseif neighbor == minNeighbor and v.position < index then - minNeighbor = neighbor - index = v.position - target = v - end + + -- 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 - end) - return target + 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) @@ -590,8 +660,12 @@ function BattleLogic.GetNeighbor(role, chooseType) 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 and math.abs(target.position - list[i].position) <= 1 then - table.insert(posList, list[i]) + 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 then -- 旁边的人和自己 + table.insert(posList, list[i]) + end end end end @@ -622,18 +696,18 @@ end -- end --Debug专用 -function BattleLogic.SetRoleValue(uid, name, value) - if objList.kvList[uid] then - objList.kvList[uid].data:SetValue(name, value) - end -end +-- 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 +-- --Debug专用 +-- function BattleLogic.SetRoleDebug(uid, isDebug) +-- if objList.kvList[uid] then +-- objList.kvList[uid].IsDebug = isDebug +-- end +-- end --Record专用 function BattleLogic.GetRecord() diff --git a/luafight/Modules/Battle/Logic/Buff/Control.lua b/luafight/Modules/Battle/Logic/Buff/Control.lua index 1bf4040f6..20194708e 100644 --- a/luafight/Modules/Battle/Logic/Buff/Control.lua +++ b/luafight/Modules/Battle/Logic/Buff/Control.lua @@ -13,7 +13,7 @@ end function Control:OnStart() if self.ctrlType == 1 then --眩晕 - self.target.enable = false + self.target.ctrl_dizzy = true elseif self.ctrlType == 2 then --沉默 self.target.ctrl_slient = true elseif self.ctrlType == 3 then --嘲讽(包括沉默) @@ -39,7 +39,7 @@ end function Control:OnEnd() if self.ctrlType == 1 then --眩晕 - self.target.enable = true + self.target.ctrl_dizzy = false elseif self.ctrlType == 2 then --沉默 self.target.ctrl_slient = false elseif self.ctrlType == 3 then --嘲讽(包括沉默) diff --git a/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua b/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua index 53bb6d600..7485ed21e 100644 --- a/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua +++ b/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua @@ -6,7 +6,7 @@ function PropertyChange:SetData(...) self.propertyName, self.Value, self.changeType = ... - self.cover = false --默认不可叠加 + self.cover = false --默认不覆盖(可叠加) self.layer = 1 self.maxLayer = 0 diff --git a/luafight/Modules/Battle/Logic/Buff/Shield.lua b/luafight/Modules/Battle/Logic/Buff/Shield.lua index ff130f883..10abac4a9 100644 --- a/luafight/Modules/Battle/Logic/Buff/Shield.lua +++ b/luafight/Modules/Battle/Logic/Buff/Shield.lua @@ -1,5 +1,8 @@ Shield = Buff:New() - +-- 无敌吸血盾的免疫状态 +local immune0 = function(buff) + return buff.type == BuffName.Control or buff.isDeBuff or buff.type == BuffName.DOT +end --初始化Buff,通过传入一些自定义参数控制成长相关的数值 function Shield:SetData(...) @@ -10,6 +13,7 @@ function Shield:SetData(...) self.isBuff = true self.atk=nil --每次扣除护盾时,记录破盾的对象 + self.cover = self.shieldType ~= ShieldTypeName.NormalReduce -- 除固定减伤盾外都不能叠加 -- 刷新排序等级 self.sort = 4 end @@ -18,6 +22,9 @@ end function Shield:OnStart() self.target.shield:Add(self) + if self.shieldType == ShieldTypeName.AllReduce then + self.target.buffFilter:Add(immune0) + end end --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd @@ -49,10 +56,11 @@ function Shield:CountShield(damage, atkRole) elseif self.shieldType == ShieldTypeName.AllReduce then finalDamage = 0 - --TODO 计算吸血 - local treatValue = math.floor(BattleUtil.ErrorCorrection(damage * self.shieldValue)) - BattleUtil.ApplyTreat(self.target, self.target, treatValue) - + --TODO 计算吸血 + if self.shieldValue ~= 0 then + local treatValue = math.floor(BattleUtil.ErrorCorrection(damage * self.shieldValue)) + BattleUtil.ApplyTreat(self.target, self.target, treatValue) + end end return finalDamage @@ -98,6 +106,13 @@ function Shield:OnEnd() break end end + -- 移除免疫效果 + for i = 1, self.target.buffFilter.size do + if self.target.buffFilter.buffer[i] == immune0 then + self.target.buffFilter:Remove(i) + break + end + end end end diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index 1f39e3007..55f826de8 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -18,7 +18,7 @@ function RoleLogic.New() exCalDmgList=BattleList.New(), proTranList=BattleList.New(), buffFilter=BattleList.New(), - Event=BattleEvent:New(),passiveList={},isDead=false,IsDebug=false,enable=false} + Event=BattleEvent:New(),passiveList={},isDead=false,IsDebug=false} setmetatable(instance, RoleLogic) return instance end @@ -54,11 +54,6 @@ 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) - -- 怒气值 - self.Rage = 4 -- 当前怒气值 - self.RageGrow = 2 -- 普通技能怒气成长 - self.SuperSkillRage = 4 -- 技能需要释放的怒气值 - self.NoRageRate = 0 -- 不消耗怒气值的概率 -- 技能释放列表 技能改为按列表顺序释放 方便添加追加技能 self.SkillList = {} @@ -80,6 +75,12 @@ function RoleLogic:Init(uid, data, position) 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 @@ -87,18 +88,18 @@ function RoleLogic:Init(uid, data, position) self.IsDebug = false - self.enable = true --眩晕 - self.ctrl_slient = false --沉默 self.lockTarget = nil --嘲讽 + self.ctrl_dizzy = false --眩晕 不能释放所有技能 + self.ctrl_slient = false --沉默 只能1技能 + self.ctrl_palsy = false --麻痹 只能2技能 self.ctrl_noheal = false --禁疗 self.ctrl_blind = false --致盲 - self.ctrl_palsy = false --麻痹 end -- 添加一个被动技能 -function RoleLogic:AddPassive(id, args, isCover) +function RoleLogic:AddPassive(id, args, isRepeat) --判断是否可以叠加 - if not isCover then + if not isRepeat then -- 不可以叠加, 如果重复则不再加入 for _, pst in ipairs(self.passiveList) do if pst[1] == id then @@ -161,6 +162,8 @@ function RoleLogic:AddRage(value, type) elseif type == 4 then --乘减算(百分比属性减算) delta = -floor(value * self.SuperSkillRage) end + -- + self.Event:DispatchEvent(BattleEventName.RoleRageChange, delta) --怒气值不可为负值 self.Rage = max(self.Rage + delta, 0) end @@ -193,10 +196,23 @@ 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 () - self.proTranList:Remove(index) - end) + if duration then + BattleLogic.WaitForTrigger(duration, function () + self:RemovePropertyTransfer(index, proTran) + end) + end + return index, proTran end +-- 删除临时属性 +function RoleLogic:RemovePropertyTransfer(index, tran) + if index <= self.proTranList.size and tran == self.proTranList.buffer[index] then + self.proTranList:Remove(index) + end +end + + + + function RoleLogic:AddBuff(buff) if self.isDead then @@ -228,8 +244,16 @@ end -- 判断角色是否可以释放技能 function RoleLogic:IsAvailable() - -- 眩晕 -- 麻痹 -- 死亡 - if not self.enable or self.ctrl_palsy or self.isDead then + -- 眩晕 -- 死亡 + if self.ctrl_dizzy or self.isDead then + return false + end + -- 沉默麻痹同时存在 + if self.ctrl_palsy and self.ctrl_slient then + return false + end + -- 麻痹同时怒气不足 + if self.ctrl_palsy and self.Rage < self.SuperSkillRage then return false end return true @@ -254,8 +278,8 @@ function RoleLogic:CheckCastSkill() local _CheckNext = function () self:CheckCastSkill() end - -- 释放普通攻击 - if skill.type == BattleSkillType.Normal and self.skill then + -- 没有麻痹,释放普通攻击 + if skill.type == BattleSkillType.Normal and not self.ctrl_palsy then -- 释放普技 self.skill:Cast(_CheckNext, skill.targets, skill.isAdd) -- 后成长怒气 @@ -269,16 +293,21 @@ function RoleLogic:CheckCastSkill() -- self.Rage = self.Rage + grow end - -- 释放大技能 - elseif skill.type == BattleSkillType.Special and self.superSkill then + -- 没有沉默,释放大技能 + elseif skill.type == BattleSkillType.Special and not self.ctrl_slient then -- 先消耗怒气 if skill.isRage then + if self.Rage < self.SuperSkillRage then + -- 怒气值不足不能释放技能 + _CheckNext() + return + end -- 检测被动技能对怒气消耗的影响 local costRage = self.SuperSkillRage local noRageRate = self.NoRageRate - local _RageCostPassivity = function(finalRate, finalCost) - noRageRate = finalRate - costRage = finalCost + local _RageCostPassivity = function(rate, cost) + noRageRate = noRageRate + rate + costRage = costRage + cost end self.Event:DispatchEvent(BattleEventName.RoleRageCost, costRage, noRageRate, _RageCostPassivity) -- 计算消耗怒气的概率,并消耗怒气 @@ -320,28 +349,46 @@ function RoleLogic:CastSkill(func) self.SkillList = {} self.CurSkillCastIndex = 0 self.SkillCastDoneFunc = func - -- 沉默 怒气值不足 没有绝技 释放普通技能 - if self.ctrl_slient or self.Rage < self.SuperSkillRage or not self.superSkill then - self:AddSkill(BattleSkillType.Normal, true, false, nil) + -- 没有沉默 + if not self.ctrl_slient and self.Rage >= self.SuperSkillRage then + -- 释放大技能 + self:AddSkill(BattleSkillType.Special, true, false, nil) + self:CheckCastSkill() + return + end + -- 没有麻痹 释放普通技能 + if not self.ctrl_palsy then + self:AddSkill(BattleSkillType.Normal, true, false, nil) self:CheckCastSkill() - return end - -- 释放大技能 消耗怒气值 - self:AddSkill(BattleSkillType.Special, true, false, nil) self:CheckCastSkill() - end --- 强制释放技能,追加技能时使用 +-- 强制释放技能,测试技能时使用 -- type 追加的技能类型 1=普技 2=特殊技 -- targets 追加技能的目标 nil则自动选择目标 -- func 追加技能释放完成回调 function RoleLogic:ForceCastSkill(type, targets, func) + self.SkillList = {} + self.CurSkillCastIndex = 0 + self.SkillCastDoneFunc = func + + -- 清除技能控制 + self.ctrl_dizzy = false --眩晕 不能释放技能 + self.ctrl_slient = false --沉默 只能1技能 + self.ctrl_palsy = false --麻痹 只能2技能 + + -- 释放技能 if type == 1 and self.skill then - self.skill:Cast(func) + self:AddSkill(BattleSkillType.Normal, true, false, nil) + self:CheckCastSkill() elseif type == 2 and self.superSkill then - self.superSkill:Cast(func) + if self.Rage < self.SuperSkillRage then + self.Rage = self.SuperSkillRage + end + self:AddSkill(BattleSkillType.Special, true, false, nil) + self:CheckCastSkill() else if func then func() end end @@ -358,8 +405,4 @@ function RoleLogic:SkillCastDone() end function RoleLogic:Update() - if not self.enable then - return - end - -- self.updateFunc() end diff --git a/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java b/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java index 8e3193b6d..b56cd83a0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java @@ -146,7 +146,8 @@ public enum ErrorCode implements IErrorCode { ANNOUNCE_SIZE(112,"公会宣言长度不符"), ALREADY_LIKE(113,"今天已经给他点过赞了"), RED_PACKAGE_NOT(114,"该红包已不存在"), - NO_FRIEND_APPLY(115,"暂无可添加好友") + NO_FRIEND_APPLY(115,"暂无可添加好友"), + NO_USE_SAME_HERO(116,"不可上阵重复英雄") ;