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