战斗逻辑

back_recharge
lvxinran 2019-12-31 17:47:29 +08:00
parent 92ccef4f64
commit 66e13d239e
5 changed files with 153 additions and 55 deletions

View File

@ -43,6 +43,24 @@ local function calBuffHit(caster, target, baseRandom)
return baseRandom
end
local function clearBuffPredicate(buff, type)
local flag = false
if type == 1 then --持续恢复
flag = buff.type == BuffName.HOT
elseif type == 2 then --护盾
flag = buff.type == BuffName.Shield
elseif type == 3 then --增益状态
flag = buff.isBuff == true
elseif type == 4 then --减益状态
flag = buff.isDeBuff == true
elseif type == 5 then --持续伤害
flag = buff.type == BuffName.DOT
elseif type == 6 then --负面状态(控制状态、减益状态和持续伤害状态)
flag = buff.type == BuffName.Control or buff.isDeBuff or buff.type == BuffName.DOT
end
return flag
end
--效果表
local effectList = {
--造成[a]%的[b]伤害
@ -946,27 +964,9 @@ local effectList = {
[55] = function(caster, target, args, interval)
local ct = args[1]
BattleLogic.WaitForTrigger(interval, function ()
if ct == 1 then --持续恢复
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
return buff.type == BuffName.HOT
end)
elseif ct == 2 then --护盾
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
return buff.type == BuffName.Shield
end)
elseif ct == 3 then --增益状态
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
return buff.isBuff == true
end)
elseif ct == 4 then --减益状态
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
return buff.isDeBuff == true
end)
elseif ct == 5 then --持续伤害
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
return buff.type == BuffName.DOT
end)
end
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
return clearBuffPredicate(buff, ct)
end)
end)
end,
--造成目标当前生命[a]%的真实伤害,为我方角色回复此技能所有由此效果带来的伤害,平均分配给我方生命最低的[b]个角色。
@ -1162,7 +1162,7 @@ local effectList = {
end
end)
end,
--造成[a]%的[b]伤害,[c]的概率附加一层增伤印记,最大[d]层。目标身上每层印记增加此技能[e]%的伤害。【aoe】
--造成[a]%的[b]伤害,[c]的概率附加一层增伤印记,最大[d]层。目标身上每层印记增加此技能[e]%的伤害。(减益印记,不可驱散)
--a[float],b[伤害类型],c[float],d[int],e[float]
[66] = function(caster, target, args, interval)
local f1 = args[1]
@ -1170,6 +1170,7 @@ local effectList = {
local f2 = args[3]
local i1 = args[4]
local f3 = args[5]
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local brand = Buff.Create(caster, BuffName.Brand, 0, "zengshang")
brand.maxLayer = i1
@ -1543,18 +1544,7 @@ local effectList = {
BattleUtil.RandomAction(f1, function ()
local count = 0
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
local flag = false
if ct == 1 then --持续恢复
flag = buff.type == BuffName.HOT
elseif ct == 2 then --护盾
flag = buff.type == BuffName.Shield
elseif ct == 3 then --增益状态
flag = buff.isBuff == true
elseif ct == 4 then --减益状态
flag = buff.isDeBuff == true
elseif ct == 5 then --持续伤害
flag = buff.type == BuffName.DOT
end
local flag = clearBuffPredicate(buff, ct)
if flag then
count = count + 1
end
@ -1563,7 +1553,7 @@ local effectList = {
end)
end)
end,
--施加[a]的[b]%护盾,持续[c]秒。护盾被击破时,对敌方全体造成最大生命值[d]%的伤害。目标最大生命值伤害总上限为施法者2.5倍攻击)
--施加[a]的[b]%护盾,持续[c]秒。护盾被击破时,对击破者造成自身最大生命值[d]%的伤害。
--a[属性],b[float],c[int],d[float]
[84] = function(caster, target, args, interval)
local pro1 = args[1]
@ -1575,11 +1565,8 @@ local effectList = {
local shield = Buff.Create(caster, BuffName.Shield, f2, val, 0)
local OnBuffEnd = function(buff)
if buff == shield and buff.framePass < buff.frameDuration then --护盾被击破
local arr = BattleUtil.ChooseTarget(target, 20000)
for i=1, #arr do
local v1 = BattleUtil.FP_Mul(arr[i]:GetRoleData(RoleDataName.MaxHp), f3)
local v2 = BattleUtil.FP_Mul(caster:GetRoleData(RoleDataName.Attack),2.5)
BattleUtil.ApplyDamage(target, arr[i], floor(min(v1, v2)))
if buff.atk and not buff.atk.isTeam then
BattleUtil.ApplyDamage(target, buff.atk, BattleUtil.FP_Mul(target:GetRoleData(RoleDataName.MaxHp), f3))
end
end
end
@ -1777,18 +1764,7 @@ local effectList = {
BattleUtil.RandomAction(f2, function ()
local count = 0
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
local flag = false
if ct == 1 then --持续恢复
flag = buff.type == BuffName.HOT
elseif ct == 2 then --护盾
flag = buff.type == BuffName.Shield
elseif ct == 3 then --增益状态
flag = buff.isBuff == true
elseif ct == 4 then --减益状态
flag = buff.isDeBuff == true
elseif ct == 5 then --持续伤害
flag = buff.type == BuffName.DOT
end
local flag = clearBuffPredicate(buff, ct)
if flag then
count = count + 1
end
@ -1797,7 +1773,79 @@ local effectList = {
end)
end
end)
end
end,
--造成[a]%的[b]伤害,为自己施加一层印记,最大[c]层。增益印记不可驱散与95使用同一个印记
--a[float],b[伤害类型],c[int]
[94] = function(caster, target, args, interval)
local f1 = args[1]
local dt = args[2]
local i1 = args[3]
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.CalDamage(caster, target, dt, f1)
local brand = Buff.Create(caster, BuffName.Brand, 0, "zengyi")
brand.maxLayer = i1
brand.clear = false
brand.isBuff = true
caster:AddBuff(brand)
end)
end,
--造成[a]%的[b]伤害,自身每层印记增加此技能[c]%的伤害。增益印记不可驱散与94使用同一个印记
--a[float],b[伤害类型],c[float]
[95] = function(caster, target, args, interval)
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local layer = 0
if BattleLogic.BuffMgr:HasBuff(caster, BuffName.Brand, function (buff)
local b = buff.flag == "zengyi"
if b then
layer = buff.layer
end
return b
end) then
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
damagingFunc(-floor(BattleUtil.FP_Mul(f2, layer, damage)))
end
caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
BattleUtil.CalDamage(caster, target, dt, f1)
caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
else
BattleUtil.CalDamage(caster, target, dt, f1)
end
end)
end,
--[b]概率造成[c],每次造成[d]的真实伤害,在[e]秒内造成[f]次伤害。91异妖用(减益,不可驱散)
--b[float],c[持续伤害状态].d[float],e[int],f[int]
[96] = function(caster, target, args, interval)
local f4 = args[1]
local d1 = args[2]
local f1 = args[3]
local f2 = args[4]
local f3 = args[5]
BattleLogic.WaitForTrigger(interval, function ()
local DOT = Buff.Create(caster, BuffName.DOT, f2, f2/f3, d1, 0, f1)
DOT.clear = false
DOT.isDeBuff = true
buffRandomAction(f4, target, DOT)
end)
end,
--[a]概率在[c]秒里总共回复[d]次生命,每次恢复[b]生命。89异妖用(增益,不可驱散)
--a[float],b[float],c[int],d[int]
[97] = function(caster, target, args, interval)
local f4 = args[1]
local i1 = args[2]
local f2 = args[3]
local f3 = args[4]
BattleLogic.WaitForTrigger(interval, function ()
local HOT = Buff.Create(caster, BuffName.HOT, f2, f2/f3, i1)
HOT.clear = false
HOT.isBuff = true
buffRandomAction(f4, target, HOT)
end)
end,
}
return effectList

View File

@ -1352,5 +1352,46 @@ local passivityList = {
end
role.Event:AddEvent(BattleEventName.PassiveCriting, OnPassiveCriting)
end,
--释放技能时,自己损失[a]%当前生命值,为此次技能增加等量伤害。
--a[float]
[73] = function(role, args)
local f1 = args[1]
local hp=0
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
damagingFunc(-hp)
end
local OnSkillCast, OnSkillCastEnd
OnSkillCast = function(skill)
hp = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Hp), f1))
role.data:SubValue(RoleDataName.Hp, hp)
role.Event:RemoveEvent(BattleEventName.SkillCast, OnSkillCast)
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
end
OnSkillCastEnd = function(skill)
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () --延迟一帧移除事件,防止触发帧和结束帧为同一帧时,被动未移除
role.Event:RemoveEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
role.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
end)
end
role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast)
end,
--死亡时,为所有我方角色增加[a]%的[b]属性,持续[c]秒。
--a[float],b[属性],c[int]
[74] = function(role, args)
local f1 = args[1]
local pro = args[2]
local f2 = args[3]
local OnDead = function(atkRole)
local arr = BattleUtil.ChooseTarget(role, 10000)
for i=1, #arr do
arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, 2))
end
end
role.Event:AddEvent(BattleEventName.RoleDead, OnDead)
end,
}
return passivityList

View File

@ -1,5 +1,8 @@
Immune = Buff:New()
local immune0 = function(buff)
return buff.type == BuffName.Control or buff.isDeBuff or buff.type == BuffName.DOT
end
local immune1 = function(buff)
return buff.type == BuffName.Control
end
@ -17,7 +20,9 @@ end
--初始化后调用一次
function Immune:OnStart()
--log("Immune:OnStart")
if self.immuneType == 1 then --免疫控制状态
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
self.target.buffFilter:Add(immune0)
elseif self.immuneType == 1 then --免疫控制状态
self.target.buffFilter:Add(immune1)
elseif self.immuneType == 2 then --免疫dot
self.target.buffFilter:Add(immune2)
@ -34,7 +39,9 @@ end
function Immune:OnEnd()
--log("Immune:OnEnd")
local immune
if self.immuneType == 1 then --免疫控制状态
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
immune = immune0
elseif self.immuneType == 1 then --免疫控制状态
immune = immune1
elseif self.immuneType == 2 then --免疫dot
immune = immune2

View File

@ -7,6 +7,7 @@ function Shield:SetData(...)
self.dmgReboundFactor = ... --伤害反弹系数
self.damageSum = 0 --记录承受的伤害
self.isBuff = true
self.atk=nil --每次扣除护盾时,记录破盾的对象
end
--初始化后调用一次

View File

@ -152,6 +152,7 @@ end
function BattleUtil.CalShield(atkRole, defRole, damage)
for i=1, defRole.shield.size do
local buff = defRole.shield.buffer[i]
buff.atk = atkRole
if damage < buff.shieldValue then
buff.shieldValue = buff.shieldValue - damage
buff.damageSum = buff.damageSum + damage