战斗逻辑同步v1.0.0

back_recharge
gaoxin 2020-11-04 14:38:54 +08:00
parent 17fc7ac344
commit 14c19ca507
8 changed files with 119 additions and 54 deletions

View File

@ -2271,9 +2271,17 @@ local effectList = {
BattleUtil.FinalDamage(skill, caster, target, damage, nil, 0, nil, true) BattleUtil.FinalDamage(skill, caster, target, damage, nil, 0, nil, true)
end) end)
end, end,
--瞬间恢复[a]*[b]%生命
--a[属性],b[float]
[119] = function(caster, target, args, interval, skill)
local pro1 = args[1]
local f1 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
local val = floor(BattleUtil.FP_Mul(target:GetRoleData(BattlePropList[pro1]), f1))
BattleUtil.CalTreat(caster, target, val)
end)
end,
} }
return effectList return effectList

View File

@ -42,7 +42,7 @@ function EffectCaster:DoEffect(caster, target, eff, duration, skill)
e.args[i] = eff.args[i] e.args[i] = eff.args[i]
end end
-- 检测被动技能对技能参数的影响 -- 检测被动技能对技能参数的影响
local function _PassiveCheck(pe) local function _PassiveCheck(pe)
if pe then if pe then
e = pe e = pe
@ -60,7 +60,7 @@ end
function EffectCaster:takeEffect(caster, target, effects, effectIndex, duration, skill) function EffectCaster:takeEffect(caster, target, effects, effectIndex, duration, skill)
for k=1, #effects do for k=1, #effects do
-- 如果不是第一个效果对列的第一个效果则判断是否命中 -- 如果不是第一个效果对列的第一个效果则判断是否命中
if k ~= 1 and effectIndex == 1 then if k ~= 1 and effectIndex == 1 then
if self:CheckTargetIsHit(target) then if self:CheckTargetIsHit(target) then
self:DoEffect(caster, target, effects[k], duration, skill) self:DoEffect(caster, target, effects[k], duration, skill)
@ -76,25 +76,25 @@ function EffectCaster:ChooseTarget()
-- --
self.effectTargets = {} self.effectTargets = {}
self.targetIsHit = {} self.targetIsHit = {}
-- 先计算出技能的目标 -- 先计算出技能的目标
for i=1, #self.effectList do for i=1, #self.effectList do
-- 是否重新选择目标 -- 是否重新选择目标
local isReTarget = true local isReTarget = true
if self.targets and self.targets[i] then if self.targets and self.targets[i] then
self.effectTargets[i] = self.targets[i] self.effectTargets[i] = self.targets[i]
-- 判断是否有有效目标 -- 判断是否有有效目标
for _, role in ipairs(self.effectTargets[i]) do for _, role in ipairs(self.effectTargets[i]) do
if not role:IsRealDead() then if not role:IsRealDead() then
isReTarget = false isReTarget = false
end end
end end
end end
-- 重新选择目标 -- 重新选择目标
if isReTarget then if isReTarget then
local effectGroup = self.effectList[i] local effectGroup = self.effectList[i]
local chooseId = effectGroup.chooseId local chooseId = effectGroup.chooseId
self.effectTargets[i] = BattleUtil.ChooseTarget(self.skill.owner, chooseId) self.effectTargets[i] = BattleUtil.ChooseTarget(self.skill.owner, chooseId)
-- 检测被动对攻击目标的影响 -- 检测被动对攻击目标的影响
if i == 1 then if i == 1 then
local function _PassiveTarget(targets) local function _PassiveTarget(targets)
self.effectTargets[i] = targets self.effectTargets[i] = targets
@ -105,19 +105,19 @@ function EffectCaster:ChooseTarget()
end end
end end
-- 释放技能 -- 释放技能
-- func 技能释放完成回调 -- func 技能释放完成回调
function EffectCaster:Cast() function EffectCaster:Cast()
-- 选择目标 -- 选择目标
self:ChooseTarget() self:ChooseTarget()
-- 对目标造成相应的效果 -- 对目标造成相应的效果
for i=1, #self.effectList do for i=1, #self.effectList do
local effectGroup = self.effectList[i] local effectGroup = self.effectList[i]
local chooseId = effectGroup.chooseId local chooseId = effectGroup.chooseId
local arr = self.effectTargets[i] local arr = self.effectTargets[i]
if arr and #arr > 0 then if arr and #arr > 0 then
-- 效果延迟1帧生效 -- 效果延迟1帧生效
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function() BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
local effects = effectGroup.effects local effects = effectGroup.effects
local weight = math.floor(chooseId % 10000 / 100) local weight = math.floor(chooseId % 10000 / 100)
@ -125,10 +125,10 @@ function EffectCaster:Cast()
if count == 0 then if count == 0 then
count = #arr count = #arr
end end
-- 全部同时生效 -- 全部同时生效
for j=1, count do for j=1, count do
if arr[j] and not arr[j]:IsRealDead() then if arr[j] and not arr[j]:IsRealDead() then
-- 检测是否命中 -- 检测是否命中
if i == 1 then if i == 1 then
self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.skill.owner, arr[j]) self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.skill.owner, arr[j])
end end
@ -140,7 +140,7 @@ function EffectCaster:Cast()
end end
end end
-- 遍历技能命中目标 -- 遍历技能命中目标
function EffectCaster:ForeachTargets(func) function EffectCaster:ForeachTargets(func)
local targets = self:GetDirectTargets() local targets = self:GetDirectTargets()
for _, role in ipairs(targets) do for _, role in ipairs(targets) do
@ -150,7 +150,7 @@ function EffectCaster:ForeachTargets(func)
end end
end end
-- 获取直接选择目标Id -- 获取直接选择目标Id
function EffectCaster:GetDirectChooseId() function EffectCaster:GetDirectChooseId()
local effectGroup = self.effectList[1] local effectGroup = self.effectList[1]
local chooseId = effectGroup.chooseId local chooseId = effectGroup.chooseId
@ -158,12 +158,12 @@ function EffectCaster:GetDirectChooseId()
end end
-- 获取技能的直接目标,和策划规定第一个效果的目标为直接效果目标,(包含miss的目标) -- 获取技能的直接目标,和策划规定第一个效果的目标为直接效果目标,(包含miss的目标)
function EffectCaster:GetDirectTargets() function EffectCaster:GetDirectTargets()
return self.effectTargets[1] return self.effectTargets[1]
end end
-- 获取直接目标不包含miss的目标可能为空 -- 获取直接目标不包含miss的目标可能为空
function EffectCaster:GetDirectTargetsNoMiss() function EffectCaster:GetDirectTargetsNoMiss()
local list = {} local list = {}
for _, role in ipairs(self.effectTargets[1]) do for _, role in ipairs(self.effectTargets[1]) do
@ -174,7 +174,7 @@ function EffectCaster:GetDirectTargetsNoMiss()
return list return list
end end
-- 获取技能目标最大人数 -- 获取技能目标最大人数
function EffectCaster:GetMaxTargetNum() function EffectCaster:GetMaxTargetNum()
local mainEffect = self.effectList[1] local mainEffect = self.effectList[1]
if not mainEffect then if not mainEffect then
@ -183,7 +183,7 @@ function EffectCaster:GetMaxTargetNum()
return BattleUtil.GetMaxTargetNum(mainEffect.chooseId) return BattleUtil.GetMaxTargetNum(mainEffect.chooseId)
end end
-- 判断是否命中 -- 判断是否命中
function EffectCaster:CheckTargetIsHit(role) function EffectCaster:CheckTargetIsHit(role)
return self.targetIsHit[role] return self.targetIsHit[role]
end end

View File

@ -54,8 +54,8 @@ local passivityList = {
local OnSkillCast = function(skill) local OnSkillCast = function(skill)
BattleUtil.RandomAction(f1, function () BattleUtil.RandomAction(f1, function ()
local duration = 0 local duration = 0
for i=1, skill.effectCaster.effectList.size do for i=1, #skill.effectCaster.effectList do
duration = max(duration, skill.effectCaster.effectList.buffer[i].duration) duration = max(duration, skill.effectCaster.effectList[i].duration)
end end
role:AddPropertyTransfer(BattlePropList[pro1], f2, BattlePropList[pro2], 2, duration + BattleLogic.GameDeltaTime * 2) role:AddPropertyTransfer(BattlePropList[pro1], f2, BattlePropList[pro2], 2, duration + BattleLogic.GameDeltaTime * 2)
end) end)
@ -3554,7 +3554,7 @@ local passivityList = {
local i1 = args[1] local i1 = args[1]
local onSkillCastEnd = function(skill) local onSkillCastEnd = function(skill)
local effectGroup = skill.effectCaster.effectList.buffer[1] local effectGroup = skill.effectCaster.effectList[1]
local chooseId = effectGroup.chooseId local chooseId = effectGroup.chooseId
local chooseLimit = floor(chooseId / 10000) % 10 local chooseLimit = floor(chooseId / 10000) % 10
if chooseLimit == 3 then -- 打纵列 if chooseLimit == 3 then -- 打纵列

View File

@ -215,30 +215,44 @@ function BattleLogic.TurnRound(debugTurn)
-- 上一轮结束 -- 上一轮结束
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundEnd, CurRound) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundEnd, CurRound)
end end
CurRound = CurRound + 1 -- 检测一次灵兽技能
CurCamp = BattleLogic.FirstCamp -- 判断先手阵营 SkillManager.CheckMonsterSkill(function()
CurSkillPos[0] = 0 CurRound = CurRound + 1
CurSkillPos[1] = 0 CurCamp = BattleLogic.FirstCamp -- 判断先手阵营
-- CurSkillPos[0] = 0
BattleLogManager.Log( CurSkillPos[1] = 0
"Round Change", --
"round", CurRound BattleLogManager.Log(
) "Round Change",
-- 轮数变化 "round", CurRound
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound) )
-- 开始 -- 轮数变化
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundStart, CurRound) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound)
--轮数变化后延时0.2秒用于初始化监听回合数被动的初始化 -- 开始
BattleLogic.WaitForTrigger(0.2,function() BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundStart, CurRound)
-- 进入新轮
BattleLogic.CheckBattleLogic()
-- 检测一次灵兽技能
SkillManager.CheckMonsterSkill(function()
--轮数变化后延时0.2秒用于初始化监听回合数被动的初始化
BattleLogic.WaitForTrigger(0.2,function()
-- 进入新轮
BattleLogic.CheckBattleLogic()
end)
end)
end) end)
else else
-- 切换阵营
CurCamp = (CurCamp + 1) % 2 -- 检测一次灵兽技能
BattleLogic.CheckBattleLogic() SkillManager.CheckMonsterSkill(function()
--轮数变化后延时0.2秒用于初始化监听回合数被动的初始化
BattleLogic.WaitForTrigger(0.2,function()
-- 切换阵营
CurCamp = (CurCamp + 1) % 2
BattleLogic.CheckBattleLogic()
end)
end)
end end
end end
--检测战斗逻辑 --检测战斗逻辑
@ -310,8 +324,8 @@ function BattleLogic.CheckBattleLogic()
BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血)
BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff
BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数
SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 行动结束 SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 行动结束
BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 开始行动 BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 开始行动
BattleLogic.TurnRoundNextFrame() BattleLogic.TurnRoundNextFrame()
end) end)
end end

View File

@ -36,7 +36,7 @@ local _ConditionConfig = {
local conId = condition[1] local conId = condition[1]
local comType = condition[2] local comType = condition[2]
local comValue = condition[3] local comValue = condition[3]
local rand = condition[3] local rand = condition[4]
-- 获取当前回合 -- 获取当前回合
local curRound = BattleLogic.GetCurRound() local curRound = BattleLogic.GetCurRound()
local isRoundOk = BattleUtil.CompareValue(curRound, comValue, comType) local isRoundOk = BattleUtil.CompareValue(curRound, comValue, comType)

View File

@ -74,7 +74,7 @@ local _TriggerConfig = {
end end
}, },
[10] = {--10回合开始前 [10] = {--10回合开始前
event = BattleEventName.BattleRoundEnd, event = BattleEventName.BattleRoundStart,
triggerFunc = function(skill, ...) triggerFunc = function(skill, ...)
return true return true
end end
@ -104,6 +104,8 @@ end
function this.InitListener() function this.InitListener()
for triggerId, config in pairs(_TriggerConfig) do for triggerId, config in pairs(_TriggerConfig) do
BattleLogic.Event:AddEvent(config.event, function(...) BattleLogic.Event:AddEvent(config.event, function(...)
-- 用于排序
local sortList = {}
-- 判断是否有需要触发的技能 -- 判断是否有需要触发的技能
local triggerSkill = this.TriggerList[triggerId] local triggerSkill = this.TriggerList[triggerId]
if not triggerSkill then if not triggerSkill then
@ -118,12 +120,26 @@ function this.InitListener()
if config.triggerFunc(skill, ... ) then if config.triggerFunc(skill, ... ) then
-- 检测是否符合子条件 -- 检测是否符合子条件
if MCondition.CheckCondition(skill, condition) then if MCondition.CheckCondition(skill, condition) then
-- 加入技能释放对列 -- 加入技能排序对列
SkillManager.AddMonsterSkill(skill) table.insert(sortList, skill)
end end
end end
end end
end end
-- 对技能进行排序
table.sort(sortList, function(a, b)
-- 同阵营按位置排序
if a.owner.camp == b.owner.camp then
return a.owner.position < b.owner.position
else
-- 不同阵营的根据先手阵营排序
return a.owner.camp == BattleLogic.FirstCamp
end
end)
-- 依次加入技能管理
for _, skill in ipairs(sortList) do
SkillManager.AddMonsterSkill(skill)
end
end) end)
end end
end end

View File

@ -74,6 +74,10 @@ function this.CheckTurnRound()
if this.MonsterSkillList and #this.MonsterSkillList > 0 then if this.MonsterSkillList and #this.MonsterSkillList > 0 then
return return
end end
-- 检测一次灵兽技能
this.CheckMonsterSkill(this.MonsterCheckFunc)
--
if this.DeadSkillList and #this.DeadSkillList > 0 then if this.DeadSkillList and #this.DeadSkillList > 0 then
return return
end end
@ -89,6 +93,21 @@ function this.CheckTurnRound()
end end
end end
-- 检测是否需要等待灵兽技能
function this.CheckMonsterSkill(func)
this.MonsterCheckFunc = func
-- 判断是否可以向下执行
if not this.IsSkilling and (not this.MonsterSkillList or #this.MonsterSkillList == 0) then
--
if this.MonsterCheckFunc then
local func = this.MonsterCheckFunc
-- 置空方法放到回调之前,避免再会调中再次调用检测方法导致方法被删除
this.MonsterCheckFunc = nil
func()
end
end
end
-- --
function this.Update() function this.Update()
-- 如果正在引导战斗 -- 如果正在引导战斗
@ -169,8 +188,9 @@ function this.Clear()
for _, skill in ipairs(this.SkillList) do for _, skill in ipairs(this.SkillList) do
skill:Dispose() skill:Dispose()
skillPool:Put(skill) skillPool:Put(skill)
end end
this.MonsterSkillList = {}
this.DeadSkillList = {}
this.SkillList = {} this.SkillList = {}
this.IsSkilling = false this.IsSkilling = false
end end

View File

@ -0,0 +1,7 @@
战斗版本1.0.0
1、创建战斗版本文件
2、灵兽技能加入