0.94战斗同步
parent
237b1d5683
commit
25339d3188
|
@ -34,8 +34,9 @@ function Buff.Create(caster, type, duration, ...)
|
|||
buff.type = type
|
||||
buff.id = BattleLogic.GenerateBuffId()
|
||||
buff.caster = caster
|
||||
buff.disperse = false
|
||||
buff.cover = false
|
||||
buff.disperse = false --该值为true时,buff在下一帧被清除
|
||||
buff.cover = false --该值为true时,同类型新buff会覆盖旧buff
|
||||
buff.clear = true --该值为false时,buff不可被驱散,除非无条件驱散
|
||||
|
||||
buff.duration = duration --持续时间为0时buff永久存在
|
||||
buff.interval = -1 --间隔帧为0时每帧触发,小于0不触发 默认不触发OnTrigger
|
||||
|
@ -87,6 +88,20 @@ function BuffManager:AddBuff(target, buff)
|
|||
buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff)
|
||||
end
|
||||
|
||||
function BuffManager:QueryBuff(target, checkFunc)
|
||||
for i=1, self.buffList.size do
|
||||
local list = self.buffList.vList[i]
|
||||
for j=1, list.size do
|
||||
local buff = list.buffer[j]
|
||||
if buff.target == target then
|
||||
if checkFunc then
|
||||
checkFunc(buff)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BuffManager:HasBuff(target, type, checkFunc)
|
||||
if self.buffList.kvList[type] then
|
||||
local buffList = self.buffList.kvList[type]
|
||||
|
@ -102,6 +117,7 @@ function BuffManager:HasBuff(target, type, checkFunc)
|
|||
return false
|
||||
end
|
||||
|
||||
--func为nil时无条件清除,否则判定clear值,执行func
|
||||
function BuffManager:ClearBuff(target, func)
|
||||
for i = 1, self.buffList.size do
|
||||
local list = self.buffList.vList[i]
|
||||
|
@ -109,7 +125,7 @@ function BuffManager:ClearBuff(target, func)
|
|||
local idx = 1
|
||||
while idx <= list.size do
|
||||
local buff = list.buffer[idx]
|
||||
if buff.target == target and (not func or (func and func(buff))) then
|
||||
if buff.target == target and (not func or (func and buff.clear and func(buff))) then
|
||||
buff:OnEnd()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buff)
|
||||
putBuff(buff)
|
||||
|
@ -122,6 +138,10 @@ function BuffManager:ClearBuff(target, func)
|
|||
end
|
||||
end
|
||||
|
||||
function BuffManager:PutBuff(buff)
|
||||
putBuff(buff)
|
||||
end
|
||||
|
||||
function BuffManager:GetBuffCount(type)
|
||||
if self.buffList[type] then
|
||||
return self.buffList[type].size
|
||||
|
@ -194,7 +214,6 @@ function BuffManager:Update()
|
|||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff)
|
||||
end
|
||||
|
||||
if buff.framePass > buff.frameDuration then
|
||||
buff.disperse = true
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -217,7 +217,7 @@ local passivityList = {
|
|||
local pro = args[2]
|
||||
local f2 = args[3]
|
||||
|
||||
local OnPassiveDamaging = function(damagingFunc)
|
||||
local OnPassiveDamaging = function(damagingFunc, atkRole, damage)
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
damagingFunc(floor(role:GetRoleData(propertyList[pro]) * f2))
|
||||
end)
|
||||
|
@ -732,6 +732,9 @@ local passivityList = {
|
|||
local f1 = args[2]
|
||||
|
||||
local OnBeHit = function(atkRole)
|
||||
if atkRole.isTeam then
|
||||
return
|
||||
end
|
||||
if atkRole.roleData.professionId == i1 then
|
||||
BattleUtil.CalTreat(role, role, f1)
|
||||
end
|
||||
|
@ -895,7 +898,7 @@ local passivityList = {
|
|||
local f2 = args[2]
|
||||
|
||||
local auraBuff = Buff.Create(role, BuffName.Aura, 0, function (r)
|
||||
BattleLogic.AddMP(role.camp, f2 * 100)
|
||||
--BattleLogic.AddMP(role.camp, f2 * 100)
|
||||
end)
|
||||
auraBuff.interval = f1
|
||||
BattleLogic.BuffMgr:AddBuff(role, auraBuff)
|
||||
|
@ -905,7 +908,7 @@ local passivityList = {
|
|||
--a[float]
|
||||
[51] = function(role, args)
|
||||
local f1 = args[1]
|
||||
BattleLogic.AddMP(role.camp, f1 * 100)
|
||||
--BattleLogic.AddMP(role.camp, f1 * 100)
|
||||
end,
|
||||
|
||||
--战斗中,队伍每损失[a]%的生命值,增加[b]%的异妖能量
|
||||
|
@ -935,7 +938,7 @@ local passivityList = {
|
|||
if hp < curHp then
|
||||
local gears = floor((maxHp - hp) / (f1 * maxHp))
|
||||
if gears > curHpGears then
|
||||
BattleLogic.AddMP(role.camp, f2 * (gears - curHpGears) * 100)
|
||||
--BattleLogic.AddMP(role.camp, f2 * (gears - curHpGears) * 100)
|
||||
curHpGears = gears
|
||||
end
|
||||
curHp = hp
|
||||
|
@ -944,5 +947,323 @@ local passivityList = {
|
|||
auraBuff.interval = 0
|
||||
BattleLogic.BuffMgr:AddBuff(role, auraBuff)
|
||||
end,
|
||||
--战斗中,治疗技能有概率额外造成[a]%的治疗,概率等于自身暴击率。
|
||||
--a[float]
|
||||
[53] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local OnPassiveTreating = function(treatingFunc)
|
||||
BattleUtil.RandomAction(role:GetRoleData(RoleDataName.Crit), function ()
|
||||
treatingFunc(f1)
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveTreating, OnPassiveTreating)
|
||||
end,
|
||||
--受击后,有[a]的概率对攻击者造成眩晕,持续[b]秒。
|
||||
--a[float],b[int]
|
||||
[54] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType)
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
if atkRole.isTeam then
|
||||
return
|
||||
end
|
||||
atkRole:AddBuff(Buff.Create(role, BuffName.Control, f2, 1))
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
|
||||
end,
|
||||
--造成伤害时,有[a]的概率立即造成攻击[b]%的伤害。
|
||||
--a[float],b[float]
|
||||
[55] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
|
||||
local lastTrigger = 0
|
||||
local OnDamage = function(defRole, damage, bCrit, finalDmg)
|
||||
lastTrigger = lastTrigger + 1
|
||||
if lastTrigger > 1 then --加入限定避免循环触发
|
||||
return
|
||||
end
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
BattleUtil.ApplyDamage(role, defRole, floor(role:GetRoleData(RoleDataName.Attack) * f2))
|
||||
end)
|
||||
lastTrigger = 0
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleDamage, OnDamage)
|
||||
end,
|
||||
--造成暴击时,额外造成目标最大生命值[a]%的伤害。(目标最大生命值伤害总上限为施法者5倍攻击)
|
||||
--a[float]
|
||||
[56] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local lastTrigger = 0
|
||||
local OnRoleCrit = function(defRole)
|
||||
lastTrigger = lastTrigger + 1
|
||||
if lastTrigger > 1 then --加入限定避免循环触发
|
||||
return
|
||||
end
|
||||
BattleUtil.ApplyDamage(role, defRole, math.min(floor(defRole:GetRoleData(RoleDataName.MaxHp) * f1), floor(role:GetRoleData(RoleDataName.Attack)*5)))
|
||||
lastTrigger = 0
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleCrit, OnRoleCrit)
|
||||
end,
|
||||
--发动技能时,若技能目标与自身发动的上一个技能目标相同,则增加[a]%的伤害。
|
||||
--a[float]
|
||||
[57] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local damageDic = {}
|
||||
local lastDamageDic = {}
|
||||
local OnSkillCastEnd = function(skill)
|
||||
lastDamageDic = damageDic
|
||||
damageDic = {}
|
||||
end
|
||||
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
|
||||
if lastDamageDic[defRole] then
|
||||
damagingFunc(-floor(f1 * damage))
|
||||
end
|
||||
damageDic[defRole] = 1
|
||||
end
|
||||
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
|
||||
end,
|
||||
--发动技能后,每个敌方角色有[a]概率获得[b],每秒造成[c]%的[d]伤害,持续[e]秒。
|
||||
--a[float],b[持续伤害类型],c[float],d[伤害类型],e[int]
|
||||
[58] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local d1 = args[2]
|
||||
local f2 = args[3]
|
||||
local dt = args[4]
|
||||
local f3 = args[5]
|
||||
|
||||
local OnSkillCastEnd = function(skill)
|
||||
local arr = BattleUtil.ChooseTarget(role, 20000)
|
||||
for i=1, #arr do
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
arr[i]:AddBuff(Buff.Create(role, BuffName.DOT, f3, 1, d1, dt, f2))
|
||||
end)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
|
||||
end,
|
||||
--每隔[a]秒,抵挡一个负面状态。(控制 dot 减益)
|
||||
--a[int]
|
||||
[59] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local count = 0
|
||||
role.buffFilter:Add(function(buff)
|
||||
local b = buff.isDeBuff or buff.type == BuffName.DOT or buff.type == BuffName.Control
|
||||
if b then
|
||||
count = count + 1
|
||||
end
|
||||
return b and count <= 1
|
||||
end)
|
||||
|
||||
local auraBuff = Buff.Create(role, BuffName.Aura, 0, function (r)
|
||||
count = 0
|
||||
end)
|
||||
auraBuff.interval = f1
|
||||
BattleLogic.BuffMgr:AddBuff(role, auraBuff)
|
||||
end,
|
||||
--我方生命最低的其他角色受到技能攻击后,自身[a]的概率对攻击者造成攻击[b]%的伤害,并造成[c],持续[d]秒。若自身处于沉默或眩晕状态,则不会触发。播放攻击特效,特效时间[e]秒。
|
||||
--a[float],b[float],c[控制状态],d[int],e[float]
|
||||
[60] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local ct = args[3]
|
||||
local f3 = args[4]
|
||||
local f4 = args[5]
|
||||
|
||||
local triggerUid = {}
|
||||
BattleLogic.Event:AddEvent(BattleEventName.RoleBeDamaged, function (defRole, atkRole, damage, bCrit, finalDmg, damageType, isDot)
|
||||
if atkRole.isTeam or role.isDead or isDot then
|
||||
return
|
||||
end
|
||||
if triggerUid[atkRole.uid] then --加入限定避免循环触发
|
||||
return
|
||||
end
|
||||
if not BattleLogic.BuffMgr:HasBuff(role, BuffName.Control, function (buff) return buff.ctrlType == 1 or buff.ctrlType == 2 end) then
|
||||
local arr = BattleUtil.ChooseTarget(role, 10110)
|
||||
local target
|
||||
if arr[1] then
|
||||
if arr[1] == role and arr[2] then
|
||||
target = arr[2]
|
||||
else
|
||||
target = arr[1]
|
||||
end
|
||||
end
|
||||
if defRole == target then
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
role.Event:DispatchEvent(BattleEventName.RoleViewBullet, f4, atkRole)
|
||||
BattleLogic.WaitForTrigger(f4, function ()
|
||||
triggerUid[atkRole.uid] = atkRole.uid
|
||||
BattleUtil.ApplyDamage(role, atkRole, floor(role:GetRoleData(RoleDataName.Attack) * f2))
|
||||
atkRole:AddBuff(Buff.Create(role, BuffName.Control, f3, ct))
|
||||
triggerUid[atkRole.uid] = nil
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end,
|
||||
--自身受到的非暴击伤害,可以转化[a]%的伤害为自身攻击,持续[b]秒。上限自身攻击的[c]%。
|
||||
--a[float],b[int],c[float]
|
||||
[61] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local f3 = args[3]
|
||||
|
||||
local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType)
|
||||
if not bCrit then
|
||||
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, RoleDataName.Attack, math.min(floor(role:GetRoleData(RoleDataName.Attack) * f3), floor(damage * f1)), 1))
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
|
||||
end,
|
||||
--发动技能后,有[a]的概率为自身及相邻加持攻击[b]%的护盾,持续[c]秒。
|
||||
--a[float],b[float],c[int]
|
||||
[62] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local f3 = args[3]
|
||||
|
||||
local OnSkillCastEnd = function(skill)
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
role:AddBuff(Buff.Create(role, BuffName.Shield, f3, floor(role:GetRoleData(RoleDataName.Attack) * f2), 0))
|
||||
local list = BattleLogic.GetNeighbor(role, 1)
|
||||
for i=1, #list do
|
||||
list[i]:AddBuff(Buff.Create(role, BuffName.Shield, f3, floor(role:GetRoleData(RoleDataName.Attack) * f2), 0))
|
||||
end
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
|
||||
end,
|
||||
--自身拥有护盾时,我方角色每次释放技能后,有[a]概率回复[b]%的[c]的治疗。
|
||||
--a[float],b[float],c[属性]
|
||||
[63] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local pro1 = args[3]
|
||||
|
||||
BattleLogic.Event:AddEvent(BattleEventName.SkillCastEnd, function (skill)
|
||||
if skill.owner.isTeam then
|
||||
return
|
||||
end
|
||||
if skill.owner.camp == role.camp then
|
||||
if BattleLogic.BuffMgr:HasBuff(role, BuffName.Shield, function (buff) return true end) then
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
BattleUtil.CalTreat(skill.owner, skill.owner, floor(role:GetRoleData(propertyList[pro1]) * f2))
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end,
|
||||
--基于生命损失的百分比,受到的伤害降低[b]%。
|
||||
--a[float]
|
||||
[64] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local OnPassiveDamaging = function(damagingFunc, atkRole, damage)
|
||||
damagingFunc(floor(damage*f1*(1-BattleUtil.GetHPPencent(role))))
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, OnPassiveDamaging)
|
||||
end,
|
||||
--我方角色死亡时,对击杀者造成[a]%的[b]伤害,令其眩晕,持续[c]秒。
|
||||
--a[float],b[伤害类型],c[int]
|
||||
[65] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local f2 = args[3]
|
||||
|
||||
BattleLogic.Event:AddEvent(BattleEventName.BattleRoleDead, function (defRole, atkRole)
|
||||
if atkRole.isTeam then
|
||||
return
|
||||
end
|
||||
if defRole.camp == role.camp then
|
||||
BattleUtil.CalDamage(role, atkRole, dt, f1)
|
||||
atkRole:AddBuff(Buff.Create(role, BuffName.Control, f2, 1))
|
||||
end
|
||||
end)
|
||||
end,
|
||||
--免疫减益状态。
|
||||
--无
|
||||
[66] = function(role, args)
|
||||
role.buffFilter:Add(function(buff)
|
||||
return buff.isDeBuff
|
||||
end)
|
||||
end,
|
||||
--敌方累计发动[a]次技能,有[b]概率发动(发动特效),对敌方全体造成眩晕效果,持续[c]秒。然后清空累计次数。播放攻击特效,特效时间[d]秒。
|
||||
--a[int],b[float],c[float]
|
||||
[67] = function(role, args)
|
||||
local i1 = args[1]
|
||||
local f1 = args[2]
|
||||
local f2 = args[3]
|
||||
local f3 = args[4]
|
||||
|
||||
local count = 0
|
||||
BattleLogic.Event:AddEvent(BattleEventName.SkillCast, function (skill)
|
||||
if skill.owner.isTeam or role.isDead then
|
||||
return
|
||||
end
|
||||
if skill.owner.camp ~= role.camp then
|
||||
count = count + 1
|
||||
if count == i1 then
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
role.Event:DispatchEvent(BattleEventName.AOE, 1-role.camp)
|
||||
BattleLogic.WaitForTrigger(f3, function ()
|
||||
local arr = BattleUtil.ChooseTarget(role, 20000)
|
||||
for i=1, #arr do
|
||||
arr[i]:AddBuff(Buff.Create(role, BuffName.Control, f2, 1))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
count = 0
|
||||
end
|
||||
end
|
||||
end)
|
||||
end,
|
||||
--受到伤害后,[a]概率为自身施加[b]的[c]%的护盾。持续[d]秒。
|
||||
--a[float],b[属性],c[float],d[int]
|
||||
[68] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local pro1 = args[2]
|
||||
local f2 = args[3]
|
||||
local f3 = args[4]
|
||||
|
||||
local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType)
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
role:AddBuff(Buff.Create(role, BuffName.Shield, f3, floor(role:GetRoleData(propertyList[pro1]) * f2), 0))
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
|
||||
end,
|
||||
--造成暴击时,额外造成目标最大生命值[a]%的伤害。造成伤害时,有[a]的概率立即造成攻击[b]%的伤害,该伤害造成的暴击伤害不会触发额外最大生命值伤害。(效果55+效果56)(目标最大生命值伤害总上限为施法者5倍攻击)
|
||||
--a[float],b[float],c[float]
|
||||
[69] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local f3 = args[3]
|
||||
|
||||
local lastTrigger = 0
|
||||
local OnDamage = function(defRole, damage, bCrit, finalDmg)
|
||||
lastTrigger = lastTrigger + 1
|
||||
if lastTrigger > 1 then --加入限定避免循环触发
|
||||
return
|
||||
end
|
||||
if bCrit then
|
||||
BattleUtil.ApplyDamage(role, defRole, math.min(floor(defRole:GetRoleData(RoleDataName.MaxHp) * f1), floor(role:GetRoleData(RoleDataName.Attack)*5)))
|
||||
else
|
||||
BattleUtil.RandomAction(f2, function ()
|
||||
BattleUtil.ApplyDamage(role, defRole, floor(role:GetRoleData(RoleDataName.Attack) * f3))
|
||||
end)
|
||||
end
|
||||
lastTrigger = 0
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleDamage, OnDamage)
|
||||
end,
|
||||
}
|
||||
return passivityList
|
|
@ -16,7 +16,7 @@ end)
|
|||
Skill = {}
|
||||
|
||||
function Skill:New()
|
||||
local o = {cd=0,effectList = BattleList.New(),owner=0,sp=0,spPass = 0,isTeamSkill=false,teamSkillType=0 }
|
||||
local o = {cd=0,effectList = BattleList.New(),owner=0,sp=0,spPass=0,isTeamSkill=false,teamSkillType=0 }
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
@ -39,11 +39,8 @@ function Skill:Init(role, effectData, type) --type 0 异妖 1 点技 2 滑技
|
|||
--效果 = {效果类型id, 效果参数1, 效果参数2, ...}
|
||||
self.effectList:Clear()
|
||||
self.owner = role
|
||||
self.sp = isTeamSkill and floor(self.cd * BattleLogic.GameFrameRate) or 0
|
||||
self.spPass = self.sp
|
||||
self.isTeamSkill = isTeamSkill
|
||||
self.teamSkillType = isTeamSkill and floor(effectData[1] / 100) or 0
|
||||
self.isManual = false
|
||||
|
||||
for i=2, #effectData do
|
||||
local v = effectData[i]
|
||||
|
@ -98,7 +95,7 @@ function Skill:Cast()
|
|||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
local duration = effectGroup.duration
|
||||
local effects = effectGroup.effects
|
||||
local nn = floor(chooseId / 10000) % 10
|
||||
local weight = floor(chooseId % 10000 / 100)
|
||||
local count = min(chooseId % 10, #arr)
|
||||
if count == 0 then
|
||||
count = #arr
|
||||
|
@ -109,7 +106,7 @@ function Skill:Cast()
|
|||
for j=1, count do
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
elseif nn == 1 or nn == 3 then
|
||||
elseif weight == 8 then --对位相邻的目标同时触发效果
|
||||
for j=1, count do
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
|
@ -144,36 +141,22 @@ function Skill:Cast()
|
|||
end
|
||||
|
||||
if not self.isTeamSkill then
|
||||
local time = max(8-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
time = BattleUtil.ErrorCorrection(time)
|
||||
if self.owner.superSkill == self then
|
||||
self.sp = 0
|
||||
self.spPass = floor(self.cd * BattleLogic.GameFrameRate)
|
||||
if BattleLogic.Type == 4 then --秘境boss的能量特殊处理
|
||||
BattleLogic.AddMP(self.owner.camp, 20)
|
||||
else
|
||||
BattleLogic.AddMP(self.owner.camp, 10)
|
||||
end
|
||||
if self.owner.skill then
|
||||
local skill = self.owner.skill
|
||||
skill.sp = 0
|
||||
skill.spPass = floor(time * BattleLogic.GameFrameRate)
|
||||
end
|
||||
--绝技读条时间=max(9-速度/(8*(等级+10)),3)
|
||||
local time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 3)
|
||||
self.owner.sp = 0
|
||||
self.owner.spPass = floor(BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
else
|
||||
self.sp = 0
|
||||
self.spPass = floor(time * BattleLogic.GameFrameRate)
|
||||
if BattleLogic.Type == 4 then --秘境boss的能量特殊处理
|
||||
BattleLogic.AddMP(self.owner.camp, 20)
|
||||
else
|
||||
BattleLogic.AddMP(self.owner.camp, 5)
|
||||
end
|
||||
--普技读条时间=max(7-速度/(8*(等级+10)),1.5)
|
||||
local time = max(7-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
self.owner.sp = 0
|
||||
self.owner.spPass = floor(BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
end
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
else
|
||||
self.sp = 0
|
||||
self.owner.curSkill = self
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
end
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
|
||||
--技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个
|
||||
local duration = 0
|
||||
|
@ -182,36 +165,12 @@ function Skill:Cast()
|
|||
end
|
||||
|
||||
BattleLogic.SetSkillUsable(self.owner.camp, false)
|
||||
self.isManual = false
|
||||
BattleLogic.WaitForTrigger(duration, function()
|
||||
BattleLogic.SetSkillUsable(self.owner.camp, true)
|
||||
if not self.isTeamSkill then
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self)
|
||||
else
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self.cd)
|
||||
end
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self)
|
||||
end)
|
||||
end
|
||||
--表现层调用
|
||||
function Skill:CanManualCast()
|
||||
return not self.isManual and self.owner.enable and (not self.owner.ctrl_slient or (self.owner.ctrl_slient and self.owner.skill == self)) and
|
||||
self.owner.camp == 0 and not self.owner.Auto and self.sp >= self.spPass
|
||||
end
|
||||
--表现层调用
|
||||
function Skill:ManualCast()
|
||||
--非调试模式下,只有我方阵营角色,且处在非自动状态下可手动释放技能
|
||||
local b = self:CanManualCast()
|
||||
--调试模式下,可无条件手动释放技能
|
||||
local b2 = self.owner.IsDebug
|
||||
if b or b2 then
|
||||
if self.owner.skill == self then
|
||||
BattleLogic.AddOption(2, self.owner.uid)
|
||||
else
|
||||
BattleLogic.AddOption(3, self.owner.uid)
|
||||
end
|
||||
self.isManual = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,17 +15,14 @@ local enemyMP
|
|||
local playerSkillUsable
|
||||
local enemySkillUsable
|
||||
|
||||
local isAuto
|
||||
|
||||
BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战
|
||||
BattleLogic.IsEnd = false
|
||||
BattleLogic.Result = -1
|
||||
BattleLogic.Event = BattleEvent.New()
|
||||
BattleLogic.BuffMgr = BuffManager.New()
|
||||
|
||||
local skillManualQueue = BattleQueue.New()
|
||||
local playerTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true, curSkill = nil, isDebug = false}
|
||||
local enemyTeamDummyRole = {camp = 1, Event = BattleLogic.Event, isTeam = true, curSkill = nil, isDebug = false}
|
||||
local playerTeamDummyRole = {camp = 0, Event = BattleEvent.New(), isTeam = true, curSkill = nil, isDebug = false}
|
||||
local enemyTeamDummyRole = {camp = 1, Event = BattleEvent.New(), isTeam = true, curSkill = nil, isDebug = false}
|
||||
local playerTeamSkillList = {}
|
||||
local enemyTeamSkillList = {}
|
||||
local playerTeamSkillIndex
|
||||
|
@ -46,11 +43,12 @@ BattleLogic.TotalOrder = 0
|
|||
BattleLogic.CurOrder = 0
|
||||
|
||||
local stage --战场分割阶段
|
||||
local stageFrame1 = 25 * BattleLogic.GameFrameRate --前期转中期的时间点
|
||||
local stageFrame2 = 40 * BattleLogic.GameFrameRate --中期转后期的时间点
|
||||
local stageFrame1 = 15 * BattleLogic.GameFrameRate --前期转中期的时间点
|
||||
local stageFrame2 = 30 * BattleLogic.GameFrameRate --中期转后期的时间点
|
||||
local curStageFrame
|
||||
|
||||
local teamSkillCastTime = {15 * BattleLogic.GameFrameRate,
|
||||
35 * BattleLogic.GameFrameRate,
|
||||
local teamSkillCastTime = {7 * BattleLogic.GameFrameRate,
|
||||
25 * BattleLogic.GameFrameRate,
|
||||
55 * BattleLogic.GameFrameRate}
|
||||
local teamSkillCastIndex
|
||||
|
||||
|
@ -85,7 +83,6 @@ function BattleLogic.Init(maxTime, data, optionData)
|
|||
BattleLogic.TotalOrder = #data.enemyData
|
||||
|
||||
BattleLogic.Clear()
|
||||
skillManualQueue:Clear()
|
||||
|
||||
curUid = 0
|
||||
curBuffId = 0
|
||||
|
@ -96,13 +93,13 @@ function BattleLogic.Init(maxTime, data, optionData)
|
|||
stage = 0
|
||||
|
||||
playerTeamDummyRole.isDebug = false
|
||||
playerTeamDummyRole.Event:ClearEvent()
|
||||
enemyTeamDummyRole.isDebug = false
|
||||
enemyTeamDummyRole.Event:ClearEvent()
|
||||
|
||||
playerSkillUsable = true
|
||||
enemySkillUsable = true
|
||||
|
||||
isAuto = true
|
||||
|
||||
BattleLogic.Event:ClearEvent()
|
||||
BattleLogic.BuffMgr:Init()
|
||||
BattleLogic.IsEnd = false
|
||||
|
@ -111,14 +108,13 @@ end
|
|||
|
||||
function BattleLogic.StartOrder()
|
||||
BattleLogic.CurOrder = BattleLogic.CurOrder + 1
|
||||
stage = 1
|
||||
stage = 0
|
||||
curStageFrame = 0
|
||||
|
||||
teamSkillCastIndex = 1
|
||||
playerTeamSkillIndex = 1
|
||||
enemyTeamSkillIndex = 1
|
||||
|
||||
curFrame = 0
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
|
||||
|
||||
if BattleLogic.CurOrder == 1 then
|
||||
for i=1, #fightData.playerData do
|
||||
BattleLogic.AddRole(fightData.playerData[i], i)
|
||||
|
@ -194,32 +190,19 @@ function BattleLogic.StartOrder()
|
|||
end
|
||||
end
|
||||
|
||||
function BattleLogic.AddMP(camp, mp)
|
||||
--if camp == 0 then
|
||||
-- if #playerTeamSkillList > 0 then
|
||||
-- playerMP = min(playerMP + mp, 100)
|
||||
-- end
|
||||
--else
|
||||
-- if #enemyTeamSkillList > 0 then
|
||||
-- enemyMP = min(enemyMP + mp, 100)
|
||||
-- end
|
||||
--end
|
||||
end
|
||||
|
||||
function BattleLogic.GetMP(camp)
|
||||
return camp == 0 and playerMP or enemyMP
|
||||
end
|
||||
|
||||
function BattleLogic.CanManualTeamSkill()
|
||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
return not isAuto and teamSkill
|
||||
end
|
||||
|
||||
function BattleLogic.GetTeamSkillCastTime()
|
||||
if teamSkillCastIndex > #playerTeamSkillList then
|
||||
return -1
|
||||
function BattleLogic.GetTeamSkillCastSlider()
|
||||
if playerTeamDummyRole.isDebug then
|
||||
return 0
|
||||
end
|
||||
return teamSkillCastTime[teamSkillCastIndex] - curFrame
|
||||
local slider = (teamSkillCastTime[teamSkillCastIndex] - curStageFrame)
|
||||
if teamSkillCastIndex == 1 then
|
||||
slider = slider / teamSkillCastTime[teamSkillCastIndex]
|
||||
elseif teamSkillCastIndex == 2 then
|
||||
slider = slider / (teamSkillCastTime[teamSkillCastIndex] - stageFrame1)
|
||||
elseif teamSkillCastIndex == 3 then
|
||||
slider = slider / (teamSkillCastTime[teamSkillCastIndex] - stageFrame2)
|
||||
end
|
||||
return slider
|
||||
end
|
||||
|
||||
function BattleLogic.GenerateBuffId()
|
||||
|
@ -273,48 +256,10 @@ function BattleLogic.AddOption(opType, opArg)
|
|||
table.insert(optionRecord, {curFrame + 1, opType, opArg})
|
||||
end
|
||||
|
||||
function BattleLogic.GetOption()
|
||||
return optionRecord
|
||||
end
|
||||
|
||||
function BattleLogic.GetTeamSkillCaster(camp)
|
||||
return camp == 0 and playerTeamDummyRole or enemyTeamDummyRole
|
||||
end
|
||||
|
||||
--执行操作逻辑
|
||||
function BattleLogic.ExecuteOption(option)
|
||||
local opType = option[2]
|
||||
local opArg = option[3]
|
||||
if opType == 1 then --全局自动手动
|
||||
for i=1, objList.size do
|
||||
local tmpObj = objList.vList[i]
|
||||
if tmpObj.camp == 0 then
|
||||
tmpObj.Auto = opArg == 1
|
||||
end
|
||||
end
|
||||
elseif opType == 2 then --释放skill
|
||||
local role = objList.kvList[opArg]
|
||||
if role and role.skill then
|
||||
skillManualQueue:Enqueue(role.skill)
|
||||
end
|
||||
elseif opType == 3 then --释放superSkill
|
||||
local role = objList.kvList[opArg]
|
||||
if role and role.superSkill then
|
||||
skillManualQueue:Enqueue(role.superSkill)
|
||||
end
|
||||
elseif opType == 4 then --释放teamSkill
|
||||
BattleLogic.CastTeamSkill(0)
|
||||
elseif opType == 5 then --设置teamSkill自动手动
|
||||
isAuto = opArg == 1
|
||||
elseif opType == 6 then --切换单个角色自动手动 arg == uid * 10 + auto(0手动,1自动)
|
||||
local auto = opArg % 10
|
||||
local uid = floor(opArg / 10)
|
||||
if objList.kvList[uid] then
|
||||
objList.kvList[uid].Auto = auto == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleLogic.HasObj(obj)
|
||||
return obj and objList.kvList[obj.uid]
|
||||
end
|
||||
|
@ -327,12 +272,28 @@ function BattleLogic.CurStage()
|
|||
return stage
|
||||
end
|
||||
|
||||
--表现层调用,显示每个阶段剩余时间百分比
|
||||
function BattleLogic.CurStageSlider()
|
||||
local slider = 0
|
||||
if stage == 1 then
|
||||
slider = (stageFrame1 - curStageFrame) / stageFrame1
|
||||
elseif stage == 2 then
|
||||
slider = (stageFrame2 - curStageFrame) / (stageFrame2 - stageFrame1)
|
||||
elseif stage == 3 then
|
||||
slider = (maxFrame / BattleLogic.TotalOrder - curStageFrame) / (maxFrame / BattleLogic.TotalOrder - stageFrame2)
|
||||
end
|
||||
return slider
|
||||
end
|
||||
|
||||
--表现层调用,显示每个阶段剩余时间
|
||||
function BattleLogic.CurStageTime()
|
||||
local time = 0
|
||||
if stage == 1 then
|
||||
time = stageFrame1 - curFrame
|
||||
time = (stageFrame1 - curStageFrame) / BattleLogic.GameFrameRate
|
||||
elseif stage == 2 then
|
||||
time = stageFrame2 - curFrame
|
||||
time = (stageFrame2 - curStageFrame) / BattleLogic.GameFrameRate
|
||||
elseif stage == 3 then
|
||||
time = (maxFrame / BattleLogic.TotalOrder - curStageFrame) / BattleLogic.GameFrameRate
|
||||
end
|
||||
return time
|
||||
end
|
||||
|
@ -390,45 +351,41 @@ end
|
|||
|
||||
function BattleLogic.Update()
|
||||
curFrame = curFrame + 1
|
||||
if curFrame > stageFrame1 and stage == 1 then
|
||||
stage = 2
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
|
||||
end
|
||||
if curFrame > stageFrame2 and stage == 2 then
|
||||
stage = 3
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
|
||||
end
|
||||
|
||||
if curFrame > teamSkillCastTime[teamSkillCastIndex] then
|
||||
if playerTeamSkillIndex == teamSkillCastIndex and playerSkillUsable then
|
||||
if playerTeamSkillList[teamSkillCastIndex] then
|
||||
playerTeamSkillList[teamSkillCastIndex]:Cast()
|
||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
||||
end
|
||||
|
||||
end
|
||||
if enemyTeamSkillIndex == teamSkillCastIndex and enemySkillUsable then
|
||||
if enemyTeamSkillList[teamSkillCastIndex] then
|
||||
enemyTeamSkillList[teamSkillCastIndex]:Cast()
|
||||
enemyTeamSkillIndex = enemyTeamSkillIndex + 1
|
||||
end
|
||||
end
|
||||
teamSkillCastIndex = min(teamSkillCastIndex + 1, #teamSkillCastTime)
|
||||
end
|
||||
|
||||
if curFrame > maxFrame then
|
||||
BattleLogic.BattleEnd(0)
|
||||
return
|
||||
end
|
||||
|
||||
for i=1, #optionRecord do
|
||||
if optionRecord[i][1] == curFrame then
|
||||
BattleLogic.ExecuteOption(optionRecord[i])
|
||||
end
|
||||
curStageFrame = curStageFrame + 1
|
||||
|
||||
if curStageFrame > 0 and stage == 0 then
|
||||
stage = 1
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
|
||||
end
|
||||
if curStageFrame > stageFrame1 and stage == 1 then
|
||||
stage = 2
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
|
||||
end
|
||||
if curStageFrame > stageFrame2 and stage == 2 then
|
||||
stage = 3
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
|
||||
end
|
||||
|
||||
if playerSkillUsable and skillManualQueue.size > 0 then --手动操作的技能进入队列,等待释放
|
||||
skillManualQueue:Dequeue():Cast()
|
||||
if teamSkillCastIndex <= #teamSkillCastTime and curStageFrame > teamSkillCastTime[teamSkillCastIndex] then
|
||||
teamSkillCastIndex = teamSkillCastIndex + 1
|
||||
end
|
||||
|
||||
if playerTeamSkillIndex < teamSkillCastIndex then
|
||||
if not playerTeamDummyRole.isDebug and playerTeamSkillList[playerTeamSkillIndex] then
|
||||
playerTeamSkillList[playerTeamSkillIndex]:Cast()
|
||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
||||
end
|
||||
end
|
||||
if enemyTeamSkillIndex < teamSkillCastIndex then
|
||||
if not enemyTeamDummyRole.isDebug and enemyTeamSkillList[enemyTeamSkillIndex] then
|
||||
enemyTeamSkillList[enemyTeamSkillIndex]:Cast()
|
||||
enemyTeamSkillIndex = enemyTeamSkillIndex + 1
|
||||
end
|
||||
end
|
||||
|
||||
local index = 1
|
||||
|
@ -443,28 +400,6 @@ function BattleLogic.Update()
|
|||
end
|
||||
end
|
||||
|
||||
--for i=1, #playerTeamSkillList do
|
||||
-- playerTeamSkillList[i].sp = min(playerTeamSkillList[i].sp + 1, playerTeamSkillList[i].spPass)
|
||||
--end
|
||||
--
|
||||
--for i=1, #enemyTeamSkillList do
|
||||
-- enemyTeamSkillList[i].sp = min(enemyTeamSkillList[i].sp + 1, enemyTeamSkillList[i].spPass)
|
||||
--end
|
||||
--
|
||||
--if playerMP == 100 and playerSkillUsable and isAuto then
|
||||
-- local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
-- if teamSkill.sp >= teamSkill.spPass then
|
||||
-- BattleLogic.CastTeamSkill(0)
|
||||
-- end
|
||||
--end
|
||||
--
|
||||
--if enemyMP == 100 and enemySkillUsable then
|
||||
-- local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
|
||||
-- if teamSkill.sp >= teamSkill.spPass then
|
||||
-- BattleLogic.CastTeamSkill(1)
|
||||
-- end
|
||||
--end
|
||||
|
||||
BattleLogic.BuffMgr:Update()
|
||||
|
||||
local bMyAllDead = true
|
||||
|
@ -482,6 +417,7 @@ function BattleLogic.Update()
|
|||
end
|
||||
if bMyAllDead then
|
||||
BattleLogic.BattleEnd(0)
|
||||
return
|
||||
end
|
||||
if bEnemyAllDead then
|
||||
if BattleLogic.CurOrder == BattleLogic.TotalOrder then
|
||||
|
@ -495,17 +431,17 @@ end
|
|||
|
||||
local posDic = {3,2,4,1,5}
|
||||
--对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的
|
||||
function BattleLogic.GetAggro(camp, position)
|
||||
function BattleLogic.GetAggro(role)
|
||||
local minNeighbor = 100
|
||||
local index = 100
|
||||
local target
|
||||
local enemyCamp = camp == 0 and 1 or 0
|
||||
local enemyCamp = role.camp == 0 and 1 or 0
|
||||
for i=1, objList.size do
|
||||
if objList.vList[i].camp == enemyCamp and not objList.vList[i].isDead then
|
||||
if position == objList.vList[i].position then
|
||||
if role.position == objList.vList[i].position then
|
||||
return objList.vList[i]
|
||||
else
|
||||
local neighbor = math.abs(posDic[position] - posDic[objList.vList[i].position])
|
||||
local neighbor = math.abs(posDic[role.position] - posDic[objList.vList[i].position])
|
||||
if neighbor < minNeighbor then
|
||||
minNeighbor = neighbor
|
||||
index = objList.vList[i].position
|
||||
|
@ -520,6 +456,18 @@ function BattleLogic.GetAggro(camp, position)
|
|||
end
|
||||
return target
|
||||
end
|
||||
--获取对位相邻站位的人 chooseType 1 我方 2 敌方(若对位的敌人死亡,则选取相邻最近的作为目标)
|
||||
function BattleLogic.GetNeighbor(role, chooseType)
|
||||
local posList = {}
|
||||
local target = chooseType == 1 and role or BattleLogic.GetAggro(role)
|
||||
local list = BattleUtil.ChooseTarget(target, 10000)
|
||||
for i=1, #list do
|
||||
if not list[i].isDead and math.abs(posDic[target.position] - posDic[list[i].position]) <= 1 then
|
||||
table.insert(posList, list[i])
|
||||
end
|
||||
end
|
||||
return posList
|
||||
end
|
||||
|
||||
function BattleLogic.ResetTeamSkillCD(camp)
|
||||
local skill = camp == 0 and playerTeamDummyRole.curSkill or enemyTeamDummyRole.curSkill
|
||||
|
|
|
@ -15,8 +15,9 @@ function Control:OnStart()
|
|||
self.target.enable = false
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
self.target.ctrl_slient = true
|
||||
elseif self.ctrlType == 3 then --嘲讽
|
||||
elseif self.ctrlType == 3 then --嘲讽(包括沉默)
|
||||
self.target.lockTarget = self.caster
|
||||
self.target.ctrl_slient = true
|
||||
elseif self.ctrlType == 4 then --禁疗
|
||||
self.target.ctrl_noheal = true
|
||||
elseif self.ctrlType == 5 then --致盲
|
||||
|
@ -37,8 +38,9 @@ function Control:OnEnd()
|
|||
self.target.enable = true
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
self.target.ctrl_slient = false
|
||||
elseif self.ctrlType == 3 then --嘲讽
|
||||
elseif self.ctrlType == 3 then --嘲讽(包括沉默)
|
||||
self.target.lockTarget = nil
|
||||
self.target.ctrl_slient = false
|
||||
elseif self.ctrlType == 4 then --禁疗
|
||||
self.target.ctrl_noheal = false
|
||||
elseif self.ctrlType == 5 then --致盲
|
||||
|
|
|
@ -8,8 +8,7 @@ function DOT:SetData(...)
|
|||
self.damageType, --1 燃烧 2 中毒 3 流血
|
||||
self.damagePro, --1 物理 2 魔法
|
||||
self.damageFactor = ... --伤害系数
|
||||
self.isDeBuff = true
|
||||
|
||||
self.isRealDamage = false
|
||||
--if self.damageType == 2 then
|
||||
-- self.cover = true
|
||||
-- self.layer = 1
|
||||
|
@ -27,7 +26,11 @@ end
|
|||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function DOT:OnTrigger()
|
||||
--log("DOT:OnTrigger")
|
||||
BattleUtil.CalDamage(self.caster, self.target, self.damagePro, self.damageFactor,0, true)
|
||||
if self.isRealDamage then
|
||||
BattleUtil.ApplyDamage(self.caster, self.target, self.damagePro)
|
||||
else
|
||||
BattleUtil.CalDamage(self.caster, self.target, self.damagePro, self.damageFactor,0, true)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ function HOT:SetData(...)
|
|||
--log("HOT:SetData")
|
||||
self.interval,
|
||||
self.healValue = ...
|
||||
self.isBuff = true
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
|
|
|
@ -12,6 +12,7 @@ end
|
|||
function Immune:SetData(...)
|
||||
--log("Immune:SetData")
|
||||
self.immuneType = ...
|
||||
self.isBuff = true
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
|
|
|
@ -10,6 +10,16 @@ function PropertyChange:SetData(...)
|
|||
self.cover = false --默认不可叠加
|
||||
self.layer = 1
|
||||
self.maxLayer = 0
|
||||
|
||||
if self.changeType == 1 then --加算
|
||||
self.isBuff = true
|
||||
elseif self.changeType == 2 then --乘加算(百分比属性加算)
|
||||
self.isBuff = true
|
||||
elseif self.changeType == 3 then --减算
|
||||
self.isDeBuff = true
|
||||
elseif self.changeType == 4 then --乘减算(百分比属性减算)
|
||||
self.isDeBuff = true
|
||||
end
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
|
@ -17,16 +27,12 @@ function PropertyChange:OnStart()
|
|||
--log("PropertyChange:OnStart")
|
||||
if self.changeType == 1 then --加算
|
||||
self.delta = self.target.data:AddValue(self.propertyName, self.Value)
|
||||
self.isBuff = true
|
||||
elseif self.changeType == 2 then --乘加算(百分比属性加算)
|
||||
self.delta = self.target.data:AddPencentValue(self.propertyName, self.Value)
|
||||
self.isBuff = true
|
||||
elseif self.changeType == 3 then --减算
|
||||
self.delta = self.target.data:SubValue(self.propertyName, self.Value)
|
||||
self.isDeBuff = true
|
||||
elseif self.changeType == 4 then --乘减算(百分比属性减算)
|
||||
self.delta = self.target.data:SubPencentValue(self.propertyName, self.Value)
|
||||
self.isDeBuff = true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ RoleDataName = {
|
|||
Speed = indexAdd(),--速度
|
||||
DamageBocusFactor = indexAdd(), --伤害加成系数(%)
|
||||
DamageReduceFactor = indexAdd(), --伤害减免系数(%)
|
||||
Hit = indexAdd(), --命中率(%)
|
||||
Dodge = indexAdd(), --闪避率(%)
|
||||
Hit = indexAdd(), --施法率(%)
|
||||
Dodge = indexAdd(), --后期基础施法率(%)
|
||||
Crit = indexAdd(), --暴击率(%)
|
||||
CritDamageFactor = indexAdd(), --暴击伤害系数(%)
|
||||
Tenacity = indexAdd(), --抗暴率(%)
|
||||
|
|
|
@ -3,6 +3,7 @@ BattleUtil = {}
|
|||
local floor = math.floor
|
||||
local max = math.max
|
||||
local min = math.min
|
||||
local posDic = {3,2,4,1,5}
|
||||
--local Random = Random
|
||||
--local RoleDataName = RoleDataName
|
||||
--local BattleEventName = BattleEventName
|
||||
|
@ -62,7 +63,7 @@ function BattleUtil.ChooseTarget(role, chooseId)
|
|||
BattleUtil.RandomList(arr)
|
||||
return {arr[1]}
|
||||
end
|
||||
return {BattleLogic.GetAggro(role.camp, role.position)}
|
||||
return {BattleLogic.GetAggro(role)}
|
||||
else
|
||||
arr = BattleLogic.Query()
|
||||
end
|
||||
|
@ -111,6 +112,14 @@ function BattleUtil.ChooseTarget(role, chooseId)
|
|||
local r2 = b:GetSkillCD()
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 8 then
|
||||
arr = BattleLogic.GetNeighbor(role, chooseType)
|
||||
elseif chooseWeight == 9 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = math.abs(posDic[role.position] - posDic[a.position]) * 10 + a.position
|
||||
local r2 = math.abs(posDic[role.position] - posDic[b.position]) * 10 + b.position
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
end
|
||||
return arr
|
||||
end
|
||||
|
@ -183,12 +192,14 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType, isD
|
|||
if defRole:GetRoleData(RoleDataName.Hp) <= 0 then
|
||||
defRole.isDead = true
|
||||
BattleLogic.BuffMgr:ClearBuff(defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleDead)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole)
|
||||
end
|
||||
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType, isDot)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType, isDot)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleDamage, atkRole, defRole, damage, bCrit, finalDmg, damageType, isDot)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeDamaged, defRole, atkRole, damage, bCrit, finalDmg, damageType, isDot)
|
||||
if bCrit then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole, damage, bCrit, finalDmg, damageType)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole, damage, bCrit, finalDmg, damageType)
|
||||
|
@ -258,9 +269,8 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
(1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor) - defRole:GetRoleData(elementDamageReduceFactor)))
|
||||
baseDamage = floor(max(baseDamage, 0.1 * attack))
|
||||
|
||||
local func
|
||||
for i=1, atkRole.exCalDmgList.size do
|
||||
func = atkRole.exCalDmgList.buffer[i]
|
||||
local func = atkRole.exCalDmgList.buffer[i]
|
||||
baseDamage = func(baseDamage)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ local max = math.max
|
|||
local min = math.min
|
||||
|
||||
local aiList = {
|
||||
[0] = function(skill, superSkill) --默认75%释放点击技、25%释放上滑技
|
||||
[0] = function(skill, superSkill)
|
||||
local stage = BattleLogic.CurStage()
|
||||
if stage == 1 then
|
||||
return true
|
||||
elseif stage == 2 then
|
||||
return Random.Range01() > superSkill.randomInStage2
|
||||
elseif stage == 3 then
|
||||
return false
|
||||
elseif stage == 2 then --中期绝技释放率=技能基础概率+施法率+后期施法率-1
|
||||
return Random.Range01() > superSkill.randomInStage2 + superSkill.owner:GetRoleData(RoleDataName.Hit) + superSkill.owner:GetRoleData(RoleDataName.Dodge) - 1
|
||||
elseif stage == 3 then--后期绝技释放率=后期施法率+施法率
|
||||
return Random.Range01() > superSkill.owner:GetRoleData(RoleDataName.Hit) + superSkill.owner:GetRoleData(RoleDataName.Dodge)
|
||||
end
|
||||
end,
|
||||
[1] = function(skill, superSkill) --只放点技
|
||||
|
@ -41,12 +41,12 @@ local skillPool = BattleObjectPool.New(function ()
|
|||
end)
|
||||
|
||||
function RoleLogic.New()
|
||||
local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0,aiIndex=1,position=0,
|
||||
local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0,aiIndex=1,position=0,sp=0,spPass=0,
|
||||
shield=BattleList.New(),
|
||||
exCalDmgList=BattleList.New(),
|
||||
proTranList=BattleList.New(),
|
||||
buffFilter=BattleList.New(),
|
||||
Event=BattleEvent:New(),passiveList=0,isDead=false,Auto=false,IsDebug=false,enable=false}
|
||||
Event=BattleEvent:New(),passiveList=0,isDead=false,IsDebug=false,enable=false}
|
||||
setmetatable(instance, RoleLogic)
|
||||
return instance
|
||||
end
|
||||
|
@ -74,16 +74,16 @@ function RoleLogic:Init(uid, data, position)
|
|||
if data.skill and #data.skill > 0 then
|
||||
self.skill = skillPool:Get()
|
||||
self.skill:Init(self, data.skill, 1)
|
||||
self.skill.sp = 0
|
||||
local time = max(8-self:GetRoleData(RoleDataName.Speed)/(8*(self:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
self.skill.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
end
|
||||
if data.superSkill and #data.superSkill > 0 then
|
||||
self.superSkill = skillPool:Get()
|
||||
self.superSkill:Init(self, data.superSkill, 2)
|
||||
self.superSkill.spPass = floor(self.superSkill.cd * BattleLogic.GameFrameRate)
|
||||
self.superSkill.sp = self.superSkill.spPass
|
||||
end
|
||||
--首次读条时间=速度/(20*(等级+10)
|
||||
self.sp = 0
|
||||
local time = self:GetRoleData(RoleDataName.Speed)/(20*(self:GetRoleData(RoleDataName.Level)+10))
|
||||
self.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
|
||||
if data.passivity and #data.passivity > 0 then
|
||||
for i = 1, #data.passivity do
|
||||
local v = data.passivity[i]
|
||||
|
@ -100,7 +100,6 @@ function RoleLogic:Init(uid, data, position)
|
|||
self.aiIndex = 1
|
||||
self.aiTempCount = 0
|
||||
|
||||
self.Auto = true
|
||||
self.IsDebug = false
|
||||
|
||||
self.enable = true --眩晕
|
||||
|
@ -111,40 +110,26 @@ function RoleLogic:Init(uid, data, position)
|
|||
|
||||
if self.skill and not self.superSkill then
|
||||
self.updateFunc = function()
|
||||
local skill = self.skill
|
||||
if skill.sp >= skill.spPass then
|
||||
if self.Auto and self:CanCastSkill() then
|
||||
skill:Cast()
|
||||
end
|
||||
if self:CanCastSkill() then
|
||||
self.skill:Cast()
|
||||
else
|
||||
skill.sp = skill.sp + 1
|
||||
self.sp = self.sp + 1
|
||||
end
|
||||
end
|
||||
elseif not self.skill and self.superSkill then
|
||||
self.updateFunc = function()
|
||||
local superSkill = self.superSkill
|
||||
if superSkill.sp >= superSkill.spPass then
|
||||
if self.Auto and self:CanCastSkill() and not self.ctrl_slient then
|
||||
superSkill:Cast()
|
||||
end
|
||||
if self:CanCastSkill() and not self.ctrl_slient then
|
||||
self.superSkill:Cast()
|
||||
else
|
||||
superSkill.sp = superSkill.sp + 1
|
||||
self.sp = self.sp + 1
|
||||
end
|
||||
end
|
||||
elseif self.skill and self.superSkill then
|
||||
self.updateFunc = function()
|
||||
local superSkill = self.superSkill
|
||||
local skill = self.skill
|
||||
if superSkill.sp >= superSkill.spPass then
|
||||
if skill.sp >= skill.spPass then
|
||||
if self.Auto and self:CanCastSkill() then
|
||||
self:ExecuteAI(skill, superSkill)
|
||||
end
|
||||
else
|
||||
skill.sp = skill.sp + 1
|
||||
end
|
||||
if self:CanCastSkill() then
|
||||
self:ExecuteAI(self.skill, self.superSkill)
|
||||
else
|
||||
superSkill.sp = superSkill.sp + 1
|
||||
self.sp = self.sp + 1
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@ -153,48 +138,21 @@ function RoleLogic:Init(uid, data, position)
|
|||
end
|
||||
|
||||
function RoleLogic:CanCastSkill()
|
||||
return self.enable and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp)
|
||||
return self.sp >= self.spPass and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp)
|
||||
end
|
||||
|
||||
function RoleLogic:GetSkillCD()
|
||||
local cd = 0
|
||||
if self.skill and not self.superSkill then
|
||||
cd = max(self.skill.spPass - self.skill.sp, 0)
|
||||
elseif not self.skill and self.superSkill then
|
||||
cd = max(self.superSkill.spPass - self.superSkill.sp, 0)
|
||||
elseif self.skill and self.superSkill then
|
||||
cd = max(self.skill.spPass - self.skill.sp, 0) + max(self.superSkill.spPass - self.superSkill.sp, 0)
|
||||
end
|
||||
return cd
|
||||
return max(self.spPass - self.sp, 0)
|
||||
end
|
||||
|
||||
function RoleLogic:AddSkillCD(value, type)
|
||||
self.Event:DispatchEvent(BattleEventName.RoleCDChanged)
|
||||
if value == 0 then --为0直接清CD
|
||||
if self.skill and not self.superSkill then
|
||||
self.skill.sp = self.skill.spPass
|
||||
elseif not self.skill and self.superSkill then
|
||||
self.superSkill.sp = self.superSkill.spPass
|
||||
elseif self.skill and self.superSkill then
|
||||
self.skill.sp = self.skill.spPass
|
||||
self.superSkill.sp = self.superSkill.spPass
|
||||
end
|
||||
self.sp = self.spPass
|
||||
return
|
||||
end
|
||||
|
||||
local cdTotal = 0
|
||||
if self.skill and not self.superSkill then
|
||||
cdTotal = self.skill.spPass
|
||||
elseif not self.skill and self.superSkill then
|
||||
cdTotal = self.superSkill.spPass
|
||||
elseif self.skill and self.superSkill then
|
||||
if self.superSkill.sp >= self.superSkill.spPass then --滑技cd生效,加点技cd,否则加滑技cd+点技cd
|
||||
cdTotal = self.skill.spPass
|
||||
else
|
||||
cdTotal = self.superSkill.spPass + self.skill.spPass
|
||||
end
|
||||
end
|
||||
|
||||
local cdTotal = self.spPass
|
||||
local delta = 0
|
||||
if type == 1 then --加算
|
||||
delta = floor(value * BattleLogic.GameFrameRate)
|
||||
|
@ -207,32 +165,10 @@ function RoleLogic:AddSkillCD(value, type)
|
|||
end
|
||||
|
||||
if delta > 0 then --加cd加cd最大值
|
||||
if self.skill and not self.superSkill then
|
||||
self.skill.spPass = self.skill.spPass + delta
|
||||
elseif not self.skill and self.superSkill then
|
||||
self.superSkill.spPass = self.superSkill.spPass + delta
|
||||
elseif self.skill and self.superSkill then
|
||||
if self.superSkill.sp < self.superSkill.spPass then --滑技cd没好,加滑技cd,否则加点技cd
|
||||
self.superSkill.spPass = self.superSkill.spPass + delta
|
||||
else
|
||||
self.skill.spPass = self.skill.spPass + delta
|
||||
end
|
||||
end
|
||||
self.spPass = self.spPass + delta
|
||||
else --减cd减cd当前值
|
||||
delta = -delta
|
||||
if self.skill and not self.superSkill then
|
||||
self.skill.sp = min(self.skill.sp + delta, self.skill.spPass)
|
||||
elseif not self.skill and self.superSkill then
|
||||
self.superSkill.sp = min(self.superSkill.sp + delta, self.superSkill.spPass)
|
||||
elseif self.skill and self.superSkill then
|
||||
if delta <= self.superSkill.spPass - self.superSkill.sp then
|
||||
self.superSkill.sp = self.superSkill.sp + delta
|
||||
else
|
||||
delta = delta - self.superSkill.spPass + self.superSkill.sp --滑技cd不够减,继续减点技cd
|
||||
self.superSkill.sp = self.superSkill.spPass
|
||||
self.skill.sp = self.skill.sp + delta
|
||||
end
|
||||
end
|
||||
self.sp = min(self.sp + delta, self.spPass)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue