战斗逻辑同步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,8 +2271,16 @@ local effectList = {
BattleUtil.FinalDamage(skill, caster, target, damage, nil, 0, nil, true)
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,
}

View File

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

View File

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

View File

@ -215,6 +215,8 @@ function BattleLogic.TurnRound(debugTurn)
-- 上一轮结束
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundEnd, CurRound)
end
-- 检测一次灵兽技能
SkillManager.CheckMonsterSkill(function()
CurRound = CurRound + 1
CurCamp = BattleLogic.FirstCamp -- 判断先手阵营
CurSkillPos[0] = 0
@ -228,17 +230,29 @@ function BattleLogic.TurnRound(debugTurn)
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound)
-- 开始
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundStart, CurRound)
-- 检测一次灵兽技能
SkillManager.CheckMonsterSkill(function()
--轮数变化后延时0.2秒用于初始化监听回合数被动的初始化
BattleLogic.WaitForTrigger(0.2,function()
-- 进入新轮
BattleLogic.CheckBattleLogic()
end)
end)
end)
else
-- 检测一次灵兽技能
SkillManager.CheckMonsterSkill(function()
--轮数变化后延时0.2秒用于初始化监听回合数被动的初始化
BattleLogic.WaitForTrigger(0.2,function()
-- 切换阵营
CurCamp = (CurCamp + 1) % 2
BattleLogic.CheckBattleLogic()
end)
end)
end
end
--检测战斗逻辑

View File

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

View File

@ -74,7 +74,7 @@ local _TriggerConfig = {
end
},
[10] = {--10回合开始前
event = BattleEventName.BattleRoundEnd,
event = BattleEventName.BattleRoundStart,
triggerFunc = function(skill, ...)
return true
end
@ -104,6 +104,8 @@ end
function this.InitListener()
for triggerId, config in pairs(_TriggerConfig) do
BattleLogic.Event:AddEvent(config.event, function(...)
-- 用于排序
local sortList = {}
-- 判断是否有需要触发的技能
local triggerSkill = this.TriggerList[triggerId]
if not triggerSkill then
@ -118,12 +120,26 @@ function this.InitListener()
if config.triggerFunc(skill, ... ) then
-- 检测是否符合子条件
if MCondition.CheckCondition(skill, condition) then
-- 加入技能释放对列
-- 加入技能排序对列
table.insert(sortList, skill)
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
return
end
-- 检测一次灵兽技能
this.CheckMonsterSkill(this.MonsterCheckFunc)
--
if this.DeadSkillList and #this.DeadSkillList > 0 then
return
end
@ -89,6 +93,21 @@ function this.CheckTurnRound()
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()
-- 如果正在引导战斗
@ -169,8 +188,9 @@ function this.Clear()
for _, skill in ipairs(this.SkillList) do
skill:Dispose()
skillPool:Put(skill)
end
this.MonsterSkillList = {}
this.DeadSkillList = {}
this.SkillList = {}
this.IsSkilling = false
end

View File

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