战斗同步
parent
5b18de9941
commit
69705d3ba1
|
@ -42,12 +42,16 @@ function Buff.Create(caster, type, duration, ...)
|
|||
-- buff.framePass = 0
|
||||
|
||||
buff.roundPass = 0
|
||||
|
||||
buff.startRound = BattleLogic.GetCurRound()
|
||||
|
||||
buff:SetData(...)
|
||||
return buff
|
||||
end
|
||||
|
||||
-- 设置触发间隔
|
||||
function Buff:SetInterval(interval)
|
||||
self.interval = interval
|
||||
return self
|
||||
end
|
||||
-- 改变buff的轮次
|
||||
function Buff:ChangeBuffDuration(type, value)
|
||||
-- 永久存在改变无效
|
||||
|
@ -57,7 +61,7 @@ function Buff:ChangeBuffDuration(type, value)
|
|||
|
||||
-- 计算
|
||||
local finalDuration = BattleUtil.ErrorCorrection(BattleUtil.CountValue(self.duration, value, type))
|
||||
self.duration = finalDuration
|
||||
self.duration = floor(finalDuration)
|
||||
if self.roundDuration then
|
||||
self.roundDuration = finalDuration
|
||||
end
|
||||
|
@ -257,11 +261,14 @@ function BuffManager:PassUpdate()
|
|||
if not buff.disperse -- 没过期
|
||||
and buff.caster.camp == curCamp -- 释放者是当前轮到的人
|
||||
and buff.caster.position == curPos then
|
||||
buff.roundPass = buff.roundPass + 1
|
||||
if buff.roundPass >= buff.roundDuration then
|
||||
buff.disperse = true
|
||||
-- 当前轮释放的buff不结算
|
||||
if buff.startRound ~= BattleLogic.GetCurRound() then
|
||||
buff.roundPass = buff.roundPass + 1
|
||||
if buff.roundPass >= buff.roundDuration then
|
||||
buff.disperse = true
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffRoundChange, buff)
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffRoundChange, buff)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -289,8 +296,6 @@ function BuffManager:TurnUpdate(sort)
|
|||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff)
|
||||
end
|
||||
else
|
||||
buff.disperse = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1974,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, 1)
|
||||
BattleUtil.SortByHpFactor(arr, 1)
|
||||
-- 治疗血量最低队友实际伤害的f2%
|
||||
BattleUtil.ApplyTreat(caster, arr[1], floor(finalDmg*f2))
|
||||
end
|
||||
|
@ -2051,12 +2051,12 @@ local effectList = {
|
|||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
|
||||
local OnBeHit = function()
|
||||
if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
|
||||
if target:GetRoleData(propertyList[pro1]) < f2 then
|
||||
if not target.isDead and BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
|
||||
local ft = target:GetRoleData(RoleDataName.Hp)/target:GetRoleData(RoleDataName.MaxHp)
|
||||
if ft < f2 then
|
||||
BattleUtil.RandomAction(f3, function()
|
||||
-- 秒杀
|
||||
local damage = target:GetRoleData(RoleDataName.Hp)
|
||||
BattleUtil.ApplyDamage(skill, caster, target, damage)
|
||||
BattleUtil.Seckill(skill, caster, target)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1673,7 +1673,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, 1)
|
||||
BattleUtil.SortByHpFactor(arr, 1)
|
||||
-- 治疗血量最低队友实际伤害的f1%
|
||||
BattleUtil.ApplyTreat(role, arr[1], floor(BattleUtil.ErrorCorrection(finalDmg*f1)))
|
||||
end
|
||||
|
@ -1767,7 +1767,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, 1)
|
||||
BattleUtil.SortByHpFactor(list, 1)
|
||||
local target = nil
|
||||
for i = 1, #list do
|
||||
if not list[i].isDead and list[i] ~= role then
|
||||
|
@ -1886,8 +1886,8 @@ local passivityList = {
|
|||
local f1 = args[1]
|
||||
local ctl = args[2]
|
||||
local i1 = args[3]
|
||||
local onRoleBeDamaged = function(caster)
|
||||
if role.isDead then
|
||||
local onRoleBeDamaged = function(caster, damage, bCrit, finalDmg, damageType, isDot, skill)
|
||||
if role.isDead and skill then
|
||||
BattleUtil.RandomAction(f1, function()
|
||||
caster:AddBuff(Buff.Create(role, BuffName.Control, i1, ctl))
|
||||
end)
|
||||
|
@ -1950,19 +1950,30 @@ local passivityList = {
|
|||
end,
|
||||
|
||||
|
||||
-- 战斗第[a]回合增加[b]%的[c],持续[d]回合,[f]改变
|
||||
-- a[int]b[float]c[属性]d[int]f[改变类型]
|
||||
-- 战斗第[a]回合增加[c]%的自身伤害持续[e]回合,[f]改变
|
||||
-- a[int]c[float]e[int]f[改变]
|
||||
[115] = function(role, args)
|
||||
local i1 = args[1]
|
||||
local f1 = args[2]
|
||||
local pro = args[3]
|
||||
local i2 = args[4] or 1
|
||||
local ct = args[5]
|
||||
local i2 = args[3] or 1
|
||||
local ct = args[4]
|
||||
|
||||
-- 如果是技能的伤害则判断加成
|
||||
local onPassiveDamaging = function(func, target, damage, skill)
|
||||
if skill then
|
||||
local dd = BattleUtil.CountValue(damage, f1, ct) - damage
|
||||
if func then func(-floor(BattleUtil.ErrorCorrection(dd))) end
|
||||
end
|
||||
end
|
||||
|
||||
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound)
|
||||
-- 第i1回合
|
||||
-- 第i1回合开始
|
||||
if curRound == i1 then
|
||||
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, i2, propertyList[pro], f1, ct))
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging)
|
||||
end
|
||||
-- 第i1+i2回合结束
|
||||
if curRound == i1 + i2 then
|
||||
role.Event:RemoveEvent(BattleEventName.PassiveDamaging, onPassiveDamaging)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
|
@ -1986,7 +1997,7 @@ local passivityList = {
|
|||
-- 技能目标每[a]改变[b]个,技能伤害增加[c]%,[d]改变
|
||||
-- a[改变类型]b[int]c[float]d[改变类型]
|
||||
[117] = function(role, args)
|
||||
local ct = args[1] -- 对方阵营中死亡数量
|
||||
local ct = args[1] -- 对方阵营中死亡数量(目前没有用到)
|
||||
local i1 = args[2]
|
||||
local f1 = args[3]
|
||||
local ct2 = args[4]
|
||||
|
@ -1997,9 +2008,16 @@ local passivityList = {
|
|||
local onSkillCast = function(skill)
|
||||
extra = 0
|
||||
if skill and skill.type == BattleSkillType.Special then
|
||||
local roleList =BattleLogic.Query(function (r) return r.camp ~= role.camp end)
|
||||
local deadNum = 6 - #roleList
|
||||
local level = math.floor(deadNum/i1)
|
||||
-- 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)
|
||||
|
||||
-- 改变值 = 技能最大目标数 - 当前目标数
|
||||
local maxNum = skill:GetMaxTargetNum()
|
||||
local curNum = #skill:GetDirectTargets()
|
||||
local lessNum = max(maxNum - curNum, 0)
|
||||
local level = math.floor(lessNum/i1)
|
||||
extra = BattleUtil.ErrorCorrection(level * f1)
|
||||
end
|
||||
end
|
||||
|
@ -2103,7 +2121,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:ChangeBuffDuration(ct, i1)
|
||||
end
|
||||
|
@ -2260,8 +2278,46 @@ local passivityList = {
|
|||
role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging)
|
||||
end,
|
||||
|
||||
-- 无132
|
||||
-- [132] = {},
|
||||
-- 直接伤害每次击杀目标增加自身伤害[a]%,[b]改变,可叠加持续至战斗结束
|
||||
-- a[float]b[改变类型]
|
||||
[132] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local ct = args[2]
|
||||
|
||||
local killNum = 0
|
||||
local extra = 0
|
||||
|
||||
-- 击杀数量累加
|
||||
local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
if skill and defRole.isDead then
|
||||
killNum = killNum + 1
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit)
|
||||
|
||||
|
||||
-- 释放技能时计算额外伤害
|
||||
local OnSkillCast = function(skill)
|
||||
if skill then
|
||||
extra = f1 * killNum
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast)
|
||||
|
||||
|
||||
-- 造成伤害时判断额外伤害
|
||||
local passivityDamaging = function(func, caster, damage, skill)
|
||||
if skill then
|
||||
if func then
|
||||
local dd = BattleUtil.CountValue(damage, extra, ct) - damage
|
||||
func(-floor(BattleUtil.ErrorCorrection(dd)))
|
||||
end
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging)
|
||||
|
||||
|
||||
end,
|
||||
|
||||
|
||||
-- 攻击时若目标[a]则当次攻击自身[b],[c]改变[d]%
|
||||
|
@ -2382,9 +2438,7 @@ local passivityList = {
|
|||
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)
|
||||
local auraBuff = Buff.Create(role, BuffName.HOT, i1, 1, tv)
|
||||
auraBuff.interval = 1
|
||||
r:AddBuff(auraBuff)
|
||||
end
|
||||
|
@ -2407,9 +2461,7 @@ local passivityList = {
|
|||
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)
|
||||
local auraBuff = Buff.Create(role, BuffName.HOT, i1, 1, tv)
|
||||
auraBuff.interval = 1
|
||||
r:AddBuff(auraBuff)
|
||||
end
|
||||
|
@ -2655,10 +2707,29 @@ local passivityList = {
|
|||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd)
|
||||
end,
|
||||
|
||||
-- TODO
|
||||
|
||||
-- 释放普通攻击如目标[a],且血量低于[b]%则有[c]%概率秒杀
|
||||
-- a[持续伤害状态]b[float]c[float]
|
||||
-- [151]
|
||||
[151] = function(role, args)
|
||||
local dot = args[1]
|
||||
local f1 = args[2]
|
||||
local f2 = args[3]
|
||||
--
|
||||
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
if skill and skill.type == BattleSkillType.Normal then
|
||||
if BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
|
||||
local ft = defRole:GetRoleData(RoleDataName.Hp)/defRole:GetRoleData(RoleDataName.MaxHp)
|
||||
if ft < f1 then
|
||||
BattleUtil.RandomAction(f2, function()
|
||||
-- 秒杀
|
||||
BattleUtil.Seckill(skill, role, defRole)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 释放技能有[a]%概率附加[b]效果持续[c]回合
|
||||
-- a[float]b[控制状态]c[int]
|
||||
|
@ -2851,7 +2922,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, 1)
|
||||
BattleUtil.SortByHpFactor(list, 1)
|
||||
local index = 0
|
||||
for i = 1, #list do
|
||||
if not list[i].isDead and index < 2 then
|
||||
|
@ -2890,11 +2961,7 @@ local passivityList = {
|
|||
local onRoleHit = function(target)
|
||||
if target.isDead then
|
||||
local list = BattleLogic.Query(function(v) return v.camp ~= role.camp end)
|
||||
table.sort(list, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.Hp) / a:GetRoleData(RoleDataName.MaxHp)
|
||||
local r2 = b:GetRoleData(RoleDataName.Hp) / b:GetRoleData(RoleDataName.MaxHp)
|
||||
return r1 < r2
|
||||
end)
|
||||
BattleUtil.SortByHpFactor(list, 1)
|
||||
local index = 0
|
||||
for i = 1, #list do
|
||||
if not list[i].isDead and index < 2 then
|
||||
|
@ -2905,6 +2972,27 @@ local passivityList = {
|
|||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
|
||||
--技能治疗系数[a]改变[b]%(作用于主动技能效果103)
|
||||
--a[改变类型]b[float]
|
||||
[206] = function(role, args)
|
||||
local ct = args[1]
|
||||
local f1 = args[2]
|
||||
|
||||
local onSkillEffectBefore = function(skill, e, func)
|
||||
if skill.type == BattleSkillType.Special then
|
||||
if e.type == 103 then -- 当前只对技能效果103生效
|
||||
local factor = BattleUtil.ErrorCorrection(BattleUtil.CountValue(e.args[3], f1, ct))
|
||||
e.args[3] = factor
|
||||
if func then func(e) end
|
||||
end
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillEffectBefore, onSkillEffectBefore)
|
||||
end,
|
||||
|
||||
}
|
||||
return passivityList
|
||||
|
|
|
@ -70,7 +70,22 @@ end
|
|||
|
||||
local function takeEffect(caster, target, effects, duration, skill)
|
||||
for k=1, #effects do
|
||||
local e = effects[k]
|
||||
local e = {type = 0, args = {}}
|
||||
e.type = effects[k].type
|
||||
for i=1, #effects[k].args do
|
||||
e.args[i] = effects[k].args[i]
|
||||
end
|
||||
|
||||
-- 检测被动技能对技能参数的影响
|
||||
local function _PassiveCheck(pe)
|
||||
if pe then
|
||||
e = pe
|
||||
end
|
||||
end
|
||||
caster.Event:DispatchEvent(BattleEventName.SkillEffectBefore, skill, e, _PassiveCheck)
|
||||
target.Event:DispatchEvent(BattleEventName.BeSkillEffectBefore, skill, e, _PassiveCheck)
|
||||
|
||||
--
|
||||
effect[e.type](caster, target, e.args, duration, skill)
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
BattleLogic.RecordEffect(caster, target, e.type, e.args, duration)
|
||||
|
@ -173,6 +188,14 @@ end
|
|||
function Skill:GetDirectTargets()
|
||||
return self.effectTargets[1]
|
||||
end
|
||||
-- 获取技能目标最大人数
|
||||
function Skill:GetMaxTargetNum()
|
||||
local mainEffect = self.effectList.buffer[1]
|
||||
if not mainEffect then
|
||||
return 0
|
||||
end
|
||||
return BattleUtil.GetMaxTargetNum(mainEffect.chooseId)
|
||||
end
|
||||
|
||||
-- 结束技能
|
||||
function Skill:EndSkill()
|
||||
|
|
|
@ -199,10 +199,7 @@ function BattleLogic.StartOrder()
|
|||
end
|
||||
|
||||
-- 开始战斗,延时一帧执行,避免战斗还没开始就释放了技能
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
-- 开始战斗
|
||||
BattleLogic.TurnRound()
|
||||
end)
|
||||
BattleLogic.TurnRoundNextFrame()
|
||||
end
|
||||
|
||||
-- 获取当前轮数
|
||||
|
@ -225,6 +222,13 @@ function BattleLogic.GetIsDebug()
|
|||
return _IsDebug
|
||||
end
|
||||
|
||||
|
||||
-- 下一帧开始下一轮
|
||||
function BattleLogic.TurnRoundNextFrame()
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
BattleLogic.TurnRound()
|
||||
end)
|
||||
end
|
||||
-- 开始轮转
|
||||
-- debugTurn 用于判断是否是debug轮转的参数
|
||||
function BattleLogic.TurnRound(debugTurn)
|
||||
|
@ -247,7 +251,6 @@ function BattleLogic.TurnRound(debugTurn)
|
|||
|
||||
-- 当前阵营下一释放技能的位置
|
||||
local cpos = CurSkillPos[CurCamp] + 1
|
||||
|
||||
if cpos == 0 then
|
||||
-- 保存当前释放技能的位置
|
||||
CurSkillPos[CurCamp] = cpos
|
||||
|
@ -263,34 +266,34 @@ function BattleLogic.TurnRound(debugTurn)
|
|||
CurSkillPos[CurCamp] = p
|
||||
-- 自己阵营中的位置 + 自己阵营的ID * 6 = 自己在PosList中的位置
|
||||
local role = PosList[p + (CurCamp * 6)]
|
||||
if role and role:IsAvailable() then
|
||||
if role and not role.isDead then
|
||||
SkillRole = role
|
||||
break
|
||||
end
|
||||
|
||||
-- 如果当前位置不能释放技能也需要走buff轮转
|
||||
BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数
|
||||
BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量
|
||||
BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血)
|
||||
BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血)
|
||||
BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff
|
||||
BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数
|
||||
end
|
||||
-- 如果找不到下一个人,直接交换阵营
|
||||
if not SkillRole then
|
||||
BattleLogic.TurnRound()
|
||||
BattleLogic.TurnRoundNextFrame()
|
||||
return
|
||||
end
|
||||
|
||||
SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnStart) -- 开始行动
|
||||
BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数
|
||||
BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量
|
||||
BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血)
|
||||
-- 释放技能后,递归交换阵营
|
||||
SkillRole:CastSkill(function()
|
||||
BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血)
|
||||
BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff
|
||||
BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数
|
||||
SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd) -- 行动结束
|
||||
BattleLogic.TurnRound()
|
||||
BattleLogic.TurnRoundNextFrame()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -347,7 +350,7 @@ function BattleLogic.CheckTeamSkillCast(camp)
|
|||
local teamSkillList = camp == 0 and playerTeamSkillList or enemyTeamSkillList
|
||||
if teamSkillList[teamSkillCastIndex] then
|
||||
if teamSkillCastIndex <= #teamSkillCastRound and CurRound >= teamSkillCastRound[teamSkillCastIndex] then
|
||||
teamSkillList[teamSkillCastIndex]:Cast(BattleLogic.TurnRound)
|
||||
teamSkillList[teamSkillCastIndex]:Cast(BattleLogic.TurnRoundNextFrame)
|
||||
if camp == 0 then
|
||||
MyTeamSkillCastIndex = MyTeamSkillCastIndex + 1
|
||||
else
|
||||
|
@ -357,7 +360,7 @@ function BattleLogic.CheckTeamSkillCast(camp)
|
|||
end
|
||||
end
|
||||
-- 没有要释放技能的异妖,切换阵营
|
||||
BattleLogic.TurnRound()
|
||||
BattleLogic.TurnRoundNextFrame()
|
||||
end
|
||||
|
||||
|
||||
|
@ -661,7 +664,7 @@ function BattleLogic.GetNeighbor(role, chooseType)
|
|||
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 -- 旁边的人和自己
|
||||
or (math.abs(target.position - list[i].position) <= 1 and floor((target.position-1)/3) == floor((list[i].position-1)/3)) then -- 旁边的人和自己
|
||||
table.insert(posList, list[i])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,6 +50,8 @@ BattleEventName = {
|
|||
BeSkillCast = indexAdd(), -- 被技能攻击前
|
||||
BeSkillCastEnd = indexAdd(), -- 被技能攻击结束
|
||||
SkillRandomBuff = indexAdd(), -- 技能控制时
|
||||
SkillEffectBefore = indexAdd(), -- 技能效果触发前
|
||||
BeSkillEffectBefore = indexAdd(), -- 技能效果触发前
|
||||
|
||||
PassiveTreating = indexAdd(),
|
||||
PassiveBeTreated = indexAdd(),
|
||||
|
|
|
@ -81,8 +81,49 @@ function BattleUtil.SortByProp(arr, prop, sort)
|
|||
end)
|
||||
return arr
|
||||
end
|
||||
-- 按血量排序
|
||||
function BattleUtil.SortByHpFactor(arr, sort)
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.Hp) / a:GetRoleData(RoleDataName.MaxHp)
|
||||
local r2 = b:GetRoleData(RoleDataName.Hp) / b:GetRoleData(RoleDataName.MaxHp)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
return arr
|
||||
end
|
||||
|
||||
-- 获取技能最大目标数
|
||||
function BattleUtil.GetMaxTargetNum(chooseId)
|
||||
local chooseType = floor(chooseId / 100000) % 10
|
||||
local chooseLimit = floor(chooseId / 10000) % 10
|
||||
local chooseWeight = floor(chooseId / 100) % 100
|
||||
local sort = floor(chooseId / 10) % 10
|
||||
local num = chooseId % 10
|
||||
|
||||
--
|
||||
if chooseType == 3 or chooseType == 4 then
|
||||
return 1
|
||||
else
|
||||
if num == 0 then
|
||||
if chooseLimit == 0 then
|
||||
if chooseWeight == 7 then
|
||||
return 4
|
||||
elseif chooseLimit == 8 then
|
||||
return 1
|
||||
else
|
||||
return 6
|
||||
end
|
||||
elseif chooseLimit == 1 or chooseLimit == 2 then
|
||||
return 3
|
||||
elseif chooseLimit == 3 then
|
||||
return 2
|
||||
end
|
||||
else
|
||||
return num
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
function BattleUtil.ChooseTarget(role, chooseId)
|
||||
local chooseType = floor(chooseId / 100000) % 10
|
||||
local chooseLimit = floor(chooseId / 10000) % 10
|
||||
|
@ -155,11 +196,7 @@ function BattleUtil.ChooseTarget(role, chooseId)
|
|||
elseif chooseWeight == 1 then -- 生命值
|
||||
BattleUtil.SortByProp(arr, RoleDataName.Hp, sort)
|
||||
elseif chooseWeight == 2 then -- 血量百分比
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.Hp) / a:GetRoleData(RoleDataName.MaxHp)
|
||||
local r2 = b:GetRoleData(RoleDataName.Hp) / b:GetRoleData(RoleDataName.MaxHp)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
BattleUtil.SortByHpFactor(arr, sort)
|
||||
elseif chooseWeight == 3 then -- 攻击力
|
||||
BattleUtil.SortByProp(arr, RoleDataName.Attack, sort)
|
||||
elseif chooseWeight == 4 then -- 防御
|
||||
|
@ -240,6 +277,26 @@ function BattleUtil.CalShield(atkRole, defRole, damage)
|
|||
return damage
|
||||
end
|
||||
|
||||
|
||||
-- 秒杀
|
||||
function BattleUtil.Seckill(skill, atkRole, defRole)
|
||||
local damage = defRole:GetRoleData(RoleDataName.Hp)
|
||||
local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage)
|
||||
if finalDmg >= 0 then
|
||||
if defRole:GetRoleData(RoleDataName.Hp) <= 0 then
|
||||
defRole.isDead = true
|
||||
BattleLogic.BuffMgr:ClearBuff(defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole)
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole)
|
||||
end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, false, finalDmg, 0, false, skill)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, false, finalDmg, 0, false, skill)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleDamage, atkRole, defRole, damage, false, finalDmg, 0, false, skill)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeDamaged, defRole, atkRole, damage, false, finalDmg, 0, false, skill)
|
||||
end
|
||||
end
|
||||
|
||||
-- 计算真实伤害
|
||||
function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, isDot)
|
||||
bCrit = bCrit or false
|
||||
|
|
Loading…
Reference in New Issue