战斗逻辑

back_recharge
lvxinran 2020-05-24 00:04:06 +08:00
parent e94cd2d5c4
commit c31dcffc5d
7 changed files with 883 additions and 112 deletions

View File

@ -2065,25 +2065,42 @@ local effectList = {
local f3 = args[6]
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target)
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
-- 检测被动技能对秒杀参数得影响
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()
-- 秒杀
BattleUtil.Seckill(skill, caster, target)
end)
end
local isSecKill = false
if 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
isSecKill = BattleUtil.RandomAction(f3, function()
-- 秒杀
BattleUtil.Seckill(skill, caster, target)
end)
end
end
-- 不秒杀造成伤害
if not isSecKill then
BattleUtil.CalDamage(skill, caster, target, dt, f1)
end
--
-- 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()
-- -- 秒杀
-- BattleUtil.Seckill(skill, caster, target)
-- end)
-- end
-- end
-- end
target.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
BattleUtil.CalDamage(skill, caster, target, dt, f1)
target.Event:RemoveEvent(BattleEventName.RoleBeHit, OnBeHit)
-- target.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
-- BattleUtil.CalDamage(skill, caster, target, dt, f1)
-- target.Event:RemoveEvent(BattleEventName.RoleBeHit, OnBeHit)
end)
end,
@ -2147,7 +2164,7 @@ local effectList = {
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target)
BattleLogic.WaitForTrigger(interval, function ()
local damage = BattleUtil.ErrorCorrection(f2 * caster:GetRoleData(BattlePropList[pro]))
BattleUtil.RandomDot(f1, dot, caster, target, i1, 1, damage)
BattleUtil.RandomDot(f1, dot, caster, target, i1, 1, floor(damage))
end)
end,

View File

@ -26,6 +26,19 @@ local min = math.min
-- RoleDataName.Tenacity,
-- RoleDataName.InitRage,
-- }
PassiveManager = {}
PassiveManager.passiveCountList = {
[0] = {},
[1] = {}
}
function PassiveManager.Init()
PassiveManager.passiveCountList = {
[0] = {},
[1] = {}
}
end
--被动技能表
local passivityList = {
@ -1875,7 +1888,9 @@ local passivityList = {
caster.Event:DispatchEvent(BattleEventName.PassiveBeRebackDamage, _CallBack)
rDamage = floor(BattleUtil.ErrorCorrection(BattleUtil.CountChangeList(rDamage, cl)))
BattleUtil.ApplyDamage(nil, role, caster, rDamage)
if rDamage ~= 0 then
BattleUtil.ApplyDamage(nil, role, caster, rDamage)
end
end
end
role.Event:AddEvent(BattleEventName.RoleBeHit, onBeHit)
@ -2075,7 +2090,7 @@ local passivityList = {
local onSkillCast = function(skill)
if skill.type == BattleSkillType.Normal then
af = 0
elseif skill.type == BattleSkillType.Normal then
elseif skill.type == BattleSkillType.Special then
af = af + f1
end
end
@ -2228,8 +2243,11 @@ local passivityList = {
local level = floor(lostDamage/levelDamage)
if level > curLevel then
local dl = level - curLevel
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f2*dl, dt)
role:AddBuff(buff)
for i = 1, dl do
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f2, dt)
buff.cover = true
role:AddBuff(buff)
end
curLevel = level
end
end
@ -2825,7 +2843,7 @@ local passivityList = {
local f2 = args[3]
--
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
if skill and skill.type == BattleSkillType.Normal and not skill.isAdd and not defRole:IsDead() then
if skill and skill.type == BattleSkillType.Normal and not defRole:IsDead() 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, role, defRole)
@ -3048,14 +3066,20 @@ local passivityList = {
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoleDead, onBattleRoleDead)
--
local cNum = 0 -- 释放技能前记录此次技能提高伤害的目标数量,防止单次技能伤害不一致的问题
local function onSkillCast()
cNum = num
end
BattleLogic.Event:AddEvent(BattleEventName.SkillCast, onSkillCast)
-- 伤害提高
local function onPassiveDamaging(damagingFunc, atkRole, defRole, damage)
if atkRole.professionId == 2 and atkRole.camp == role.camp then
-- 技能伤害提高
local function onPassiveDamaging(damagingFunc, atkRole, defRole, damage, skill)
if atkRole.professionId == 2 and atkRole.camp == role.camp and skill and skill.type == BattleSkillType.Special then
-- 地元素特殊
local f = atkRole.element == ele and f2 or f1
local dd = BattleUtil.CountValue(damage, f * num, CountTypeName.AddPencent) - damage
local dd = BattleUtil.CountValue(damage, f * cNum, CountTypeName.AddPencent) - damage
damagingFunc(-floor(BattleUtil.ErrorCorrection(dd)))
end
end
@ -3069,13 +3093,14 @@ local passivityList = {
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)))
local function onCritDamageReduceFactor(damagingFunc, atkRole, defRole)
if defRole == role then
if damagingFunc then
damagingFunc(f1, ct)
end
end
end
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, onPassiveBeDamaging)
role.Event:AddEvent(BattleEventName.CritDamageReduceFactor, onCritDamageReduceFactor)
end,
-- 战斗中生命每减少[a]%,自身伤害就[b]改变[c]%,减少为[d]改变
@ -3974,5 +3999,678 @@ local passivityList = {
end,
-- 如果自身是[a],则[d]改变[b]的[c][g改变[e]的[f]
-- a[位置],b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型]
[208] = function(role, args)
local i1 = args[1]
local f1 = args[2]
local pro1 = args[3]
local ct1 = args[4]
local f2 = args[5]
local pro2 = args[6]
local ct2 = args[7]
if BattleUtil.GetRolePosType(role.position) == i1 then
BattleUtil.AddProp(role, pro1, f1, ct1)
BattleUtil.AddProp(role, pro2, f2, ct2)
end
end,
-- 我方[a]武将全部阵亡后,如果自身是[a],则[d]改变[b]的[c]
-- a[位置],b[位置],c[float],d[属性],e[改变类型]
[209] = function(role, args)
local i1 = args[1]
local i2 = args[2]
local f1 = args[3]
local pro = args[4]
local ct = args[5]
local function _OnRoleRealDead(deadRole)
if role.camp == deadRole.camp then
local list = BattleUtil.GetRoleListByPosType(role.camp, i1)
if not list or #list == 0 then
if BattleUtil.GetRolePosType(role.position) == i2 then
BattleUtil.AddProp(role, pro, f1, ct)
-- 移除事件监听
BattleLogic.Event:RemoveEvent(BattleEventName.RoleRealDead, _OnRoleRealDead)
end
end
end
end
BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, _OnRoleRealDead)
end,
-- 如果自身是[a]和[b]武将则[e]改变[c]的[d]
-- a[类型],b[类型],c[float],d[属性],e[改变类型]
[210] = function(role, args)
local pf1 = args[1]
local pf2 = args[2]
local f1 = args[3]
local pro = args[4]
local ct = args[5]
if role.professionId == pf1 or role.professionId == pf2 then
BattleUtil.AddProp(role, pro, f1, ct)
end
end,
-- 第[a]回合开始时,如果自身血量最低,则恢复[b]*[c]的血量
-- a[int],b[属性],c[float]
[211] = function(role, args)
if PassiveManager.passiveCountList[role.camp][211] and PassiveManager.passiveCountList[role.camp][211] > 0 then
return
end
PassiveManager.passiveCountList[role.camp][211] = 1
local round = args[1]
local pro = args[2]
local f1 = args[3]
local function onRoundChange(curRound)
if curRound == round then
local list = RoleManager.Query(function(r) return r.camp == role.camp end)
list = BattleUtil.SortByProp(list, RoleDataName.Hp, 1)
local base = list[1]:GetRoleData(BattlePropList[pro])
local value = floor(BattleUtil.ErrorCorrection(base* f1))
BattleUtil.ApplyTreat(list[1], list[1], value)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange)
end,
-- 战斗开始时, 自身血量高于[a]% 则[d]改变[b]的[c]
-- a[float],b[float],c[属性],d[改变类型]
[212] = function(role, args)
local f1 = args[1]
local f2 = args[2]
local pro = args[3]
local ct = args[4]
local hp = role:GetRoleData(RoleDataName.Hp)
local maxHp = role:GetRoleData(RoleDataName.MaxHp)
if hp/maxHp >= f1 then
BattleUtil.AddProp(role, pro, f2, ct)
end
end,
-- 战斗开始时,回复自身[a]点怒气 --
-- a[int]
[213] = function(role, args)
local i1 = args[1]
local function onRoundChange(curRound)
if curRound == 1 then
role:AddRage(i1, CountTypeName.Add)
-- BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, onRoundChange)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange)
end,
-- 同阵营只会有一个生效
-- 第[a]回合中,敌人受到的任何伤害会对其他敌人造成该伤害[b]%的伤害
-- a[float],b[float]
[214] = function(role, args)
if PassiveManager.passiveCountList[role.camp][214] and PassiveManager.passiveCountList[role.camp][214] > 0 then
return
end
PassiveManager.passiveCountList[role.camp][214] = 1
local i1 = args[1]
local f1 = args[2]
local function OnDamage(func, atkRole, defRole, damage, skill, dotType, bCrit, damageType)
if defRole.camp ~= role.camp then
if skill or dotType then
local list = RoleManager.Query(function(r) return r.camp == defRole.camp and r ~= defRole end)
for _, r in ipairs(list) do
local dd = floor(BattleUtil.ErrorCorrection(damage* f1))
BattleUtil.ApplyDamage(nil, role, r, dd)
end
end
end
end
local function onRoundChange(curRound)
if curRound == i1 then
BattleLogic.Event:AddEvent(BattleEventName.FinalDamage, OnDamage)
elseif curRound == i1 + 1 then
BattleLogic.Event:RemoveEvent(BattleEventName.FinalDamage, OnDamage)
-- BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, onRoundChange)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange)
end,
-- 战斗开始时,使随机一名敌人受到的伤害增加[a]%,持续[b]回合。持续期间目标敌人死亡时,转移给另一名随机敌人
-- a[float],b[int]
[215] = function(role, args)
if PassiveManager.passiveCountList[role.camp][215] and PassiveManager.passiveCountList[role.camp][215] > 0 then
return
end
PassiveManager.passiveCountList[role.camp][215] = 1
local f1 = args[1]
local i1 = args[2]
local target
local function RandomTarget()
local list = RoleManager.Query(function(r)
return r.camp ~= role.camp
end)
if #list < 1 then return end
local index = Random.RangeInt(1, #list)
target = list[index]
end
-- 伤害增加
local function _OnPassiveDamaging(damagingFunc, atkRole, defRole, damage)
if defRole == target then
local dd = floor(BattleUtil.ErrorCorrection(damage* f1))
if damagingFunc then damagingFunc(-dd) end
end
end
-- 死亡重新随机
local function _OnRoleRealDead(deadRole)
if deadRole == target then
RandomTarget()
end
end
--
local function onRoundChange(curRound)
if curRound == 1 then
RandomTarget()
BattleLogic.Event:AddEvent(BattleEventName.PassiveDamaging, _OnPassiveDamaging)
BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, _OnRoleRealDead)
elseif curRound == i1 + 1 then
target = nil
BattleLogic.Event:RemoveEvent(BattleEventName.PassiveDamaging, _OnPassiveDamaging)
BattleLogic.Event:RemoveEvent(BattleEventName.RoleRealDead, _OnRoleRealDead)
-- BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, onRoundChange)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange)
end,
-- 第[a]回合开始时,对敌方全体造成目标最大生命值[b]%的伤害,并有[c]%概率造成[d]效果,持续[e]回合。
-- a[int],b[float],c[float],d[控制类型],e[int]
[216] = function(role, args)
if PassiveManager.passiveCountList[role.camp][216] and PassiveManager.passiveCountList[role.camp][216] > 0 then
return
end
PassiveManager.passiveCountList[role.camp][216] = 1
local i1 = args[1]
local f1 = args[2]
local f2 = args[3]
local ctrl = args[4]
local i2 = args[5]
local function onRoundChange(curRound)
if curRound == i1 then
local list = RoleManager.Query(function(r) return r.camp ~= role.camp end)
for _, r in ipairs(list) do
--
local dd = floor(BattleUtil.ErrorCorrection(r:GetRoleData(RoleDataName.MaxHp)* f1))
local das = BattleUtil.PreCountShield(r, dd) -- 计算护盾吸收后的伤害值
local hp = r:GetRoleData(RoleDataName.Hp)
-- 有瑕疵百分比减伤盾可能出现剩余血量不为1的问题
if das > hp then -- 护盾后伤害值依然致死
dd = dd - das + hp - 1
end
BattleUtil.ApplyDamage(nil, role, r, dd)
--概率控制
BattleUtil.RandomControl(f2, ctrl, role, r, i2)
end
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange)
end,
-- 战斗结束时,恢复自身[a]的损失血量
-- a[float]
[217] = function(role, args)
local f1 = args[1]
local function onBeforeBattleEnd()
if not role:IsDead() then
local maxHp = BattleUtil.ErrorCorrection(role:GetRoleData(RoleDataName.MaxHp))
local hp = BattleUtil.ErrorCorrection(role:GetRoleData(RoleDataName.Hp))
local dd = floor((maxHp - hp) * f1)
BattleUtil.ApplyTreat(role, role, dd)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BeforeBattleEnd, onBeforeBattleEnd)
end,
--[218] 用 79实现
-- 敌方首次释放技能时,自身获得[a]*[b]的护盾,持续[c]回合
-- a[属性],b[float],c[int]
[219] = function(role, args)
local pro = args[1]
local f1 = args[2]
local i1 = args[3]
local counter = 0
local function _OnSkillCast(skill)
if counter == 0 and skill.owner.camp ~= role.camp and skill.type == BattleSkillType.Special then
local dd = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro])*f1))
local buff = Buff.Create(skill.owner, BuffName.Shield, i1, ShieldTypeName.NormalReduce, dd, 0)
role:AddBuff(buff)
counter = counter + 1
-- BattleLogic.Event:RemoveEvent(BattleEventName.SkillCast, _OnSkillCast)
end
end
BattleLogic.Event:AddEvent(BattleEventName.SkillCast, _OnSkillCast)
end,
-- 每当敌方英雄死亡时,自身[d]改变[b]的[c][g改变[e]的[f]
-- b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型]
[220] = function(role, args)
local f1 = args[1]
local pro1 = args[2]
local ct1 = args[3]
local f2 = args[4]
local pro2 = args[5]
local ct2 = args[6]
local function _OnRoleRealDead(deadRole)
if role.camp ~= deadRole.camp then
BattleUtil.AddProp(role, pro1, f1, ct1)
BattleUtil.AddProp(role, pro2, f2, ct2)
end
end
BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, _OnRoleRealDead)
end,
-- 我方武将造成伤害时,[a]概率降低目标[b]%的[c]。若同时拥有效果222则降低的属性加给伤害者。
-- a[float],b[float],c[属性]
[221] = function(role, args)
local rand = args[1]
local f1 = args[2]
local pro = args[3]
role:AddBuff(Buff.Create(role, BuffName.Brand, 0, "YUAN")) -- 鸳
--
local function _OnRoleHit(target)
BattleUtil.RandomAction(rand, function()
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, CountTypeName.Sub)
buff.cover = true
buff.maxLayer = 1
target:AddBuff(buff)
-- BattleUtil.AddProp(target, pro, f1, CountTypeName.Sub)
if BattleLogic.BuffMgr:HasBuff(role, BuffName.Brand, function(buff) return buff.flag == "YANG" end) then
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, CountTypeName.Add)
buff.cover = true
buff.maxLayer = 1
role:AddBuff(buff)
-- BattleUtil.AddProp(role, pro, f1, CountTypeName.Add)
end
end)
end
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
end,
-- 我方武将造成伤害时,[a]概率降低目标[b]%的[c]。若同时拥有效果221则降低的属性加给伤害者。
-- a[float],b[float],c[属性]
[222] = function(role, args)
local rand = args[1]
local f1 = args[2]
local pro = args[3]
role:AddBuff(Buff.Create(role, BuffName.Brand, 0, "YANG")) -- 鸯
--
local function _OnRoleHit(target)
BattleUtil.RandomAction(rand, function()
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, CountTypeName.Sub)
buff.cover = true
buff.maxLayer = 1
target:AddBuff(buff)
-- BattleUtil.AddProp(target, pro, f1, CountTypeName.Sub)
if BattleLogic.BuffMgr:HasBuff(role, BuffName.Brand, function(buff) return buff.flag == "YUAN" end) then
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, CountTypeName.Add)
buff.cover = true
buff.maxLayer = 1
role:AddBuff(buff)
-- BattleUtil.AddProp(role, pro, f1, CountTypeName.Add)
end
end)
end
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
end,
-- 我方武将造成伤害时,[a]概率附加[b]效果,每回合造成攻击[c]%的伤害,持续[d]秒。
-- a[float],b[持续伤害效果],c[float],d[int]
[223] = function(role, args)
local rand = args[1]
local dot = args[2]
local f1 = args[3]
local i1 = args[3]
local function _OnRoleHit(target)
-- BattleUtil.RandomDot(rand, dot, role, target, i1, 1, )
BattleUtil.RandomAction(rand, function()
target:AddBuff(Buff.Create(role, BuffName.DOT, i1, 1, dot, 2, f1))
end)
end
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
end,
-- 我方武将造成伤害时,[a]概率附加攻击[b]%的真伤。
-- a[float],b[float]
[224] = function(role, args)
local rand = args[1]
local f1 = args[2]
local function _OnRoleHit(target)
BattleUtil.RandomAction(rand, function()
-- local dd = floor(BattleUtil.ErrorCorrection(role:GetRoleData(RoleDataName.Attack)*f1))
BattleUtil.CalDamage(nil, role, target, 1, f1, 1)
end)
end
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
end,
-- 斩杀生命低于[a]的敌人
-- a[float]
[226] = function(role, args)
local f1 = args[1]
--
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
if skill and not defRole:IsDead() then
-- 检测被动技能对秒杀参数得影响
local bf, kf = BattleUtil.CheckSeckill(f1, 0, role, defRole)
--
local ft = defRole:GetRoleData(RoleDataName.Hp)/defRole:GetRoleData(RoleDataName.MaxHp)
if ft < bf then
-- 秒杀
BattleUtil.Seckill(skill, role, defRole)
end
end
end
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
end,
-- 杀敌回复自身[a]*[b]的血量
-- a[属性],b[float]
[227] = function(role, args)
local pro = args[1]
local f1 = args[2]
-- 杀敌回血
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
if skill and defRole:IsDead() then
-- 回血
local dd = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro])*f1))
BattleUtil.ApplyTreat(role, role, dd)
end
end
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
end,
-- 敌人生命越高,造成的伤害越高,最高[a]%
-- a[float]
[228] = function(role, args)
local f1 = args[1]
local OnPassiveDamaging = function(damagingFunc, target, damage)
damagingFunc(-floor(BattleUtil.FP_Mul(f1, damage, BattleUtil.GetHPPencent(target))))
end
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
end,
-- 自己血量越低,造成伤害越高,最多[a]%
-- a[float]
[229] = function(role, args)
local f1 = args[1]
local OnPassiveDamaging = function(damagingFunc, target, damage)
damagingFunc(-floor(BattleUtil.FP_Mul(f1, damage, 1 - BattleUtil.GetHPPencent(role))))
end
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
end,
-- 同阵营只生效一次
-- 敌方武将[c]改变[a]的[b]
-- a[float],b[属性],c[改变类型]
[230] = function(role, args)
if PassiveManager.passiveCountList[role.camp][230] and PassiveManager.passiveCountList[role.camp][230] > 0 then
return
end
PassiveManager.passiveCountList[role.camp][230] = 1
local f1 = args[1]
local pro = args[2]
local ct = args[3]
local function _OnRoundChange(curRound)
if curRound == 1 then
local list = RoleManager.Query(function(r)
return r.camp ~= role.camp
end)
for _, r in ipairs(list) do
BattleUtil.AddProp(r, pro, f1, ct)
end
-- BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end,
-- 我方[a]武将每回合[d]改变[b]的[c],可叠加
-- a[元素],b[float],c[属性],d[改变类型]
[231] = function(role, args)
local ele = args[1]
local f1 = args[2]
local pro = args[3]
local ct = args[4]
local function _OnRoundChange(curRound)
if role.element == ele then
BattleUtil.AddProp(role, pro, f1, ct)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end,
-- 我方[a]武将每回合恢复[b]的损失血量
-- a[元素],b[float]
[232] = function(role, args)
local ele = args[1]
local f1 = args[2]
local function _OnRoundChange(curRound)
if role.element == ele then
local maxHp = BattleUtil.ErrorCorrection(role:GetRoleData(RoleDataName.MaxHp))
local hp = BattleUtil.ErrorCorrection(role:GetRoleData(RoleDataName.Hp))
local dd = floor((maxHp - hp) * f1)
BattleUtil.ApplyTreat(role, role, dd)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end,
-- 我方[a]武将每回合获得[b]*[c]的护盾,持续[d]回合
-- a[元素],b[属性],c[float],d[int]
[233] = function(role, args)
local ele = args[1]
local pro = args[2]
local f1 = args[3]
local i1 = args[4]
local function _OnRoundChange(curRound)
if role.element == ele then
local dd = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro])*f1))
local buff = Buff.Create(role, BuffName.Shield, i1, ShieldTypeName.NormalReduce, dd, 0)
role:AddBuff(buff)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end,
-- 我方[a]武将每回合[b]概率回复[c]点怒气
-- a[元素],b[float],c[int]
[234] = function(role, args)
local ele = args[1]
local f1 = args[2]
local i1 = args[3]
local function _OnRoundChange(curRound)
if role.element == ele then
BattleUtil.RandomAction(f1, function()
role:AddRage(i1, CountTypeName.Add)
end)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end,
-- 我方每有一个[a]武将,自身[d]改变[b]的[c],可叠加(第一回合开始时生效)
-- a[元素],b[float],c[属性],d[改变类型]
[235] = function(role, args)
local ele = args[1]
local f1 = args[2]
local pro = args[3]
local ct = args[4]
local function _OnRoundChange(curRound)
if curRound == 1 then
local list = RoleManager.Query(function(r)
return r.camp == role.camp and r.element == ele
end)
--
local num = #list
BattleUtil.AddProp(role, pro, f1*num, ct)
end
end
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, _OnRoundChange)
end,
-- 猎妖之路专属
-- 根据同时拥有夜明珠的数量获得效果2个[c]改变[a]的[b]3个[f]改变[d]的[e]4个[i]改变[g]的[h]
-- a[float],b[属性],c[改变类型],d[float],e[属性],f[改变类型],g[float],h[属性],i[改变类型]
[237] = function(role, args)
local f1 = args[1]
local pro1 = args[2]
local ct1 = args[3]
local f2 = args[4]
local pro2 = args[5]
local ct2 = args[6]
local f3 = args[7]
local pro3 = args[8]
local ct3 = args[9]
local num = OutDataManager.GetOutData(role.camp, OutDataName.DarkGlowBallNum)
if num >= 2 then
BattleUtil.AddProp(role, pro1, f1, ct1)
end
if num >= 3 then
BattleUtil.AddProp(role, pro2, f2, ct2)
end
if num >= 4 then
BattleUtil.AddProp(role, pro3, f3, ct3)
end
end,
-- 猎妖之路专属
-- 在大闹天空的第[a]层中,我方武将[d]改变[b]的[c][g改变[e]的[f]
-- a[位置],b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型]
[238] = function(role, args)
local flr = args[1]
local f1 = args[2]
local pro1 = args[3]
local ct1 = args[4]
local f2 = args[5]
local pro2 = args[6]
local ct2 = args[7]
if OutDataManager.GetOutData(role.camp, OutDataName.DaNaoTianGongFloor) == flr then
BattleUtil.AddProp(role, pro1, f1, ct1)
BattleUtil.AddProp(role, pro2, f2, ct2)
end
end,
-- 猎妖之路专属
-- 每有一件紫色品质以上的战利品,我方武将[d]改变[b]的[c][g改变[e]的[f],最多[h]层
-- b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型],h[int]
[239] = function(role, args)
local f1 = args[1]
local pro1 = args[2]
local ct1 = args[3]
local f2 = args[4]
local pro2 = args[5]
local ct2 = args[6]
local maxNum = args[7]
-- 紫+橙
local num = OutDataManager.GetOutData(role.camp, OutDataName.PerpleGloryItemNum) + OutDataManager.GetOutData(role.camp, OutDataName.OrangeGloryItemNum)
num = min(maxNum, num)
BattleUtil.AddProp(role, pro1, f1 * num, ct1)
BattleUtil.AddProp(role, pro2, f2 * num, ct2)
end,
-- 猎妖之路专属
-- 每使用一次神秘药水,我方武将[c]改变[a]的[b],最多[d]层
-- a[float],b[属性],c[改变类型],d[int]
[240] = function(role, args)
local f1 = args[1]
local pro1 = args[2]
local ct1 = args[3]
local maxNum = args[4]
-- 紫+橙
local num = OutDataManager.GetOutData(role.camp, OutDataName.MisteryLiquidUsedTimes)
num = min(maxNum, num)
BattleUtil.AddProp(role, pro1, f1 * num, ct1)
end,
-- 每当友方英雄死亡时,自身[d]改变[b]的[c][g]改变[e]的[f]
-- b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型]
[241] = function(role, args)
local f1 = args[1]
local pro1 = args[2]
local ct1 = args[3]
local f2 = args[4]
local pro2 = args[5]
local ct2 = args[6]
local function _OnRoleRealDead(deadRole)
if role.camp == deadRole.camp then
BattleUtil.AddProp(role, pro1, f1, ct1)
BattleUtil.AddProp(role, pro2, f2, ct2)
end
end
BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, _OnRoleRealDead)
end,
}
return passivityList

View File

@ -1,6 +1,7 @@
require("Modules.Battle.Logic.SkillManager")
require("Modules.Battle.Logic.RoleManager")
require("Modules.Battle.Logic.OutDataManager")
@ -85,6 +86,8 @@ function BattleLogic.Init(data, optionData, maxRound)
RoleManager.Init()
SkillManager.Init()
OutDataManager.Init(fightData)
PassiveManager.Init()
end
function BattleLogic.StartOrder()
@ -303,6 +306,10 @@ end
-- 战斗结束
function BattleLogic.BattleEnd(result)
--
BattleLogic.Event:DispatchEvent(BattleEventName.BeforeBattleEnd, result)
--
BattleLogic.IsEnd = true
BattleLogic.Result = result
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result)

View File

@ -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
@ -56,7 +56,7 @@ end
--只有当Cover字段为true时触发返回true则被新效果覆盖
function PropertyChange:OnCover(newBuff)
local b = self.propertyName == newBuff.propertyName and self.changeType == newBuff.changeType
local b = self:OnCompare(newBuff)
if b then
if newBuff.maxLayer == 0 then
newBuff.layer = newBuff.layer + self.layer
@ -75,7 +75,7 @@ end
-- 比较buff
function PropertyChange:OnCompare(buff)
return self.changeType == buff.changeType and self.propertyName == buff.propertyName
return self.changeType == buff.changeType and self.propertyName == buff.propertyName and self.duration == buff.duration
end
return PropertyChange

View File

@ -67,8 +67,30 @@ function Shield:CountShield(damage, atkRole)
end
end
--
-- self.caster.Event:DispatchEvent(BattleEventName.ShildTrigger, self)
self.target.Event:DispatchEvent(BattleEventName.ShildTrigger, self)
BattleLogic.Event:DispatchEvent(BattleEventName.ShildTrigger, self)
return finalDamage
end
-- 提前计算护盾吸收伤害
function Shield:PreCountShield(damage)
local finalDamage = 0
if self.shieldType == ShieldTypeName.NormalReduce then
if damage > self.shieldValue then
finalDamage = damage - self.shieldValue
end
elseif self.shieldType == ShieldTypeName.RateReduce then
local reduceDamage = math.floor(BattleUtil.ErrorCorrection(damage * self.shieldValue))
finalDamage = damage - reduceDamage
elseif self.shieldType == ShieldTypeName.AllReduce then
finalDamage = 0
end
return finalDamage
end
-- 改变护盾值(固定减伤盾:减伤值 百分比减伤盾:减伤百分比 无敌盾:吸血率)
function Shield:ChangeShieldValue(type, value)
@ -86,10 +108,13 @@ 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 = 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))
local dd = math.floor(self.dmgReboundFactor * self.damageSum)
if dd > 0 and self.atk then
BattleUtil.ApplyDamage(nil, self.target, self.atk, dd)
end
-- local arr = RoleManager.Query(function (r) return r.camp ~= self.target.camp end)
-- for j = 1, #arr do
-- end
self.target.shield:Remove(i)
break
end

View File

@ -7,6 +7,7 @@ end
BattleEventName = {
BattleOrderChange = indexAdd(),
BattleOrderEnd = indexAdd(),
BeforeBattleEnd = indexAdd(),
BattleEnd = indexAdd(),
AddRole = indexAdd(),
RemoveRole = indexAdd(),
@ -49,6 +50,8 @@ BattleEventName = {
FinalDamage = indexAdd(),
FinalBeDamage = indexAdd(),
CritDamageReduceFactor = indexAdd(), -- 暴击伤害减免系数
SkillCast = indexAdd(), -- 技能攻击前
SkillCastEnd = indexAdd(), -- 技能攻击结束
BeSkillCast = indexAdd(), -- 被技能攻击前
@ -68,6 +71,7 @@ BattleEventName = {
PassiveBeRandomControl = indexAdd(),
PassiveRandomDot = indexAdd(),
PassiveBeRandomDot = indexAdd(),
PassiveRebackDamage = indexAdd(),
PassiveBeRebackDamage = indexAdd(),
@ -104,6 +108,7 @@ BattleEventName = {
BuffDurationChange = indexAdd(),
ShildValueChange = indexAdd(),
ShildTrigger = indexAdd(),
Curse_ShareDamage = indexAdd(),
Be_Curse_ShareDamage = indexAdd(),
@ -217,4 +222,13 @@ BattlePropList = {
CurseTypeName = {
ShareDamage = 1,
}
OutDataName = {
DarkGlowBallNum = 1,
DaNaoTianGongFloor = 2,
PerpleGloryItemNum = 3,
OrangeGloryItemNum = 4,
MisteryLiquidUsedTimes = 5
}

View File

@ -262,17 +262,14 @@ function BattleUtil.CalShield(atkRole, defRole, damage)
for i=1, defRole.shield.size do
local buff = defRole.shield.buffer[i]
damage = buff:CountShield(damage, atkRole)
-- buff.atk = atkRole
-- if damage < buff.shieldValue then
-- buff.shieldValue = buff.shieldValue - damage
-- buff.damageSum = buff.damageSum + damage
-- return 0
-- else
-- buff.damageSum = buff.damageSum + buff.shieldValue
-- damage = damage - buff.shieldValue
-- buff.shieldValue = 0
-- buff.disperse = true
-- end
end
return damage
end
-- 提前计算护盾后伤害
function BattleUtil.PreCountShield(defRole, damage)
for i=1, defRole.shield.size do
local buff = defRole.shield.buffer[i]
damage = buff:PreCountShield(damage)
end
return damage
end
@ -330,7 +327,6 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy
-- 计算护盾减伤
damage = BattleUtil.CalShield(atkRole, defRole, damage)
-- 造成的最终伤害
local damagingFunc = function(dmgDeduction)
damage = damage - dmgDeduction
@ -384,13 +380,7 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedBefore, atkRole, factorFunc, damageType, skill)
baseFactor = BattleUtil.ErrorCorrection(baseFactor)
local bCrit = false
local baseDamage
-- 是否暴击: 暴击率 = 自身暴击率 - 对方抗暴率
local critRandom = Random.Range01()
local critCondition = clamp(atkRole:GetRoleData(RoleDataName.Crit)-defRole:GetRoleData(RoleDataName.Tenacity), 0, 1)
bCrit = critRandom <= critCondition
bCrit = bCrit or defRole.isFlagCrit == true -- 必定暴击
-- 防御(据伤害类型决定)
local defence = 0
if damageType == 1 then --1 物理 2 魔法
@ -402,68 +392,55 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i
local attack = atkRole:GetRoleData(RoleDataName.Attack)
-- 无视防御系数
ignoreDef = 1 - (ignoreDef or 0)
-- 基础伤害 = 攻击力 - 防御力
baseDamage = max(attack - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
-- 基础伤害增加系数
local addDamageFactor = 1 + atkRole:GetRoleData(RoleDataName.DamageBocusFactor) - defRole:GetRoleData(RoleDataName.DamageReduceFactor)
-- 是否暴击: 暴击率 = 自身暴击率 - 对方抗暴率
local bCrit = false
local critRandom = Random.Range01()
local critCondition = clamp(atkRole:GetRoleData(RoleDataName.Crit) - defRole:GetRoleData(RoleDataName.Tenacity), 0, 1)
bCrit = critRandom <= critCondition
bCrit = bCrit or defRole.isFlagCrit == true -- 必定暴击
-- 计算暴伤害系数
local critDamageFactor = 1
local critDamageReduceFactor = 0 -- 暴击伤害减免
--计算暴击
if bCrit then
--加入被动效果 触发暴击被动
local cl = {}
local onCritDamageReduceFactor = function(v, ct)
if v then
table.insert(cl, {v, ct})
end
end
atkRole.Event:DispatchEvent(BattleEventName.CritDamageReduceFactor, onCritDamageReduceFactor, atkRole, defRole)
defRole.Event:DispatchEvent(BattleEventName.CritDamageReduceFactor, onCritDamageReduceFactor, atkRole, defRole)
BattleLogic.Event:DispatchEvent(BattleEventName.CritDamageReduceFactor, onCritDamageReduceFactor, atkRole, defRole)
critDamageReduceFactor = max(BattleUtil.CountChangeList(critDamageReduceFactor, cl), 0)
-- 计算额外暴击伤害
local critDamageFactor = atkRole:GetRoleData(RoleDataName.CritDamageFactor)
critDamageFactor = 1.3 + atkRole:GetRoleData(RoleDataName.CritDamageFactor) - critDamageReduceFactor
--加入被动效果 触发暴击被动
local critFunc = function(critEx) critDamageFactor = critEx end
atkRole.Event:DispatchEvent(BattleEventName.PassiveCriting, critFunc)
--计算基础伤害:伤害 = 攻击力 * 暴击伤害系数 - 防御 *1 - 无视防御系数)
baseDamage = max(BattleUtil.FP_Mul(attack, critDamageFactor) - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
else
baseDamage = max(attack - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
end
-- 自身属性对应对方的属性伤害减免系数
local elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
if atkRole.element == 1 then
elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
elseif atkRole.element == 2 then
elementDamageReduceFactor = RoleDataName.WindDamageReduceFactor
elseif atkRole.element == 3 then
elementDamageReduceFactor = RoleDataName.IceDamageReduceFactor
elseif atkRole.element == 4 then
elementDamageReduceFactor = RoleDataName.LandDamageReduceFactor
elseif atkRole.element == 5 then
elementDamageReduceFactor = RoleDataName.LightDamageReduceFactor
elseif atkRole.element == 6 then
elementDamageReduceFactor = RoleDataName.DarkDamageReduceFactor
end
-- 公式伤害 = 基础伤害 * 基础伤害系数 * 增伤系数 * 爆伤系数
local fixDamage = floor(BattleUtil.FP_Mul(baseDamage, baseFactor, addDamageFactor, critDamageFactor))
--伤害 =(基础伤害*1+己伤害加成-目标伤害减免)*1+己方属性伤害加成-目标属性伤害减免10%*己攻)
baseDamage = BattleUtil.FP_Mul(baseDamage, baseFactor,
1 + atkRole:GetRoleData(RoleDataName.DamageBocusFactor) - defRole:GetRoleData(RoleDataName.DamageReduceFactor),
(1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor) - defRole:GetRoleData(elementDamageReduceFactor)))
--属性克制关系:光暗互克,火克风,风克地,地克水,水克火
-- local atkEle = atkRole.roleData.element
-- local defEle = defRole.roleData.element
-- local restrain = atkEle == 1 and defEle == 2 or
-- atkEle == 4 and defEle == 3 or
-- atkEle == 2 and defEle == 4 or
-- atkEle == 3 and defEle == 1 or
-- atkEle == 5 and defEle == 6 or
-- atkEle == 6 and defEle == 5
-- if restrain then
-- baseDamage = floor(max(BattleUtil.FP_Mul(1.25, baseDamage), BattleUtil.FP_Mul(0.1, attack)))
-- else
-- baseDamage = floor(max(baseDamage, BattleUtil.FP_Mul(0.1, attack)))
-- end
-- 计算
baseDamage = floor(max(baseDamage, BattleUtil.FP_Mul(0.1, attack)))
-- 计算额外伤害数值加成
local damageFunc = function(damage) baseDamage = damage end
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageAfter, defRole, damageFunc, baseDamage)
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedAfter, atkRole, damageFunc, baseDamage)
-- 公式计算完成
local damageFunc = function(damage) fixDamage = damage end
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageAfter, defRole, damageFunc, fixDamage)
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedAfter, atkRole, damageFunc, fixDamage)
local finalDmg = 0 --计算实际造成的扣血
if not defRole:IsRealDead() then
finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, baseDamage, bCrit, damageType, dotType)
finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, fixDamage, bCrit, damageType, dotType)
end
return finalDmg, bCrit
end
@ -706,13 +683,11 @@ 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
if bv and bct then
table.insert(bcl, {bv, bct})
end
if kv and kct then
table.insert(kcl, {kv, kct})
end
end
caster.Event:DispatchEvent(BattleEventName.PassiveSeckill, _CallBack)
@ -722,3 +697,38 @@ function BattleUtil.CheckSeckill(bf, kf, caster, target)
return bf, kf
end
-- 获取位置类型
-- 1 前排
-- 2 后排
function BattleUtil.GetRolePosType(pos)
if pos <= 3 then
return 1
elseif pos > 3 then
return 2
end
end
-- 根据位置类型获取数据
function BattleUtil.GetRoleListByPosType(camp, posType)
if posType == 1 then
return RoleManager.Query(function (r) return r.camp ~= camp and r.position <= 3 end)
elseif posType == 2 then
return RoleManager.Query(function (r) return r.camp ~= camp and r.position > 3 end)
end
end
-- 通用增加属性的方法
function BattleUtil.AddProp(role, prop, value, ct)
if ct == 1 then --加算
role.data:AddValue(BattlePropList[prop], value)
elseif ct == 2 then --乘加算(百分比属性加算)
role.data:AddPencentValue(BattlePropList[prop], value)
elseif ct == 3 then --减算
role.data:SubValue(BattlePropList[prop], value)
elseif ct == 4 then --乘减算(百分比属性减算)
role.data:SubPencentValue(BattlePropList[prop], value)
end
end