From 0a7bc08b074da9637efbe0baefa98f8ff733c5e7 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Tue, 16 Mar 2021 14:15:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luafight/Modules/Battle/Logic/Base/Buff.lua | 65 +++++---- .../Battle/Logic/Base/EffectCaster.lua | 40 +++--- .../Modules/Battle/Logic/Base/Passivity.lua | 136 +++++------------- luafight/Modules/Battle/Logic/BattleLogic.lua | 23 +-- luafight/Modules/Battle/Readme.txt | 6 + 5 files changed, 105 insertions(+), 165 deletions(-) diff --git a/luafight/Modules/Battle/Logic/Base/Buff.lua b/luafight/Modules/Battle/Logic/Base/Buff.lua index fc456b455..1c87f6a4f 100644 --- a/luafight/Modules/Battle/Logic/Base/Buff.lua +++ b/luafight/Modules/Battle/Logic/Base/Buff.lua @@ -263,37 +263,40 @@ function BuffManager:Update() 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) - buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff) - isCovered = true - 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 + -- 是覆盖类型的buff且有老buff buff表现层修改所有cover 字段没用了 注释 by:王振兴 2021/03/11 20:40 + -- 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) + -- buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff) + -- isCovered = true + -- 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 + buffList:Add(buff) + buff:OnStart() + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) end -- 清除过期buff diff --git a/luafight/Modules/Battle/Logic/Base/EffectCaster.lua b/luafight/Modules/Battle/Logic/Base/EffectCaster.lua index 200c990ce..9569e7b85 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],self.skill) 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 4f66b11cc..f2f1a2864 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -1839,34 +1839,27 @@ local passivityList = { - -- 释放技能后给除自己外己方生命最少的[a]名武将附加无敌盾持续[b]回合(只剩自己则不加) - -- a[int] b[int] + -- 释放技能后给除自己外己方生命最少的武将附加无敌盾持续[b]回合(只剩自己则不加) + --b[属性] [104] = function(role, args,id,judge) local i1 = args[1] - local num = args[2] -- 释放技能后 local onSkillEnd = function(skill) if skill and not skill.isTriggerJudge and judge==1 then return end - local heros={} if skill.type == BattleSkillType.Special then local list = RoleManager.Query(function(v) return v.camp == role.camp end) BattleUtil.SortByHpFactor(list, 1) local target = nil for i = 1, #list do if not list[i]:IsRealDead() and list[i] ~= role then - -- target = list[i] - table.insert(heros,list[i]) - -- break + target = list[i] + break end end - if heros then - for i = 1, i1 do - if heros[i] then - heros[i]:AddBuff(Buff.Create(role, BuffName.Shield, num, ShieldTypeName.AllReduce, 0, 0)) - end - end + if target then + target:AddBuff(Buff.Create(role, BuffName.Shield, i1, ShieldTypeName.AllReduce, 0, 0)) end end end @@ -2740,15 +2733,15 @@ local passivityList = { end, - -- 战斗第开始无敌[a]回合 + -- 战斗第[a]回合无敌 -- a[int] [141] = function(role, args) local i1 = args[1] local buff BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) -- 第i1回合开始 - if curRound == 1 then - buff = Buff.Create(role, BuffName.Shield, i1, ShieldTypeName.AllReduce, 0, 0) + if curRound == i1 then + buff = Buff.Create(role, BuffName.Shield, 0, ShieldTypeName.AllReduce, 0, 0) buff.clear = false role:AddBuff(buff) end @@ -3122,7 +3115,7 @@ local passivityList = { role.Event:AddEvent(BattleEventName.RoleHit, onHit) end, - -- 复活友方[a]位阵亡的英雄并回复其[b]%的生命每场战斗触发[c]次;复活的如果是[d]阵营,回复[e]% + -- 复活友方第[a]位阵亡的英雄并回复其[b]%的生命每场战斗触发[c]次;复活的如果是[d]阵营,回复[e]% -- a[int]b[float]c[int] d[int] e[float] (d,e不配就不会额外回复) [154] = function(role, args) local i1 = args[1] @@ -3141,7 +3134,7 @@ local passivityList = { f1=v1 end counter = counter + 1 - if counter <= i1 then + if counter == i1 then deadRole:SetRelive(f1) end end @@ -3195,11 +3188,10 @@ local passivityList = { role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) end, - -- 释放技能后回复当前本方阵容最靠前[a]名武将[b]点怒气 - -- a[int] b[int] + -- 释放技能后回复当前本方阵容最靠前武将[a]点怒气 + -- a[int] [158] = function(role, args,id,judge) local i1 = args[1] - local num = args[2] local onSkillCastEnd = function(skill) if skill and not skill.isTriggerJudge and judge==1 then return @@ -3209,14 +3201,10 @@ local passivityList = { table.sort(list, function(a, b) return a.position < b.position end) - local aaa = 0 for i= 1, #list do if list[i] and not list[i]:IsRealDead() then - BattleUtil.CalRage(role, list[i], num, CountTypeName.Add) - aaa=aaa+1 - if aaa==i1 then - break - end + BattleUtil.CalRage(role, list[i], i1, CountTypeName.Add) + break end end end @@ -4771,19 +4759,16 @@ local passivityList = { end, -- 大闹天宫胜利次数 - [225] = function(role, args,id,judge) + [225] = function(role, args) --王振兴添加 local f1 = args[1] local pro1 = args[2] local ct1 = args[3] local maxNum = args[4] -- 紫+橙 - local num = OutDataManager.GetOutData(role.camp,id) - -- LogError("id: "..id.." 胜利次数:"..num) + local num = OutDataManager.GetOutData(role.camp, OutDataName.WinTimes) + num = min(maxNum, num) - if num==0 then - return - end BattleUtil.AddProp(role, pro1, f1 * num, ct1) end, @@ -4977,7 +4962,7 @@ local passivityList = { -- 猎妖之路专属 -- 根据同时拥有夜明珠的数量获得效果:2个:[c]改变[a]的[b];3个:[f]改变[d]的[e];4个:[i]改变[g]的[h] -- a[float],b[属性],c[改变类型],d[float],e[属性],f[改变类型],g[float],h[属性],i[改变类型] - [237] = function(role, args,id,judge) + [237] = function(role, args) local f1 = args[1] local pro1 = args[2] local ct1 = args[3] @@ -4989,7 +4974,7 @@ local passivityList = { local ct3 = args[9] - local num = OutDataManager.GetOutData(role.camp,id) + local num = OutDataManager.GetOutData(role.camp, OutDataName.DarkGlowBallNum) if num >= 2 then BattleUtil.AddProp(role, pro1, f1, ct1) end @@ -5003,7 +4988,7 @@ local passivityList = { -- 猎妖之路专属 -- 在大闹天空的第[a]层中,我方武将[d]改变[b]的[c],[g改变[e]的[f] -- a[位置],b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型] - [238] = function(role, args,id,judge) + [238] = function(role, args) local flr = args[1] local f1 = args[2] local pro1 = args[3] @@ -5012,7 +4997,7 @@ local passivityList = { local pro2 = args[6] local ct2 = args[7] - if OutDataManager.GetOutData(role.camp,id) == flr then + if OutDataManager.GetOutData(role.camp, OutDataName.DaNaoTianGongFloor) == flr then BattleUtil.AddProp(role, pro1, f1, ct1) BattleUtil.AddProp(role, pro2, f2, ct2) end @@ -5020,7 +5005,7 @@ local passivityList = { -- 猎妖之路专属 -- 每有一件紫色品质以上的战利品,我方武将[d]改变[b]的[c],[g改变[e]的[f],最多[h]层 -- b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型],h[int] - [239] = function(role, args,id,judge) + [239] = function(role, args) local f1 = args[1] local pro1 = args[2] local ct1 = args[3] @@ -5030,7 +5015,7 @@ local passivityList = { local maxNum = args[7] -- 紫+橙 - local num = OutDataManager.GetOutData(role.camp, id) + local num = OutDataManager.GetOutData(role.camp, OutDataName.OrangeGloryItemNum) + OutDataManager.GetOutData(role.camp, OutDataName.RedGloryItemNum) num = min(maxNum, num) BattleUtil.AddProp(role, pro1, f1 * num, ct1) BattleUtil.AddProp(role, pro2, f2 * num, ct2) @@ -5038,15 +5023,15 @@ local passivityList = { -- 猎妖之路专属 -- 每使用一次神秘药水,我方武将[c]改变[a]的[b],最多[d]层 -- a[float],b[属性],c[改变类型],d[int] - [240] = function(role, args,id,judge) + [240] = function(role, args) local f1 = args[1] local pro1 = args[2] local ct1 = args[3] local maxNum = args[4] -- 紫+橙 - local num = OutDataManager.GetOutData(role.camp, id) - --LogError("笔使用次数:"..num) + local num = OutDataManager.GetOutData(role.camp, OutDataName.MisteryLiquidUsedTimes) + num = min(maxNum, num) BattleUtil.AddProp(role, pro1, f1 * num, ct1) end, @@ -5859,19 +5844,16 @@ local passivityList = { end role.Event:AddEvent(BattleEventName.PassiveBeDamaging, onPassiveBeDamaging) end, - -- 战斗第[a]回合开始概率无敌,回合数每增加1,概率是之前的[b] - -- a[int] b[float] + -- 战斗第回合概率无敌,回合数每增加1,概率是之前的[a] + -- a[float] [272] = function(role, args) local i1 = args[1] - local p1 =args[2] local buff=nil local isTrigger=true BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound) local pro=0 - if curRound>i1 then - pro=p1^(curRound-i1) - else - pro=1 + if curRound>0 then + pro=i1^(curRound-1) end if isTrigger then local isAdd=BattleUtil.RandomAction(pro, function () @@ -6717,59 +6699,5 @@ local passivityList = { end BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, onRoleHit) end, - --英雄[a],附加的[b]种类[c]类型buff,持续时间改变[d][e]回合 - --a[int],b[int buff类型],c[int type类型],d[int 改变类型],e[int] - [306] = function(role, args) - local id = args[1] - local tp1 = args[2] - local tp2 = args[3] - local ct = args[4] - local round = args[5] - local OnBuffCaster = function(buff) - if not buff then - return - end - if buff.type~=tp1 then - return - end - if role.roleId~=id then - return - end - if buff.type == BuffName.PropertyChange then - if buff.changeType~=tp2 then - return - end - elseif buff.type==BuffName.Control then - if buff.ctrlType~=tp2 then - return - end - elseif buff.type== BuffName.DOT then - if buff.damageType~=tp2 then - return - end - elseif buff.type== BuffName.HOT then - - elseif buff.type== BuffName.Shield then - if buff.shieldType~=tp2 then - return - end - elseif buff.type== BuffName.Immune then - if buff.immuneType~=tp2 then - return - end - end - - if ct == 1 then --加算 - buff.duration = buff.duration + round - elseif ct == 2 then --乘加算(百分比属性加算) - buff.duration = buff.duration * (1 + round) - elseif ct == 3 then --减算 - buff.duration = buff.duration - round - elseif ct == 4 then --乘减算(百分比属性减算) - buff.duration = buff.duration * (1 - round) - end - end - role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) - end, } -return passivityList \ No newline at end of file +return passivityList diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index a9a172bc1..5545103b5 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -116,8 +116,7 @@ function BattleLogic.CheckFirstCamp() end end -function BattleLogic.StartOrder() - -- +function BattleLogic.InitOrder() BattleLogic.CurOrder = BattleLogic.CurOrder + 1 if BattleLogic.CurOrder == 1 then local playerData = fightData.playerData @@ -144,7 +143,6 @@ function BattleLogic.StartOrder() end end - else RoleManager.ClearEnemy() local orderList = fightData.enemyData[BattleLogic.CurOrder] @@ -159,14 +157,19 @@ function BattleLogic.StartOrder() MonsterManager.AddMonster(enemyMonsterList[i]) end end - end - -- 检测先后手 - BattleLogic.CheckFirstCamp() - -- 开始战斗,延时一帧执行,避免战斗还没开始就释放了技能 - BattleLogic.TurnRoundNextFrame() - -- 战斗开始 - BattleLogic.Event:DispatchEvent(BattleEventName.BattleStart) +end + +function BattleLogic.StartTurnRound() + BattleLogic.CheckFirstCamp()-- 检测先后手 + BattleLogic.TurnRoundNextFrame()-- 开始战斗,延时一帧执行,避免战斗还没开始就释放了技能 + BattleLogic.Event:DispatchEvent(BattleEventName.BattleStart)-- 战斗开始 +end + + +function BattleLogic.StartOrder() + BattleLogic.InitOrder() + BattleLogic.StartTurnRound() end -- 获取当前轮数 diff --git a/luafight/Modules/Battle/Readme.txt b/luafight/Modules/Battle/Readme.txt index 87b854234..a6579b378 100644 --- a/luafight/Modules/Battle/Readme.txt +++ b/luafight/Modules/Battle/Readme.txt @@ -1,3 +1,9 @@ +v1.0.22 + 1、被动249修改 + +v1.0.22 + 1、效果叠加显示修改,注释逻辑里关于效果覆盖的代码 + 2 同步战斗逻辑添加boss展示 v1.0.21 1、混乱后的普攻不触发任何特性 2 舍身济世分担的伤害改为可以触发被动