From 14c19ca507eb4a25f47f42444676e061631a1fdd Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 4 Nov 2020 14:38:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E9=80=BB=E8=BE=91=E5=90=8C?= =?UTF-8?q?=E6=AD=A5v1.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luafight/Modules/Battle/Logic/Base/Effect.lua | 14 ++++- .../Battle/Logic/Base/EffectCaster.lua | 40 ++++++------- .../Modules/Battle/Logic/Base/Passivity.lua | 6 +- luafight/Modules/Battle/Logic/BattleLogic.lua | 60 ++++++++++++------- .../Logic/Monster/MonsterSkill/MCondition.lua | 2 +- .../Logic/Monster/MonsterSkill/MTrigger.lua | 22 ++++++- .../Modules/Battle/Logic/SkillManager.lua | 22 ++++++- luafight/Readme.txt | 7 +++ 8 files changed, 119 insertions(+), 54 deletions(-) create mode 100644 luafight/Readme.txt diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index bb77ef8c6..615e9ab12 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -2271,9 +2271,17 @@ 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, + } return effectList \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Base/EffectCaster.lua b/luafight/Modules/Battle/Logic/Base/EffectCaster.lua index 4e21512e0..9e28b7e5b 100644 --- a/luafight/Modules/Battle/Logic/Base/EffectCaster.lua +++ b/luafight/Modules/Battle/Logic/Base/EffectCaster.lua @@ -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 diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index 8f6a3c9a6..a45cb7ea7 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -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 -- 打纵列 diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index 6c52ba5af..a961af0b5 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -215,30 +215,44 @@ function BattleLogic.TurnRound(debugTurn) -- 上一轮结束 BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundEnd, CurRound) end - CurRound = CurRound + 1 - CurCamp = BattleLogic.FirstCamp -- 判断先手阵营 - CurSkillPos[0] = 0 - CurSkillPos[1] = 0 - -- - BattleLogManager.Log( - "Round Change", - "round", CurRound - ) - -- 轮数变化 - BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound) - -- 开始 - BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundStart, CurRound) - --轮数变化后延时0.2秒用于初始化监听回合数被动的初始化 - BattleLogic.WaitForTrigger(0.2,function() - -- 进入新轮 - BattleLogic.CheckBattleLogic() + -- 检测一次灵兽技能 + SkillManager.CheckMonsterSkill(function() + CurRound = CurRound + 1 + CurCamp = BattleLogic.FirstCamp -- 判断先手阵营 + CurSkillPos[0] = 0 + CurSkillPos[1] = 0 + -- + BattleLogManager.Log( + "Round Change", + "round", CurRound + ) + -- 轮数变化 + 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 - -- 切换阵营 - 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 --检测战斗逻辑 @@ -310,8 +324,8 @@ function BattleLogic.CheckBattleLogic() BattleLogic.BuffMgr:TurnUpdate(3) -- 计算持续伤害(流血) BattleLogic.BuffMgr:TurnUpdate(4) -- 计算其他buff BattleLogic.BuffMgr:PassUpdate() -- 计算buff轮数 - SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 行动结束 - BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 开始行动 + SkillRole.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 行动结束 + BattleLogic.Event:DispatchEvent(BattleEventName.RoleTurnEnd, SkillRole) -- 开始行动 BattleLogic.TurnRoundNextFrame() end) end diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua index a7e3eeff0..2ddc8b26b 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MCondition.lua @@ -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) diff --git a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua index 1af9b9715..4bf2664d2 100644 --- a/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua +++ b/luafight/Modules/Battle/Logic/Monster/MonsterSkill/MTrigger.lua @@ -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 - -- 加入技能释放对列 - SkillManager.AddMonsterSkill(skill) + -- 加入技能排序对列 + 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 diff --git a/luafight/Modules/Battle/Logic/SkillManager.lua b/luafight/Modules/Battle/Logic/SkillManager.lua index d0cd284b1..06de56ba3 100644 --- a/luafight/Modules/Battle/Logic/SkillManager.lua +++ b/luafight/Modules/Battle/Logic/SkillManager.lua @@ -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 diff --git a/luafight/Readme.txt b/luafight/Readme.txt new file mode 100644 index 000000000..ba668391d --- /dev/null +++ b/luafight/Readme.txt @@ -0,0 +1,7 @@ + + + +战斗版本:1.0.0 + + 1、创建战斗版本文件 + 2、灵兽技能加入 \ No newline at end of file