战斗同步

back_recharge
lvxinran 2021-01-14 17:18:41 +08:00
parent 934632c4c5
commit b7f10ac10e
11 changed files with 238 additions and 34 deletions

View File

@ -1,3 +1,5 @@
-- windows
package.path = package.path ..';luafight/?.lua';
-- linux
package.path = package.path ..';../luafight/?.lua';
@ -11,13 +13,21 @@ require("Modules.Battle.Logic.Misc.BattleObjectPool")
require("Modules.Battle.Logic.Base.BattleEvent")
require("Modules.Battle.Logic.Base.Random")
require("Modules.Battle.Logic.Base.RoleData")
require("Modules.Battle.Logic.Base.Buff")
require("Modules.Battle.Logic.Base.Skill")
require("Modules.Battle.Logic.Base.Passivity")
require("Modules.Battle.Logic.Role.RoleLogic")
require("Modules.Battle.Logic.Role.RoleData")
require("Modules.Battle.Logic.Role.RoleManager")
require("Modules.Battle.Logic.Role.Skill")
require("Modules.Battle.Logic.BattleLogic")
require("Modules.Battle.Logic.RoleLogic")
require("Modules.Battle.Logic.SkillManager")
require("Modules.Battle.Logic.OutDataManager")
require("Modules.Battle.Logic.BattleLogManager")
require("Modules.Battle.Logic.Monster.MonsterManager")
local BattleMain = {}
local BattleLogic = BattleLogic
@ -215,11 +225,31 @@ function BattleMain.Execute(args, fightData, optionData)
Random.SetSeed(args.seed)
BattleLogic.Init(fightData, optionData, _maxRound)
BattleLogic.Type = _type
if _type == 9 or _type == 10 or _type == 11 then
if _type == BATTLE_SERVER_TYPE.TOPFight -- 巅峰赛
or _type == BATTLE_SERVER_TYPE.GuildBossFight -- 公会boss
or _type == BATTLE_SERVER_TYPE.CarBossFight -- 车迟boss
or _type == BATTLE_SERVER_TYPE.GuildChallenge then -- 公会副本
AddRecord(fightData)
end
BattleLogic.StartOrder()
-- local startTime = os.clock()
-- local cor = coroutine.create(function()
-- while not BattleLogic.IsEnd do
-- print(os.clock())
-- if os.clock() - startTime > 3 then
-- assert(false, "fight time out!!!")
-- break
-- end
-- end
-- end)
-- coroutine.resume(cor)
--debug.sethook(
-- function (event, line)
-- BattleLogManager.Log(debug.getinfo(2).short_src .. ":" .. line)
-- end
--, "l")
while not BattleLogic.IsEnd do
BattleLogic.Update()
end
@ -227,16 +257,18 @@ function BattleMain.Execute(args, fightData, optionData)
isError = true
errorCache = "error:\n"..debug.traceback(err).."\n"
end) then
local resultList = {}
local resultList = {0, 0, 0, 0, 0, 0}
if BattleLogic.Result == 1 then --胜利记录我方剩余血量
local arr = RoleManager.Query(function (r) return r.camp == 0 end, true)
for i=1, #arr do
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
local pos = arr[i].position
resultList[pos] = arr[i]:GetRoleData(RoleDataName.Hp)
end
elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量
local arr = RoleManager.Query(function (r) return r.camp == 1 end, true)
for i=1, #arr do
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
local pos = arr[i].position
resultList[pos] = arr[i]:GetRoleData(RoleDataName.Hp)
end
end
@ -251,7 +283,7 @@ function BattleMain.Execute(args, fightData, optionData)
--end
--print("最终运行帧数:"..BattleLogic.CurFrame())
local curRound, maxRound = BattleLogic.GetCurRound()
if curRound > maxRound and _type == 9 then
if curRound > maxRound and _type == BATTLE_SERVER_TYPE.TOPFight then --巅峰赛超出最大回合要根据伤害量判断胜负
local playerDamage=0
local enemyDamage=0
for k,v in pairs(BattleRecord)do
@ -262,11 +294,27 @@ function BattleMain.Execute(args, fightData, optionData)
end
end
resultList.result = playerDamage > enemyDamage and 1 or 0
elseif curRound > maxRound and _type == BATTLE_SERVER_TYPE.SenLuoHuanJing then -- 森罗幻境超时返回两边血量战斗结果为2
resultList = {0, 0, 0, 0, 0, 0}
-- 第一位保存我方血量
local arr = RoleManager.Query(function (r) return r.camp == 0 end, true)
if arr[1] then
resultList[1] = arr[1]:GetRoleData(RoleDataName.Hp)
end
-- 第二位保存地方血量
local arr = RoleManager.Query(function (r) return r.camp == 1 end, true)
if arr[1] then
resultList[2] = arr[1]:GetRoleData(RoleDataName.Hp)
end
-- 结果为2
resultList.result = 2
else
resultList.result = BattleLogic.Result
end
if _type == 10 or _type == 11 then -- 公会boss和车迟斗法boss返回伤害值
if _type == BATTLE_SERVER_TYPE.GuildBossFight -- 公会boss
or _type == BATTLE_SERVER_TYPE.CarBossFight -- 车迟boss
or _type == BATTLE_SERVER_TYPE.GuildChallenge then -- 公会副本 -- 返回伤害值
local playerDamage=0
for k,v in pairs(BattleRecord)do
if v.camp == 0 then
@ -290,7 +338,25 @@ function BattleMain.Execute(args, fightData, optionData)
os.date("%H"),
os.date("%M"),
os.date("%S"))
local file = io.open("luafight/LogError/"..time..".txt", "a")
local file
local platform
-- linux
if not file then
file = io.open("../luafight/LogError/"..time..".txt", "a")
platform = "Linux"
end
-- local window server
if not file then
file = io.open("luafight/LogError/"..time..".txt", "a")
platform = "Local Windows Server"
end
-- local
if not file then
file = io.open("LogError/"..time..".txt", "a")
platform = "Local"
end
file:write(platform..":\n\n\n")
file:write(errorCache)
file:write("seed:\n"..tostring(args.seed).."\n")
file:write("type:\n"..tostring(args.type).."\n")

View File

@ -225,7 +225,10 @@ function BattleMain.Execute(args, fightData, optionData)
Random.SetSeed(args.seed)
BattleLogic.Init(fightData, optionData, _maxRound)
BattleLogic.Type = _type
if _type == 9 or _type == 10 or _type == 11 or _type == 14 then
if _type == BATTLE_SERVER_TYPE.TOPFight -- 巅峰赛
or _type == BATTLE_SERVER_TYPE.GuildBossFight -- 公会boss
or _type == BATTLE_SERVER_TYPE.CarBossFight -- 车迟boss
or _type == BATTLE_SERVER_TYPE.GuildChallenge then -- 公会副本
AddRecord(fightData)
end
BattleLogic.StartOrder()
@ -280,7 +283,7 @@ function BattleMain.Execute(args, fightData, optionData)
--end
--print("最终运行帧数:"..BattleLogic.CurFrame())
local curRound, maxRound = BattleLogic.GetCurRound()
if curRound > maxRound and _type == 9 then
if curRound > maxRound and _type == BATTLE_SERVER_TYPE.TOPFight then --巅峰赛超出最大回合要根据伤害量判断胜负
local playerDamage=0
local enemyDamage=0
for k,v in pairs(BattleRecord)do
@ -291,11 +294,27 @@ function BattleMain.Execute(args, fightData, optionData)
end
end
resultList.result = playerDamage > enemyDamage and 1 or 0
elseif curRound > maxRound and _type == BATTLE_SERVER_TYPE.SenLuoHuanJing then -- 森罗幻境超时返回两边血量战斗结果为2
resultList = {0, 0, 0, 0, 0, 0}
-- 第一位保存我方血量
local arr = RoleManager.Query(function (r) return r.camp == 0 end, true)
if arr[1] then
resultList[1] = arr[1]:GetRoleData(RoleDataName.Hp)
end
-- 第二位保存地方血量
local arr = RoleManager.Query(function (r) return r.camp == 1 end, true)
if arr[1] then
resultList[2] = arr[1]:GetRoleData(RoleDataName.Hp)
end
-- 结果为2
resultList.result = 2
else
resultList.result = BattleLogic.Result
end
if _type == 10 or _type == 11 or _type == 14 then -- 公会boss和车迟斗法boss返回伤害值
if _type == BATTLE_SERVER_TYPE.GuildBossFight -- 公会boss
or _type == BATTLE_SERVER_TYPE.CarBossFight -- 车迟boss
or _type == BATTLE_SERVER_TYPE.GuildChallenge then -- 公会副本 -- 返回伤害值
local playerDamage=0
for k,v in pairs(BattleRecord)do
if v.camp == 0 then

View File

@ -2269,10 +2269,12 @@ local effectList = {
-- a[属性],b[float]
[118] = function(caster, target, args, interval, skill)
local pro = args[1]
local f1 = args[2]
local f1 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
local damage = BattleUtil.ErrorCorrection(f1 * caster:GetRoleData(BattlePropList[pro]))
if (pro==12 or pro==13) and BattleUtil.CheckIsBoss(target) then
return
end
local damage = floor(BattleUtil.ErrorCorrection(f1 * caster:GetRoleData(BattlePropList[pro])))
BattleUtil.FinalDamage(skill, caster, target, damage, nil, 0, nil, true)
end)
end,
@ -2328,6 +2330,30 @@ local effectList = {
end
BattleUtil.SeckillHP(skill,caster,target,pro)
end,
-- 造成目标[a]*[b]%的直接伤害(不会被分摊机制分摊)
-- a[属性],b[float]
[124] = function(caster, target, args, interval, skill)
local pro = args[1]
local f1 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
if (pro==12 or pro==13) and BattleUtil.CheckIsBoss(target) then
return
end
local damage = floor(BattleUtil.ErrorCorrection(f1 * target:GetRoleData(BattlePropList[pro])))
BattleUtil.FinalDamage(skill, caster, target, damage, nil, 0, nil, true)
end)
end,
-- 目标[a]增加[b]%持续[c]回合,效果可叠加,[d]改变
-- a[属性]b[float]c[int]d[改变类型]
[125] = function(caster, target, args, interval, skill)
local pro = args[1]
local f1 = args[2]
local i1 = args[3]
local ct = args[4]
BattleLogic.WaitForTrigger(interval, function ()
target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, i1, BattlePropList[pro], f1, ct))
end)
end,
}

View File

@ -4883,7 +4883,7 @@ local passivityList = {
--怪物的身份表份标识 挂上这个效果就会变成参数对应的类型
[244] = function(role, args)
local f1 = args[1]
role.data.enemyType=f1
role.enemyType=f1
BattleUtil.CheckIsBoss(role)
end,
-- (直接伤害(目前没有明确定义直接伤害))直接伤害击杀目标自身增加[a]点怒气 重写92被动效果 每次释放技能只触发一次

View File

@ -363,12 +363,13 @@ function BattleLogic.Update()
return
end
if CurRound > MaxRound then
if BattleLogic.Type==9 or BattleLogic.Type==17 then
if allHeroDamage>allEnemyDamage then
BattleLogic.BattleEnd(1)
else
BattleLogic.BattleEnd(0)
end
if BattleLogic.Type == BATTLE_SERVER_TYPE.TOPFight -- 巅峰赛
or BattleLogic.Type == BATTLE_SERVER_TYPE.Firend then -- 好友切磋
if allHeroDamage>allEnemyDamage then
BattleLogic.BattleEnd(1)
else
BattleLogic.BattleEnd(0)
end
else
BattleLogic.BattleEnd(0)
end

View File

@ -4,6 +4,28 @@ local function indexAdd()
return index
end
BATTLE_SERVER_TYPE = {
StoryFight = 1, --故事副本
MapExploreFight = 2, -- 地图探索
ArenaFight = 3, --竞技场
InvasionBossFight = 4,--秘境boss
AdventureLock = 5, -- 解锁秘境
GuildFight = 6, -- 公会站
BloodyFight = 7, -- 血战
MonterFight = 8, -- 兽潮
TOPFight = 9, -- 巅峰赛
GuildBossFight = 10, -- 工会boss
CarBossFight = 11, -- 车迟斗法挑战boss
CarPersonFight = 12, -- 车迟斗法抢夺
EXPEDITION = 13, -- 远征
GuildChallenge = 14, --公会副本
NewGeneral = 15,--新将
TenDespairArray = 16,--十绝阵
Firend = 17,--好友
SenLuoHuanJing = 18,-- 森罗环境
}
BattleEventName = {
BattleStart = indexAdd(),
@ -177,6 +199,8 @@ BuffName = {
Immune = "Immune",
NoDead = "NoDead",
Curse = "Curse",
KylinMark = "KylinMark",
Exile = "Exile",
}
DotType = {

View File

@ -345,9 +345,9 @@ end
--检测是否为boss
function BattleUtil.CheckIsBoss(role)
if not role then
return
return false
end
if role.data.enemyType==EnemyType.Boss then
if role.enemyType==EnemyType.Boss then
--弹免疫
role.Event:DispatchEvent(BattleEventName.ShowHintText, BattleArtFontType.Immune)
return true

View File

@ -46,13 +46,74 @@ local _ConditionConfig = {
return isRoundOk and isRandomOk
end,
[4] = function(skill, condition) --4:行动单位的职业设定 【比较类型】 N
[4] = function(skill, condition) --4:场上燃烧目标的数量 【比较类型】 N
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
-- 当前释放技能的单位的职业
local professionId = skill.owner.professionId
return professionId == comValue
local list = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp
end)
if not list then
return false
end
local num=0
for key, value in pairs(list) do
local isHave=BattleLogic.BuffMgr:HasBuff(value, BuffName.DOT, function(buff) return buff.damageType == 1 end)
if isHave then
num=num+1
end
end
return BattleUtil.CompareValue(num, comValue, comType)
end,
[5] = function(skill, condition) --5敌方上场神将数量 且概率(万分比)
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local rand = condition[4]
local roleList = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp
end)
local isEnough=BattleUtil.CompareValue(#roleList, comValue, comType)
local r = Random.Range01()
-- 判断概率
if isEnough then
return r>rand/10000
end
return false
end,
[6] = function(skill, condition) --6敌方任意神将生命百分比 【比较类型】 N万分比
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local round = condition[4]
-- 获取该技能相同阵营人物
local roleList = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp
end)
-- 判断
local r = Random.Range01()
for _, role in ipairs(roleList) do
local hpf = role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp)
if BattleUtil.CompareValue(hpf, comValue/10000, comType) then
return round/10000>r
end
end
return false
end,
[7] = function(skill, condition) --7检测是否有可以放逐的目标
local list=skill.owner.exileTargets
if list then
local roleList = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp and not BattleUtil.ChecklistIsContainValue(list,role)
end)
if roleList and #roleList>0 then
return true
end
end
return false
end,
}

View File

@ -90,7 +90,7 @@ local _TriggerConfig = {
triggerFunc = function(skill, ...)
local args = {...}
local castSkill = args[1]
return castSkill.owner.camp == skill.owner.camp
return castSkill.owner.camp == skill.owner.camp and castSkill.owner.job==2 and (castSkill.type==BattleSkillType.DeadSkill or castSkill.type==BattleSkillType.Extra or castSkill.type==BattleSkillType.Special)
end
},
}

View File

@ -33,13 +33,14 @@ function RoleLogic:Init(uid, data, position)
self.name = data.name
self.element = data.element
self.professionId = data.professionId
self.job=data.job
self.star = data.star or 1
-- LogError("英雄uid".. self.roleId .." " .. self.star)
self.shield:Clear() --护盾列表
self.exCalDmgList:Clear() --额外计算伤害列表
self.buffFilter:Clear() --buff屏蔽列表
self.proTranList:Clear() --属性转换列表
self.isHaveNoDead = false -- 是否有不灭
self.isHaveNoDead = false --是否有不灭
self.Event:ClearEvent()
self.skill = data.skill
@ -98,8 +99,7 @@ function RoleLogic:Init(uid, data, position)
end
end
end
-- 初始怒气值放在被动之后计算,使被动对初始怒气的影响生效
-- 初始怒气值放在被动之后计算,使被动对初始怒气的影响生效
self.Rage = self.Rage + self:GetRoleData(RoleDataName.InitRage)-- 当前怒气值
end

View File

@ -157,15 +157,22 @@ function this.Update()
-- 检测一下轮转
this.IsSkilling = false
-- this.CheckTurnRound()
-- 检测一次灵兽技能
this.CheckMonsterSkill(this.MonsterCheckFunc)
if this.MonsterCheckFunc then
this.CheckMonsterSkill(this.MonsterCheckFunc)
else
this.CheckMonsterSkill(this.CheckTurnRound)
end
end)
else
-- 检测一下轮转
this.IsSkilling = false
-- this.CheckTurnRound()
-- 检测一次灵兽技能
this.CheckMonsterSkill(this.MonsterCheckFunc)
if this.MonsterCheckFunc then
this.CheckMonsterSkill(this.MonsterCheckFunc)
else
this.CheckMonsterSkill(this.CheckTurnRound)
end
end
return
end