back_recharge
wangyuan 2019-05-09 17:50:38 +08:00
parent 56d87dbaf6
commit 1efd3bd58d
6 changed files with 128 additions and 34 deletions

View File

@ -119,17 +119,17 @@ local function generateRecordFile()
io.close(file) io.close(file)
end end
function BattleMain.Execute(seed, fightData, optionData) function BattleMain.Execute(args, fightData, optionData)
_fightData = fightData _fightData = fightData
_optionData = optionData _optionData = optionData
--print(PrintTable(fightData)) print(PrintTable(fightData))
--该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步 --该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步
BattleLogic.IsOpenBattleRecord = false BattleLogic.IsOpenBattleRecord = false
if xpcall(function () if xpcall(function ()
Random.SetSeed(seed) Random.SetSeed(args.seed)
BattleLogic.Init(fightData, optionData) BattleLogic.Init(args.maxTime, fightData, optionData)
BattleLogic.StartOrder() BattleLogic.StartOrder()
while not BattleLogic.IsEnd do while not BattleLogic.IsEnd do

View File

@ -145,17 +145,20 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
end, end,
--发动技能后,使仇恨目标受到治疗效果降低[a],持续[b] --发动技能后,[c]使仇恨目标受到治疗效果降低[a],持续[b]
--a[float],b[int] --a[float],b[int],c[float]
[3] = function(role, args) [3] = function(role, args)
local f1 = args[1] local f1 = args[1]
local f2 = args[2] local f2 = args[2]
local f3 = args[3]
local OnSkillCastEnd = function(skill) local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 40000) BattleUtil.RandomAction(f3, function ()
if arr[1] then local arr = chooseTarget(role, 40000)
BattleUtil.CalDamage(role, arr[1], dt, f2) if arr[1] then
end arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, RoleDataName.CureFacter, f1, 3))
end
end)
end end
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
end, end,
@ -414,7 +417,7 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
end, end,
--发动技能后,[d]改变自身[a]属性[b],持续[c]秒 --发动技能后,[d]改变仇恨目标[a]属性[b],持续[c]秒
--a[属性],b[int],c[int],d[改变类型] --a[属性],b[int],c[int],d[改变类型]
[17] = function(role, args) [17] = function(role, args)
local pro1 = args[1] local pro1 = args[1]
@ -423,9 +426,10 @@ local passivityList = {
local ct = args[4] local ct = args[4]
local OnSkillCastEnd = function(skill) local OnSkillCastEnd = function(skill)
BattleUtil.RandomAction(f1, function () local arr = chooseTarget(role, 40000)
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct)) if arr[1] then
end) arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct))
end
end end
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
end, end,
@ -451,6 +455,8 @@ local passivityList = {
--a[float] --a[float]
[19] = function(role, args) [19] = function(role, args)
local f1 = args[1] local f1 = args[1]
role.data:AddValue(RoleDataName.CureFacter, f1)
end, end,
--[b]造成的持续伤害时间延长[a]。 --[b]造成的持续伤害时间延长[a]。
@ -650,7 +656,7 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore) role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore)
end, end,
--发动技能后,[d]改变方全体[a]属性[b],持续[c]秒 --发动技能后,[d]改变方全体[a]属性[b],持续[c]秒
--a[属性],b[float],c[int],d[改变类型] --a[属性],b[float],c[int],d[改变类型]
[30] = function(role, args) [30] = function(role, args)
local pro = args[1] local pro = args[1]
@ -659,7 +665,7 @@ local passivityList = {
local ct = args[4] local ct = args[4]
local OnSkillCastEnd = function(skill) local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 10000) local arr = chooseTarget(role, 20000)
for i=1, #arr do for i=1, #arr do
arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct)) arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct))
end end
@ -838,5 +844,78 @@ local passivityList = {
end end
role.Event:AddEvent(BattleEventName.PassiveCriting, OnPassiveCriting) role.Event:AddEvent(BattleEventName.PassiveCriting, OnPassiveCriting)
end, end,
--发动技能后,[d]改变仇恨目标[a]属性[b],持续整场战斗,属性最多可改变[c]
--a[属性],b[float],c[float],d[改变类型]
[43] = function(role, args)
local pro = args[1]
local f1 = args[2]
local i1 = args[3]
local ct = args[4]
local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 40000)
if arr[1] then
local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, ct)
buff.cover = true
buff.maxLayer = i1
arr[1]:AddBuff(buff)
end
end
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
end,
--发动技能后,[a]的概率[e]改变自身[b]属性[c],持续[d]秒。
--a[float],b[属性],c[float],d[int],e[改变类型]
[44] = 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 ()
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro], f2, ct))
end)
end
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
end,
--免疫[a]控制状态。
--a[控制类型]
[45] = function(role, args)
local ct = args[1]
role.buffFilter:Add(function(buff)
return buff.type == BuffName.Control and (ct == 0 or buff.ctrlType == ct)
end)
end,
--免疫[a]持续伤害状态。
--a[持续伤害类型]
[46] = function(role, args)
local dt = args[1]
role.buffFilter:Add(function(buff)
return buff.type == BuffName.DOT and (dt == 0 or buff.damageType == dt)
end)
end,
--战斗中,[c]改变[a]属性[b]。
--a[属性],b[float],c[改变类型]
[47] = function(role, args)
local pro = args[1]
local f1 = args[2]
local ct = args[3]
if ct == 1 then --加算
role.data:AddValue(propertyList[pro], f1)
elseif ct == 2 then --乘加算(百分比属性加算)
role.data:AddPencentValue(propertyList[pro], f1)
elseif ct == 3 then --减算
role.data:SubValue(propertyList[pro], f1)
elseif ct == 4 then --乘减算(百分比属性减算)
role.data:SubPencentValue(propertyList[pro], f1)
end
end,
} }
return passivityList return passivityList

View File

@ -268,12 +268,12 @@ function Skill:Cast()
BattleLogic.AddMP(self.owner.camp, 10) BattleLogic.AddMP(self.owner.camp, 10)
if self.owner.skill then if self.owner.skill then
local skill = self.owner.skill local skill = self.owner.skill
local time = max(6-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5) local time = max(8-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
skill.sp = 0 skill.sp = 0
skill.spPass = floor(time * BattleLogic.GameFrameRate) skill.spPass = floor(time * BattleLogic.GameFrameRate)
end end
else else
local time = max(6-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5) local time = max(8-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
self.sp = 0 self.sp = 0
self.spPass = floor(time * BattleLogic.GameFrameRate) self.spPass = floor(time * BattleLogic.GameFrameRate)
BattleLogic.AddMP(self.owner.camp, 8) BattleLogic.AddMP(self.owner.camp, 8)

View File

@ -26,7 +26,7 @@ BattleLogic.Event = BattleEvent.New()
BattleLogic.BuffMgr = BuffManager.New() BattleLogic.BuffMgr = BuffManager.New()
local playerTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true} local playerTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true}
local enemyTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true} local enemyTeamDummyRole = {camp = 1, Event = BattleLogic.Event, isTeam = true}
local playerTeamSkillList = {} local playerTeamSkillList = {}
local enemyTeamSkillList = {} local enemyTeamSkillList = {}
local playerTeamSkillIndex local playerTeamSkillIndex
@ -46,8 +46,7 @@ BattleLogic.TotalOrder = 0
--当前波次 --当前波次
BattleLogic.CurOrder = 0 BattleLogic.CurOrder = 0
local maxFrame = BattleLogic.GameFrameRate * 300 --战斗最大用时5分钟超时判负 local maxFrame --战斗最大用时,超时判负
local actionPool = BattleObjectPool.New(function () local actionPool = BattleObjectPool.New(function ()
return { 0, 0 } return { 0, 0 }
end) end)
@ -60,11 +59,12 @@ local rolePool = BattleObjectPool.New(function ()
return RoleLogic.New() return RoleLogic.New()
end) end)
function BattleLogic.Init(data, optionData) function BattleLogic.Init(maxTime, data, optionData)
if BattleLogic.IsOpenBattleRecord then if BattleLogic.IsOpenBattleRecord then
record = {} record = {}
end end
maxFrame = BattleLogic.GameFrameRate * maxTime
fightData = data fightData = data
if optionData then if optionData then
optionRecord = optionData optionRecord = optionData

View File

@ -62,7 +62,16 @@ end
function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType) function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType)
bCrit = bCrit or false bCrit = bCrit or false
damageType = damageType or 0 damageType = damageType or 0
damage = floor(damage + 0.5)
if atkRole.isTeam then
--max技能基础伤害*1+已方异妖伤害加成-目标异妖伤害减免30%×技能基础伤害)
local arr = BattleLogic.Query(function (r) return r.camp == atkRole.camp end)
local n = 0
for i=1, #arr do
n = n + arr[i]:GetRoleData(RoleDataName.TeamDamageBocusFactor)
end
damage = floor(max(damage * (1 + n / #arr - defRole:GetRoleData(RoleDataName.TeamDamageReduceFactor)), 0.3 * damage))
end
--加入被动效果 --加入被动效果
local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end
@ -111,7 +120,7 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
local bCrit = false local bCrit = false
local baseDamage local baseDamage
ignoreDef = 1 - (ignoreDef or 0) ignoreDef = 1 - (ignoreDef or 0)
bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit), 0, 1) bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit)-defRole:GetRoleData(RoleDataName.Tenacity), 0, 1)
local defence = 0 local defence = 0
if damageType == 1 then --1 物理 2 魔法 if damageType == 1 then --1 物理 2 魔法
defence = defRole:GetRoleData(RoleDataName.PhysicalDefence) defence = defRole:GetRoleData(RoleDataName.PhysicalDefence)
@ -135,7 +144,7 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
baseDamage = max(attack - 0.5 * defence * ignoreDef, 0) baseDamage = max(attack - 0.5 * defence * ignoreDef, 0)
end end
--伤害 =(基础伤害*1+己伤害加成-目标伤害减免)*1+己方属性伤害加成-目标属性伤害减免10%*己攻) --伤害 =(基础伤害*1+己伤害加成-目标伤害减免)*1+己方属性伤害加成-目标属性伤害减免10%*己攻)
local element = 1 local exFactor = 1 + atkRole:GetRoleData(RoleDataName.DamageBocusFactor) - defRole:GetRoleData(RoleDataName.DamageReduceFactor)
local elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor local elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
if atkRole.element == 1 then if atkRole.element == 1 then
elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
@ -150,9 +159,9 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
elseif atkRole.element == 6 then elseif atkRole.element == 6 then
elementDamageReduceFactor = RoleDataName.DarkDamageReduceFactor elementDamageReduceFactor = RoleDataName.DarkDamageReduceFactor
end end
element = (1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor)) * max(1 - defRole:GetRoleData(elementDamageReduceFactor), 0) exFactor = exFactor * (1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor) - defRole:GetRoleData(elementDamageReduceFactor))
baseDamage = baseDamage * baseFactor * element baseDamage = baseDamage * baseFactor * exFactor
baseDamage = floor(max(baseDamage, 0.1 * attack)) baseDamage = floor(max(baseDamage, 0.1 * attack))
local func local func
@ -181,8 +190,9 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
baseFactor = baseFactor or 1 baseFactor = baseFactor or 1
local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp) local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp)
local hp = targetRole:GetRoleData(RoleDataName.Hp) local hp = targetRole:GetRoleData(RoleDataName.Hp)
local factor = castRole:GetRoleData(RoleDataName.TreatFacter) local factor = castRole:GetRoleData(RoleDataName.TreatFacter) + 1
local baseTreat = floor(value * baseFactor * (factor + 1) + 0.5) local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter) + 1
local baseTreat = floor(value * baseFactor * factor * factor2 + 0.5)
--加入被动效果 --加入被动效果
local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end

View File

@ -54,11 +54,16 @@ function RoleLogic:Init(uid, data)
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
for i = 1, #data.passivity do if data.passivity and #data.passivity > 0 then
local v = data.passivity[i] for i = 1, #data.passivity do
local id = v[1] local v = data.passivity[i]
local args = v[2] local id = v[1]
Passivity[id](self, args) local args = {}
for j = 2, #v do
args[j-1] = v[j]
end
Passivity[id](self, args)
end
end end
self.isDead = self:GetRoleData(RoleDataName.Hp) <= 0 self.isDead = self:GetRoleData(RoleDataName.Hp) <= 0