同战斗逻辑
parent
7ff90d3a74
commit
7d68e534e7
|
@ -25,14 +25,14 @@ function BattleEvent:AddEvent(sEventName, fListener, pObj, bOnce)
|
||||||
self.m_listeners[sEventName]:Add(item)
|
self.m_listeners[sEventName]:Add(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleEvent:RemoveEvent(sEventName, fListener)
|
function BattleEvent:RemoveEvent(sEventName, fListener, pObj)
|
||||||
if not self.m_listeners[sEventName] then
|
if not self.m_listeners[sEventName] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local v
|
local v
|
||||||
for i=1, self.m_listeners[sEventName].size do
|
for i=1, self.m_listeners[sEventName].size do
|
||||||
v = self.m_listeners[sEventName].buffer[i]
|
v = self.m_listeners[sEventName].buffer[i]
|
||||||
if v.func == fListener then
|
if v.func == fListener and pObj == v.obj then
|
||||||
itemPool:Put(v)
|
itemPool:Put(v)
|
||||||
self.m_listeners[sEventName]:Remove(i)
|
self.m_listeners[sEventName]:Remove(i)
|
||||||
break
|
break
|
||||||
|
|
|
@ -868,5 +868,25 @@ local passivityList = {
|
||||||
role.data:SubPencentValue(propertyList[pro2], f2)
|
role.data:SubPencentValue(propertyList[pro2], f2)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
--发动技能后,[a]概率[e]改变敌方全体[b]属性[c],持续[d]秒
|
||||||
|
--a[float],b[属性],c[float],d[int],e[改变类型]
|
||||||
|
[49] = function(role, args)
|
||||||
|
local f1 = args[1]
|
||||||
|
local pro = args[2]
|
||||||
|
local f2 = args[3]
|
||||||
|
local f3 = args[4]
|
||||||
|
local ct = args[5]
|
||||||
|
|
||||||
|
local OnSkillCastEnd = function(skill)
|
||||||
|
BattleUtil.RandomAction(f1, function ()
|
||||||
|
local arr = BattleUtil.ChooseTarget(role, 20000)
|
||||||
|
for i=1, #arr do
|
||||||
|
arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro], f2, ct))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
return passivityList
|
return passivityList
|
|
@ -16,22 +16,23 @@ end)
|
||||||
Skill = {}
|
Skill = {}
|
||||||
|
|
||||||
function Skill:New()
|
function Skill:New()
|
||||||
local o = {cd=0,effectList = BattleList.New(),owner=0,sp=0,spPass = 0,isTeamSkill=false }
|
local o = {cd=0,effectList = BattleList.New(),owner=0,sp=0,spPass = 0,isTeamSkill=false,teamSkillType=0 }
|
||||||
setmetatable(o, self)
|
setmetatable(o, self)
|
||||||
self.__index = self
|
self.__index = self
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
function Skill:Init(role, effectData)
|
function Skill:Init(role, effectData, isTeamSkill)
|
||||||
self.cd = effectData[1]
|
self.cd = isTeamSkill and effectData[1] % 100 or effectData[1] --异妖技能的cd数据为:类型*100 + cd
|
||||||
|
|
||||||
--skill = {cd, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
|
--skill = {cd, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
|
||||||
--效果 = {效果类型id, 效果参数1, 效果参数2, ...}
|
--效果 = {效果类型id, 效果参数1, 效果参数2, ...}
|
||||||
self.effectList:Clear()
|
self.effectList:Clear()
|
||||||
self.owner = role
|
self.owner = role
|
||||||
self.sp = 0
|
self.sp = isTeamSkill and floor(self.cd * BattleLogic.GameFrameRate) or 0
|
||||||
self.spPass = 0
|
self.spPass = self.sp
|
||||||
self.isTeamSkill = false
|
self.isTeamSkill = isTeamSkill
|
||||||
|
self.teamSkillType = isTeamSkill and floor(effectData[1] / 100) or 0
|
||||||
self.isManual = false
|
self.isManual = false
|
||||||
|
|
||||||
for i=2, #effectData do
|
for i=2, #effectData do
|
||||||
|
@ -157,8 +158,9 @@ function Skill:Cast()
|
||||||
end
|
end
|
||||||
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||||
else
|
else
|
||||||
|
self.sp = 0
|
||||||
self.owner.curSkill = self
|
self.owner.curSkill = self
|
||||||
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self.cd, self.owner) --队伍技能结构和其他相同,只是cd项为对应异妖类型
|
BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
--技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个
|
--技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个
|
||||||
|
|
|
@ -26,8 +26,8 @@ BattleLogic.Event = BattleEvent.New()
|
||||||
BattleLogic.BuffMgr = BuffManager.New()
|
BattleLogic.BuffMgr = BuffManager.New()
|
||||||
|
|
||||||
local skillManualQueue = BattleQueue.New()
|
local skillManualQueue = BattleQueue.New()
|
||||||
local playerTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true, curSkill = nil}
|
local playerTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true, curSkill = nil, isDebug = false}
|
||||||
local enemyTeamDummyRole = {camp = 1, Event = BattleLogic.Event, isTeam = true, curSkill = nil}
|
local enemyTeamDummyRole = {camp = 1, Event = BattleLogic.Event, isTeam = true, curSkill = nil, isDebug = false}
|
||||||
local playerTeamSkillList = {}
|
local playerTeamSkillList = {}
|
||||||
local enemyTeamSkillList = {}
|
local enemyTeamSkillList = {}
|
||||||
local playerTeamSkillIndex
|
local playerTeamSkillIndex
|
||||||
|
@ -49,10 +49,6 @@ BattleLogic.CurOrder = 0
|
||||||
|
|
||||||
local maxFrame --战斗最大用时,超时判负
|
local maxFrame --战斗最大用时,超时判负
|
||||||
|
|
||||||
local teamSkillCD = 40 * BattleLogic.GameFrameRate --异妖cd
|
|
||||||
local lastPlayerTeamSkillFrame
|
|
||||||
local lastEnemyTeamSkillFrame
|
|
||||||
|
|
||||||
local actionPool = BattleObjectPool.New(function ()
|
local actionPool = BattleObjectPool.New(function ()
|
||||||
return { 0, 0 }
|
return { 0, 0 }
|
||||||
end)
|
end)
|
||||||
|
@ -91,15 +87,15 @@ function BattleLogic.Init(maxTime, data, optionData)
|
||||||
playerMP = 0
|
playerMP = 0
|
||||||
enemyMP = 0
|
enemyMP = 0
|
||||||
|
|
||||||
|
playerTeamDummyRole.isDebug = false
|
||||||
|
enemyTeamDummyRole.isDebug = false
|
||||||
|
|
||||||
playerTeamSkillIndex = 1
|
playerTeamSkillIndex = 1
|
||||||
enemyTeamSkillIndex = 1
|
enemyTeamSkillIndex = 1
|
||||||
|
|
||||||
playerSkillUsable = true
|
playerSkillUsable = true
|
||||||
enemySkillUsable = true
|
enemySkillUsable = true
|
||||||
|
|
||||||
lastPlayerTeamSkillFrame = 0
|
|
||||||
lastEnemyTeamSkillFrame = 0
|
|
||||||
|
|
||||||
isAuto = true
|
isAuto = true
|
||||||
|
|
||||||
BattleLogic.Event:ClearEvent()
|
BattleLogic.Event:ClearEvent()
|
||||||
|
@ -113,6 +109,7 @@ function BattleLogic.StartOrder()
|
||||||
if BattleLogic.CurOrder == 1 then
|
if BattleLogic.CurOrder == 1 then
|
||||||
for i=1, #fightData.playerData do
|
for i=1, #fightData.playerData do
|
||||||
BattleLogic.AddRole(fightData.playerData[i])
|
BattleLogic.AddRole(fightData.playerData[i])
|
||||||
|
|
||||||
end
|
end
|
||||||
for i=1, #fightData.enemyData[BattleLogic.CurOrder] do
|
for i=1, #fightData.enemyData[BattleLogic.CurOrder] do
|
||||||
BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i])
|
BattleLogic.AddRole(fightData.enemyData[BattleLogic.CurOrder][i])
|
||||||
|
@ -124,8 +121,7 @@ function BattleLogic.StartOrder()
|
||||||
end
|
end
|
||||||
for i=1, #fightData.playerData.teamSkill do
|
for i=1, #fightData.playerData.teamSkill do
|
||||||
playerTeamSkillList[i] = skillPool:Get()
|
playerTeamSkillList[i] = skillPool:Get()
|
||||||
playerTeamSkillList[i]:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i])
|
playerTeamSkillList[i]:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i], true)
|
||||||
playerTeamSkillList[i].isTeamSkill = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, #enemyTeamSkillList do
|
for i=1, #enemyTeamSkillList do
|
||||||
|
@ -134,8 +130,7 @@ function BattleLogic.StartOrder()
|
||||||
end
|
end
|
||||||
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
|
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
|
||||||
enemyTeamSkillList[i] = skillPool:Get()
|
enemyTeamSkillList[i] = skillPool:Get()
|
||||||
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i])
|
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], true)
|
||||||
enemyTeamSkillList[i].isTeamSkill = true
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
BattleLogic.ClearOrder()
|
BattleLogic.ClearOrder()
|
||||||
|
@ -149,8 +144,7 @@ function BattleLogic.StartOrder()
|
||||||
end
|
end
|
||||||
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
|
for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamSkill do
|
||||||
enemyTeamSkillList[i] = skillPool:Get()
|
enemyTeamSkillList[i] = skillPool:Get()
|
||||||
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i])
|
enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], true)
|
||||||
enemyTeamSkillList[i].isTeamSkill = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
BattleLogic.InitAggro()
|
BattleLogic.InitAggro()
|
||||||
|
@ -173,7 +167,16 @@ function BattleLogic.GetMP(camp)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleLogic.CanManualTeamSkill()
|
function BattleLogic.CanManualTeamSkill()
|
||||||
return not isAuto and playerMP == 100 and (lastPlayerTeamSkillFrame == 0 or curFrame - lastPlayerTeamSkillFrame >= teamSkillCD)
|
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||||
|
return not isAuto and playerMP == 100 and teamSkill and teamSkill.sp >= teamSkill.spPass
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleLogic.GetTeamSkillCDPass()
|
||||||
|
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||||
|
if not teamSkill then
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return teamSkill.sp / teamSkill.spPass
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleLogic.GenerateBuffId()
|
function BattleLogic.GenerateBuffId()
|
||||||
|
@ -285,6 +288,10 @@ function BattleLogic.GetOption()
|
||||||
return optionRecord
|
return optionRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleLogic.GetTeamSkillCaster(camp)
|
||||||
|
return camp == 0 and playerTeamDummyRole or enemyTeamDummyRole
|
||||||
|
end
|
||||||
|
|
||||||
--执行操作逻辑
|
--执行操作逻辑
|
||||||
function BattleLogic.ExecuteOption(option)
|
function BattleLogic.ExecuteOption(option)
|
||||||
local opType = option[2]
|
local opType = option[2]
|
||||||
|
@ -307,16 +314,7 @@ function BattleLogic.ExecuteOption(option)
|
||||||
skillManualQueue:Enqueue(role.superSkill)
|
skillManualQueue:Enqueue(role.superSkill)
|
||||||
end
|
end
|
||||||
elseif opType == 4 then --释放teamSkill
|
elseif opType == 4 then --释放teamSkill
|
||||||
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
BattleLogic.CastTeamSkill(0)
|
||||||
if teamSkill then
|
|
||||||
teamSkill:Cast()
|
|
||||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
|
||||||
if playerTeamSkillIndex > #playerTeamSkillList then
|
|
||||||
playerTeamSkillIndex = 1
|
|
||||||
end
|
|
||||||
playerMP = 0
|
|
||||||
lastPlayerTeamSkillFrame = curFrame
|
|
||||||
end
|
|
||||||
elseif opType == 5 then --设置teamSkill自动手动
|
elseif opType == 5 then --设置teamSkill自动手动
|
||||||
isAuto = opArg == 1
|
isAuto = opArg == 1
|
||||||
elseif opType == 6 then --切换单个角色自动手动 arg == uid * 10 + auto(0手动,1自动)
|
elseif opType == 6 then --切换单个角色自动手动 arg == uid * 10 + auto(0手动,1自动)
|
||||||
|
@ -416,30 +414,25 @@ function BattleLogic.Update()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if playerMP == 100 and playerSkillUsable and isAuto and
|
for i=1, #playerTeamSkillList do
|
||||||
(lastPlayerTeamSkillFrame == 0 or curFrame - lastPlayerTeamSkillFrame >= teamSkillCD) then
|
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]
|
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||||
if teamSkill then
|
if teamSkill.sp >= teamSkill.spPass then
|
||||||
teamSkill:Cast()
|
BattleLogic.CastTeamSkill(0)
|
||||||
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
|
||||||
if playerTeamSkillIndex > #playerTeamSkillList then
|
|
||||||
playerTeamSkillIndex = 1
|
|
||||||
end
|
|
||||||
playerMP = 0
|
|
||||||
lastPlayerTeamSkillFrame = curFrame
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if enemyMP == 100 and enemySkillUsable and
|
|
||||||
(lastEnemyTeamSkillFrame == 0 or curFrame - lastEnemyTeamSkillFrame >= teamSkillCD) then
|
if enemyMP == 100 and enemySkillUsable then
|
||||||
local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
|
local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
|
||||||
if teamSkill then
|
if teamSkill.sp >= teamSkill.spPass then
|
||||||
teamSkill:Cast()
|
BattleLogic.CastTeamSkill(1)
|
||||||
enemyTeamSkillIndex = enemyTeamSkillIndex + 1
|
|
||||||
if enemyTeamSkillIndex > #enemyTeamSkillList then
|
|
||||||
enemyTeamSkillIndex = 1
|
|
||||||
end
|
|
||||||
enemyMP = 0
|
|
||||||
lastEnemyTeamSkillFrame = curFrame
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -471,12 +464,46 @@ function BattleLogic.Update()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleLogic.ResetTeamSkillCD(camp)
|
||||||
|
local skill = camp == 0 and playerTeamDummyRole.curSkill or enemyTeamDummyRole.curSkill
|
||||||
|
if skill then
|
||||||
|
skill.spPass = floor(skill.cd % 100 * BattleLogic.GameFrameRate)
|
||||||
|
skill.sp = skill.spPass
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleLogic.CastTeamSkill(camp)
|
||||||
|
if camp == 0 then
|
||||||
|
local teamSkill = playerTeamSkillList[playerTeamSkillIndex]
|
||||||
|
if teamSkill then
|
||||||
|
teamSkill:Cast()
|
||||||
|
playerTeamSkillIndex = playerTeamSkillIndex + 1
|
||||||
|
if playerTeamSkillIndex > #playerTeamSkillList then
|
||||||
|
playerTeamSkillIndex = 1
|
||||||
|
end
|
||||||
|
playerMP = 0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex]
|
||||||
|
if teamSkill then
|
||||||
|
teamSkill:Cast()
|
||||||
|
enemyTeamSkillIndex = enemyTeamSkillIndex + 1
|
||||||
|
if enemyTeamSkillIndex > #enemyTeamSkillList then
|
||||||
|
enemyTeamSkillIndex = 1
|
||||||
|
end
|
||||||
|
enemyMP = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Debug专用
|
--Debug专用
|
||||||
function BattleLogic.SetDebug()
|
function BattleLogic.SetDebug()
|
||||||
for i=1, objList.size do
|
for i=1, objList.size do
|
||||||
local v = objList.vList[i]
|
local v = objList.vList[i]
|
||||||
v.IsDebug = not v.IsDebug
|
v.IsDebug = not v.IsDebug
|
||||||
end
|
end
|
||||||
|
playerTeamDummyRole.isDebug = not playerTeamDummyRole.isDebug
|
||||||
|
enemyTeamDummyRole.isDebug = not enemyTeamDummyRole.isDebug
|
||||||
end
|
end
|
||||||
|
|
||||||
--Debug专用
|
--Debug专用
|
||||||
|
|
|
@ -44,14 +44,14 @@ function RoleLogic:Init(uid, data)
|
||||||
self.passiveList = {}
|
self.passiveList = {}
|
||||||
if data.skill and #data.skill > 0 then
|
if data.skill and #data.skill > 0 then
|
||||||
self.skill = skillPool:Get()
|
self.skill = skillPool:Get()
|
||||||
self.skill:Init(self, data.skill)
|
self.skill:Init(self, data.skill, false)
|
||||||
self.skill.sp = 0
|
self.skill.sp = 0
|
||||||
local time = max(6-self:GetRoleData(RoleDataName.Speed)/(8*(self:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
local time = max(6-self:GetRoleData(RoleDataName.Speed)/(8*(self:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||||
self.skill.spPass = floor( time * BattleLogic.GameFrameRate)
|
self.skill.spPass = floor( time * BattleLogic.GameFrameRate)
|
||||||
end
|
end
|
||||||
if data.superSkill and #data.superSkill > 0 then
|
if data.superSkill and #data.superSkill > 0 then
|
||||||
self.superSkill = skillPool:Get()
|
self.superSkill = skillPool:Get()
|
||||||
self.superSkill:Init(self, data.superSkill)
|
self.superSkill:Init(self, data.superSkill, false)
|
||||||
self.superSkill.spPass = floor(self.superSkill.cd * BattleLogic.GameFrameRate)
|
self.superSkill.spPass = floor(self.superSkill.cd * BattleLogic.GameFrameRate)
|
||||||
self.superSkill.sp = self.superSkill.spPass
|
self.superSkill.sp = self.superSkill.spPass
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue