diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index 409e3c2d6..4958bad8c 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -2,6 +2,7 @@ local effect = require("Modules/Battle/Logic/Base/Effect") local floor = math.floor local max = math.max local min = math.min +local gameFrameRate = BattleLogic.GameFrameRate --local BattleConst = BattleConst --local RoleDataName = RoleDataName --local BattleEventName = BattleEventName @@ -91,8 +92,9 @@ local function chooseTarget(role, chooseId, exceptList) end if exceptNum > 0 then - for i=1, exceptNum do - for j=#arr, i+1, -1 do + local count = #arr + for i=1, min(exceptNum, count) do + for j=count, i+1, -1 do arr[j] = arr[j-1] end arr[i] = exceptList.buffer[i] @@ -100,12 +102,6 @@ local function chooseTarget(role, chooseId, exceptList) end return arr end -local effectPool = BattleObjectPool.New(function () - return {0, {}} -- type, {args, ...} -end) -local effectGroupPool = BattleObjectPool.New(function () - return { 0, 0, {}} -- chooseId, duration, {effect1, effect2, ...} -end) Skill = {} @@ -131,11 +127,11 @@ function Skill:Init(role, effectData) local v for i=2, #effectData do v = effectData[i] - local effectGroup = effectGroupPool:Get() -- chooseId, duration, {effect1, effect2, ...} + local effectGroup = { 0, 0, {}} -- chooseId, duration, {effect1, effect2, ...} effectGroup[1] = v[1] --chooseId effectGroup[2] = v[2] --duration for j=3, #v do --effectList - local effect = effectPool:Get() -- type, {args, ...} + local effect = {0, {}} -- type, {args, ...} effect[1] = v[j][1] for k=2, #v[j] do effect[2][k-1] = v[j][k] @@ -146,18 +142,6 @@ function Skill:Init(role, effectData) end end -function Skill:Dispose() - local effectGroup - for i=1, self.effectList.size do - effectGroup = self.effectList.buffer[i] - for k=1, #effectGroup[3] do - effectPool:Put(effectGroup[3][k]) - effectGroup[3][k] = nil - end - effectGroupPool:Put(effectGroup) - end -end - function Skill:ResetCD() if not self.isTeamSkill then if self.owner.superSkill == self then diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index 26e403341..74e7b78ee 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -14,8 +14,6 @@ local enemyMP local playerAggro local enemyAggro -local playerAggroChangable -local enemyAggroChangable local playerSkillUsable local enemySkillUsable @@ -84,9 +82,6 @@ function BattleLogic.Init(data, optionData) playerTeamSkillIndex = 1 enemyTeamSkillIndex = 1 - playerAggroChangable = true - enemyAggroChangable = true - playerSkillUsable = true enemySkillUsable = true @@ -185,24 +180,12 @@ end function BattleLogic.SetAggro(role, duration) if role.camp == 1 then - if playerAggroChangable then - playerAggro = role - if enemySkillUsable then - BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, role, max(duration/2, 0.3)) - end - playerAggroChangable = false - BattleLogic.WaitForTrigger(duration-BattleLogic.GameDeltaTime, function () --减去一帧避免卡点 - playerAggroChangable = true - end) + playerAggro = role + if enemySkillUsable then + BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, role, max(duration/2, 0.3)) end else - if enemyAggroChangable then - enemyAggro = role - enemyAggroChangable = false - BattleLogic.WaitForTrigger(duration-BattleLogic.GameDeltaTime, function () --减去一帧避免卡点 - enemyAggroChangable = true - end) - end + enemyAggro = role end end @@ -249,12 +232,14 @@ function BattleLogic.GetSkillUsable(camp) end function BattleLogic.WaitForTrigger(delayTime, action) + delayTime = floor(delayTime * 100000 + 0.5) / 100000 --进行精度处理,避免前后端计算不一致 + local delayFrame = floor(delayTime * BattleLogic.GameFrameRate + 0.5) local item = actionPool:Get() - item[1] = curFrame + floor(delayTime * BattleLogic.GameFrameRate + 0.5) + item[1] = curFrame + delayFrame item[2] = action tbActionList:Add(item) if BattleLogic.IsOpenBattleRecord then - BattleLogic.RecordDelayTrigger(delayTime, curFrame + floor(delayTime * BattleLogic.GameFrameRate + 0.5)) + BattleLogic.RecordDelayTrigger(delayTime, curFrame + delayFrame) end end @@ -284,19 +269,13 @@ function BattleLogic.CurFrame() return curFrame end - ---local list = {} function BattleLogic.Query(func, inCludeDeadRole) - --for i=1, #list do - -- list[i] = nil - --end local list = {} local index = 1 if func then for i=1, objList.size do local v = objList.vList[i] if func(v) and (inCludeDeadRole or not v.isDead) then - --if memoize(func, v) and (inCludeDeadRole or not v.isDead) then list[index] = v index = index + 1 end @@ -474,7 +453,7 @@ end --Record专用 function BattleLogic.RecordDelayTrigger(delayFrame, triggerFrame) - table.insert(record, string.format("frame:%d, delayFrame:%d, triggerFrame:%d", curFrame, delayFrame, triggerFrame)) + table.insert(record, string.format("frame:%d, delayTime:%f, triggerFrame:%d", curFrame, delayFrame, triggerFrame)) end --Record专用 diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index ef549287f..eeb5074a3 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -72,12 +72,10 @@ end function RoleLogic:Dispose() if self.skill then - self.skill:Dispose() skillPool:Put(self.skill) self.skill = nil end if self.superSkill then - self.superSkill:Dispose() skillPool:Put(self.superSkill) self.superSkill = nil end diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SSkillLogicConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SSkillLogicConfig.java index d0875544d..2d99a9fac 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SSkillLogicConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SSkillLogicConfig.java @@ -57,7 +57,7 @@ public class SSkillLogicConfig implements BaseConfig { return effect; } - public int getEffectValueIndex (int[][] effectArr,int value){ + public int getEffectValueIndex (int[][] effectArr,int value, int index){ StringBuilder effectStr = new StringBuilder(); for (int[] effects :effectArr){ for (int eff :effects){ @@ -73,14 +73,18 @@ public class SSkillLogicConfig implements BaseConfig { for (int i =0 ; i < ints.length; i++){ map.put(i,ints[i]); } - int index = 0; + int backIndex = 0; + int flag = 0; for (Map.Entry entry : map.entrySet()){ if (entry.getValue() == value){ - index = entry.getKey(); - break; + backIndex = entry.getKey(); + if (flag == index){ + break; + } + flag++; } } - return index; + return backIndex; } public float[][] getEffectValue() { @@ -120,7 +124,7 @@ public class SSkillLogicConfig implements BaseConfig { }else { effectInfo.append("|").append(effects[i]); } - int index = getEffectValueIndex(effect, effects[i]); + int index = getEffectValueIndex(effect, effects[i], i ); float[] effectValue = effectValues[index]; for (float effectVal : effectValue) { effectInfo.append("#").append(effectVal);