back_recharge
wangyuan 2019-10-10 11:03:42 +08:00
parent 994f38dd78
commit afafa4fd38
6 changed files with 178 additions and 168 deletions

View File

@ -33,13 +33,6 @@ local function buffRandomAction(random, caster, target, buffType, duration, ...)
end
end
local function casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
if caster.camp == 0 and target.camp == 1 then
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, interval)
end
end
local function calBuffHit(caster, target, baseRandom)
if caster.isTeam then --异妖不走效果命中公式
return baseRandom
@ -55,7 +48,7 @@ local effectList = {
[1] = function(caster, target, args, interval)
local f1 = args[1]
local dt = args[2]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.CalDamage(caster, target, dt, f1)
end)
@ -114,9 +107,6 @@ local effectList = {
local count = Random.RangeInt(i1, i2)
local d = interval / count
if caster.camp == 0 and target.camp == 1 then
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, d)
end
for i=1, count do
BattleLogic.WaitForTrigger(d * (i-1), function ()
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, d, target)
@ -173,7 +163,7 @@ local effectList = {
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local dmg = BattleUtil.CalDamage(caster, target, dt, f1)
BattleUtil.CalTreat(caster, caster, floor(dmg * f2))
@ -186,7 +176,7 @@ local effectList = {
local dt = args[2]
local i1 = args[3]
local f2 = args[4]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if target.roleData.professionId == i1 then
f1 = f1 + f2
@ -224,7 +214,7 @@ local effectList = {
local rid = args[4]
local f3 = args[5]
local i1 = args[6]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local layer
if BattleLogic.BuffMgr:HasBuff(target, BuffName.Brand, function (buff)
@ -247,7 +237,7 @@ local effectList = {
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local dmg, crit = BattleUtil.CalDamage(caster, target, dt, f1)
if target.isDead then
@ -286,7 +276,7 @@ local effectList = {
local dt = args[2]
local i1 = args[3]
local f2 = calBuffHit(caster, target, args[4])
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local dmg = floor(caster:GetRoleData(propertyList[dt]) * f1)
if target.roleData.professionId == i1 then
@ -306,7 +296,7 @@ local effectList = {
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local d, crit = BattleUtil.CalDamage(caster, target, dt, f1)
if crit then
@ -332,9 +322,6 @@ local effectList = {
count = count + 1
end
local d = interval / count
if caster.camp == 0 and target.camp == 1 then
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, d)
end
for i=1, count do
BattleLogic.WaitForTrigger(d * (i-1), function ()
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, d, target)
@ -351,7 +338,7 @@ local effectList = {
local dt = args[2]
local i1 = args[3]
local f2 = args[4]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if BattleLogic.BuffMgr:HasBuff(target, BuffName.Control, function (buff) return i1 == 0 or buff.ctrlType == i1 end) then
f1 = f1 + f2
@ -396,7 +383,7 @@ local effectList = {
local dt = args[2]
local ht = args[3]
local f2 = args[4]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if BattleLogic.BuffMgr:HasBuff(target, BuffName.HOT, function (buff) return true end) then
f1 = f1 + f2
@ -465,7 +452,7 @@ local effectList = {
local dt = args[2]
local dot = args[3]
local f2 = args[4]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
f1 = f1 + f2
@ -485,9 +472,6 @@ local effectList = {
local count = Random.RangeInt(i1, i2)
local d = interval / count
if caster.camp == 0 and target.camp == 1 then
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, d)
end
for i=1, count do
BattleLogic.WaitForTrigger(d * (i-1), function ()
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, d, target)
@ -507,7 +491,7 @@ local effectList = {
local dt = args[2]
local ct = args[3]
local f2 = args[4]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if BattleLogic.BuffMgr:HasBuff(target, BuffName.Control, function (buff) return ct == 0 or buff.ctrlType == ct end) then
BattleUtil.CalDamage(caster, target, dt, f1, f2)
@ -647,7 +631,7 @@ local effectList = {
--a[int]
[38] = function(caster, target, args, interval)
local d = args[1]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if not target.isDead then
BattleUtil.ApplyDamage(caster, target, d)
@ -659,7 +643,7 @@ local effectList = {
[39] = function(caster, target, args, interval)
local d1 = args[1]
local d2 = args[2]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
target:AddBuff(Buff.Create(caster, BuffName.DOT, d2, 1, 0, d1, 1))
end)
@ -682,7 +666,7 @@ local effectList = {
local f2 = calBuffHit(caster, target, args[3])
local f3 = args[4]
local f4 = calBuffHit(caster, target, args[5])
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.RandomAction(f2, function ()
f1 = f1 + f3
@ -740,7 +724,7 @@ local effectList = {
local pro2 = args[7]
local ct2 = args[8]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local proTran1 = {proName = propertyList[pro1], tranProName = propertyList[pro1], tranFactor = f2, changeType = ct1}
local proTran2 = {proName = propertyList[pro2], tranProName = propertyList[pro2], tranFactor = f3, changeType = ct2}
@ -771,7 +755,7 @@ local effectList = {
local f2 = args[3]
local pro1 = args[4]
local i1 = args[5]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local dmg, crit = BattleUtil.CalDamage(caster, target, dt, f1)
if target.isDead then
@ -790,7 +774,7 @@ local effectList = {
local pt = args[3]
local f2 = args[4]
local f3 = args[5]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if target.roleData.professionId == pt then
BattleUtil.CalDamage(caster, target, dt, f1+f3, f2)
@ -804,7 +788,7 @@ local effectList = {
[48] = function(caster, target, args, interval)
local pro = args[1]
local d = args[2]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.ApplyDamage(caster, target, floor(caster:GetRoleData(propertyList[pro]) * d))
end)
@ -815,7 +799,7 @@ local effectList = {
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.CalDamage(caster, target, dt, f1)
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
@ -842,7 +826,7 @@ local effectList = {
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
if BattleUtil.GetHPPencent(target) < f2 then
BattleUtil.ApplyDamage(caster, target, target:GetRoleData(RoleDataName.Hp))
@ -900,7 +884,7 @@ local effectList = {
local f1 = args[1]
local dt = args[2]
local f2 = args[3]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
local flag = "fuling"..caster.uid
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.CalDamage(caster, target, dt, f1)
@ -982,7 +966,7 @@ local effectList = {
[56] = function(caster, target, args, interval)
local f1 = args[1]
local i1 = args[2]
casterBulletEffect(caster, target, interval)
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local damage = BattleUtil.ApplyDamage(caster, target, floor(target:GetRoleData(RoleDataName.Hp) * f1))
local arr = BattleUtil.ChooseTarget(caster, 10110)

View File

@ -22,8 +22,18 @@ function Skill:New()
return o
end
function Skill:Init(role, effectData, isTeamSkill)
self.cd = isTeamSkill and effectData[1] % 100 or effectData[1] --异妖技能的cd数据为类型*100 + cd
function Skill:Init(role, effectData, type) --type 0 异妖 1 点技 2 滑技
local isTeamSkill = type == 0
if type == 0 then --异妖
self.cd = effectData[1] % 100 --异妖技能的cd数据为类型*100 + cd
self.randomInStage2 = 0
elseif type == 1 then --点技
self.cd = 0 --点技 cd为0
self.randomInStage2 = 0
elseif type == 2 then --滑技
self.cd = effectData[1] % 100 --上滑技的cd数据为中期上滑概率*100000 + cd
self.randomInStage2 = (effectData[1] - self.cd) / 100000
end
--skill = {cd, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
--效果 = {效果类型id, 效果参数1, 效果参数2, ...}
@ -93,12 +103,6 @@ function Skill:Cast()
if count == 0 then
count = #arr
end
if self.owner.camp == 0 and nn == 2 then --我方释放效果开始切镜头
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomIn, 0.3)
BattleLogic.WaitForTrigger(duration, function()
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomOut, 0.3)
end)
end
if chooseId == 10000 or chooseId == 20000 then --10000 我方aoe 20000 敌方aoe
local camp = chooseId == 10000 and self.owner.camp or 1 - self.owner.camp
self.owner.Event:DispatchEvent(BattleEventName.AOE, camp)
@ -139,7 +143,6 @@ function Skill:Cast()
end
end
BattleLogic.SetAggro(self.owner)
if not self.isTeamSkill then
local time = max(8-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
time = BattleUtil.ErrorCorrection(time)

View File

@ -12,9 +12,6 @@ local curFrame
local playerMP
local enemyMP
local playerAggro
local enemyAggro
local playerSkillUsable
local enemySkillUsable
@ -48,6 +45,15 @@ BattleLogic.TotalOrder = 0
--当前波次
BattleLogic.CurOrder = 0
local stage --战场分割阶段
local stageFrame1 = 25 * BattleLogic.GameFrameRate --前期转中期的时间点
local stageFrame2 = 40 * BattleLogic.GameFrameRate --中期转后期的时间点
local teamSkillCastTime = {15 * BattleLogic.GameFrameRate,
35 * BattleLogic.GameFrameRate,
55 * BattleLogic.GameFrameRate}
local teamSkillCastIndex
local maxFrame --战斗最大用时,超时判负
local actionPool = BattleObjectPool.New(function ()
@ -87,13 +93,11 @@ function BattleLogic.Init(maxTime, data, optionData)
playerMP = 0
enemyMP = 0
stage = 0
playerTeamDummyRole.isDebug = false
enemyTeamDummyRole.isDebug = false
playerTeamSkillIndex = 1
enemyTeamSkillIndex = 1
playerSkillUsable = true
enemySkillUsable = true
@ -107,13 +111,20 @@ end
function BattleLogic.StartOrder()
BattleLogic.CurOrder = BattleLogic.CurOrder + 1
stage = 1
teamSkillCastIndex = 1
playerTeamSkillIndex = 1
enemyTeamSkillIndex = 1
curFrame = 0
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
if BattleLogic.CurOrder == 1 then
for i=1, #fightData.playerData do
BattleLogic.AddRole(fightData.playerData[i])
BattleLogic.AddRole(fightData.playerData[i], i)
end
for i=1, #fightData.enemyData[BattleLogic.CurOrder] do
BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i])
BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i], i)
end
for i=1, #playerTeamSkillList do
@ -122,7 +133,7 @@ function BattleLogic.StartOrder()
end
for i=1, #fightData.playerData.teamSkill do
playerTeamSkillList[i] = skillPool:Get()
playerTeamSkillList[i]:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i], true)
playerTeamSkillList[i]:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i], 0)
end
for i=1, #fightData.playerData.teamPassive do
for j=1, #fightData.playerData.teamPassive[i] do
@ -142,7 +153,7 @@ function BattleLogic.StartOrder()
end
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
enemyTeamSkillList[i] = skillPool:Get()
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], true)
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], 0)
end
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do
for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do
@ -158,7 +169,7 @@ function BattleLogic.StartOrder()
else
BattleLogic.ClearOrder()
for i=1, #fightData.enemyData[BattleLogic.CurOrder] do
BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i])
BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i], i)
end
for i=1, #enemyTeamSkillList do
@ -167,7 +178,7 @@ function BattleLogic.StartOrder()
end
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
enemyTeamSkillList[i] = skillPool:Get()
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], true)
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], 0)
end
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do
for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do
@ -181,19 +192,18 @@ function BattleLogic.StartOrder()
end
end
end
BattleLogic.InitAggro()
end
function BattleLogic.AddMP(camp, mp)
if camp == 0 then
if #playerTeamSkillList > 0 then
playerMP = min(playerMP + mp, 100)
end
else
if #enemyTeamSkillList > 0 then
enemyMP = min(enemyMP + mp, 100)
end
end
--if camp == 0 then
-- if #playerTeamSkillList > 0 then
-- playerMP = min(playerMP + mp, 100)
-- end
--else
-- if #enemyTeamSkillList > 0 then
-- enemyMP = min(enemyMP + mp, 100)
-- end
--end
end
function BattleLogic.GetMP(camp)
@ -202,15 +212,14 @@ end
function BattleLogic.CanManualTeamSkill()
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
return not isAuto and playerMP == 100 and teamSkill and teamSkill.sp >= teamSkill.spPass
return not isAuto and teamSkill
end
function BattleLogic.GetTeamSkillCDPass()
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
if not teamSkill then
return 1
function BattleLogic.GetTeamSkillCastTime()
if teamSkillCastIndex > #playerTeamSkillList then
return -1
end
return teamSkill.sp / teamSkill.spPass
return teamSkillCastTime[teamSkillCastIndex] - curFrame
end
function BattleLogic.GenerateBuffId()
@ -218,70 +227,16 @@ function BattleLogic.GenerateBuffId()
return curBuffId
end
function BattleLogic.AddRole(roleData)
function BattleLogic.AddRole(roleData, position)
curUid = curUid + 1
local role = rolePool:Get()
role:Init(curUid, roleData)
role:Init(curUid, roleData, position)
objList:Add(curUid, role)
if not role.isDead then
BattleLogic.Event:DispatchEvent(BattleEventName.AddRole, role)
end
end
function BattleLogic.InitAggro()
for i=1, objList.size do
if objList.vList[i].camp == 1 then
playerAggro = objList.vList[i]
break
end
end
for i=1, objList.size do
if objList.vList[i].camp == 0 then
enemyAggro = objList.vList[i]
break
end
end
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, playerAggro, 1)
end
function BattleLogic.SetAggro(role)
if role.isTeam then
return
end
if role.camp == 1 then
playerAggro = role
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, role, 1)
else
enemyAggro = role
end
end
function BattleLogic.GetAggro(camp)
if camp == 0 then
if not playerAggro or playerAggro.isDead then
for i=1, objList.size do
if objList.vList[i].camp == 1 and not objList.vList[i].isDead then
playerAggro = objList.vList[i]
BattleLogic.SetAggro(playerAggro)
break
end
end
end
return playerAggro
else
if not enemyAggro or enemyAggro.isDead then
for i=1, objList.size do
if objList.vList[i].camp == 0 and not objList.vList[i].isDead then
enemyAggro = objList.vList[i]
BattleLogic.SetAggro(enemyAggro)
break
end
end
end
return enemyAggro
end
end
function BattleLogic.SetSkillUsable(camp, value)
if camp == 0 then
playerSkillUsable = value
@ -368,6 +323,20 @@ function BattleLogic.CurFrame()
return curFrame
end
function BattleLogic.CurStage()
return stage
end
function BattleLogic.CurStageTime()
local time = 0
if stage == 1 then
time = stageFrame1 - curFrame
elseif stage == 2 then
time = stageFrame2 - curFrame
end
return time
end
function BattleLogic.Query(func, inCludeDeadRole)
local list = {}
local index = 1
@ -421,6 +390,32 @@ end
function BattleLogic.Update()
curFrame = curFrame + 1
if curFrame > stageFrame1 and stage == 1 then
stage = 2
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
end
if curFrame > stageFrame2 and stage == 2 then
stage = 3
BattleLogic.Event:DispatchEvent(BattleEventName.BattleStageChange, stage)
end
if curFrame > teamSkillCastTime[teamSkillCastIndex] then
if playerTeamSkillIndex == teamSkillCastIndex and playerSkillUsable then
if playerTeamSkillList[teamSkillCastIndex] then
playerTeamSkillList[teamSkillCastIndex]:Cast()
playerTeamSkillIndex = playerTeamSkillIndex + 1
end
end
if enemyTeamSkillIndex == teamSkillCastIndex and enemySkillUsable then
if enemyTeamSkillList[teamSkillCastIndex] then
enemyTeamSkillList[teamSkillCastIndex]:Cast()
enemyTeamSkillIndex = enemyTeamSkillIndex + 1
end
end
teamSkillCastIndex = min(teamSkillCastIndex + 1, #teamSkillCastTime)
end
if curFrame > maxFrame then
BattleLogic.BattleEnd(0)
return
@ -448,27 +443,27 @@ function BattleLogic.Update()
end
end
for i=1, #playerTeamSkillList do
playerTeamSkillList[i].sp = min(playerTeamSkillList[i].sp + 1, playerTeamSkillList[i].spPass)
end
for i=1, #enemyTeamSkillList do
enemyTeamSkillList[i].sp = min(enemyTeamSkillList[i].sp + 1, enemyTeamSkillList[i].spPass)
end
if playerMP == 100 and playerSkillUsable and isAuto then
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
if teamSkill.sp >= teamSkill.spPass then
BattleLogic.CastTeamSkill(0)
end
end
if enemyMP == 100 and enemySkillUsable then
local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
if teamSkill.sp >= teamSkill.spPass then
BattleLogic.CastTeamSkill(1)
end
end
--for i=1, #playerTeamSkillList do
-- playerTeamSkillList[i].sp = min(playerTeamSkillList[i].sp + 1, playerTeamSkillList[i].spPass)
--end
--
--for i=1, #enemyTeamSkillList do
-- enemyTeamSkillList[i].sp = min(enemyTeamSkillList[i].sp + 1, enemyTeamSkillList[i].spPass)
--end
--
--if playerMP == 100 and playerSkillUsable and isAuto then
-- local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
-- if teamSkill.sp >= teamSkill.spPass then
-- BattleLogic.CastTeamSkill(0)
-- end
--end
--
--if enemyMP == 100 and enemySkillUsable then
-- local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
-- if teamSkill.sp >= teamSkill.spPass then
-- BattleLogic.CastTeamSkill(1)
-- end
--end
BattleLogic.BuffMgr:Update()
@ -498,6 +493,34 @@ function BattleLogic.Update()
end
end
local posDic = {3,2,4,1,5}
--对位规则: 1敌方相同对位 2若死亡或不存在选取相邻阵位最近且阵位索引最小的
function BattleLogic.GetAggro(camp, position)
local minNeighbor = 100
local index = 100
local target
local enemyCamp = camp == 0 and 1 or 0
for i=1, objList.size do
if objList.vList[i].camp == enemyCamp and not objList.vList[i].isDead then
if position == objList.vList[i].position then
return objList.vList[i]
else
local neighbor = math.abs(posDic[position] - posDic[objList.vList[i].position])
if neighbor < minNeighbor then
minNeighbor = neighbor
index = objList.vList[i].position
target = objList.vList[i]
elseif neighbor == minNeighbor and objList.vList[i].position < index then
minNeighbor = neighbor
index = objList.vList[i].position
target = objList.vList[i]
end
end
end
end
return target
end
function BattleLogic.ResetTeamSkillCD(camp)
local skill = camp == 0 and playerTeamDummyRole.curSkill or enemyTeamDummyRole.curSkill
if skill then

View File

@ -6,6 +6,7 @@ end
BattleEventName = {
BattleOrderChange = indexAdd(),
BattleStageChange = indexAdd(),
BattleEnd = indexAdd(),
AddRole = indexAdd(),
RemoveRole = indexAdd(),
@ -42,10 +43,6 @@ BattleEventName = {
PassiveDamaging = indexAdd(),
PassiveCriting = indexAdd(),
ZoomIn = indexAdd(),
ZoomChange = indexAdd(),
ZoomOut = indexAdd(),
AOE = indexAdd(),
RoleViewBullet = indexAdd(), --弹道飞行击中表现

View File

@ -62,7 +62,7 @@ function BattleUtil.ChooseTarget(role, chooseId)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {BattleLogic.GetAggro(role.camp)}
return {BattleLogic.GetAggro(role.camp, role.position)}
else
arr = BattleLogic.Query()
end
@ -185,11 +185,6 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType, isD
BattleLogic.BuffMgr:ClearBuff(defRole)
defRole.Event:DispatchEvent(BattleEventName.RoleDead)
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole)
if defRole.camp == 1 then
BattleLogic.WaitForTrigger(1, function ()
BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, BattleLogic.GetAggro(0), 1)
end)
end
end
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType, isDot)

View File

@ -10,7 +10,14 @@ local min = math.min
local aiList = {
[0] = function(skill, superSkill) --默认75%释放点击技、25%释放上滑技
return Random.Range01() <= 0.75
local stage = BattleLogic.CurStage()
if stage == 1 then
return true
elseif stage == 2 then
return Random.Range01() > superSkill.randomInStage2
elseif stage == 3 then
return false
end
end,
[1] = function(skill, superSkill) --只放点技
return true
@ -34,7 +41,7 @@ local skillPool = BattleObjectPool.New(function ()
end)
function RoleLogic.New()
local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0,aiIndex = 1,
local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0,aiIndex=1,position=0,
shield=BattleList.New(),
exCalDmgList=BattleList.New(),
proTranList=BattleList.New(),
@ -44,8 +51,9 @@ function RoleLogic.New()
return instance
end
function RoleLogic:Init(uid, data)
function RoleLogic:Init(uid, data, position)
self.uid = uid
self.position = position
self.roleData = data
self.data:Init(self, data.property)
@ -65,14 +73,14 @@ function RoleLogic:Init(uid, data)
self.passiveList = {}
if data.skill and #data.skill > 0 then
self.skill = skillPool:Get()
self.skill:Init(self, data.skill, false)
self.skill:Init(self, data.skill, 1)
self.skill.sp = 0
local time = max(8-self:GetRoleData(RoleDataName.Speed)/(8*(self:GetRoleData(RoleDataName.Level)+10)), 1.5)
self.skill.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
end
if data.superSkill and #data.superSkill > 0 then
self.superSkill = skillPool:Get()
self.superSkill:Init(self, data.superSkill, false)
self.superSkill:Init(self, data.superSkill, 2)
self.superSkill.spPass = floor(self.superSkill.cd * BattleLogic.GameFrameRate)
self.superSkill.sp = self.superSkill.spPass
end