back_recharge
lvxinran 2019-10-10 13:41:35 +08:00
commit 6b0ef26a42
17 changed files with 261 additions and 198 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

View File

@ -131,4 +131,9 @@ public class SGlobalActivity implements BaseConfig {
public int getShopId() {
return shopId;
}
public int getResetGrade() {
return resetGrade;
}
}

View File

@ -106,9 +106,9 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
}
if(sGlobalActivity.getType() == 30){
Poster.getPoster().dispatchEvent(new LuckWheelEvent(uid));
Poster.getPoster().dispatchEvent(new LuckWheelEvent(uid,time));
}else {
Poster.getPoster().dispatchEvent(new LuckWheelAdvanceEvent(uid));
Poster.getPoster().dispatchEvent(new LuckWheelAdvanceEvent(uid,time));
}
PlayerInfoProto.GetLuckWheelRandRewardResponse.Builder builder = PlayerInfoProto.GetLuckWheelRandRewardResponse.newBuilder();

View File

@ -69,6 +69,18 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
activityManager.initAllActivityMission(id);
}
/**
*
* @param user
* @throws Exception
*/
public void reSetValue(User user) throws Exception {
ActivityManager activityManager = user.getActivityManager();
activityManager.removeActivity(id);
activityManager.initAllActivityMission(id);
}
@Override
public void update(User user, int count) {
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
@ -135,8 +147,14 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
int[][] reward = sActivityRewardConfig.getReward();
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.TAKE_ACTIVITY_REWARD);
checkAndSetProgress(activityMission, activityProgressInfo, sActivityRewardConfig, missionId);
//send
sendActivityProgress(session, activityMission, Collections.singleton(missionId));
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
if(null!=sGlobalActivity&&ActivityLogic.getInstance().checkActivityMissionFinishAndTaked(id,activityMission)&&sGlobalActivity.getResetGrade()==1){
reSetValue(user);
activityMission.setValue(activityMission.getValue()-sActivityRewardConfig.getValues()[0][0]);
sendActivityProgress(session, activityMission,null);
}else {
sendActivityProgress(session, activityMission, Collections.singleton(missionId));
}
KtEventUtils.onKtEvent(user, ParamEventBean.UserActivityEvent, id, missionId);
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
@ -226,7 +244,7 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
return true;
}
public void onActivityEndSelfWithDealReward(User user) throws Exception {
void onActivityEndSelfWithDealReward(User user) throws Exception {
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (sGlobalActivity.getIsMail() == 1)
onActivityEndDealReward(user);
@ -261,7 +279,7 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
takeAllReward(sessionByUid);
}
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(ActivityMission activityMission) {
List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(ActivityMission activityMission) {
return getAllMissInfo(activityMission, null);
}

View File

@ -467,29 +467,32 @@ public class ActivityLogic {
}
}
private void checkActivityMissionFinishAndTaked(int activityId, ActivityMission activityMission) {
public boolean checkActivityMissionFinishAndTaked(int activityId, ActivityMission activityMission) {
Map<Integer, ActivityProgressInfo> activityProgressInfoMap = activityMission.getActivityProgressInfoMap();
boolean isAllTaked = true;
for (Map.Entry<Integer, ActivityProgressInfo> item : activityProgressInfoMap.entrySet()) {
ActivityProgressInfo activityProgressInfo = item.getValue();
Integer missionStatus = activityProgressInfo.getState();
int missionStatus = activityProgressInfo.getState();
if (missionStatus == ActivityType.WILL_TAKE) {
isAllTaked = false;
return false;
}
if (SGlobalActivity.getsGlobalActivityMap().get(activityId).getType() == ActivityType.TREASURE) {
if (missionStatus == ActivityType.HAD_TAKED) {
isAllTaked = false;
return false;
}
}
}
if (activityProgressInfoMap.isEmpty()) {
isAllTaked = false;
return false;
}
if (isAllTaked) {
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
if(sGlobalActivity.getResetGrade()==0){
activityMission.updateActivityState(ActivityType.FINISH_STATE);
}
return true;
}
public int getInitActivityMissionProgress(int activityId) {
int defalutProgress = 0;
switch (activityId) {

View File

@ -34,11 +34,11 @@ public class FightMainEventHandler implements IEventHandler{
if(sGlobalSystemConfigs == null){
return;
}
int uid = fightMainEvent.getUid();
User user = UserManager.getUser(uid);
for(SGlobalSystemConfig sGlobalSystemConfig : sGlobalSystemConfigs){
int[][] openGifts = sGlobalSystemConfig.getOpenGifts();
if(openGifts!=null && openGifts.length>0){
int uid = fightMainEvent.getUid();
User user = UserManager.getUser(uid);
ItemUtil.drop(user,openGifts, BIReason.SYSTERM_OPEN_REWARD);
}
}

View File

@ -1,17 +1,11 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SDailyTasksConfig;
import com.ljsd.jieling.config.SDialRewardConfig;
import com.ljsd.jieling.config.SDialRewardSetting;
import com.ljsd.jieling.config.SGlobalActivity;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.LuckWheelAdvanceEvent;
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
import com.ljsd.jieling.logic.dao.ActivityMission;
import com.ljsd.jieling.logic.dao.LuckWheelMission;
import com.ljsd.jieling.logic.dao.LuckWheelPosInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
@ -26,7 +20,7 @@ import java.util.*;
*/
public abstract class LuckWheelActivity extends AbstractActivity {
private static int Dial_PerScore;//每转一次获得的积分
private int Dial_PerScore;//每转一次获得的积分
@Override
public void initActivity(User user) throws Exception {
@ -51,7 +45,7 @@ public abstract class LuckWheelActivity extends AbstractActivity {
super.onEvent(event);
if (!(event instanceof LuckWheelEvent))
return;
update(UserManager.getUser(((LuckWheelEvent) event).getUid()), Dial_PerScore);
update(UserManager.getUser(((LuckWheelEvent) event).getUid()), Dial_PerScore*((LuckWheelEvent) event).getTime());
}
@Override
@ -59,6 +53,11 @@ public abstract class LuckWheelActivity extends AbstractActivity {
activityMission.setValue(count + activityMission.getValue());
}
@Override
boolean takeRewardsProcess(ISession session, SActivityRewardConfig sActivityRewardConfig, ActivityProgressInfo activityProgressInfo) throws Exception {
return checkValue(session, sActivityRewardConfig, activityProgressInfo);
}
/**
*
*/

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SGlobalSystemConfig;
import com.ljsd.jieling.config.SMainLevelConfig;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.activity.event.FightMainEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
@ -23,6 +24,17 @@ public class UserLevelEventHandler implements IEventHandler{
return;
UserLevelEvent userLevelEvent = (UserLevelEvent) event;
int level = userLevelEvent.getLevel();
int uid = userLevelEvent.getUid();
User user = UserManager.getUser(uid);
int state = user.getMainLevelManager().getState();
if(state == -1 ){
int fightId = user.getMainLevelManager().getFightId();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
if(level>=sMainLevelConfig.getLevelLimit()){
user.getMainLevelManager().setState(1);
}
}
List<SGlobalSystemConfig> sGlobalSystemConfigs = SGlobalSystemConfig.sGlobalSystemConfigMapByTypeAndConditionMap.get(2).get(level);
if(sGlobalSystemConfigs == null){
return;
@ -30,8 +42,6 @@ public class UserLevelEventHandler implements IEventHandler{
for(SGlobalSystemConfig sGlobalSystemConfig : sGlobalSystemConfigs){
int[][] openGifts = sGlobalSystemConfig.getOpenGifts();
if(openGifts!=null && openGifts.length>0){
int uid = userLevelEvent.getUid();
User user = UserManager.getUser(uid);
ItemUtil.drop(user,openGifts, BIReason.SYSTERM_OPEN_REWARD);
}
}

View File

@ -9,7 +9,7 @@ package com.ljsd.jieling.logic.activity.event;
*/
public class LuckWheelAdvanceEvent extends LuckWheelEvent{
public LuckWheelAdvanceEvent(int uid) {
super(uid);
public LuckWheelAdvanceEvent(int uid, int time) {
super(uid, time);
}
}

View File

@ -8,15 +8,25 @@ package com.ljsd.jieling.logic.activity.event;
*/
public class LuckWheelEvent implements IEvent{
private int uid;
private int time;
public LuckWheelEvent(int uid) {
public LuckWheelEvent(int uid, int time) {
this.uid = uid;
this.time = time;
}
public int getUid() {
return uid;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public void setUid(int uid) {
this.uid = uid;
}

View File

@ -50,6 +50,11 @@ public class MainLevelManager extends MongoBase {
}
public void setState(int state){
this.state = state;
updateString("state",state);
}
public void updateFight(int fightId,int state){
if(fightId!=1011){
updateStateInfo();

View File

@ -329,6 +329,9 @@ public class PlayerManager extends MongoBase {
public void vipFlush( Set<Integer> removePrivileges) {
for(Integer id : vipInfo.keySet()){
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(id);
if(null == sPrivilegeTypeConfig){
continue;
}
int refreshType = sPrivilegeTypeConfig.getRefreshType()[0];
if(refreshType == 1){
vipInfo.put(id,0);