战斗修改
parent
870b745e05
commit
bf2cfc3bcf
|
@ -66,4 +66,4 @@ function BattleEvent:ClearEvent()
|
|||
listPool:Put(v)
|
||||
self.m_listeners[k]=nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,13 +38,34 @@ function Buff.Create(caster, type, duration, ...)
|
|||
buff.clear = true --该值为false时,buff不可被驱散,除非无条件驱散
|
||||
|
||||
buff.duration = duration --持续时间为0时buff永久存在
|
||||
buff.interval = -1 --间隔帧为0时每帧触发,小于0不触发 默认不触发OnTrigger
|
||||
buff.framePass = 0
|
||||
buff.interval = -1 --间隔帧为0时每回合触发,小于0不触发 默认不触发OnTrigger
|
||||
-- buff.framePass = 0
|
||||
|
||||
buff.roundPass = 0
|
||||
|
||||
|
||||
buff:SetData(...)
|
||||
return buff
|
||||
end
|
||||
|
||||
-- 改变buff的轮次
|
||||
function Buff:ChangeBuffDuration(type, value)
|
||||
-- 永久存在改变无效
|
||||
if self.duration <= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- 计算
|
||||
local finalDuration = BattleUtil.ErrorCorrection(BattleUtil.CountValue(self.duration, value, type))
|
||||
self.duration = finalDuration
|
||||
if self.roundDuration then
|
||||
self.roundDuration = finalDuration
|
||||
end
|
||||
|
||||
-- 发送事件
|
||||
self.caster.Event:DispatchEvent(BattleEventName.BuffDurationChange, self)
|
||||
end
|
||||
|
||||
BuffManager = {}
|
||||
BuffManager.__index = BuffManager
|
||||
|
||||
|
@ -54,6 +75,14 @@ function BuffManager.New()
|
|||
return instance
|
||||
end
|
||||
|
||||
-- 根据类型获取buff的刷新级别
|
||||
-- local _TypeToLevel = {
|
||||
-- [] = ,
|
||||
-- }
|
||||
function BuffManager.GetLevelByType(type)
|
||||
|
||||
end
|
||||
|
||||
function BuffManager:Init()
|
||||
while self.buffQueue.size > 0 do
|
||||
putBuff(self.buffQueue:Dequeue())
|
||||
|
@ -72,7 +101,7 @@ end
|
|||
function BuffManager:AddBuff(target, buff)
|
||||
buff.target = target
|
||||
self.buffQueue:Enqueue(buff)
|
||||
buff.frameDuration = floor(buff.duration * BattleLogic.GameFrameRate)
|
||||
-- buff.frameDuration = floor(buff.duration * BattleLogic.GameFrameRate)
|
||||
--if buff.isBuff then --TODO:增益buff持续时间加成
|
||||
-- local buffBocus = buff.caster:GetRoleData(RoleDataName.BuffBocus)
|
||||
-- buff.frameDuration = floor(buff.duration * (1 + buffBocus + buff.exCtrlTime) * BattleLogic.GameFrameRate)
|
||||
|
@ -83,7 +112,10 @@ function BuffManager:AddBuff(target, buff)
|
|||
-- buff.frameDuration = floor(buff.duration * (1 - debuffReduce - buff.exCtrlTime) * BattleLogic.GameFrameRate)
|
||||
--end
|
||||
|
||||
buff.frameInterval = floor(buff.interval * BattleLogic.GameFrameRate)
|
||||
-- buff.frameInterval = floor(buff.interval * BattleLogic.GameFrameRate)
|
||||
|
||||
buff.roundDuration = buff.duration
|
||||
buff.roundInterval = buff.interval
|
||||
buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff)
|
||||
end
|
||||
|
||||
|
@ -148,7 +180,9 @@ function BuffManager:GetBuffCount(type)
|
|||
return 0
|
||||
end
|
||||
|
||||
-- 每帧刷新
|
||||
function BuffManager:Update()
|
||||
-- 检测上一帧生成的buff,加入管理
|
||||
while self.buffQueue.size > 0 do
|
||||
local buff = self.buffQueue:Dequeue()
|
||||
local buffList
|
||||
|
@ -158,14 +192,18 @@ function BuffManager:Update()
|
|||
else
|
||||
buffList = self.buffDic.kvList[buff.type]
|
||||
end
|
||||
|
||||
-- 是覆盖类型的buff且有老buff
|
||||
if buff.cover and buffList.size > 0 then
|
||||
local isCovered = false
|
||||
for i=1, buffList.size do
|
||||
local oldBuff = buffList.buffer[i]
|
||||
if oldBuff.cover and oldBuff.target == buff.target and oldBuff.clear == buff.clear and oldBuff:OnCover(buff) then --判定该效果能否被覆盖
|
||||
-- 结束并回收老buff
|
||||
oldBuff:OnEnd()
|
||||
oldBuff.target.Event:DispatchEvent(BattleEventName.BuffEnd, oldBuff)
|
||||
putBuff(oldBuff)
|
||||
-- 覆盖老buff
|
||||
buffList.buffer[i] = buff
|
||||
buff:OnStart()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff)
|
||||
|
@ -174,50 +212,27 @@ function BuffManager:Update()
|
|||
break
|
||||
end
|
||||
end
|
||||
-- 没有覆盖,新buff
|
||||
if not isCovered then
|
||||
buffList:Add(buff)
|
||||
buff:OnStart()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff)
|
||||
end
|
||||
else
|
||||
-- 新buff
|
||||
buffList:Add(buff)
|
||||
buff:OnStart()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff)
|
||||
end
|
||||
end
|
||||
|
||||
-- 清除过期buff
|
||||
for i=1, self.buffDic.size do
|
||||
local buffList = self.buffDic.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
|
||||
buff.framePass = buff.framePass + 1
|
||||
if buff.frameDuration == 0 then
|
||||
if buff.frameInterval == 0 or buff.framePass % buff.frameInterval == 0 then
|
||||
if not buff:OnTrigger() then
|
||||
buff.disperse = true
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff)
|
||||
end
|
||||
elseif buff.frameInterval < 0 then
|
||||
if buff.framePass > buff.frameDuration then
|
||||
buff.disperse = true
|
||||
end
|
||||
else
|
||||
if buff.frameInterval == 0 or buff.framePass % buff.frameInterval == 0 then
|
||||
if not buff:OnTrigger() then
|
||||
buff.disperse = true
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff)
|
||||
end
|
||||
if buff.framePass > buff.frameDuration then
|
||||
buff.disperse = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if buff.disperse then
|
||||
buff:OnEnd()
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buff)
|
||||
|
@ -230,3 +245,50 @@ function BuffManager:Update()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 每一个人的轮次都刷新
|
||||
function BuffManager:TurnUpdate(sort)
|
||||
for i=1, self.buffDic.size do
|
||||
local buffList = self.buffDic.vList[i]
|
||||
if buffList.size > 0 then
|
||||
local index = 1
|
||||
while index <= buffList.size do
|
||||
local buff = buffList.buffer[index]
|
||||
local curCamp, curPos = BattleLogic.GetCurTurn()
|
||||
if buff.sort == sort -- 当前buff刷新等级
|
||||
and buff.target.camp == curCamp -- 当前阵营
|
||||
and buff.target.position == curPos then -- 当前位置
|
||||
--印记类型的buff不处理更新逻辑
|
||||
if buff.roundDuration == 0 and buff.roundInterval < 0 then
|
||||
else
|
||||
buff.roundPass = buff.roundPass + 1
|
||||
if buff.roundDuration == 0 then
|
||||
if buff.roundInterval == 0 or buff.roundPass % buff.roundInterval == 0 then
|
||||
if not buff:OnTrigger() then
|
||||
buff.disperse = true
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff)
|
||||
end
|
||||
elseif buff.roundInterval < 0 then
|
||||
if buff.roundPass > buff.roundDuration then
|
||||
buff.disperse = true
|
||||
end
|
||||
else
|
||||
if buff.roundInterval == 0 or buff.roundPass % buff.roundInterval == 0 then
|
||||
if not buff:OnTrigger() then
|
||||
buff.disperse = true
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffTrigger, buff)
|
||||
end
|
||||
if buff.roundPass > buff.roundDuration then
|
||||
buff.disperse = true
|
||||
end
|
||||
end
|
||||
buff.target.Event:DispatchEvent(BattleEventName.BuffRoundChange, buff)
|
||||
end
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -64,4 +64,4 @@ function Random.RangeInt(v1, v2)
|
|||
else
|
||||
return v1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,8 +7,8 @@ local function isFactor(name)
|
|||
end
|
||||
|
||||
function RoleData.New()
|
||||
local instance = {role=0, data={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
|
||||
orginData={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0}}
|
||||
local instance = {role=0, data={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0},
|
||||
orginData={0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0}}
|
||||
setmetatable(instance, RoleData)
|
||||
return instance
|
||||
end
|
||||
|
@ -106,4 +106,4 @@ function RoleData:Foreach(func)
|
|||
for k,v in ipairs(self.data) do
|
||||
func(k, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,23 +24,16 @@ end
|
|||
|
||||
function Skill:Init(role, effectData, type) --type 0 异妖 1 点技 2 滑技
|
||||
local isTeamSkill = type == 0
|
||||
if type == 0 then --异妖
|
||||
self.cd = effectData[1] % 100 --异妖技能的cd数据为:类型*100 + 站位
|
||||
self.randomInStage2 = 0
|
||||
elseif type == 1 then --点技
|
||||
self.cd = 0 --点技 cd为0
|
||||
self.randomInStage2 = 0
|
||||
elseif type == 2 then --滑技
|
||||
self.cd = effectData[1] % 100 --上滑技的cd数据为:中期上滑概率*100000 + cd
|
||||
self.randomInStage2 = (effectData[1] - self.cd) / 100000
|
||||
end
|
||||
|
||||
--skill = {cd, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
|
||||
self.type = type
|
||||
--skill = {技能ID, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
|
||||
--效果 = {效果类型id, 效果参数1, 效果参数2, ...}
|
||||
self.effectList:Clear()
|
||||
self.owner = role
|
||||
self.isTeamSkill = isTeamSkill
|
||||
self.teamSkillType = isTeamSkill and floor(effectData[1] / 100) or 0
|
||||
self.id = effectData[1] -- 技能ID
|
||||
-- self.EffectDuration = 0 -- 效果命中需要的时间
|
||||
|
||||
|
||||
for i=2, #effectData do
|
||||
local v = effectData[i]
|
||||
|
@ -75,21 +68,28 @@ function Skill:Dispose()
|
|||
end
|
||||
end
|
||||
|
||||
local function takeEffect(caster, target, effects, duration)
|
||||
local function takeEffect(caster, target, effects, duration, skill)
|
||||
for k=1, #effects do
|
||||
local e = effects[k]
|
||||
effect[e.type](caster, target, e.args, duration)
|
||||
effect[e.type](caster, target, e.args, duration, skill)
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
BattleLogic.RecordEffect(caster, target, e.type, e.args, duration)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Skill:Cast()
|
||||
-- 释放技能
|
||||
-- func 技能释放完成回调
|
||||
-- targets 指定技能释放目标
|
||||
-- isAdd 是否是追加技能
|
||||
function Skill:Cast(func, targets, isAdd)
|
||||
self.castDoneFunc = func
|
||||
self.effectTargets = {}
|
||||
self.isAdd = isAdd
|
||||
for i=1, self.effectList.size do
|
||||
local effectGroup = self.effectList.buffer[i]
|
||||
local chooseId = effectGroup.chooseId
|
||||
local arr = BattleUtil.ChooseTarget(self.owner, chooseId)
|
||||
local arr = targets or BattleUtil.ChooseTarget(self.owner, chooseId)
|
||||
if #arr > 0 then
|
||||
--效果延迟1帧生效
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
|
@ -100,74 +100,98 @@ function Skill:Cast()
|
|||
if count == 0 then
|
||||
count = #arr
|
||||
end
|
||||
if chooseId == 10000 or chooseId == 20000 then --10000 我方aoe 20000 敌方aoe
|
||||
local camp = chooseId == 10000 and self.owner.camp or 1 - self.owner.camp
|
||||
self.owner.Event:DispatchEvent(BattleEventName.AOE, camp)
|
||||
for j=1, count do
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
elseif weight == 8 then --对位相邻的目标同时触发效果
|
||||
for j=1, count do
|
||||
takeEffect(self.owner, arr[j], effects, duration)
|
||||
end
|
||||
else
|
||||
local d = duration / (count + 1) --分割多人目标施加效果的时间,按照(1+1+..+2)的时间权重占比分配
|
||||
for j=1, count do
|
||||
local index = j
|
||||
local cd = j == count and d * 2 or d
|
||||
BattleLogic.WaitForTrigger(d * (j-1), function()
|
||||
local r = arr[index]
|
||||
if not r or r.isDead then --当被选取的目标已经死亡或者没有,则重新选取,若重新选取的目标也死亡或者没有,则从之前的目标中选取第一个不死亡的
|
||||
arr = BattleUtil.ChooseTarget(self.owner, chooseId)
|
||||
r = arr[index]
|
||||
if not r then --当没有新增的被选取目标时,可能为空
|
||||
for i=1, #arr do
|
||||
if not arr[i].isDead then
|
||||
takeEffect(self.owner, arr[i], effects, cd)
|
||||
return
|
||||
end
|
||||
end
|
||||
if not r then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
takeEffect(self.owner, r, effects, cd)
|
||||
end)
|
||||
|
||||
-- 全部同时生效
|
||||
for j=1, count do
|
||||
if arr[j] and not arr[j].isDead then
|
||||
takeEffect(self.owner, arr[j], effects, duration, self)
|
||||
-- 加入目标列表
|
||||
table.insert(self.effectTargets, arr[j])
|
||||
end
|
||||
end
|
||||
|
||||
-- if chooseId == 100000 or chooseId == 200000 then --10000 我方aoe 20000 敌方aoe
|
||||
-- local camp = chooseId == 100000 and self.owner.camp or 1 - self.owner.camp
|
||||
-- self.owner.Event:DispatchEvent(BattleEventName.AOE, camp)
|
||||
-- for j=1, count do
|
||||
-- takeEffect(self.owner, arr[j], effects, duration, self)
|
||||
-- -- 加入目标列表
|
||||
-- table.insert(self.effectTargets, arr[j])
|
||||
-- end
|
||||
-- elseif weight == 7 then --对位相邻的目标同时触发效果
|
||||
-- for j=1, count do
|
||||
-- takeEffect(self.owner, arr[j], effects, duration, self)
|
||||
-- -- 加入目标列表
|
||||
-- table.insert(self.effectTargets, arr[j])
|
||||
-- end
|
||||
-- else
|
||||
-- for j = 1, count do
|
||||
-- local index = j
|
||||
-- local r = arr[index]
|
||||
-- -- if not r or r.isDead then --当被选取的目标已经死亡或者没有,则重新选取,若重新选取的目标也死亡或者没有,则从之前的目标中选取第一个不死亡的
|
||||
-- -- if not targets then -- 如果是指定目标释放的则不再选取目标
|
||||
-- -- arr = BattleUtil.ChooseTarget(self.owner, chooseId)
|
||||
-- -- r = arr[index]
|
||||
-- -- if not r then --当没有新增的被选取目标时,可能为空
|
||||
-- -- for i=1, #arr do
|
||||
-- -- if not arr[i].isDead then
|
||||
-- -- r = arr[i]
|
||||
-- -- break
|
||||
-- -- end
|
||||
-- -- end
|
||||
-- -- end
|
||||
-- -- end
|
||||
-- -- end
|
||||
-- --
|
||||
-- if r and not r.isDead then
|
||||
-- takeEffect(self.owner, r, effects, duration, self)
|
||||
-- -- 加入目标列表
|
||||
-- table.insert(self.effectTargets, r)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if not self.isTeamSkill then
|
||||
local type = BattleLogic.Type
|
||||
local isPVEMonster = self.owner.camp == 1 and (type == 1 or type == 2 or type == 4 or type == 5 or type == 8)
|
||||
local time = 0
|
||||
if isPVEMonster then
|
||||
if self.owner.superSkill == self then
|
||||
--怪物绝技读条时间=max(10-速度/(8*(等级+10)),2)
|
||||
time = max(10-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 2)
|
||||
else
|
||||
--怪物普技读条时间==max(9-速度/(8*(等级+10)),1)
|
||||
time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1)
|
||||
end
|
||||
else
|
||||
if self.owner.superSkill == self then
|
||||
--绝技读条时间=max(9-速度/(8*(等级+10)),3)
|
||||
time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 3)
|
||||
else
|
||||
--普技读条时间=max(7-速度/(8*(等级+10)),1.5)
|
||||
time = max(7-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
end
|
||||
end
|
||||
self.owner.sp = 0
|
||||
self.owner.spPass = floor(BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
else
|
||||
-- 计算技能CD的没有用了
|
||||
-- if not self.isTeamSkill then
|
||||
-- local type = BattleLogic.Type
|
||||
-- local isPVEMonster = self.owner.camp == 1 and (type == 1 or type == 2 or type == 4 or type == 5 or type == 8)
|
||||
-- local time = 0
|
||||
-- if isPVEMonster then
|
||||
-- if self.owner.superSkill == self then
|
||||
-- --怪物绝技读条时间=max(10-速度/(8*(等级+10)),2)
|
||||
-- time = max(10-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 2)
|
||||
-- else
|
||||
-- --怪物普技读条时间==max(9-速度/(8*(等级+10)),1)
|
||||
-- time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1)
|
||||
-- end
|
||||
-- else
|
||||
-- if self.owner.superSkill == self then
|
||||
-- --绝技读条时间=max(9-速度/(8*(等级+10)),3)
|
||||
-- time = max(9-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 3)
|
||||
-- else
|
||||
-- --普技读条时间=max(7-速度/(8*(等级+10)),1.5)
|
||||
-- time = max(7-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
-- end
|
||||
-- end
|
||||
-- self.owner.sp = 0
|
||||
-- self.owner.spPass = floor(BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
-- else
|
||||
-- self.owner.curSkill = self
|
||||
-- end
|
||||
--
|
||||
if self.isTeamSkill then
|
||||
self.owner.curSkill = self
|
||||
end
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
|
||||
-- 延时一帧执行,避免战斗还没开始就释放了技能
|
||||
-- BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||
-- end)
|
||||
|
||||
|
||||
--技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个
|
||||
local duration = 0
|
||||
|
@ -180,8 +204,28 @@ function Skill:Cast()
|
|||
BattleLogic.SetSkillUsable(self.owner.camp, true)
|
||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self)
|
||||
for _, tr in ipairs(self.effectTargets) do
|
||||
tr.Event:DispatchEvent(BattleEventName.BeSkillCastEnd, self)
|
||||
end
|
||||
-- 技能结束
|
||||
self:EndSkill()
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 结束技能
|
||||
function Skill:EndSkill()
|
||||
-- 技能结束后摇后结束技能释放
|
||||
-- if self.isAdd then
|
||||
-- if self.castDoneFunc then self.castDoneFunc() end
|
||||
-- else
|
||||
-- 非追加技能加入技能后摇
|
||||
BattleLogic.WaitForTrigger(0.5, function()
|
||||
if self.castDoneFunc then self.castDoneFunc() end
|
||||
end)
|
||||
-- end
|
||||
--
|
||||
self.effectTargets = {}
|
||||
self.isAdd = nil
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,12 @@ local min = math.min
|
|||
local objList = BattleDictionary.New()
|
||||
local removeObjList = BattleList.New()
|
||||
|
||||
local MaxRound = 20
|
||||
local CurRound = 0
|
||||
local CurCamp = 0
|
||||
local CurSkillPos = {}
|
||||
local PosList = {}
|
||||
|
||||
local curUid
|
||||
local curBuffId
|
||||
local curFrame
|
||||
|
@ -26,6 +32,9 @@ local enemyTeamDummyRole = {camp = 1, Event = BattleEvent.New(), isTeam = true,
|
|||
local playerTeamSkillList = {}
|
||||
local enemyTeamSkillList = {}
|
||||
|
||||
local _IsDebug
|
||||
|
||||
|
||||
local fightData
|
||||
local record
|
||||
local optionRecord
|
||||
|
@ -40,17 +49,12 @@ BattleLogic.TotalOrder = 0
|
|||
--当前波次
|
||||
BattleLogic.CurOrder = 0
|
||||
|
||||
local stage --战场分割阶段
|
||||
local stageFrame1 = 15 * BattleLogic.GameFrameRate --前期转中期的时间点
|
||||
local stageFrame2 = 30 * BattleLogic.GameFrameRate --中期转后期的时间点
|
||||
local curStageFrame
|
||||
local teamSkillCastRound = {2, 4, 6}
|
||||
local MyTeamSkillCastIndex
|
||||
local EnemyTeamSkillCastIndex
|
||||
|
||||
local teamSkillCastTime = {7 * BattleLogic.GameFrameRate,
|
||||
22 * BattleLogic.GameFrameRate,
|
||||
45 * BattleLogic.GameFrameRate}
|
||||
local teamSkillCastIndex
|
||||
|
||||
local maxFrame --战斗最大用时,超时判负
|
||||
-- local maxFrame --战斗最大用时,超时判负
|
||||
|
||||
local actionPool = BattleObjectPool.New(function ()
|
||||
return { 0, 0 }
|
||||
|
@ -64,12 +68,12 @@ local rolePool = BattleObjectPool.New(function ()
|
|||
return RoleLogic.New()
|
||||
end)
|
||||
|
||||
function BattleLogic.Init(maxTime, data, optionData)
|
||||
function BattleLogic.Init(data, optionData)
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
record = {}
|
||||
end
|
||||
|
||||
maxFrame = BattleLogic.GameFrameRate * maxTime
|
||||
-- maxFrame = BattleLogic.GameFrameRate * maxTime
|
||||
fightData = data
|
||||
if optionData then
|
||||
optionRecord = optionData
|
||||
|
@ -86,8 +90,9 @@ function BattleLogic.Init(maxTime, data, optionData)
|
|||
curBuffId = 0
|
||||
curFrame = 0
|
||||
|
||||
stage = 0
|
||||
CurRound = 0
|
||||
|
||||
_IsDebug = false
|
||||
playerTeamDummyRole.isDebug = false
|
||||
playerTeamDummyRole.Event:ClearEvent()
|
||||
enemyTeamDummyRole.isDebug = false
|
||||
|
@ -106,12 +111,12 @@ function BattleLogic.Init(maxTime, data, optionData)
|
|||
end
|
||||
|
||||
function BattleLogic.StartOrder()
|
||||
--
|
||||
BattleLogic.CurOrder = BattleLogic.CurOrder + 1
|
||||
stage = 0
|
||||
curStageFrame = 0
|
||||
teamSkillCastIndex = 1
|
||||
|
||||
if BattleLogic.CurOrder == 1 then
|
||||
MyTeamSkillCastIndex = 1
|
||||
EnemyTeamSkillCastIndex = 1
|
||||
|
||||
for i=1, #fightData.playerData do
|
||||
BattleLogic.AddRole(fightData.playerData[i], i)
|
||||
end
|
||||
|
@ -128,7 +133,7 @@ function BattleLogic.StartOrder()
|
|||
for i=1, #fightData.playerData.teamSkill do
|
||||
local skill = skillPool:Get()
|
||||
skill:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i], 0)
|
||||
playerTeamSkillList[skill.cd] = skill
|
||||
playerTeamSkillList[i] = skill
|
||||
end
|
||||
for i=1, #fightData.playerData.teamPassive do
|
||||
for j=1, #fightData.playerData.teamPassive[i] do
|
||||
|
@ -151,7 +156,7 @@ function BattleLogic.StartOrder()
|
|||
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
|
||||
local skill = skillPool:Get()
|
||||
skill:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], 0)
|
||||
enemyTeamSkillList[skill.cd] = skill
|
||||
enemyTeamSkillList[i] = skill
|
||||
end
|
||||
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do
|
||||
for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do
|
||||
|
@ -177,7 +182,7 @@ function BattleLogic.StartOrder()
|
|||
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
|
||||
local skill = skillPool:Get()
|
||||
skill:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], 0)
|
||||
enemyTeamSkillList[skill.cd] = skill
|
||||
enemyTeamSkillList[i] = skill
|
||||
end
|
||||
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do
|
||||
for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do
|
||||
|
@ -191,16 +196,120 @@ function BattleLogic.StartOrder()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 开始战斗,延时一帧执行,避免战斗还没开始就释放了技能
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
-- 开始战斗
|
||||
BattleLogic.TurnRound()
|
||||
end)
|
||||
end
|
||||
|
||||
function BattleLogic.TakeTeamPassivity(teamCaster, id, args)
|
||||
for i=1, objList.size do
|
||||
if objList.vList[i].camp == teamCaster.camp then
|
||||
BattleUtil.Passivity[id](objList.vList[i], args)
|
||||
-- 获取当前轮数
|
||||
function BattleLogic.GetCurRound()
|
||||
-- body
|
||||
return CurRound, MaxRound
|
||||
end
|
||||
|
||||
-- 获取当前轮次信息
|
||||
function BattleLogic.GetCurTurn()
|
||||
-- body
|
||||
return CurCamp, CurSkillPos[CurCamp]
|
||||
end
|
||||
|
||||
-- 设置是否是debug
|
||||
function BattleLogic.SetIsDebug(isDebug)
|
||||
_IsDebug = isDebug
|
||||
end
|
||||
function BattleLogic.GetIsDebug()
|
||||
return _IsDebug
|
||||
end
|
||||
|
||||
-- 开始轮转
|
||||
-- debugTurn 用于判断是否是debug轮转的参数
|
||||
function BattleLogic.TurnRound(debugTurn)
|
||||
if BattleLogic.GetIsDebug() and not debugTurn then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.DebugStop)
|
||||
return
|
||||
end
|
||||
-- 第一次进入 或者 本轮结束 初始化流程状态
|
||||
if CurRound == 0 or (CurSkillPos[0] == 6 and CurSkillPos[1] == 6) then
|
||||
CurRound = CurRound + 1
|
||||
CurCamp = 0
|
||||
CurSkillPos[0] = -1 -- 先从异妖开始检测
|
||||
CurSkillPos[1] = -1
|
||||
-- 轮数变化
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound)
|
||||
else
|
||||
-- 切换阵营
|
||||
CurCamp = (CurCamp + 1) % 2
|
||||
end
|
||||
|
||||
-- 当前阵营下一释放技能的位置
|
||||
local cpos = CurSkillPos[CurCamp] + 1
|
||||
|
||||
if cpos == 0 then
|
||||
-- 保存当前释放技能的位置
|
||||
CurSkillPos[CurCamp] = cpos
|
||||
-- 检测异妖技能释放
|
||||
BattleLogic.CheckTeamSkillCast(CurCamp)
|
||||
else
|
||||
-- 找到下一个释放技能的人
|
||||
local SkillRole
|
||||
for p = cpos, 6 do
|
||||
-- 保存当前位置
|
||||
CurSkillPos[CurCamp] = p
|
||||
-- 自己阵营中的位置 + 自己阵营的ID * 6 = 自己在PosList中的位置
|
||||
local role = PosList[p + (CurCamp * 6)]
|
||||
if role and role:IsAvailable() then
|
||||
SkillRole = role
|
||||
break
|
||||
end
|
||||
|
||||
-- 如果当前位置不能释放技能也需要走buff轮转
|
||||
BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量
|
||||
BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血)
|
||||
BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血)
|
||||
BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff
|
||||
end
|
||||
-- 如果找不到下一个人,直接交换阵营
|
||||
if not SkillRole then
|
||||
BattleLogic.TurnRound()
|
||||
return
|
||||
end
|
||||
|
||||
SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnStart)
|
||||
BattleLogic.BuffMgr:TurnUpdate(1) -- 计算恢复血量
|
||||
BattleLogic.BuffMgr:TurnUpdate(2) -- 计算持续伤害(除去流血)
|
||||
-- 释放技能后,递归交换阵营
|
||||
SkillRole:CastSkill(function()
|
||||
BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血)
|
||||
BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff
|
||||
SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd)
|
||||
BattleLogic.TurnRound()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 触发异妖被动
|
||||
function BattleLogic.TakeTeamPassivity(teamCaster, id, args)
|
||||
objList:Foreach(function(k, v)
|
||||
BattleUtil.Passivity[id](v, args)
|
||||
end)
|
||||
end
|
||||
|
||||
-- 获取当前等待释放技能的异妖的序号
|
||||
function BattleLogic.GetTeamSkillCastIndex(camp)
|
||||
-- body
|
||||
if camp == 0 then
|
||||
return MyTeamSkillCastIndex
|
||||
else
|
||||
return EnemyTeamSkillCastIndex
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取异妖
|
||||
function BattleLogic.GetTeamSkill(camp, pos)
|
||||
if camp == 0 then
|
||||
return playerTeamSkillList[pos]
|
||||
|
@ -209,35 +318,80 @@ function BattleLogic.GetTeamSkill(camp, pos)
|
|||
end
|
||||
end
|
||||
|
||||
function BattleLogic.GetTeamSkillCastSlider()
|
||||
if playerTeamDummyRole.isDebug or teamSkillCastIndex > #teamSkillCastTime then
|
||||
-- 获取异妖技能CD
|
||||
function BattleLogic.GetTeamSkillCastSlider(camp)
|
||||
local teamSkillCastIndex = BattleLogic.GetTeamSkillCastIndex(camp)
|
||||
if playerTeamDummyRole.isDebug or teamSkillCastIndex > #teamSkillCastRound then
|
||||
return 0
|
||||
end
|
||||
local slider = (teamSkillCastTime[teamSkillCastIndex] - curStageFrame)
|
||||
local slider = 0
|
||||
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)
|
||||
slider = CurRound / teamSkillCastRound[teamSkillCastIndex]
|
||||
else
|
||||
slider = (CurRound - teamSkillCastRound[teamSkillCastIndex - 1]) / (teamSkillCastRound[teamSkillCastIndex] - teamSkillCastRound[teamSkillCastIndex - 1])
|
||||
end
|
||||
return slider
|
||||
end
|
||||
|
||||
-- 检测异妖技能是否可以释放
|
||||
function BattleLogic.CheckTeamSkillCast(camp)
|
||||
local teamSkillCastIndex = BattleLogic.GetTeamSkillCastIndex(camp)
|
||||
local teamSkillList = camp == 0 and playerTeamSkillList or enemyTeamSkillList
|
||||
if teamSkillList[teamSkillCastIndex] then
|
||||
if teamSkillCastIndex <= #teamSkillCastRound and CurRound >= teamSkillCastRound[teamSkillCastIndex] then
|
||||
teamSkillList[teamSkillCastIndex]:Cast(BattleLogic.TurnRound)
|
||||
if camp == 0 then
|
||||
MyTeamSkillCastIndex = MyTeamSkillCastIndex + 1
|
||||
else
|
||||
EnemyTeamSkillCastIndex = EnemyTeamSkillCastIndex + 1
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
-- 没有要释放技能的异妖,切换阵营
|
||||
BattleLogic.TurnRound()
|
||||
end
|
||||
|
||||
|
||||
function BattleLogic.GenerateBuffId()
|
||||
if not curBuffId then
|
||||
curBuffId = 0
|
||||
end
|
||||
curBuffId = curBuffId + 1
|
||||
return curBuffId
|
||||
end
|
||||
|
||||
-- 角色数据添加
|
||||
function BattleLogic.AddRole(roleData, position)
|
||||
if not curUid then
|
||||
curUid = 0
|
||||
end
|
||||
curUid = curUid + 1
|
||||
local role = rolePool:Get()
|
||||
role:Init(curUid, roleData, position)
|
||||
objList:Add(curUid, role)
|
||||
if roleData.camp == 0 then
|
||||
PosList[position] = role -- 1-6 我方英雄
|
||||
else
|
||||
PosList[position + 6] = role-- 7-12 敌方英雄
|
||||
end
|
||||
if not role.isDead then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.AddRole, role)
|
||||
end
|
||||
end
|
||||
-- 获取角色数据
|
||||
function BattleLogic.GetRole(camp, pos)
|
||||
return PosList[pos + camp*6]
|
||||
end
|
||||
-- 获取某阵营所有角色
|
||||
function BattleLogic.GetRoleByCamp(camp)
|
||||
local list = {}
|
||||
for i = 1, 6 do
|
||||
list[i] = PosList[i + camp * 6]
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
|
||||
function BattleLogic.SetSkillUsable(camp, value)
|
||||
if camp == 0 then
|
||||
|
@ -280,54 +434,23 @@ function BattleLogic.GetTeamSkillCaster(camp)
|
|||
end
|
||||
|
||||
function BattleLogic.HasObj(obj)
|
||||
return obj and objList.kvList[obj.uid]
|
||||
return obj and objList:Get(obj.uid)
|
||||
end
|
||||
|
||||
function BattleLogic.CurFrame()
|
||||
return curFrame
|
||||
end
|
||||
|
||||
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 - curStageFrame) / BattleLogic.GameFrameRate
|
||||
elseif stage == 2 then
|
||||
time = (stageFrame2 - curStageFrame) / BattleLogic.GameFrameRate
|
||||
elseif stage == 3 then
|
||||
time = (maxFrame / BattleLogic.TotalOrder - curStageFrame) / BattleLogic.GameFrameRate
|
||||
end
|
||||
return time
|
||||
end
|
||||
|
||||
function BattleLogic.Query(func, inCludeDeadRole)
|
||||
local list = {}
|
||||
local index = 1
|
||||
if func then
|
||||
for i=1, objList.size do
|
||||
local v = objList.vList[i]
|
||||
objList:Foreach(function(k, v)
|
||||
if func(v) and (inCludeDeadRole or not v.isDead) then
|
||||
list[index] = v
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
@ -370,11 +493,15 @@ end
|
|||
|
||||
function BattleLogic.Update()
|
||||
curFrame = curFrame + 1
|
||||
if curFrame > maxFrame then
|
||||
-- if curFrame > maxFrame then
|
||||
-- BattleLogic.BattleEnd(0)
|
||||
-- return
|
||||
-- end
|
||||
if bMyAllDead then
|
||||
BattleLogic.BattleEnd(0)
|
||||
return
|
||||
end
|
||||
if bMyAllDead then
|
||||
if CurRound > 20 then
|
||||
BattleLogic.BattleEnd(0)
|
||||
return
|
||||
end
|
||||
|
@ -387,31 +514,6 @@ function BattleLogic.Update()
|
|||
end
|
||||
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 teamSkillCastIndex <= #teamSkillCastTime and curStageFrame > teamSkillCastTime[teamSkillCastIndex] then
|
||||
if not playerTeamDummyRole.isDebug and playerTeamSkillList[teamSkillCastIndex] then
|
||||
playerTeamSkillList[teamSkillCastIndex]:Cast()
|
||||
end
|
||||
if not enemyTeamDummyRole.isDebug and enemyTeamSkillList[teamSkillCastIndex] then
|
||||
enemyTeamSkillList[teamSkillCastIndex]:Cast()
|
||||
end
|
||||
teamSkillCastIndex = teamSkillCastIndex + 1
|
||||
end
|
||||
|
||||
local index = 1
|
||||
while index <= tbActionList.size do
|
||||
local action = tbActionList.buffer[index]
|
||||
|
@ -428,47 +530,48 @@ function BattleLogic.Update()
|
|||
|
||||
bMyAllDead = true
|
||||
bEnemyAllDead = true
|
||||
for i=1, objList.size do
|
||||
local tmpObj = objList.vList[i]
|
||||
if not tmpObj.isDead then
|
||||
tmpObj:Update()
|
||||
if tmpObj.camp == 0 then
|
||||
objList:Foreach(function(k, v)
|
||||
if not v.isDead then
|
||||
v:Update()
|
||||
if v.camp == 0 then
|
||||
bMyAllDead = false
|
||||
else
|
||||
bEnemyAllDead = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
if bEnemyAllDead then
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleOrderEnd, BattleLogic.CurOrder)
|
||||
end
|
||||
end
|
||||
|
||||
local posDic = {3,2,4,1,5}
|
||||
--对位规则: 1敌方相同对位 2若死亡或不存在,选取相邻阵位最近且阵位索引最小的
|
||||
function BattleLogic.GetAggro(role)
|
||||
local minNeighbor = 100
|
||||
local index = 100
|
||||
local target
|
||||
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 role.position == objList.vList[i].position then
|
||||
return objList.vList[i]
|
||||
objList:Foreach(function(k, v)
|
||||
if v.camp == enemyCamp and not v.isDead then
|
||||
if role.position == v.position then
|
||||
minNeighbor = 0
|
||||
index = v.position
|
||||
target = v
|
||||
return "break" --终止foreach
|
||||
else
|
||||
local neighbor = math.abs(posDic[role.position] - posDic[objList.vList[i].position])
|
||||
local neighbor = math.abs(role.position - v.position)
|
||||
if neighbor < minNeighbor then
|
||||
minNeighbor = neighbor
|
||||
index = objList.vList[i].position
|
||||
target = objList.vList[i]
|
||||
elseif neighbor == minNeighbor and objList.vList[i].position < index then
|
||||
index = v.position
|
||||
target = v
|
||||
elseif neighbor == minNeighbor and v.position < index then
|
||||
minNeighbor = neighbor
|
||||
index = objList.vList[i].position
|
||||
target = objList.vList[i]
|
||||
index = v.position
|
||||
target = v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
return target
|
||||
end
|
||||
--获取对位相邻站位的人 chooseType 1 我方 2 敌方(对位的敌人受到嘲讽的影响,若对位的敌人死亡,则选取相邻最近的作为目标)
|
||||
|
@ -487,7 +590,7 @@ function BattleLogic.GetNeighbor(role, chooseType)
|
|||
if target then
|
||||
local list = BattleLogic.Query(function (r) return r.camp == target.camp end)
|
||||
for i=1, #list do
|
||||
if not list[i].isDead and math.abs(posDic[target.position] - posDic[list[i].position]) <= 1 then
|
||||
if not list[i].isDead and math.abs(target.position - list[i].position) <= 1 then
|
||||
table.insert(posList, list[i])
|
||||
end
|
||||
end
|
||||
|
@ -495,22 +598,14 @@ function BattleLogic.GetNeighbor(role, chooseType)
|
|||
return posList
|
||||
end
|
||||
|
||||
function BattleLogic.ResetTeamSkillCD(camp)
|
||||
local skill = camp == 0 and playerTeamDummyRole.curSkill or enemyTeamDummyRole.curSkill
|
||||
if skill then
|
||||
skill.spPass = floor(skill.cd % 100 * BattleLogic.GameFrameRate)
|
||||
skill.sp = skill.spPass
|
||||
end
|
||||
end
|
||||
|
||||
function BattleLogic.CastTeamSkill(camp)
|
||||
if camp == 0 then
|
||||
local teamSkill = playerTeamSkillList[teamSkillCastIndex]
|
||||
local teamSkill = playerTeamSkillList[MyTeamSkillCastIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
end
|
||||
else
|
||||
local teamSkill = enemyTeamSkillList[teamSkillCastIndex]
|
||||
local teamSkill = enemyTeamSkillList[EnemyTeamSkillCastIndex]
|
||||
if teamSkill then
|
||||
teamSkill:Cast()
|
||||
end
|
||||
|
@ -518,14 +613,13 @@ function BattleLogic.CastTeamSkill(camp)
|
|||
end
|
||||
|
||||
--Debug专用
|
||||
function BattleLogic.SetDebug()
|
||||
for i=1, objList.size do
|
||||
local v = objList.vList[i]
|
||||
v.IsDebug = not v.IsDebug
|
||||
end
|
||||
playerTeamDummyRole.isDebug = not playerTeamDummyRole.isDebug
|
||||
enemyTeamDummyRole.isDebug = not enemyTeamDummyRole.isDebug
|
||||
end
|
||||
-- function BattleLogic.SetDebug()
|
||||
-- objList:Foreach(function(k, v)
|
||||
-- v.IsDebug = not v.IsDebug
|
||||
-- end)
|
||||
-- playerTeamDummyRole.isDebug = not playerTeamDummyRole.isDebug
|
||||
-- enemyTeamDummyRole.isDebug = not enemyTeamDummyRole.isDebug
|
||||
-- end
|
||||
|
||||
--Debug专用
|
||||
function BattleLogic.SetRoleValue(uid, name, value)
|
||||
|
@ -595,4 +689,4 @@ function BattleLogic.GenerateRecordFile()
|
|||
file:write(record[i].."\n")
|
||||
end
|
||||
io.close(file)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,18 +2,20 @@ Aura = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function Aura:SetData(...)
|
||||
--log("Aura:SetData")
|
||||
|
||||
self.action = ...
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function Aura:OnStart()
|
||||
--log("Aura:OnStart")
|
||||
|
||||
end
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function Aura:OnTrigger()
|
||||
--log("Aura:OnTrigger")
|
||||
|
||||
if self.action then
|
||||
self.action(self.target)
|
||||
end
|
||||
|
@ -22,13 +24,13 @@ end
|
|||
|
||||
--效果结束时调用一次
|
||||
function Aura:OnEnd()
|
||||
--log("Aura:OnEnd")
|
||||
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Aura:OnCover(newBuff)
|
||||
--log("Aura:OnCover")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return Aura
|
||||
return Aura
|
||||
|
|
|
@ -2,27 +2,29 @@ Brand = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function Brand:SetData(...)
|
||||
--log("Brand:SetData")
|
||||
|
||||
self.flag, self.endFunc = ... --标记,结束回调
|
||||
self.cover = true
|
||||
self.layer = 1
|
||||
self.maxLayer = 0
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function Brand:OnStart()
|
||||
--log("Brand:OnStart")
|
||||
|
||||
end
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function Brand:OnTrigger()
|
||||
--log("Brand:OnTrigger")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--效果结束时调用一次
|
||||
function Brand:OnEnd()
|
||||
--log("Brand:OnEnd")
|
||||
|
||||
if self.endFunc then
|
||||
self.endFunc()
|
||||
self.endFunc = nil
|
||||
|
@ -32,7 +34,7 @@ end
|
|||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Brand:OnCover(newBuff)
|
||||
--log("Brand:OnCover")
|
||||
|
||||
local b = newBuff.flag == self.flag
|
||||
if b then
|
||||
if newBuff.maxLayer == 0 then
|
||||
|
@ -47,4 +49,4 @@ function Brand:OnCover(newBuff)
|
|||
return b
|
||||
end
|
||||
|
||||
return Brand
|
||||
return Brand
|
||||
|
|
|
@ -2,14 +2,16 @@ Control = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function Control:SetData(...)
|
||||
--log("Control:SetData")
|
||||
|
||||
self.ctrlType = ...
|
||||
self.cover = true --控制效果可被覆盖
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function Control:OnStart()
|
||||
--log("Control:OnStart")
|
||||
|
||||
if self.ctrlType == 1 then --眩晕
|
||||
self.target.enable = false
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
|
@ -21,18 +23,21 @@ function Control:OnStart()
|
|||
self.target.ctrl_noheal = true
|
||||
elseif self.ctrlType == 5 then --致盲
|
||||
self.target.ctrl_blind = true
|
||||
|
||||
elseif self.ctrlType == 7 then --麻痹
|
||||
self.target.ctrl_palsy = true
|
||||
end
|
||||
end
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function Control:OnTrigger()
|
||||
--log("Control:OnTrigger")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--效果结束时调用一次
|
||||
function Control:OnEnd()
|
||||
--log("Control:OnEnd")
|
||||
|
||||
if self.ctrlType == 1 then --眩晕
|
||||
self.target.enable = true
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
|
@ -44,13 +49,16 @@ function Control:OnEnd()
|
|||
self.target.ctrl_noheal = false
|
||||
elseif self.ctrlType == 5 then --致盲
|
||||
self.target.ctrl_blind = false
|
||||
|
||||
elseif self.ctrlType == 7 then --麻痹
|
||||
self.target.ctrl_palsy = false
|
||||
end
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Control:OnCover(newBuff)
|
||||
--log("Control:OnCover")
|
||||
|
||||
return newBuff.ctrlType == self.ctrlType
|
||||
end
|
||||
|
||||
return Control
|
||||
return Control
|
||||
|
|
|
@ -2,10 +2,10 @@ DOT = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function DOT:SetData(...)
|
||||
--log("DOT:SetData")
|
||||
|
||||
self.interval,
|
||||
self.damageType, --1 燃烧 2 中毒 3 流血
|
||||
self.damagePro, --1 物理 2 魔法
|
||||
self.damageType, --1 燃烧 2 中毒 3 流血 4 灼烧
|
||||
self.damagePro, --1 物理 2 魔法 (真实伤害时 为伤害值)
|
||||
self.damageFactor = ... --伤害系数
|
||||
self.isRealDamage = false
|
||||
--if self.damageType == 2 then
|
||||
|
@ -15,6 +15,12 @@ function DOT:SetData(...)
|
|||
-- self.cover = false
|
||||
-- self.layer = nil
|
||||
--end
|
||||
|
||||
-- 刷新排序等级
|
||||
self.sort = 2
|
||||
if self.damageType == 3 then -- 流血buff在行动之后刷新
|
||||
self.sort = 3
|
||||
end
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
|
@ -26,23 +32,23 @@ end
|
|||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function DOT:OnTrigger()
|
||||
--log("DOT:OnTrigger")
|
||||
|
||||
if self.isRealDamage then
|
||||
BattleUtil.ApplyDamage(self.caster, self.target, self.damagePro)
|
||||
BattleUtil.ApplyDamage(nil, self.caster, self.target, self.damagePro)
|
||||
else
|
||||
BattleUtil.CalDamage(self.caster, self.target, self.damagePro, self.damageFactor,0, true)
|
||||
BattleUtil.CalDamage(nil, self.caster, self.target, self.damagePro, self.damageFactor,0, true)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--效果结束时调用一次
|
||||
function DOT:OnEnd()
|
||||
--log("DOT:OnEnd")
|
||||
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function DOT:OnCover(newBuff)
|
||||
--log("DOT:OnCover")
|
||||
|
||||
--if self.damageType == 2 then
|
||||
-- newBuff.layer = self.layer + 1
|
||||
-- newBuff.damageFactor =
|
||||
|
@ -50,4 +56,4 @@ function DOT:OnCover(newBuff)
|
|||
return true
|
||||
end
|
||||
|
||||
return DOT
|
||||
return DOT
|
||||
|
|
|
@ -2,20 +2,23 @@ HOT = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function HOT:SetData(...)
|
||||
--log("HOT:SetData")
|
||||
|
||||
self.interval,
|
||||
self.healValue = ...
|
||||
|
||||
-- 刷新排序等级
|
||||
self.sort = 1 -- 最先计算回血
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function HOT:OnStart()
|
||||
--log("HOT:OnStart")
|
||||
|
||||
self.target.Event:DispatchEvent(BattleEventName.RoleBeHealed, self.caster)
|
||||
end
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function HOT:OnTrigger()
|
||||
--log("HOT:OnTrigger")
|
||||
|
||||
if not self.target.ctrl_noheal or self.target.isDead then --禁疗和死亡无法加血
|
||||
BattleUtil.ApplyTreat(self.caster, self.target, self.healValue)
|
||||
end
|
||||
|
@ -24,13 +27,13 @@ end
|
|||
|
||||
--效果结束时调用一次
|
||||
function HOT:OnEnd()
|
||||
--log("HOT:OnEnd")
|
||||
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function HOT:OnCover(newBuff)
|
||||
--log("HOT:OnCover")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return HOT
|
||||
return HOT
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
-- 免疫效果
|
||||
Immune = Buff:New()
|
||||
|
||||
local immune0 = function(buff)
|
||||
|
@ -12,14 +13,17 @@ end
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function Immune:SetData(...)
|
||||
--log("Immune:SetData")
|
||||
|
||||
self.immuneType = ...
|
||||
self.isBuff = true
|
||||
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function Immune:OnStart()
|
||||
--log("Immune:OnStart")
|
||||
|
||||
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
|
||||
self.target.buffFilter:Add(immune0)
|
||||
elseif self.immuneType == 1 then --免疫控制状态
|
||||
|
@ -31,13 +35,13 @@ end
|
|||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function Immune:OnTrigger()
|
||||
--log("Immune:OnTrigger")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--效果结束时调用一次
|
||||
function Immune:OnEnd()
|
||||
--log("Immune:OnEnd")
|
||||
|
||||
local immune
|
||||
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
|
||||
immune = immune0
|
||||
|
@ -56,8 +60,8 @@ end
|
|||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Immune:OnCover(newBuff)
|
||||
--log("Immune:OnCover")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return Immune
|
||||
return Immune
|
||||
|
|
|
@ -2,7 +2,7 @@ PropertyChange = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function PropertyChange:SetData(...)
|
||||
--log("PropertyChange:SetData")
|
||||
|
||||
self.propertyName,
|
||||
self.Value,
|
||||
self.changeType = ...
|
||||
|
@ -19,11 +19,13 @@ function PropertyChange:SetData(...)
|
|||
elseif self.changeType == 4 then --乘减算(百分比属性减算)
|
||||
self.isDeBuff = true
|
||||
end
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function PropertyChange:OnStart()
|
||||
--log("PropertyChange:OnStart")
|
||||
|
||||
if self.changeType == 1 then --加算
|
||||
self.delta = self.target.data:AddValue(self.propertyName, self.Value)
|
||||
elseif self.changeType == 2 then --乘加算(百分比属性加算)
|
||||
|
@ -37,13 +39,13 @@ end
|
|||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function PropertyChange:OnTrigger()
|
||||
--log("PropertyChange:OnTrigger")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--效果结束时调用一次
|
||||
function PropertyChange:OnEnd()
|
||||
--log("PropertyChange:OnEnd")
|
||||
|
||||
if self.changeType == 3 or self.changeType == 4 then
|
||||
self.target.data:AddValue(self.propertyName, self.delta)
|
||||
else
|
||||
|
@ -53,7 +55,7 @@ end
|
|||
|
||||
--只有当Cover字段为true时触发,返回true则被新效果覆盖
|
||||
function PropertyChange:OnCover(newBuff)
|
||||
--log("PropertyChange:OnCover")
|
||||
|
||||
local b = self.propertyName == newBuff.propertyName and self.changeType == newBuff.changeType
|
||||
if b then
|
||||
if newBuff.maxLayer == 0 then
|
||||
|
@ -71,4 +73,4 @@ function PropertyChange:OnCover(newBuff)
|
|||
return b
|
||||
end
|
||||
|
||||
return PropertyChange
|
||||
return PropertyChange
|
||||
|
|
|
@ -2,45 +2,109 @@ Shield = Buff:New()
|
|||
|
||||
--初始化Buff,通过传入一些自定义参数控制成长相关的数值
|
||||
function Shield:SetData(...)
|
||||
--log("Shield:SetData")
|
||||
self.shieldValue, --护盾值
|
||||
|
||||
self.shieldType, -- 护盾类型(1 固定减伤盾 2 百分比减伤盾 3 无敌盾)
|
||||
self.shieldValue, -- 护盾值(固定减伤盾:减伤值 百分比减伤盾:减伤百分比 无敌盾:吸血率)
|
||||
self.dmgReboundFactor = ... --伤害反弹系数
|
||||
self.damageSum = 0 --记录承受的伤害
|
||||
self.isBuff = true
|
||||
self.atk=nil --每次扣除护盾时,记录破盾的对象
|
||||
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function Shield:OnStart()
|
||||
--log("Shield:OnStart")
|
||||
|
||||
self.target.shield:Add(self)
|
||||
end
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function Shield:OnTrigger()
|
||||
--log("Shield:OnTrigger")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- 计算护盾
|
||||
function Shield:CountShield(damage, atkRole)
|
||||
self.atk = atkRole
|
||||
local finalDamage = 0
|
||||
if self.shieldType == ShieldTypeName.NormalReduce then
|
||||
|
||||
if damage < self.shieldValue then
|
||||
self.shieldValue = self.shieldValue - damage
|
||||
self.damageSum = self.damageSum + damage
|
||||
else
|
||||
self.damageSum = self.damageSum + self.shieldValue
|
||||
finalDamage = damage - self.shieldValue
|
||||
self.shieldValue = 0
|
||||
self.disperse = true
|
||||
end
|
||||
|
||||
elseif self.shieldType == ShieldTypeName.RateReduce then
|
||||
local reduceDamage = math.floor(BattleUtil.ErrorCorrection(damage * self.shieldValue))
|
||||
finalDamage = damage - reduceDamage
|
||||
self.damageSum = self.damageSum + reduceDamage
|
||||
|
||||
elseif self.shieldType == ShieldTypeName.AllReduce then
|
||||
finalDamage = 0
|
||||
--TODO 计算吸血
|
||||
local treatValue = math.floor(BattleUtil.ErrorCorrection(damage * self.shieldValue))
|
||||
BattleUtil.ApplyTreat(self.target, self.target, treatValue)
|
||||
|
||||
end
|
||||
|
||||
return finalDamage
|
||||
end
|
||||
|
||||
-- 改变护盾值(固定减伤盾:减伤值 百分比减伤盾:减伤百分比 无敌盾:吸血率)
|
||||
function Shield:ChangeShieldValue(type, value)
|
||||
-- 计算
|
||||
local finalValue = BattleUtil.ErrorCorrection(BattleUtil.CountValue(self.shieldValue, value, type))
|
||||
self.shieldValue = finalValue
|
||||
-- 发送事件
|
||||
self.caster.Event:DispatchEvent(BattleEventName.ShildValueChange, self)
|
||||
end
|
||||
|
||||
--效果结束时调用一次
|
||||
function Shield:OnEnd()
|
||||
--log("Shield:OnEnd")
|
||||
for i = 1, self.target.shield.size do
|
||||
if self.target.shield.buffer[i] == self then
|
||||
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))
|
||||
|
||||
-- 计算反伤
|
||||
if self.shieldType == ShieldTypeName.NormalReduce then
|
||||
for i = 1, self.target.shield.size do
|
||||
if self.target.shield.buffer[i] == self then
|
||||
local arr = BattleLogic.Query(function (r) return r.camp ~= self.target.camp end)
|
||||
for j = 1, #arr do
|
||||
BattleUtil.ApplyDamage(nil, self.target, arr[j], math.floor(self.dmgReboundFactor * self.damageSum))
|
||||
end
|
||||
self.target.shield:Remove(i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
elseif self.shieldType == ShieldTypeName.RateReduce then
|
||||
for i = 1, self.target.shield.size do
|
||||
if self.target.shield.buffer[i] == self then
|
||||
self.target.shield:Remove(i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
elseif self.shieldType == ShieldTypeName.AllReduce then
|
||||
for i = 1, self.target.shield.size do
|
||||
if self.target.shield.buffer[i] == self then
|
||||
self.target.shield:Remove(i)
|
||||
break
|
||||
end
|
||||
self.target.shield:Remove(i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
function Shield:OnCover(newBuff)
|
||||
--log("Shield:OnCover")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return Shield
|
||||
return Shield
|
||||
|
|
|
@ -7,7 +7,6 @@ end
|
|||
BattleEventName = {
|
||||
BattleOrderChange = indexAdd(),
|
||||
BattleOrderEnd = indexAdd(),
|
||||
BattleStageChange = indexAdd(),
|
||||
BattleEnd = indexAdd(),
|
||||
AddRole = indexAdd(),
|
||||
RemoveRole = indexAdd(),
|
||||
|
@ -16,6 +15,7 @@ BattleEventName = {
|
|||
MpSub = indexAdd(),
|
||||
BattleRoleDead = indexAdd(),
|
||||
BattleSkillUsable = indexAdd(),
|
||||
BattleRoundChange = indexAdd(),
|
||||
|
||||
RoleBeDamaged = indexAdd(),
|
||||
RoleDamage = indexAdd(),
|
||||
|
@ -37,9 +37,17 @@ BattleEventName = {
|
|||
RoleRevive = indexAdd(),
|
||||
RolePropertyChanged = indexAdd(),
|
||||
RoleCDChanged = indexAdd(),
|
||||
RoleTurnStart = indexAdd(), -- 角色回合开始
|
||||
RoleTurnEnd = indexAdd(), -- 角色回合结束
|
||||
RoleRageGrow = indexAdd(), -- 角色怒气成长
|
||||
RoleRageCost = indexAdd(), -- 角色怒气消耗
|
||||
RoleControl = indexAdd(), -- 角色释放控制技能
|
||||
RoleBeControl = indexAdd(), -- 角色被控制
|
||||
|
||||
SkillCast = indexAdd(),
|
||||
SkillCastEnd = indexAdd(),
|
||||
SkillCast = indexAdd(), -- 技能攻击前
|
||||
SkillCastEnd = indexAdd(), -- 技能攻击结束
|
||||
BeSkillCastEnd = indexAdd(), -- 被技能攻击结束
|
||||
SkillRandomBuff = indexAdd(), -- 技能控制时
|
||||
|
||||
PassiveTreating = indexAdd(),
|
||||
PassiveBeTreated = indexAdd(),
|
||||
|
@ -58,6 +66,14 @@ BattleEventName = {
|
|||
BuffEnd = indexAdd(),
|
||||
BuffCountChange = indexAdd(),
|
||||
BuffCover = indexAdd(),
|
||||
BuffRoundChange = indexAdd(),
|
||||
BuffDurationChange = indexAdd(),
|
||||
|
||||
ShildValueChange = indexAdd(),
|
||||
|
||||
|
||||
|
||||
DebugStop = indexAdd(),
|
||||
}
|
||||
|
||||
index = 0
|
||||
|
@ -87,6 +103,7 @@ RoleDataName = {
|
|||
LightDamageReduceFactor = indexAdd(), --光系伤害减免系数(%)
|
||||
DarkDamageReduceFactor = indexAdd(), --暗系伤害减免系数(%)
|
||||
ElementDamageBocusFactor = indexAdd(), --属性伤害加成系数(%)
|
||||
InitRage = indexAdd(), --初始怒气值
|
||||
}
|
||||
|
||||
BuffName = {
|
||||
|
@ -100,5 +117,28 @@ BuffName = {
|
|||
Immune = "Immune",
|
||||
}
|
||||
|
||||
DotType = {
|
||||
All = 0,
|
||||
Burn = 1,
|
||||
Poison = 2,
|
||||
Blooding = 3,
|
||||
}
|
||||
|
||||
BattleSkillType = {
|
||||
Monster = 0,
|
||||
Normal = 1,
|
||||
Special = 2,
|
||||
}
|
||||
|
||||
CountTypeName = {
|
||||
Add = 1,
|
||||
AddPencent = 2,
|
||||
Sub = 2,
|
||||
SubPencent = 2,
|
||||
}
|
||||
|
||||
ShieldTypeName = {
|
||||
NormalReduce = 1, -- 固定值减伤
|
||||
RateReduce = 2, -- 百分比减伤
|
||||
AllReduce = 3, -- 无敌护盾
|
||||
}
|
|
@ -35,6 +35,10 @@ function BattleDictionary:Remove(k)
|
|||
end
|
||||
end
|
||||
|
||||
function BattleDictionary:Get(k)
|
||||
return self.kvList[k]
|
||||
end
|
||||
|
||||
function BattleDictionary:Set(k,v)
|
||||
self:Remove(k)
|
||||
self:Add(k,v)
|
||||
|
@ -54,7 +58,9 @@ end
|
|||
function BattleDictionary:Foreach(func)
|
||||
for i = 1, self.size do
|
||||
if func then
|
||||
func(self.kList[i], self.vList[i])
|
||||
if func(self.kList[i], self.vList[i]) == "break" then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,4 +27,4 @@ end
|
|||
|
||||
function BattleList:Count()
|
||||
return self.size
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@ 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
|
||||
|
@ -34,12 +33,55 @@ function BattleUtil.FP_Mul(...)
|
|||
return f
|
||||
end
|
||||
|
||||
-- 选择前排
|
||||
function BattleUtil.ChooseFRow(arr)
|
||||
local tempArr = {}
|
||||
for _, r in ipairs(arr) do
|
||||
if r.position <= 3 and not r.isDead then
|
||||
table.insert(tempArr, r)
|
||||
end
|
||||
end
|
||||
return tempArr
|
||||
end
|
||||
-- 选择后排
|
||||
function BattleUtil.ChooseBRow(arr)
|
||||
local tempArr = {}
|
||||
for _, r in ipairs(arr) do
|
||||
if r.position > 3 and not r.isDead then
|
||||
table.insert(tempArr, r)
|
||||
end
|
||||
end
|
||||
return tempArr
|
||||
end
|
||||
-- 选择一列(col == 0 表示第三列哦)
|
||||
function BattleUtil.ChooseCol(arr, col)
|
||||
local tempArr = {}
|
||||
for _, role in ipairs(arr) do
|
||||
if role.position % 3 == col then
|
||||
table.insert(tempArr, role)
|
||||
end
|
||||
end
|
||||
return tempArr
|
||||
end
|
||||
-- 根据属性排序
|
||||
function BattleUtil.SortByProp(arr, prop, sort)
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(prop)
|
||||
local r2 = b:GetRoleData(prop)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
return arr
|
||||
end
|
||||
|
||||
|
||||
function BattleUtil.ChooseTarget(role, chooseId)
|
||||
local chooseType = floor(chooseId / 10000) % 10
|
||||
local chooseWeight = floor(chooseId / 100) % 10
|
||||
local chooseType = floor(chooseId / 100000) % 10
|
||||
local chooseLimit = floor(chooseId / 10000) % 10
|
||||
local chooseWeight = floor(chooseId / 100) % 100
|
||||
local sort = floor(chooseId / 10) % 10
|
||||
local num = chooseId % 10
|
||||
local arr
|
||||
-- 选择类型
|
||||
if chooseType == 1 then
|
||||
arr = BattleLogic.Query(function (r) return r.camp == role.camp end)
|
||||
elseif chooseType == 2 then
|
||||
|
@ -68,62 +110,68 @@ function BattleUtil.ChooseTarget(role, chooseId)
|
|||
arr = BattleLogic.Query()
|
||||
end
|
||||
|
||||
--选择范围
|
||||
if chooseLimit == 0 then --选择全体不做任何操作
|
||||
|
||||
elseif chooseLimit == 1 then-- 前排
|
||||
local tempArr = BattleUtil.ChooseFRow(arr)
|
||||
if #tempArr == 0 then -- 没有选择后排
|
||||
tempArr = BattleUtil.ChooseBRow(arr)
|
||||
end
|
||||
arr = tempArr
|
||||
elseif chooseLimit == 2 then-- 后排
|
||||
local tempArr = BattleUtil.ChooseBRow(arr)
|
||||
if #tempArr == 0 then -- 没有选择前排
|
||||
tempArr = BattleUtil.ChooseFRow(arr)
|
||||
end
|
||||
arr = tempArr
|
||||
elseif chooseLimit == 3 then-- 对列
|
||||
local myCol = role.position % 3
|
||||
local tempArr = BattleUtil.ChooseCol(arr, myCol)
|
||||
if #tempArr == 0 then -- 对列没有人,按顺序找到有人得列
|
||||
for i = 1, 3 do
|
||||
local col = i % 3 -- 0 表示第三列嗷
|
||||
tempArr = BattleUtil.ChooseCol(arr, col)
|
||||
if #tempArr ~= 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
arr = tempArr
|
||||
end
|
||||
|
||||
-- 选择条件
|
||||
if chooseWeight == 0 or role.ctrl_blind then --致盲时排序无效
|
||||
BattleUtil.RandomList(arr)
|
||||
elseif chooseWeight == 1 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.Hp)
|
||||
local r2 = b:GetRoleData(RoleDataName.Hp)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 2 then
|
||||
elseif chooseWeight == 1 then -- 生命值
|
||||
BattleUtil.SortByProp(arr, RoleDataName.Hp, sort)
|
||||
elseif chooseWeight == 2 then -- 血量百分比
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.Hp) / a:GetRoleData(RoleDataName.MaxHp)
|
||||
local r2 = b:GetRoleData(RoleDataName.Hp) / b:GetRoleData(RoleDataName.MaxHp)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 3 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.Attack)
|
||||
local r2 = b:GetRoleData(RoleDataName.Attack)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 4 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.PhysicalDefence)
|
||||
local r2 = b:GetRoleData(RoleDataName.PhysicalDefence)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 5 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.PhysicalDefence)
|
||||
local r2 = b:GetRoleData(RoleDataName.PhysicalDefence)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 6 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetRoleData(RoleDataName.MagicDefence)
|
||||
local r2 = b:GetRoleData(RoleDataName.MagicDefence)
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 7 then
|
||||
BattleUtil.Sort(arr, function(a, b)
|
||||
local r1 = a:GetSkillCD()
|
||||
local r2 = b:GetSkillCD()
|
||||
if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
end)
|
||||
elseif chooseWeight == 8 then
|
||||
elseif chooseWeight == 3 then -- 攻击力
|
||||
BattleUtil.SortByProp(arr, RoleDataName.Attack, sort)
|
||||
elseif chooseWeight == 4 then -- 防御
|
||||
BattleUtil.SortByProp(arr, RoleDataName.PhysicalDefence, sort)
|
||||
elseif chooseWeight == 5 then -- 护甲
|
||||
BattleUtil.SortByProp(arr, RoleDataName.PhysicalDefence, sort)
|
||||
elseif chooseWeight == 6 then -- 魔抗
|
||||
BattleUtil.SortByProp(arr, RoleDataName.MagicDefence, sort)
|
||||
elseif chooseWeight == 7 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)
|
||||
-- elseif chooseWeight == 9 then -- 展位距离
|
||||
-- BattleUtil.Sort(arr, function(a, b)
|
||||
-- local r1 = math.abs(role.position - a.position) * 10 + a.position
|
||||
-- local r2 = math.abs(role.position - b.position) * 10 + b.position
|
||||
-- if sort == 1 then return r1 > r2 else return r1 < r2 end
|
||||
-- end)
|
||||
end
|
||||
return arr
|
||||
end
|
||||
|
||||
|
||||
function BattleUtil.CreateBuffId(skill, index)
|
||||
local id = 0
|
||||
if skill.preAI then --主动技能生成buff
|
||||
|
@ -134,6 +182,7 @@ function BattleUtil.CreateBuffId(skill, index)
|
|||
return id
|
||||
end
|
||||
|
||||
-- 计算命中率
|
||||
function BattleUtil.CalHit(atkRole, defRole)
|
||||
--命中率 = clamp(自身命中率-敌方闪避率,0,1)
|
||||
local hit = atkRole:GetRoleData(RoleDataName.Hit)
|
||||
|
@ -149,25 +198,28 @@ function BattleUtil.CalHit(atkRole, defRole)
|
|||
return bHit
|
||||
end
|
||||
|
||||
-- 计算护盾
|
||||
function BattleUtil.CalShield(atkRole, defRole, damage)
|
||||
for i=1, defRole.shield.size do
|
||||
local buff = defRole.shield.buffer[i]
|
||||
buff.atk = atkRole
|
||||
if damage < buff.shieldValue then
|
||||
buff.shieldValue = buff.shieldValue - damage
|
||||
buff.damageSum = buff.damageSum + damage
|
||||
return 0
|
||||
else
|
||||
buff.damageSum = buff.damageSum + buff.shieldValue
|
||||
damage = damage - buff.shieldValue
|
||||
buff.shieldValue = 0
|
||||
buff.disperse = true
|
||||
end
|
||||
damage = buff:CountShield(damage, atkRole)
|
||||
-- buff.atk = atkRole
|
||||
-- if damage < buff.shieldValue then
|
||||
-- buff.shieldValue = buff.shieldValue - damage
|
||||
-- buff.damageSum = buff.damageSum + damage
|
||||
-- return 0
|
||||
-- else
|
||||
-- buff.damageSum = buff.damageSum + buff.shieldValue
|
||||
-- damage = damage - buff.shieldValue
|
||||
-- buff.shieldValue = 0
|
||||
-- buff.disperse = true
|
||||
-- end
|
||||
end
|
||||
return damage
|
||||
end
|
||||
|
||||
function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType, isDot)
|
||||
-- 计算真实伤害
|
||||
function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, isDot)
|
||||
bCrit = bCrit or false
|
||||
damageType = damageType or 0
|
||||
isDot = isDot or false
|
||||
|
@ -187,6 +239,9 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType, isD
|
|||
atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage)
|
||||
defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage)
|
||||
|
||||
-- 计算护盾减伤
|
||||
damage = BattleUtil.CalShield(atkRole, defRole, damage)
|
||||
|
||||
if damage > 0 then
|
||||
local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage)
|
||||
if finalDmg > 0 then
|
||||
|
@ -198,10 +253,10 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType, isD
|
|||
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)
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType, isDot, skill)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType, isDot, skill)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleDamage, atkRole, defRole, damage, bCrit, finalDmg, damageType, isDot, skill)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeDamaged, defRole, atkRole, damage, bCrit, finalDmg, damageType, isDot, skill)
|
||||
if bCrit then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole, damage, bCrit, finalDmg, damageType)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole, damage, bCrit, finalDmg, damageType)
|
||||
|
@ -218,11 +273,13 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType, isD
|
|||
end
|
||||
|
||||
--执行完整的命中,伤害,暴击计算,返回命中,暴击
|
||||
--atkRole攻击者 defRole受击者 damageType伤害类型 baseFactor伤害系数 ignoreDef无视防御参数 isDot是否是dot
|
||||
function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDef, isDot)
|
||||
--skill造成伤害的技能 atkRole攻击者 defRole受击者 damageType伤害类型 baseFactor伤害系数 ignoreDef无视防御参数 isDot是否是dot
|
||||
function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, ignoreDef, isDot)
|
||||
if atkRole.isTeam and not defRole.isDead then --如果是队伍技能,计算真实伤害,则damageType为伤害值
|
||||
return BattleUtil.ApplyDamage(atkRole, defRole, damageType), false
|
||||
return BattleUtil.ApplyDamage(skill, atkRole, defRole, damageType), false
|
||||
end
|
||||
|
||||
-- 计算技能额外伤害系数加成
|
||||
baseFactor = baseFactor or 1
|
||||
local factorFunc = function(exFactor) baseFactor = baseFactor + exFactor end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageBefore, defRole, factorFunc, damageType)
|
||||
|
@ -231,27 +288,35 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
|
||||
local bCrit = false
|
||||
local baseDamage
|
||||
ignoreDef = 1 - (ignoreDef or 0)
|
||||
-- 是否暴击: 暴击率 = 自身暴击率 - 对方抗暴率
|
||||
bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit)-defRole:GetRoleData(RoleDataName.Tenacity), 0, 1)
|
||||
bCrit = bCrit or defRole.isFlagCrit == true
|
||||
bCrit = bCrit or defRole.isFlagCrit == true -- 必定暴击
|
||||
-- 防御(据伤害类型决定)
|
||||
local defence = 0
|
||||
if damageType == 1 then --1 物理 2 魔法
|
||||
defence = defRole:GetRoleData(RoleDataName.PhysicalDefence)
|
||||
else
|
||||
defence = defRole:GetRoleData(RoleDataName.MagicDefence)
|
||||
end
|
||||
-- 攻击力
|
||||
local attack = atkRole:GetRoleData(RoleDataName.Attack)
|
||||
-- 无视防御系数
|
||||
ignoreDef = 1 - (ignoreDef or 0)
|
||||
|
||||
--计算暴击
|
||||
if bCrit then
|
||||
-- 计算额外暴击伤害
|
||||
local critDamageFactor = atkRole:GetRoleData(RoleDataName.CritDamageFactor)
|
||||
--加入被动效果
|
||||
--加入被动效果 触发暴击被动
|
||||
local critFunc = function(critEx) critDamageFactor = critEx end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.PassiveCriting, critFunc)
|
||||
--计算基础伤害:伤害 = 攻击力 * 暴击伤害系数 - 防御 *(1 - 无视防御系数)
|
||||
baseDamage = max(BattleUtil.FP_Mul(attack, critDamageFactor) - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
|
||||
else
|
||||
baseDamage = max(attack - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
|
||||
end
|
||||
|
||||
-- 自身属性对应对方的属性伤害减免系数
|
||||
local elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
|
||||
if atkRole.element == 1 then
|
||||
elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
|
||||
|
@ -288,14 +353,14 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
baseDamage = floor(max(baseDamage, BattleUtil.FP_Mul(0.1, attack)))
|
||||
end
|
||||
|
||||
-- 计算额外伤害数值加成
|
||||
local damageFunc = function(damage) baseDamage = damage end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageAfter, defRole, damageFunc, baseDamage)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedAfter, atkRole, damageFunc, baseDamage)
|
||||
|
||||
baseDamage = BattleUtil.CalShield(atkRole, defRole, baseDamage)
|
||||
local finalDmg = 0 --计算实际造成的扣血
|
||||
if not defRole.isDead then
|
||||
finalDmg = BattleUtil.ApplyDamage(atkRole, defRole, baseDamage, bCrit, damageType, isDot)
|
||||
finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, baseDamage, bCrit, damageType, isDot)
|
||||
end
|
||||
return finalDmg, bCrit
|
||||
end
|
||||
|
@ -321,7 +386,6 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
|||
local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end
|
||||
castRole.Event:DispatchEvent(BattleEventName.PassiveTreating, treatingFunc, targetRole)
|
||||
targetRole.Event:DispatchEvent(BattleEventName.PassiveBeTreated, treatingFunc, castRole)
|
||||
|
||||
local treat = min(baseTreat, maxHp - hp)
|
||||
if treat > 0 then
|
||||
targetRole.data:AddValue(RoleDataName.Hp, treat)
|
||||
|
@ -383,4 +447,19 @@ function BattleUtil.GetHPPencent(role)
|
|||
return role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp)
|
||||
end
|
||||
|
||||
|
||||
-- 计算数值
|
||||
function BattleUtil.CountValue(v1, v2, ct)
|
||||
local v = v1
|
||||
if ct == 1 then --加算
|
||||
v = v + v2
|
||||
elseif ct == 2 then --乘加算(百分比属性加算)
|
||||
v = v * (1 + v2)
|
||||
elseif ct == 3 then --减算
|
||||
v = v - v2
|
||||
elseif ct == 4 then --乘减算(百分比属性减算)
|
||||
v = v * (1 - v2)
|
||||
end
|
||||
-- 做一个正确性检测
|
||||
-- v = BattleUtil.ErrorCorrection(v)
|
||||
return v
|
||||
end
|
|
@ -8,34 +8,6 @@ local floor = math.floor
|
|||
local max = math.max
|
||||
local min = math.min
|
||||
|
||||
local aiList = {
|
||||
[0] = function(skill, superSkill)
|
||||
local stage = BattleLogic.CurStage()
|
||||
if stage == 1 then
|
||||
return true
|
||||
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) --只放点技
|
||||
return true
|
||||
end,
|
||||
[2] = function(skill, superSkill) --只放滑技
|
||||
return false
|
||||
end,
|
||||
[3] = function(skill, superSkill) --上滑技初始概率为5%,每次释放点击技后,增加上滑技释放概率20%,释放上滑技后,上滑技释放概率回到5%。
|
||||
local b = Random.Range01() > (0.05 + 0.2 * skill.owner.aiTempCount)
|
||||
if b then
|
||||
skill.owner.aiTempCount = skill.owner.aiTempCount + 1
|
||||
else
|
||||
skill.owner.aiTempCount = 0
|
||||
end
|
||||
return b
|
||||
end,
|
||||
}
|
||||
|
||||
local skillPool = BattleObjectPool.New(function ()
|
||||
return Skill:New()
|
||||
end)
|
||||
|
@ -46,7 +18,7 @@ function RoleLogic.New()
|
|||
exCalDmgList=BattleList.New(),
|
||||
proTranList=BattleList.New(),
|
||||
buffFilter=BattleList.New(),
|
||||
Event=BattleEvent:New(),passiveList=0,isDead=false,IsDebug=false,enable=false}
|
||||
Event=BattleEvent:New(),passiveList={},isDead=false,IsDebug=false,enable=false}
|
||||
setmetatable(instance, RoleLogic)
|
||||
return instance
|
||||
end
|
||||
|
@ -69,7 +41,6 @@ function RoleLogic:Init(uid, data, position)
|
|||
|
||||
self.Event:ClearEvent()
|
||||
|
||||
self.passiveList = {}
|
||||
if data.skill and #data.skill > 0 then
|
||||
self.skill = skillPool:Get()
|
||||
self.skill:Init(self, data.skill, 1)
|
||||
|
@ -83,6 +54,18 @@ function RoleLogic:Init(uid, data, position)
|
|||
local time = self:GetRoleData(RoleDataName.Speed)/(20*(self:GetRoleData(RoleDataName.Level)+10))
|
||||
self.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
|
||||
-- 怒气值
|
||||
self.Rage = 4 -- 当前怒气值
|
||||
self.RageGrow = 2 -- 普通技能怒气成长
|
||||
self.SuperSkillRage = 4 -- 技能需要释放的怒气值
|
||||
self.NoRageRate = 0 -- 不消耗怒气值的概率
|
||||
|
||||
-- 技能释放列表 技能改为按列表顺序释放 方便添加追加技能
|
||||
self.SkillList = {}
|
||||
self.CurSkillCastIndex = 0
|
||||
self.SkillCastDoneFunc = nil
|
||||
--
|
||||
self.passiveList = {}
|
||||
if data.passivity and #data.passivity > 0 then
|
||||
for i = 1, #data.passivity do
|
||||
local v = data.passivity[i]
|
||||
|
@ -92,58 +75,53 @@ function RoleLogic:Init(uid, data, position)
|
|||
args[j-1] = v[j]
|
||||
end
|
||||
BattleUtil.Passivity[id](self, args)
|
||||
-- 加入被动列表
|
||||
table.insert(self.passiveList, {id, args})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
self.aiOrder = data.ai
|
||||
self.aiIndex = 1
|
||||
self.aiTempCount = 0
|
||||
|
||||
self.IsDebug = false
|
||||
|
||||
self.enable = true --眩晕
|
||||
self.ctrl_slient = false --沉默
|
||||
self.lockTarget = nil --嘲讽
|
||||
self.ctrl_noheal = false --禁疗
|
||||
self.ctrl_blind = false --致盲
|
||||
|
||||
if self.skill and not self.superSkill then
|
||||
self.updateFunc = function()
|
||||
if self:CanCastSkill() then
|
||||
self.skill:Cast()
|
||||
else
|
||||
self.sp = self.sp + 1
|
||||
end
|
||||
end
|
||||
elseif not self.skill and self.superSkill then
|
||||
self.updateFunc = function()
|
||||
if self:CanCastSkill() and not self.ctrl_slient then
|
||||
self.superSkill:Cast()
|
||||
else
|
||||
self.sp = self.sp + 1
|
||||
end
|
||||
end
|
||||
elseif self.skill and self.superSkill then
|
||||
self.updateFunc = function()
|
||||
if self:CanCastSkill() then
|
||||
self:ExecuteAI(self.skill, self.superSkill)
|
||||
else
|
||||
self.sp = self.sp + 1
|
||||
end
|
||||
end
|
||||
else
|
||||
self.updateFunc = function() end
|
||||
end
|
||||
self.enable = true --眩晕
|
||||
self.ctrl_slient = false --沉默
|
||||
self.lockTarget = nil --嘲讽
|
||||
self.ctrl_noheal = false --禁疗
|
||||
self.ctrl_blind = false --致盲
|
||||
self.ctrl_palsy = false --麻痹
|
||||
end
|
||||
|
||||
-- 添加一个被动技能
|
||||
function RoleLogic:AddPassive(id, args, isCover)
|
||||
--判断是否可以叠加
|
||||
if not isCover then
|
||||
-- 不可以叠加, 如果重复则不再加入
|
||||
for _, pst in ipairs(self.passiveList) do
|
||||
if pst[1] == id then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 被动生效
|
||||
BattleUtil.Passivity[id](self, args)
|
||||
-- 加入被动列表
|
||||
table.insert(self.passiveList, {id, args})
|
||||
end
|
||||
--
|
||||
function RoleLogic:CanCastSkill()
|
||||
return self.sp >= self.spPass and not self.IsDebug and BattleLogic.GetSkillUsable(self.camp)
|
||||
end
|
||||
|
||||
-- 废弃的方法
|
||||
function RoleLogic:GetSkillCD()
|
||||
return max(self.spPass - self.sp, 0)
|
||||
end
|
||||
|
||||
-- 废弃的方法
|
||||
function RoleLogic:AddSkillCD(value, type)
|
||||
self.Event:DispatchEvent(BattleEventName.RoleCDChanged)
|
||||
if value == 0 then --为0直接清CD
|
||||
|
@ -171,6 +149,22 @@ function RoleLogic:AddSkillCD(value, type)
|
|||
end
|
||||
end
|
||||
|
||||
-- 改变怒气值
|
||||
function RoleLogic:AddRage(value, type)
|
||||
local delta = 0
|
||||
if type == 1 then --加算
|
||||
delta = value
|
||||
elseif type == 2 then --乘加算(百分比属性加算)
|
||||
delta = floor(value * self.SuperSkillRage)
|
||||
elseif type == 3 then --减算
|
||||
delta = -value
|
||||
elseif type == 4 then --乘减算(百分比属性减算)
|
||||
delta = -floor(value * self.SuperSkillRage)
|
||||
end
|
||||
--怒气值不可为负值
|
||||
self.Rage = max(self.Rage + delta, 0)
|
||||
end
|
||||
|
||||
function RoleLogic:GetRoleData(property)
|
||||
local tarPro = self.data:GetData(property)
|
||||
local item
|
||||
|
@ -231,36 +225,141 @@ function RoleLogic:Dispose()
|
|||
end
|
||||
end
|
||||
|
||||
function RoleLogic:ExecuteAI(skill, superSkill)
|
||||
local ai
|
||||
if self.aiOrder and self.aiOrder[self.aiIndex] then
|
||||
ai = aiList[self.aiOrder[self.aiIndex]]
|
||||
|
||||
-- 判断角色是否可以释放技能
|
||||
function RoleLogic:IsAvailable()
|
||||
-- 眩晕 -- 麻痹 -- 死亡
|
||||
if not self.enable or self.ctrl_palsy or self.isDead then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- 检测自身的技能释放
|
||||
function RoleLogic:CheckCastSkill()
|
||||
-- 角色不可用直接结束技能释放
|
||||
if not self:IsAvailable() then
|
||||
self:SkillCastDone()
|
||||
return
|
||||
end
|
||||
-- 没有要释放的技能了结束技能释放
|
||||
if self.CurSkillCastIndex >= #self.SkillList then
|
||||
self:SkillCastDone()
|
||||
return
|
||||
end
|
||||
-- 拿到下一个技能
|
||||
self.CurSkillCastIndex = self.CurSkillCastIndex + 1
|
||||
local skill = self.SkillList[self.CurSkillCastIndex]
|
||||
-- 技能释放回调(递归检测下一个技能)
|
||||
local _CheckNext = function ()
|
||||
self:CheckCastSkill()
|
||||
end
|
||||
-- 释放普通攻击
|
||||
if skill.type == BattleSkillType.Normal and self.skill then
|
||||
-- 释放普技
|
||||
self.skill:Cast(_CheckNext, skill.targets, skill.isAdd)
|
||||
-- 后成长怒气
|
||||
if skill.isRage then
|
||||
-- 检测被动技能对怒气成长的影响
|
||||
local grow = self.RageGrow
|
||||
local _RageGrowPassivity = function(finalGrow)
|
||||
grow = finalGrow
|
||||
end
|
||||
self.Event:DispatchEvent(BattleEventName.RoleRageGrow, grow, _RageGrowPassivity)
|
||||
--
|
||||
self.Rage = self.Rage + grow
|
||||
end
|
||||
-- 释放大技能
|
||||
elseif skill.type == BattleSkillType.Special and self.superSkill then
|
||||
-- 先消耗怒气
|
||||
if skill.isRage then
|
||||
-- 检测被动技能对怒气消耗的影响
|
||||
local costRage = self.SuperSkillRage
|
||||
local noRageRate = self.NoRageRate
|
||||
local _RageCostPassivity = function(finalRate, finalCost)
|
||||
noRageRate = finalRate
|
||||
costRage = finalCost
|
||||
end
|
||||
self.Event:DispatchEvent(BattleEventName.RoleRageCost, costRage, noRageRate, _RageCostPassivity)
|
||||
-- 计算消耗怒气的概率,并消耗怒气
|
||||
local costRate = 1 - noRageRate
|
||||
costRate = costRate > 1 and 1 or costRate
|
||||
costRate = costRate < 0 and 0 or costRate
|
||||
BattleUtil.RandomAction(costRate, function()
|
||||
self.Rage = self.Rage - costRage
|
||||
end)
|
||||
end
|
||||
-- 释放绝技
|
||||
self.superSkill:Cast(_CheckNext, skill.targets, skill.isAdd)
|
||||
-- 没有符合条件的技能直接进入下一个技能检测
|
||||
else
|
||||
ai = aiList[0]
|
||||
_CheckNext()
|
||||
end
|
||||
|
||||
if self.ctrl_slient then --沉默不能放上滑技
|
||||
skill:Cast()
|
||||
else
|
||||
if ai(skill, superSkill) then
|
||||
skill:Cast()
|
||||
else
|
||||
superSkill:Cast()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.aiOrder then
|
||||
if self.aiIndex == #self.aiOrder then
|
||||
self.aiIndex = 1
|
||||
else
|
||||
self.aiIndex = self.aiIndex + 1
|
||||
end
|
||||
-- 加入一个技能
|
||||
-- type 加入的技能类型
|
||||
-- targets 指定目标
|
||||
-- isAdd 是否是追加技能
|
||||
-- isRage 是否正常操作怒气值
|
||||
function RoleLogic:AddSkill(type, isRage, isAdd, targets)
|
||||
local skill = {
|
||||
type = type,
|
||||
isRage = isRage,
|
||||
isAdd = isAdd,
|
||||
targets = targets,
|
||||
}
|
||||
table.insert(self.SkillList, skill)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 正常触发技能
|
||||
function RoleLogic:CastSkill(func)
|
||||
self.SkillList = {}
|
||||
self.CurSkillCastIndex = 0
|
||||
self.SkillCastDoneFunc = func
|
||||
-- 沉默 怒气值不足 没有绝技 释放普通技能
|
||||
if self.ctrl_slient or self.Rage < self.SuperSkillRage or not self.superSkill then
|
||||
self:AddSkill(BattleSkillType.Normal, true, false, nil)
|
||||
self:CheckCastSkill()
|
||||
|
||||
return
|
||||
end
|
||||
-- 释放大技能 消耗怒气值
|
||||
self:AddSkill(BattleSkillType.Special, true, false, nil)
|
||||
self:CheckCastSkill()
|
||||
|
||||
end
|
||||
|
||||
-- 强制释放技能,追加技能时使用
|
||||
-- type 追加的技能类型 1=普技 2=特殊技
|
||||
-- targets 追加技能的目标 nil则自动选择目标
|
||||
-- func 追加技能释放完成回调
|
||||
function RoleLogic:ForceCastSkill(type, targets, func)
|
||||
if type == 1 and self.skill then
|
||||
self.skill:Cast(func)
|
||||
elseif type == 2 and self.superSkill then
|
||||
self.superSkill:Cast(func)
|
||||
else
|
||||
if func then func() end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 技能释放完毕
|
||||
function RoleLogic:SkillCastDone()
|
||||
BattleLogic.WaitForTrigger(1, function()
|
||||
if self.SkillCastDoneFunc then
|
||||
self.SkillCastDoneFunc()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function RoleLogic:Update()
|
||||
if not self.enable then
|
||||
return
|
||||
end
|
||||
self.updateFunc()
|
||||
end
|
||||
-- self.updateFunc()
|
||||
end
|
||||
|
|
|
@ -278,11 +278,11 @@ public class FightDataUtil {
|
|||
}
|
||||
SSkillLogicVo sSkillLogicVo = SSkillLogicConfig.getsSkillLogicVo(Integer.valueOf(skillId));
|
||||
if (sSkillLogicVo != null && sSkillLogicVo.getSkillTargetVoList().size()>0) {
|
||||
float cd = sSkillLogicVo.getCd();
|
||||
if(args!=null&&args.length>0){
|
||||
cd+=Integer.parseInt(args[0]);
|
||||
}
|
||||
skill.rawset(1, LuaValue.valueOf(cd));
|
||||
// float cd = sSkillLogicVo.getCd();
|
||||
// if(args!=null&&args.length>0){
|
||||
// cd+=Integer.parseInt(args[0]);
|
||||
// }
|
||||
skill.rawset(1, LuaValue.valueOf(skillId));
|
||||
List<LuaValue> effectList = getEffect(sSkillLogicVo);
|
||||
int size = effectList.size();
|
||||
if (size > 0) {
|
||||
|
@ -298,8 +298,11 @@ public class FightDataUtil {
|
|||
List<LuaValue> effectList = new ArrayList<>();
|
||||
for (SkillTargetVo skillTargetVos : sSkillLogicVo.getSkillTargetVoList()) {
|
||||
LuaValue effect = new LuaTable();
|
||||
int skillDisplay =sSkillLogicVo.getSkillDisplay();
|
||||
SCombatControl sCombatControl = STableManager.getConfig(SCombatControl.class).get(skillDisplay);
|
||||
int KeyFrame = sCombatControl.getKeyFrame();
|
||||
effect.rawset(1, LuaValue.valueOf(skillTargetVos.getTargetId()));
|
||||
effect.rawset(2, LuaValue.valueOf(skillTargetVos.getContinuedTime()));
|
||||
effect.rawset(2, LuaValue.valueOf(KeyFrame));
|
||||
List<LuaValue> effectValueList = getEffectArgs(skillTargetVos.getEffectVale());
|
||||
int size = effectValueList.size();
|
||||
if (size > 0) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="CombatControl")
|
||||
public class SCombatControl implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int keyFrame;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getKeyFrame() {
|
||||
return keyFrame;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -24,6 +24,7 @@ public class SSkillLogicConfig implements BaseConfig {
|
|||
|
||||
private float cd;
|
||||
|
||||
private int skillDisplay;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
@ -65,6 +66,9 @@ public class SSkillLogicConfig implements BaseConfig {
|
|||
return cd;
|
||||
}
|
||||
|
||||
public int getSkillDisplay() {
|
||||
return skillDisplay;
|
||||
}
|
||||
|
||||
private SSkillLogicVo getSSkillLogicVo(SSkillLogicConfig sSkillLogicConfig) {
|
||||
float[][] targets = sSkillLogicConfig.getTarget();
|
||||
|
@ -76,14 +80,13 @@ public class SSkillLogicConfig implements BaseConfig {
|
|||
for (int i = 0; i < targets.length ; i++){
|
||||
SkillTargetVo skillTargetVo = new SkillTargetVo();
|
||||
skillTargetVo.setTargetId((int) targets[i][0]);
|
||||
skillTargetVo.setContinuedTime(targets[i][1]);
|
||||
skillTargetVo.setEffectVale(getEffectVal(effect[i],effectValue,index));
|
||||
index = index + effect[i].length;
|
||||
skillTargetVos.add(skillTargetVo);
|
||||
}
|
||||
SSkillLogicVo sSkillLogicVo = new SSkillLogicVo();
|
||||
sSkillLogicVo.setSkillId(sSkillLogicConfig.getId());
|
||||
sSkillLogicVo.setCd(sSkillLogicConfig.getCd());
|
||||
sSkillLogicVo.setSkillDisplay(sSkillLogicConfig.getSkillDisplay());
|
||||
sSkillLogicVo.setSkillTargetVoList(skillTargetVos);
|
||||
return sSkillLogicVo;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ public class SSkillLogicVo{
|
|||
|
||||
private int skillId;
|
||||
|
||||
private float cd;
|
||||
private int skillDisplay;
|
||||
|
||||
private List<SkillTargetVo> skillTargetVoList;
|
||||
|
||||
|
@ -18,12 +18,12 @@ public class SSkillLogicVo{
|
|||
this.skillId = skillId;
|
||||
}
|
||||
|
||||
public float getCd() {
|
||||
return cd;
|
||||
public int getSkillDisplay() {
|
||||
return skillDisplay;
|
||||
}
|
||||
|
||||
public void setCd(float cd) {
|
||||
this.cd = cd;
|
||||
public void setSkillDisplay(int skillDisplay) {
|
||||
this.skillDisplay = skillDisplay;
|
||||
}
|
||||
|
||||
public List<SkillTargetVo> getSkillTargetVoList() {
|
||||
|
|
|
@ -5,7 +5,6 @@ public class SkillTargetVo {
|
|||
|
||||
private int targetId;
|
||||
|
||||
private float continuedTime; //技能效果持续时间
|
||||
|
||||
private float[][] effectVale; //技能效果
|
||||
|
||||
|
@ -18,13 +17,6 @@ public class SkillTargetVo {
|
|||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public float getContinuedTime() {
|
||||
return continuedTime;
|
||||
}
|
||||
|
||||
public void setContinuedTime(float continuedTime) {
|
||||
this.continuedTime = continuedTime;
|
||||
}
|
||||
|
||||
public float[][] getEffectVale() {
|
||||
return effectVale;
|
||||
|
|
Loading…
Reference in New Issue