战斗校验
parent
d4de27130e
commit
1f56530128
|
@ -56,12 +56,11 @@ function BuffManager.New()
|
|||
end
|
||||
|
||||
function BuffManager:Init()
|
||||
for i=1, self.buffQueue.size do
|
||||
buffListPool:Put(self.buffQueue:Dequeue())
|
||||
while self.buffQueue.size > 0 do
|
||||
putBuff:Put(self.buffQueue:Dequeue())
|
||||
end
|
||||
local list
|
||||
for i = 1, self.buffList.size do
|
||||
list = self.buffList.vList[i]
|
||||
local list = self.buffList.vList[i]
|
||||
for j=1, list.size do
|
||||
putBuff(list.buffer[j])
|
||||
end
|
||||
|
@ -92,13 +91,14 @@ function BuffManager:AddBuff(target, buff)
|
|||
end
|
||||
|
||||
function BuffManager:HasBuff(target, type, checkFunc)
|
||||
local v, buff
|
||||
for i=1, self.buffList:Count() do
|
||||
v = self.buffList.vList[i]
|
||||
if v.size > 0 then
|
||||
buff = v.buffer[1]
|
||||
if buff.target == target and buff.type == type and (not checkFunc or (checkFunc and checkFunc(buff))) then
|
||||
return true
|
||||
if self.buffList.kvList[type] then
|
||||
local buffList = self.buffList.kvList[type]
|
||||
for i=1, buffList.size do
|
||||
local v = buffList.buffer[i]
|
||||
if v.target == target then
|
||||
if (not checkFunc or (checkFunc and checkFunc(v))) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -106,13 +106,12 @@ function BuffManager:HasBuff(target, type, checkFunc)
|
|||
end
|
||||
|
||||
function BuffManager:ClearBuff(target, func)
|
||||
local list, buff, idx
|
||||
for i = 1, self.buffList.size do
|
||||
list = self.buffList.vList[i]
|
||||
local list = self.buffList.vList[i]
|
||||
if list.size > 0 then
|
||||
idx = 1
|
||||
local idx = 1
|
||||
while idx <= list.size do
|
||||
buff = list.buffer[idx]
|
||||
local buff = list.buffer[idx]
|
||||
if buff.target == target and (not func or (func and func(buff))) then
|
||||
buff:OnEnd()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buff)
|
||||
|
@ -126,31 +125,42 @@ function BuffManager:ClearBuff(target, func)
|
|||
end
|
||||
end
|
||||
|
||||
function BuffManager:GetBuffCount(id)
|
||||
if self.buffList[id] then
|
||||
return self.buffList[id].size
|
||||
function BuffManager:GetBuffCount(type)
|
||||
if self.buffList[type] then
|
||||
return self.buffList[type].size
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function BuffManager:Update()
|
||||
for i=1, self.buffQueue.size do
|
||||
while self.buffQueue.size > 0 do
|
||||
local buff = self.buffQueue:Dequeue()
|
||||
local buffList
|
||||
if not self.buffList.kvList[buff.id] then
|
||||
if not self.buffList.kvList[buff.type] then
|
||||
buffList = buffListPool:Get()
|
||||
self.buffList:Add(buff.id, buffList)
|
||||
self.buffList:Add(buff.type, buffList)
|
||||
else
|
||||
buffList = self.buffList.kvList[buff.id]
|
||||
buffList = self.buffList.kvList[buff.type]
|
||||
end
|
||||
if buff.cover and buffList.size > 0 then
|
||||
if buffList.buffer[1]:OnCover(buff) then --判定该效果能否被覆盖
|
||||
buffList.buffer[1]:OnEnd()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buffList.buffer[1])
|
||||
buffList.buffer[1] = buff
|
||||
local isCovered = false
|
||||
for i=1, buffList.size do
|
||||
local oldBuff = buffList.buffer[i]
|
||||
if oldBuff.target == buff.target and oldBuff:OnCover(buff) then --判定该效果能否被覆盖
|
||||
oldBuff:OnEnd()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buffList.buffer[i])
|
||||
buffList.buffer[i] = buff
|
||||
buff:OnStart()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff)
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff)
|
||||
isCovered = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not isCovered then
|
||||
buffList:Add(buff)
|
||||
buff:OnStart()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff)
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff)
|
||||
end
|
||||
else
|
||||
if buff.maxCount == 0 or buffList.size < buff.maxCount then --限制相同效果的数量,为0则不限制
|
||||
|
@ -160,14 +170,12 @@ function BuffManager:Update()
|
|||
end
|
||||
end
|
||||
end
|
||||
local v
|
||||
for i = 1, self.buffList.size do
|
||||
v = self.buffList.vList[i]
|
||||
if v.size > 0 then
|
||||
local idx = 1
|
||||
local buff
|
||||
while idx <= v.size do
|
||||
buff = v.buffer[idx]
|
||||
for i=1, self.buffList.size do
|
||||
local buffList = self.buffList.vList[i]
|
||||
if buffList.size > 0 then
|
||||
local index = 1
|
||||
while index <= buffList.size do
|
||||
local buff = buffList.buffer[index]
|
||||
--印记类型的buff不处理更新逻辑
|
||||
if buff.frameDuration == 0 and buff.frameInterval < 0 then
|
||||
else
|
||||
|
@ -200,9 +208,9 @@ function BuffManager:Update()
|
|||
buff:OnEnd()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buff)
|
||||
putBuff(buff)
|
||||
v:Remove(idx)
|
||||
buffList:Remove(index)
|
||||
else
|
||||
idx = idx + 1
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -129,7 +129,7 @@ local effectList = {
|
|||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
BattleUtil.RandomAction(f2, function ()
|
||||
if target.skill then
|
||||
if f2 == 0 then --值为0时,直接清除CD
|
||||
if f1 == 0 then --值为0时,直接清除CD
|
||||
target.skill.sp = target.skill.spPass
|
||||
else
|
||||
if ct == 1 then --加算
|
||||
|
@ -211,18 +211,16 @@ local effectList = {
|
|||
target:AddBuff(Buff.Create(caster, BuffName.DOT, f2, 1, d1, dt, f1))
|
||||
end)
|
||||
end,
|
||||
--造成[a]%的[b]伤害,[c]%概率[d]专属伤害加深印记(如果有印记,无印记伤害*(1+印记数量*[e])
|
||||
--a[float],b[伤害类型],c[float],d[角色id],e[float]
|
||||
--造成[a]%的[b]伤害,[c]%概率[d]专属伤害加深印记(如果有印记,[a]*(1+印记数量*[e])),印记最多[f]层
|
||||
--a[float],b[伤害类型],c[float],d[角色id],e[float],f[int]
|
||||
[14] = function(caster, target, args, interval)
|
||||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local f2 = args[3] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local rid = args[4]
|
||||
local f3 = args[5]
|
||||
local i1 = args[6]
|
||||
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval)
|
||||
if caster.camp == 0 and target.camp == 1 then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, interval)
|
||||
end
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
local layer
|
||||
if BattleLogic.BuffMgr:HasBuff(target, BuffName.Brand, function (buff)
|
||||
|
@ -232,7 +230,7 @@ local effectList = {
|
|||
end
|
||||
return b
|
||||
end) then
|
||||
BattleUtil.CalDamage(caster, target, dt,f1 + layer * f3)
|
||||
BattleUtil.CalDamage(caster, target, dt,f1 * (1 + min(layer, i1) * f3))
|
||||
else
|
||||
BattleUtil.CalDamage(caster, target, dt, f1)
|
||||
end
|
||||
|
@ -267,10 +265,9 @@ local effectList = {
|
|||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local f2 = args[3]
|
||||
local value = floor(target:GetRoleData(propertyList[dt]) * f1)
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, value, f1, 3))
|
||||
caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, value, f1, 1))
|
||||
target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[dt], f1, 4))
|
||||
caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[dt], f1, 2))
|
||||
end)
|
||||
end,
|
||||
--造成[a]%的[b]伤害,如果是[c],有[d]%必定暴击
|
||||
|
@ -548,12 +545,37 @@ local effectList = {
|
|||
--[b]%改变[d]重击技能CD[a]秒 ,持续[c]秒 (0代表清除所有)
|
||||
--a[float],b[float],c[改变类型]
|
||||
[32] = function(caster, target, args, interval)
|
||||
local f1 = args[1] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local ib1 = args[2]
|
||||
local f2 = args[3]
|
||||
local f1 = args[1]
|
||||
local f2 = args[2] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local ct = args[3]
|
||||
local d = args[4]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
target:AddBuff(Buff.Create(caster, BuffName.Immune, f2, ib1))
|
||||
BattleUtil.RandomAction(f2, function ()
|
||||
local func = function()
|
||||
if target.skill then
|
||||
if f1 == 0 then --值为0时,直接清除CD
|
||||
target.skill.sp = target.skill.spPass
|
||||
else
|
||||
if ct == 1 then --加算
|
||||
target.skill.sp = max(target.skill.sp - floor(f1 * BattleLogic.GameFrameRate), 0)
|
||||
elseif ct == 2 then --乘加算(百分比属性加算)
|
||||
target.skill.sp = max(target.skill.sp - floor(target.skill.spPass * f1),0)
|
||||
elseif ct == 3 then --减算
|
||||
target.skill.sp = min(target.skill.sp + floor(f1 * BattleLogic.GameFrameRate), target.skill.spPass)
|
||||
elseif ct == 4 then --乘减算(百分比属性减算)
|
||||
target.skill.sp = min(target.skill.sp + floor(target.skill.spPass * f1), target.skill.spPass)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
func()
|
||||
local trigger = function(skill) --新增监听事件,在印记技能结束回调时移除(印记buff可覆盖旧buff)
|
||||
func()
|
||||
end
|
||||
target.Event:AddEvent(BattleEventName.SkillCast, trigger)
|
||||
target:AddBuff(Buff.Create(caster, BuffName.Brand, d, "cd", function ()
|
||||
target.Event:RemoveEvent(BattleEventName.SkillCast, trigger)
|
||||
end))
|
||||
end)
|
||||
end)
|
||||
end,
|
||||
|
|
|
@ -24,7 +24,7 @@ local function chooseTarget(role, chooseId, exceptList)
|
|||
return r.camp == role.camp
|
||||
end)
|
||||
elseif chooseType == 2 then
|
||||
if role.lockTarget and num == 1 then
|
||||
if role.lockTarget and num == 1 then --嘲讽时对单个敌军生效
|
||||
return {role.lockTarget}
|
||||
end
|
||||
arr = BattleLogic.Query(function (r)
|
||||
|
@ -36,15 +36,41 @@ local function chooseTarget(role, chooseId, exceptList)
|
|||
return r.camp ~= role.camp
|
||||
end)
|
||||
elseif chooseType == 3 then
|
||||
if role.ctrl_blind then --致盲时自身变随机友军
|
||||
arr = BattleLogic.Query(function (r)
|
||||
for i=1, exceptList.size do
|
||||
if r.uid == exceptList.buffer[i].uid then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return r.camp == role.camp
|
||||
end)
|
||||
BattleUtil.RandomList(arr)
|
||||
return {arr[1]}
|
||||
end
|
||||
return {role}
|
||||
elseif chooseType == 4 then
|
||||
if role.lockTarget then --嘲讽时对仇恨目标生效
|
||||
return {role.lockTarget}
|
||||
end
|
||||
if role.ctrl_blind then --致盲时仇恨目标变随机
|
||||
arr = BattleLogic.Query(function (r)
|
||||
for i=1, exceptList.size do
|
||||
if r.uid == exceptList.buffer[i].uid then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return r.camp ~= role.camp
|
||||
end)
|
||||
BattleUtil.RandomList(arr)
|
||||
return {arr[1]}
|
||||
end
|
||||
return {BattleLogic.GetAggro(role.camp)}
|
||||
else
|
||||
arr = BattleLogic.Query()
|
||||
end
|
||||
|
||||
BattleUtil.RandomList(arr)
|
||||
if chooseWeight == 0 then
|
||||
if chooseWeight == 0 or role.ctrl_blind then --致盲时排序无效
|
||||
BattleUtil.RandomList(arr)
|
||||
elseif chooseWeight == 1 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
|
@ -102,10 +128,10 @@ local function chooseTarget(role, chooseId, exceptList)
|
|||
return arr
|
||||
end
|
||||
local effectPool = BattleObjectPool.New(function ()
|
||||
return {0, {}} -- type, {args, ...}
|
||||
return { type = 0, args = {}} -- type, {args, ...}
|
||||
end)
|
||||
local effectGroupPool = BattleObjectPool.New(function ()
|
||||
return { 0, 0, {}} -- chooseId, duration, {effect1, effect2, ...}
|
||||
return { chooseId = 0, duration = 0, effects = {}} -- chooseId, duration, {effect1, effect2, ...}
|
||||
end)
|
||||
|
||||
Skill = {}
|
||||
|
@ -129,86 +155,59 @@ function Skill:Init(role, effectData)
|
|||
self.choosedList:Clear()
|
||||
self.isTeamSkill = false
|
||||
|
||||
local v
|
||||
for i=2, #effectData do
|
||||
v = effectData[i]
|
||||
local v = effectData[i]
|
||||
local effectGroup = effectGroupPool:Get() -- chooseId, duration, {effect1, effect2, ...}
|
||||
effectGroup[1] = v[1] --chooseId
|
||||
effectGroup[2] = v[2] --duration
|
||||
effectGroup.chooseId = v[1] --chooseId
|
||||
effectGroup.duration = v[2] --duration
|
||||
for j=3, #v do --effectList
|
||||
local effect = effectPool:Get() -- type, {args, ...}
|
||||
effect[1] = v[j][1]
|
||||
effect.type = v[j][1]
|
||||
for k=2, #v[j] do
|
||||
effect[2][k-1] = v[j][k]
|
||||
effect.args[k-1] = v[j][k]
|
||||
end
|
||||
effectGroup[3][j-2] = effect
|
||||
effectGroup.effects[j-2] = effect
|
||||
end
|
||||
self.effectList:Add(effectGroup)
|
||||
end
|
||||
end
|
||||
|
||||
function Skill:Dispose()
|
||||
local effectGroup
|
||||
local effect
|
||||
while self.effectList.size > 0 do
|
||||
effectGroup = self.effectList.buffer[self.effectList.size]
|
||||
for k=1, #effectGroup[3] do
|
||||
effect = effectGroup[3][k]
|
||||
for j=1, #effect[2] do
|
||||
effect[2][j] = nil
|
||||
local effectGroup = self.effectList.buffer[self.effectList.size]
|
||||
for k=1, #effectGroup.effects do
|
||||
local effect = effectGroup.effects[k]
|
||||
for j=1, #effect.args do
|
||||
effect.args[j] = nil
|
||||
end
|
||||
effectPool:Put(effect)
|
||||
effectGroup[3][k] = nil
|
||||
effectGroup.effects[k] = nil
|
||||
end
|
||||
effectGroupPool:Put(effectGroup)
|
||||
self.effectList:Remove(self.effectList.size)
|
||||
end
|
||||
end
|
||||
|
||||
function Skill:ResetCD()
|
||||
if not self.isTeamSkill then
|
||||
if self.owner.superSkill == self then
|
||||
self.sp = 0
|
||||
self.spPass = floor(self.cd * BattleLogic.GameFrameRate)
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
BattleLogic.AddMP(self.owner.camp, 10)
|
||||
if self.owner.skill then
|
||||
local skill = self.owner.skill
|
||||
local time = max(6-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
skill.sp = 0
|
||||
skill.spPass = floor(time * BattleLogic.GameFrameRate)
|
||||
end
|
||||
else
|
||||
local time = max(6-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
self.sp = 0
|
||||
self.spPass = floor(time * BattleLogic.GameFrameRate)
|
||||
BattleLogic.AddMP(self.owner.camp, 8)
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
local function takeEffect(caster, target, effects, duration)
|
||||
for k=1, #effects do
|
||||
local e = effects[k]
|
||||
effect[e.type](caster, target, e.args, duration)
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
BattleLogic.RecordEffect(caster, target, e.type, e.args, duration)
|
||||
end
|
||||
else
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self.cd) --队伍技能结构和其他相同,只是cd项为对应异妖类型
|
||||
end
|
||||
|
||||
local duration = 0
|
||||
for i=1, self.effectList.size do
|
||||
duration = max(duration, self.effectList.buffer[i][2])
|
||||
end
|
||||
BattleLogic.SetSkillUsable(self.owner.camp, false)
|
||||
BattleLogic.WaitForTrigger(duration, function()
|
||||
BattleLogic.SetSkillUsable(self.owner.camp, true)
|
||||
end)
|
||||
BattleLogic.SetAggro(self.owner, 0)
|
||||
end
|
||||
|
||||
function Skill:Cast()
|
||||
for i=1, self.effectList.size do
|
||||
local effectGroup = self.effectList.buffer[i]
|
||||
local chooseId = effectGroup[1]
|
||||
local duration = effectGroup[2]
|
||||
local chooseId = effectGroup.chooseId
|
||||
local arr = chooseTarget(self.owner, chooseId, self.choosedList)
|
||||
if #arr > 0 then
|
||||
--延迟1帧释放效果
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function ()
|
||||
--效果延迟1帧生效
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
local duration = effectGroup.duration
|
||||
local effects = effectGroup.effects
|
||||
local nn = floor(chooseId / 10000) % 10
|
||||
if self.owner.camp == 0 and nn == 2 then --我方释放效果开始切镜头
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomIn, 0.3)
|
||||
|
@ -219,34 +218,16 @@ function Skill:Cast()
|
|||
if chooseId == 10000 then --我方aoe
|
||||
self.owner.Event:DispatchEvent(BattleEventName.AOE, 0)
|
||||
for j=1, #arr do
|
||||
for k=1, #effectGroup[3] do
|
||||
local v = effectGroup[3][k]
|
||||
effect[v[1]](self.owner, arr[j], v[2], duration)
|
||||
--if BattleLogic.IsOpenBattleRecord then
|
||||
-- BattleLogic.RecordEffect(v[1], self.owner, arr[j], v[2], duration)
|
||||
--end
|
||||
end
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
elseif chooseId == 20000 then --敌方aoe
|
||||
self.owner.Event:DispatchEvent(BattleEventName.AOE, 1)
|
||||
for j=1, #arr do
|
||||
for k=1, #effectGroup[3] do
|
||||
local v = effectGroup[3][k]
|
||||
effect[v[1]](self.owner, arr[j], v[2], duration)
|
||||
--if BattleLogic.IsOpenBattleRecord then
|
||||
-- BattleLogic.RecordEffect(v[1], self.owner, arr[j], v[2], duration)
|
||||
--end
|
||||
end
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
elseif nn == 1 or nn == 3 then
|
||||
for j=1, #arr do
|
||||
for k=1, #effectGroup[3] do
|
||||
local v = effectGroup[3][k]
|
||||
effect[v[1]](self.owner, arr[j], v[2], duration)
|
||||
--if BattleLogic.IsOpenBattleRecord then
|
||||
-- BattleLogic.RecordEffect(v[1], self.owner, arr[j], v[2], duration)
|
||||
--end
|
||||
end
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
else
|
||||
local count = chooseId % 10
|
||||
|
@ -262,14 +243,7 @@ function Skill:Cast()
|
|||
if not r then --当没有新增的被选取目标时,可能为空
|
||||
for i=1, #arr do
|
||||
if not arr[i].isDead then
|
||||
r = arr[i]
|
||||
for k=1, #effectGroup[3] do
|
||||
local v = effectGroup[3][k]
|
||||
effect[v[1]](self.owner, r, v[2], cd)
|
||||
--if BattleLogic.IsOpenBattleRecord then
|
||||
-- BattleLogic.RecordEffect(v[1], self.owner, r, v[2], cd)
|
||||
--end
|
||||
end
|
||||
takeEffect(self.owner, arr[i], effects, cd)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -279,27 +253,51 @@ function Skill:Cast()
|
|||
end
|
||||
end
|
||||
self.choosedList:Add(r)
|
||||
for k=1, #effectGroup[3] do
|
||||
local v = effectGroup[3][k]
|
||||
effect[v[1]](self.owner, r, v[2], cd)
|
||||
--if BattleLogic.IsOpenBattleRecord then
|
||||
-- BattleLogic.RecordEffect(v[1], self.owner, r, v[2], cd)
|
||||
--end
|
||||
end
|
||||
takeEffect(self.owner, r, effects, cd)
|
||||
end)
|
||||
end
|
||||
BattleLogic.WaitForTrigger(duration, function()
|
||||
self.choosedList:Clear()
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
self:ResetCD()
|
||||
|
||||
BattleLogic.SetAggro(self.owner)
|
||||
if not self.isTeamSkill then
|
||||
if self.owner.superSkill == self then
|
||||
self.sp = 0
|
||||
self.spPass = floor(self.cd * BattleLogic.GameFrameRate)
|
||||
BattleLogic.AddMP(self.owner.camp, 10)
|
||||
if self.owner.skill then
|
||||
local skill = self.owner.skill
|
||||
local time = max(6-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
skill.sp = 0
|
||||
skill.spPass = floor(time * BattleLogic.GameFrameRate)
|
||||
end
|
||||
else
|
||||
local time = max(6-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
self.sp = 0
|
||||
self.spPass = floor(time * BattleLogic.GameFrameRate)
|
||||
BattleLogic.AddMP(self.owner.camp, 8)
|
||||
end
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
else
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self.cd) --队伍技能结构和其他相同,只是cd项为对应异妖类型
|
||||
end
|
||||
|
||||
local duration = 0
|
||||
for i=1, self.effectList.size do
|
||||
duration = max(duration, self.effectList.buffer[i].duration)
|
||||
end
|
||||
|
||||
BattleLogic.SetSkillUsable(self.owner.camp, false)
|
||||
BattleLogic.WaitForTrigger(duration, function()
|
||||
self.choosedList:Clear()
|
||||
BattleLogic.SetSkillUsable(self.owner.camp, true)
|
||||
end)
|
||||
end
|
||||
--表现层调用
|
||||
function Skill:CanManualCast()
|
||||
return not self.owner.IsDebug and self.owner.camp == 0 and not self.owner.Auto and self.sp >= self.spPass and BattleLogic.GetSkillUsable(self.owner.camp)
|
||||
return self.owner:CanCastSkill() and self.owner.camp == 0 and not self.owner.Auto and self.sp >= self.spPass
|
||||
end
|
||||
--表现层调用
|
||||
function Skill:ManualCast()
|
||||
|
|
|
@ -2,8 +2,8 @@ BattleLogic = {}
|
|||
|
||||
local floor = math.floor
|
||||
local min = math.min
|
||||
local max = math.min
|
||||
local objList = BattleDictionary.New()
|
||||
local removeObjList = BattleList.New()
|
||||
|
||||
local curUid
|
||||
local curBuffId
|
||||
|
@ -18,6 +18,8 @@ local enemyAggro
|
|||
local playerSkillUsable
|
||||
local enemySkillUsable
|
||||
|
||||
local isAuto
|
||||
|
||||
BattleLogic.IsEnd = false
|
||||
BattleLogic.Result = -1
|
||||
BattleLogic.Event = BattleEvent.New()
|
||||
|
@ -88,6 +90,8 @@ function BattleLogic.Init(data, optionData)
|
|||
playerSkillUsable = true
|
||||
enemySkillUsable = true
|
||||
|
||||
isAuto = true
|
||||
|
||||
BattleLogic.Event:ClearEvent()
|
||||
BattleLogic.BuffMgr:Init()
|
||||
BattleLogic.IsEnd = false
|
||||
|
@ -144,9 +148,13 @@ end
|
|||
|
||||
function BattleLogic.AddMP(camp, mp)
|
||||
if camp == 0 then
|
||||
playerMP = min(playerMP + mp, 100)
|
||||
if #playerTeamSkillList > 0 then
|
||||
playerMP = min(playerMP + mp, 100)
|
||||
end
|
||||
else
|
||||
enemyMP = min(playerMP + mp, 100)
|
||||
if #enemyTeamSkillList > 0 then
|
||||
enemyMP = min(enemyMP + mp, 100)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -154,6 +162,10 @@ function BattleLogic.GetMP(camp)
|
|||
return camp == 0 and playerMP or enemyMP
|
||||
end
|
||||
|
||||
function BattleLogic.GetAuto()
|
||||
return isAuto
|
||||
end
|
||||
|
||||
function BattleLogic.GenerateBuffId()
|
||||
curBuffId = curBuffId + 1
|
||||
return curBuffId
|
||||
|
@ -182,14 +194,13 @@ function BattleLogic.InitAggro()
|
|||
break
|
||||
end
|
||||
end
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, playerAggro, 1)
|
||||
end
|
||||
|
||||
function BattleLogic.SetAggro(role, duration)
|
||||
function BattleLogic.SetAggro(role)
|
||||
if role.camp == 1 then
|
||||
playerAggro = role
|
||||
if enemySkillUsable then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, role, max(duration/2, 0.3))
|
||||
end
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, role, 1)
|
||||
else
|
||||
enemyAggro = role
|
||||
end
|
||||
|
@ -201,7 +212,7 @@ function BattleLogic.GetAggro(camp)
|
|||
for i=1, objList.size do
|
||||
if objList.vList[i].camp == 1 and not objList.vList[i].isDead then
|
||||
playerAggro = objList.vList[i]
|
||||
BattleLogic.SetAggro(playerAggro, 0)
|
||||
BattleLogic.SetAggro(playerAggro)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -212,7 +223,7 @@ function BattleLogic.GetAggro(camp)
|
|||
for i=1, objList.size do
|
||||
if objList.vList[i].camp == 0 and not objList.vList[i].isDead then
|
||||
enemyAggro = objList.vList[i]
|
||||
BattleLogic.SetAggro(enemyAggro, 0)
|
||||
BattleLogic.SetAggro(enemyAggro)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -261,27 +272,17 @@ function BattleLogic.HasObj(obj)
|
|||
return obj and objList.kvList[obj.uid]
|
||||
end
|
||||
|
||||
function BattleLogic.RemoveObj(uid)
|
||||
local role = objList.kvList[uid]
|
||||
if role then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RemoveRole, role)
|
||||
role:Dispose()
|
||||
rolePool:Put(role)
|
||||
objList:Remove(uid)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleLogic.CurFrame()
|
||||
return curFrame
|
||||
end
|
||||
|
||||
function BattleLogic.Query(func, inCludeDeadRole)
|
||||
function BattleLogic.Query(func)
|
||||
local list = {}
|
||||
local index = 1
|
||||
if func then
|
||||
for i=1, objList.size do
|
||||
local v = objList.vList[i]
|
||||
if func(v) and (inCludeDeadRole or not v.isDead) then
|
||||
if func(v) and not v.isDead then
|
||||
list[index] = v
|
||||
index = index + 1
|
||||
end
|
||||
|
@ -298,7 +299,14 @@ end
|
|||
|
||||
function BattleLogic.Clear()
|
||||
while objList.size > 0 do
|
||||
BattleLogic.RemoveObj(objList.vList[objList.size].uid)
|
||||
objList.vList[objList.size]:Dispose()
|
||||
removeObjList:Add(objList.vList[objList.size])
|
||||
objList:Remove(objList.vList[objList.size].uid)
|
||||
end
|
||||
while removeObjList.size > 0 do
|
||||
removeObjList.buffer[removeObjList.size]:Dispose()
|
||||
rolePool:Put(removeObjList.buffer[removeObjList.size])
|
||||
removeObjList:Remove(removeObjList.size)
|
||||
end
|
||||
while tbActionList.size > 0 do
|
||||
actionPool:Put(tbActionList.buffer[tbActionList.size])
|
||||
|
@ -310,15 +318,16 @@ function BattleLogic.ClearOrder()
|
|||
local index = 1
|
||||
while index <= objList.size do
|
||||
if objList.vList[index].camp == 1 then
|
||||
BattleLogic.RemoveObj(objList.vList[index].uid)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RemoveRole, objList.vList[index])
|
||||
objList.vList[index]:Dispose()
|
||||
removeObjList:Add(objList.vList[index])
|
||||
objList:Remove(objList.vList[index].uid)
|
||||
else
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local tmpObj, index, bMyAllDead, bEnemyAllDead
|
||||
|
||||
function BattleLogic.Update()
|
||||
curFrame = curFrame + 1
|
||||
if curFrame > maxFrame then
|
||||
|
@ -331,8 +340,9 @@ function BattleLogic.Update()
|
|||
local opType = optionRecord[i][2]
|
||||
local opArg = optionRecord[i][3]
|
||||
if opType == 1 then --自动手动
|
||||
isAuto = opArg == 1
|
||||
for i=1, objList.size do
|
||||
tmpObj = objList.vList[i]
|
||||
local tmpObj = objList.vList[i]
|
||||
if tmpObj.camp == 0 then
|
||||
tmpObj.Auto = opArg == 1
|
||||
end
|
||||
|
@ -347,22 +357,28 @@ function BattleLogic.Update()
|
|||
if role and role.superSkill then
|
||||
role.superSkill:Cast()
|
||||
end
|
||||
elseif opType == 4 then --释放teamSkill
|
||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
index = 1
|
||||
local index = 1
|
||||
while index <= tbActionList.size do
|
||||
if tbActionList.buffer[index][1] <= curFrame then
|
||||
tbActionList.buffer[index][2]()
|
||||
actionPool:Put(tbActionList.buffer[index])
|
||||
local action = tbActionList.buffer[index]
|
||||
if action[1] <= curFrame then
|
||||
action[2]()
|
||||
actionPool:Put(action)
|
||||
tbActionList:Remove(index)
|
||||
else
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
|
||||
if playerMP == 100 and playerSkillUsable then
|
||||
if playerMP == 100 and playerSkillUsable and isAuto then
|
||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
|
@ -370,8 +386,8 @@ function BattleLogic.Update()
|
|||
if playerTeamSkillIndex > #playerTeamSkillList then
|
||||
playerTeamSkillIndex = 1
|
||||
end
|
||||
playerMP = 0
|
||||
end
|
||||
playerMP = 0
|
||||
end
|
||||
if enemyMP == 100 and enemySkillUsable then
|
||||
local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
|
||||
|
@ -381,16 +397,16 @@ function BattleLogic.Update()
|
|||
if enemyTeamSkillIndex > #enemyTeamSkillList then
|
||||
enemyTeamSkillIndex = 1
|
||||
end
|
||||
enemyMP = 0
|
||||
end
|
||||
enemyMP = 0
|
||||
end
|
||||
|
||||
BattleLogic.BuffMgr:Update()
|
||||
|
||||
bMyAllDead = true
|
||||
bEnemyAllDead = true
|
||||
local bMyAllDead = true
|
||||
local bEnemyAllDead = true
|
||||
for i=1, objList.size do
|
||||
tmpObj = objList.vList[i]
|
||||
local tmpObj = objList.vList[i]
|
||||
if not tmpObj.isDead then
|
||||
tmpObj:Update()
|
||||
if tmpObj.camp == 0 then
|
||||
|
@ -415,9 +431,8 @@ end
|
|||
|
||||
--Debug专用
|
||||
function BattleLogic.SetDebug()
|
||||
local v
|
||||
for i=1, objList.size do
|
||||
v = objList.vList[i]
|
||||
local v = objList.vList[i]
|
||||
v.IsDebug = not v.IsDebug
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ Brand = Buff:New()
|
|||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function Brand:SetData(...)
|
||||
--log("Brand:SetData")
|
||||
self.flag = ...
|
||||
self.flag, self.endFunc = ... --标记,结束回调
|
||||
self.cover = true
|
||||
self.layer = 1
|
||||
end
|
||||
|
@ -23,13 +23,19 @@ end
|
|||
--效果结束时调用一次
|
||||
function Brand:OnEnd()
|
||||
--log("Brand:OnEnd")
|
||||
if self.endFunc then
|
||||
self.endFunc()
|
||||
end
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Brand:OnCover(newBuff)
|
||||
--log("Brand:OnCover")
|
||||
newBuff.layer = self.layer + 1
|
||||
return true
|
||||
local b = newBuff.flag == self.flag
|
||||
if b then
|
||||
newBuff.layer = self.layer + 1
|
||||
end
|
||||
return b
|
||||
end
|
||||
|
||||
return Brand
|
|
@ -5,6 +5,7 @@ Control = Buff:New()
|
|||
function Control:SetData(...)
|
||||
--log("Control:SetData")
|
||||
self.ctrlType = ...
|
||||
self.cover = true --控制效果可被覆盖
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
|
@ -13,13 +14,13 @@ function Control:OnStart()
|
|||
if self.ctrlType == 1 then --眩晕
|
||||
self.target.enable = false
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
|
||||
self.target.ctrl_slient = true
|
||||
elseif self.ctrlType == 3 then --嘲讽
|
||||
self.target.lockTarget = self.caster
|
||||
elseif self.ctrlType == 4 then --禁疗
|
||||
|
||||
self.target.ctrl_noheal = true
|
||||
elseif self.ctrlType == 5 then --致盲
|
||||
|
||||
self.target.ctrl_blind = true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -35,20 +36,20 @@ function Control:OnEnd()
|
|||
if self.ctrlType == 1 then --眩晕
|
||||
self.target.enable = true
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
|
||||
self.target.ctrl_slient = false
|
||||
elseif self.ctrlType == 3 then --嘲讽
|
||||
self.target.lockTarget = nil
|
||||
elseif self.ctrlType == 4 then --禁疗
|
||||
|
||||
self.target.ctrl_noheal = false
|
||||
elseif self.ctrlType == 5 then --致盲
|
||||
|
||||
self.target.ctrl_blind = false
|
||||
end
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Control:OnCover(newBuff)
|
||||
--log("Control:OnCover")
|
||||
return true
|
||||
return newBuff.ctrlType == self.ctrlType
|
||||
end
|
||||
|
||||
return Control
|
|
@ -26,7 +26,10 @@ function Shield:OnEnd()
|
|||
--log("Shield:OnEnd")
|
||||
for i = 1, self.target.shield.size do
|
||||
if self.target.shield.buffer[i] == self then
|
||||
BattleUtil.ApplyDamage(self.caster, self.target, math.floor(self.dmgReboundFactor * self.damageSum))
|
||||
local arr = BattleLogic.Query(function (r) return r.camp ~= self.target.camp end)
|
||||
for j = 1, #arr do
|
||||
BattleUtil.ApplyDamage(self.target, arr[j], math.floor(self.dmgReboundFactor * self.damageSum))
|
||||
end
|
||||
self.target.shield:Remove(i)
|
||||
break
|
||||
end
|
||||
|
|
|
@ -44,7 +44,6 @@ end
|
|||
|
||||
function BattleUtil.CalCrit(atkRole, defRole)
|
||||
local bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit), 0, 1)
|
||||
|
||||
if bCrit then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole)
|
||||
|
@ -53,9 +52,8 @@ function BattleUtil.CalCrit(atkRole, defRole)
|
|||
end
|
||||
|
||||
function BattleUtil.CalShield(atkRole, defRole, damage)
|
||||
local buff
|
||||
for i=1, defRole.shield.size do
|
||||
buff = defRole.shield.buffer[i]
|
||||
local buff = defRole.shield.buffer[i]
|
||||
if damage < buff.shieldValue then
|
||||
buff.shieldValue = buff.shieldValue - damage
|
||||
buff.damageSum = buff.damageSum + damage
|
||||
|
@ -86,7 +84,9 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit)
|
|||
defRole.Event:DispatchEvent(BattleEventName.RoleDead)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole)
|
||||
if defRole.camp == 1 then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, BattleLogic.GetAggro(0), 0.3)
|
||||
BattleLogic.WaitForTrigger(1, function ()
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, BattleLogic.GetAggro(0), 1)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -143,7 +143,7 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
element = (1 + atkData:GetData(RoleDataName.ElementDamageBocusFactor)) * (1 - defData:GetData(elementDamageReduceFactor))
|
||||
|
||||
baseDamage = baseDamage * baseFactor * element
|
||||
baseDamage = max(baseDamage, 0.1 * attack)
|
||||
baseDamage = floor(max(baseDamage, 0.1 * attack))
|
||||
|
||||
local func
|
||||
for i=1, atkRole.exCalDmgList.size do
|
||||
|
@ -160,6 +160,9 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
end
|
||||
|
||||
function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
||||
if targetRole.ctrl_noheal then --禁疗无法加血
|
||||
return
|
||||
end
|
||||
baseFactor = baseFactor or 1
|
||||
local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp)
|
||||
local hp = targetRole:GetRoleData(RoleDataName.Hp)
|
||||
|
|
|
@ -63,6 +63,56 @@ function RoleLogic:Init(uid, data)
|
|||
self.Auto = true
|
||||
self.IsDebug = false
|
||||
self.enable = true
|
||||
|
||||
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
|
||||
else
|
||||
skill.sp = skill.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() then
|
||||
superSkill:Cast()
|
||||
end
|
||||
else
|
||||
superSkill.sp = superSkill.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
|
||||
if Random.Range01() <= 0.75 then
|
||||
skill:Cast()
|
||||
else
|
||||
superSkill:Cast()
|
||||
end
|
||||
end
|
||||
else
|
||||
skill.sp = skill.sp + 1
|
||||
end
|
||||
else
|
||||
superSkill.sp = superSkill.sp + 1
|
||||
end
|
||||
end
|
||||
else
|
||||
self.updateFunc = function() end
|
||||
end
|
||||
end
|
||||
|
||||
function RoleLogic:CanCastSkill()
|
||||
return self.enable and not self.ctrl_slient and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp)
|
||||
end
|
||||
|
||||
function RoleLogic:GetRoleData(property)
|
||||
|
@ -98,37 +148,5 @@ function RoleLogic:Update()
|
|||
if not self.enable then
|
||||
return
|
||||
end
|
||||
if self.superSkill then
|
||||
if self.superSkill.sp >= self.superSkill.spPass then
|
||||
if self.skill then
|
||||
if self.skill.sp >= self.skill.spPass then
|
||||
if self.Auto and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp) then
|
||||
if Random.Range01() <= 0.75 then
|
||||
self.skill:Cast()
|
||||
else
|
||||
self.superSkill:Cast()
|
||||
end
|
||||
end
|
||||
else
|
||||
self.skill.sp = self.skill.sp + 1
|
||||
end
|
||||
else
|
||||
if self.Auto and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp) then
|
||||
self.superSkill:Cast()
|
||||
end
|
||||
end
|
||||
else
|
||||
self.superSkill.sp = self.superSkill.sp + 1
|
||||
end
|
||||
else
|
||||
if self.skill then
|
||||
if self.skill.sp >= self.skill.spPass then
|
||||
if self.Auto and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp) then
|
||||
self.skill:Cast()
|
||||
end
|
||||
else
|
||||
self.skill.sp = self.skill.sp + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
self.updateFunc()
|
||||
end
|
Loading…
Reference in New Issue