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