战斗逻辑同步

dev_chengFeng
gaoxin 2020-09-25 12:22:12 +08:00 committed by JieLing
parent c3cce0b06e
commit 541b4fc271
8 changed files with 211 additions and 103 deletions

View File

@ -2118,7 +2118,7 @@ local effectList = {
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target) caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target)
BattleLogic.WaitForTrigger(interval, function () BattleLogic.WaitForTrigger(interval, function ()
local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType) local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, 0, BattlePropList[pro1], f2, ct)) caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, 0, BattlePropList[pro1], f2, ct))
end end
end end

View File

@ -1479,9 +1479,12 @@ local passivityList = {
[78] = function(role, args) [78] = function(role, args)
local pro = args[1] local pro = args[1]
local f1 = args[2] local f1 = args[2]
LogBattle("开始治疗")
local val = floor(BattleUtil.FP_Mul(f1, role:GetRoleData(BattlePropList[pro]))) --这里加一个延时,防止执行时显示层还没有初始化,从而没有表现
BattleUtil.CalTreat(role, role, val) BattleLogic.WaitForTrigger(0.05, function()
local val = floor(BattleUtil.FP_Mul(f1, role:GetRoleData(BattlePropList[pro])))
BattleUtil.CalTreat(role, role, val)
end)
end, end,
--战斗结束时,为自身回复[a]*[b]的血量。 --战斗结束时,为自身回复[a]*[b]的血量。
--a[属性],b[float] --a[属性],b[float]
@ -1563,7 +1566,7 @@ local passivityList = {
-- buff.cover = true -- 可以叠加 -- buff.cover = true -- 可以叠加
-- buff.clear = false -- 不可驱散 -- buff.clear = false -- 不可驱散
-- role:AddBuff(buff) -- role:AddBuff(buff)
if skill and not skill.isAdd and defRole:IsDead() and BattleUtil.CheckIsNoDead(defRole) then if skill and not skill.isAdd and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
role:AddRage(i1, CountTypeName.Add) role:AddRage(i1, CountTypeName.Add)
end end
end end
@ -1782,7 +1785,7 @@ local passivityList = {
local ct = args[3] local ct = args[3]
-- 释放技能后 -- 释放技能后
local onRoleHit = function(defRole) local onRoleHit = function(defRole)
if defRole:IsDead() and BattleUtil.CheckIsNoDead(defRole) then if defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, ct) local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, ct)
-- buff.cover = true -- buff.cover = true
role:AddBuff(buff) role:AddBuff(buff)
@ -1990,7 +1993,7 @@ local passivityList = {
local i1 = args[1] local i1 = args[1]
-- 释放技能后 -- 释放技能后
local onRoleHit = function(target) local onRoleHit = function(target)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
for i = 1, i1 do for i = 1, i1 do
role:AddSkill(BattleSkillType.Normal, false, true, nil) role:AddSkill(BattleSkillType.Normal, false, true, nil)
end end
@ -2036,7 +2039,7 @@ local passivityList = {
local f1 = args[1] local f1 = args[1]
-- 释放技能后 -- 释放技能后
local onRoleHit = function(target) local onRoleHit = function(target)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
local treat = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.MaxHp), f1)) local treat = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.MaxHp), f1))
BattleUtil.CalTreat(role, role, treat) BattleUtil.CalTreat(role, role, treat)
end end
@ -2225,7 +2228,7 @@ local passivityList = {
local f1 = args[1] local f1 = args[1]
-- 释放技能后 -- 释放技能后
local onRoleHit = function(target) local onRoleHit = function(target)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
local buff = Buff.Create(role, BuffName.PropertyChange, 1, RoleDataName.Crit, f1, CountTypeName.Add) local buff = Buff.Create(role, BuffName.PropertyChange, 1, RoleDataName.Crit, f1, CountTypeName.Add)
role:AddBuff(buff) role:AddBuff(buff)
end end
@ -2380,7 +2383,7 @@ local passivityList = {
-- 击杀数量累加 -- 击杀数量累加
local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
if skill and defRole:IsDead() and BattleUtil.CheckIsNoDead(defRole) then if skill and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
killNum = killNum + 1 killNum = killNum + 1
end end
end end
@ -2518,7 +2521,8 @@ local passivityList = {
if skill.type == BattleSkillType.Special then if skill.type == BattleSkillType.Special then
local list = skill:GetDirectTargetsNoMiss() local list = skill:GetDirectTargetsNoMiss()
if list then if list then
local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro]) * f1))
LogBattle(role:GetRoleData(pro).." ".. f1.." " .. tv)
for _, r in ipairs(list) do for _, r in ipairs(list) do
local auraBuff = Buff.Create(role, BuffName.HOT, i1, 1, tv) local auraBuff = Buff.Create(role, BuffName.HOT, i1, 1, tv)
auraBuff.interval = 1 auraBuff.interval = 1
@ -2541,7 +2545,8 @@ local passivityList = {
if skill.type == BattleSkillType.Normal then if skill.type == BattleSkillType.Normal then
local list = skill:GetDirectTargetsNoMiss() local list = skill:GetDirectTargetsNoMiss()
if list then if list then
local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(pro) * f1)) local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro]) * f1))
LogBattle(role:GetRoleData(pro).." ".. f1.." " .. tv)
for _, r in ipairs(list) do for _, r in ipairs(list) do
local auraBuff = Buff.Create(role, BuffName.HOT, i1, 1, tv) local auraBuff = Buff.Create(role, BuffName.HOT, i1, 1, tv)
auraBuff.interval = 1 auraBuff.interval = 1
@ -2760,7 +2765,7 @@ local passivityList = {
local dot = args[1] local dot = args[1]
local f1 = args[2] local f1 = args[2]
local function onHit(target) local function onHit(target)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
local maxHp = role:GetRoleData(RoleDataName.MaxHp) local maxHp = role:GetRoleData(RoleDataName.MaxHp)
local value = floor(BattleUtil.ErrorCorrection(maxHp* f1)) local value = floor(BattleUtil.ErrorCorrection(maxHp* f1))
BattleUtil.ApplyTreat(role, role, value) BattleUtil.ApplyTreat(role, role, value)
@ -2852,13 +2857,16 @@ local passivityList = {
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
if skill and skill.type == BattleSkillType.Normal and not defRole:IsDead() then if skill and skill.type == BattleSkillType.Normal and not defRole:IsDead() then
if BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then if BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
local isBoss=BattleUtil.CheckIsBoss(defRole)
if isBoss then
return
end
-- 检测被动技能对秒杀参数得影响 -- 检测被动技能对秒杀参数得影响
local bf, kf = BattleUtil.CheckSeckill(f1, f2, role, defRole) local bf, kf = BattleUtil.CheckSeckill(f1, f2, role, defRole)
-- --
local ft = defRole:GetRoleData(RoleDataName.Hp)/defRole:GetRoleData(RoleDataName.MaxHp) local ft = defRole:GetRoleData(RoleDataName.Hp)/defRole:GetRoleData(RoleDataName.MaxHp)
if ft < bf then if ft < bf then
BattleUtil.RandomAction(kf, function() BattleUtil.RandomAction(kf, function()
-- 秒杀
BattleUtil.Seckill(skill, role, defRole) BattleUtil.Seckill(skill, role, defRole)
end) end)
end end
@ -2895,7 +2903,7 @@ local passivityList = {
local i1 = args[1] local i1 = args[1]
local onHit = function(target, damage, bCrit, finalDmg) local onHit = function(target, damage, bCrit, finalDmg)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
role:AddRage(i1, CountTypeName.Add) role:AddRage(i1, CountTypeName.Add)
end end
end end
@ -3239,7 +3247,7 @@ local passivityList = {
local dt = args[2] local dt = args[2]
-- 直接伤害后 -- 直接伤害后
local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill)
if skill and not skill.isAdd and target:IsDead() and BattleUtil.CheckIsNoDead(target) then if skill and not skill.isAdd and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
local list = RoleManager.Query(function(v) return v.camp ~= role.camp end) local list = RoleManager.Query(function(v) return v.camp ~= role.camp end)
BattleUtil.SortByHpFactor(list, 1) BattleUtil.SortByHpFactor(list, 1)
local index = 0 local index = 0
@ -3511,7 +3519,7 @@ local passivityList = {
local f1 = args[1] local f1 = args[1]
local onRoleHit = function(target) local onRoleHit = function(target)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
local target = RoleManager.GetAliveAggro(role) local target = RoleManager.GetAliveAggro(role)
BattleUtil.CalDamage(nil, role, target, 1, f1) BattleUtil.CalDamage(nil, role, target, 1, f1)
end end
@ -3804,7 +3812,7 @@ local passivityList = {
[197] = function(role, args) [197] = function(role, args)
local f1 = args[1] local f1 = args[1]
local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill) local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill)
if skill and skill.type == BattleSkillType.Special and target:IsDead() and BattleUtil.CheckIsNoDead(target) then if skill and skill.type == BattleSkillType.Special and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
BattleUtil.RandomAction(f1, function() BattleUtil.RandomAction(f1, function()
role:AddRage(target.Rage, CountTypeName.Add) role:AddRage(target.Rage, CountTypeName.Add)
end) end)
@ -3889,6 +3897,10 @@ local passivityList = {
role:AddRage(i1, CountTypeName.Add) role:AddRage(i1, CountTypeName.Add)
local function onPassiveSeckill(func) local function onPassiveSeckill(func)
local isBoss=BattleUtil.CheckIsBoss(defRole)
if isBoss then
return
end
if func then func(f1, CountTypeName.Cover) end if func then func(f1, CountTypeName.Cover) end
end end
role.Event:AddEvent(BattleEventName.PassiveSeckill, onPassiveSeckill) role.Event:AddEvent(BattleEventName.PassiveSeckill, onPassiveSeckill)
@ -3920,9 +3932,6 @@ local passivityList = {
end end
end end
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
-- 秒杀概率无法复活 -- 秒杀概率无法复活
local function onSecKill(target) local function onSecKill(target)
BattleUtil.RandomAction(f3, function() BattleUtil.RandomAction(f3, function()
@ -3930,7 +3939,6 @@ local passivityList = {
end) end)
end end
role.Event:AddEvent(BattleEventName.Seckill, onSecKill) role.Event:AddEvent(BattleEventName.Seckill, onSecKill)
end, end,
@ -4264,7 +4272,11 @@ local passivityList = {
if das > hp then -- 护盾后伤害值依然致死 if das > hp then -- 护盾后伤害值依然致死
dd = dd - das + hp - 1 dd = dd - das + hp - 1
end end
BattleUtil.ApplyDamage(nil, role, r, dd) --boss 免疫生命百分比伤害
local isBoss=BattleUtil.CheckIsBoss(r)
if not isBoss then
BattleUtil.ApplyDamage(nil, role, r, dd)
end
--概率控制 --概率控制
BattleUtil.RandomControl(f2, ctrl, role, r, i2) BattleUtil.RandomControl(f2, ctrl, role, r, i2)
end end
@ -4455,6 +4467,10 @@ local passivityList = {
local f1 = args[1] local f1 = args[1]
-- --
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill) local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
local isBoss=BattleUtil.CheckIsBoss(defRole)
if isBoss then
return
end
if skill and not defRole:IsDead() then if skill and not defRole:IsDead() then
-- 检测被动技能对秒杀参数得影响 -- 检测被动技能对秒杀参数得影响
local bf, kf = BattleUtil.CheckSeckill(f1, 0, role, defRole) local bf, kf = BattleUtil.CheckSeckill(f1, 0, role, defRole)
@ -4736,9 +4752,7 @@ local passivityList = {
local onSkillEnd = function(skill) local onSkillEnd = function(skill)
if skill and skill.type == BattleSkillType.Special then if skill and skill.type == BattleSkillType.Special then
BattleUtil.RandomAction(f1, function() BattleUtil.RandomAction(f1, function()
BattleLogic.WaitForTrigger(0.1, function() role:InsertExtraSkill(f2,f3)
role:InsertExtraSkill(f2,f3)
end)
end) end)
end end
end end
@ -4750,17 +4764,20 @@ local passivityList = {
local f1 = args[1] local f1 = args[1]
local f2=args[2] local f2=args[2]
local onRoleHit = function(target) local onRoleHit = function(target)
if target:IsDead() and BattleUtil.CheckIsNoDead(target) and not role:IsDead() then if target:IsDead() and not BattleUtil.CheckIsNoDead(target) and not role:IsDead() then
-- local target = RoleManager.GetAliveAggro(role) -- local target = RoleManager.GetAliveAggro(role)
--BattleUtil.CalDamage(nil, role, target, 1, f1) --BattleUtil.CalDamage(nil, role, target, 1, f1)
--加一个延时操作,防止有的英雄有死亡后再释放一次技能的被动 by:王振兴 --加一个延时操作,防止有的英雄有死亡后再释放一次技能的被动 by:王振兴
BattleLogic.WaitForTrigger(1, function()
role:InsertExtraSkill(f1,f2) role:InsertExtraSkill(f1,f2)
end)
end end
end end
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit) role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
end, end,
--怪物的身份表份标识 挂上这个效果就会变成参数对应的类型
[244] = function(role, args)
local f1 = args[1]
role.data.enemyType=f1
BattleUtil.CheckIsBoss(role)
end,
} }
return passivityList return passivityList

View File

@ -1,6 +1,19 @@
BattleLogManager = {} BattleLogManager = {}
local this = BattleLogManager local this = BattleLogManager
local isLog = false and AppConst.platform == "EDITOR" local isEditor = AppConst and AppConst.Platform == "EDITOR"
local isDebug = false
function LogBattle(str)
if isDebug then
if isEditor then
LogGreen(str)
else
print(str)
end
end
end
local isLog = true or isEditor
local function pairsByKeys(t) local function pairsByKeys(t)
local a = {} local a = {}
@ -93,6 +106,8 @@ function this.Log(...)
log = log .. string.format("%s = %s, ", key, value) log = log .. string.format("%s = %s, ", key, value)
end end
table.insert(this.logList, log) table.insert(this.logList, log)
-- 打印一下
LogBattle(log)
end end
function this.WriteFile() function this.WriteFile()
@ -108,17 +123,17 @@ function this.WriteFile()
local platform local platform
-- linux -- linux
if not file then if not file then
file = io.open("../luafight/BattleRecord/log-"..(this.userId or time)..".txt", "a") file = io.open("../luafight/BattleRecord/log-"..(this.userId or time)..".txt", "w")
platform = "Linux" platform = "Linux"
end end
-- local window server -- local window server
if not file then if not file then
file = io.open("luafight/BattleRecord/log-"..(this.userId or time)..".txt", "a") file = io.open("luafight/BattleRecord/log-"..(this.userId or time)..".txt", "w")
platform = "Local Windows Server" platform = "Local Windows Server"
end end
-- local -- local
if not file then if not file then
file = io.open("BattleRecord/log-"..(this.userId or time)..".txt", "a") file = io.open("BattleRecord/log-"..(this.userId or time)..".txt", "w")
platform = "Local" platform = "Local"
end end

View File

@ -1,30 +1,27 @@
BattleLogic = {} BattleLogic = {}
local floor = math.floor local floor = math.floor
local min = math.min local min = math.min
-- local objList = BattleDictionary.New() -- local objList = BattleDictionary.New()
local removeObjList = BattleList.New() local removeObjList = BattleList.New()
local MaxRound = 20 local MaxRound = 20
local CurRound = 0 local CurRound = 0
local CurCamp = 0 local CurCamp = 0
local CurSkillPos = {} local CurSkillPos = {}
local PosList = {} local PosList = {}
local curFrame local curFrame
BattleLogic.Type = -1 -- 0 切磋 1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 8 兽潮 9巅峰战
BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 8 兽潮 9巅峰战
BattleLogic.IsEnd = false BattleLogic.IsEnd = false
BattleLogic.Result = -1 BattleLogic.Result = -1
BattleLogic.Event = BattleEvent.New() BattleLogic.Event = BattleEvent.New()
BattleLogic.BuffMgr = BuffManager.New() BattleLogic.BuffMgr = BuffManager.New()
local _IsDebug local _IsDebug
local fightData local fightData
local record local record
local userData local userData
--所有英雄伤害和治疗
local allHeroDamage=0
--所有怪的伤害和治疗
local allEnemyDamage=0
--是否开启战斗日志 --是否开启战斗日志
BattleLogic.IsOpenBattleRecord = false BattleLogic.IsOpenBattleRecord = false
--逻辑帧频 --逻辑帧频
@ -34,8 +31,6 @@ BattleLogic.GameDeltaTime = 1 / BattleLogic.GameFrameRate
BattleLogic.TotalOrder = 0 BattleLogic.TotalOrder = 0
--当前波次 --当前波次
BattleLogic.CurOrder = 0 BattleLogic.CurOrder = 0
local actionPool = BattleObjectPool.New(function () local actionPool = BattleObjectPool.New(function ()
return { 0, 0 } return { 0, 0 }
end) end)
@ -65,7 +60,8 @@ function BattleLogic.Init(data, _userData, maxRound)
CurRound = 0 CurRound = 0
MaxRound = maxRound or 20 MaxRound = maxRound or 20
allHeroDamage= 0
allEnemyDamage= 0
_IsDebug = false _IsDebug = false
BattleLogic.Event:ClearEvent() BattleLogic.Event:ClearEvent()
@ -78,8 +74,31 @@ function BattleLogic.Init(data, _userData, maxRound)
OutDataManager.Init(fightData) OutDataManager.Init(fightData)
PassiveManager.Init() PassiveManager.Init()
BattleLogManager.Init(fightData, userData) BattleLogManager.Init(fightData, userData)
end
--监听英雄受到治疗
BattleLogic.Event:AddEvent(BattleEventName.RoleBeTreated,function (castRole, realTreat, treat)
if castRole.camp==0 then
LogBattle("我方 英雄治疗"..treat)
allHeroDamage=allHeroDamage+treat
else
LogBattle("敌方 英雄治疗"..treat)
allEnemyDamage=allEnemyDamage+treat
end
end)
--监听英雄受到攻击
BattleLogic.Event:AddEvent(BattleEventName.RoleBeDamaged,function (defRole, atkRole, damage, bCrit, finalDmg, damageType, dotType)
--我方阵营总攻击
if atkRole.camp==0 then
allHeroDamage=allHeroDamage+damage
LogBattle("我方 英雄攻击"..damage)
--敌方阵营
else
allEnemyDamage=allEnemyDamage+damage
LogBattle("敌方 英雄攻击"..damage)
end
end)
end
-- 检测先手阵营 -- 检测先手阵营
function BattleLogic.CheckFirstCamp() function BattleLogic.CheckFirstCamp()
-- 默认我方先手 -- 默认我方先手
@ -161,8 +180,7 @@ end
-- debugTurn 用于判断是否是debug轮转的参数 -- debugTurn 用于判断是否是debug轮转的参数
function BattleLogic.TurnRound(debugTurn) function BattleLogic.TurnRound(debugTurn)
if BattleLogic.GetIsDebug() and not debugTurn then if BattleLogic.GetIsDebug() and not debugTurn then
LogGreen(Language[10227]) LogBattle("-------------")
LogBlue("-------------")
BattleLogic.Event:DispatchEvent(BattleEventName.DebugStop) BattleLogic.Event:DispatchEvent(BattleEventName.DebugStop)
return return
end end
@ -172,7 +190,6 @@ function BattleLogic.TurnRound(debugTurn)
CurCamp = BattleLogic.FirstCamp -- 判断先手阵营 CurCamp = BattleLogic.FirstCamp -- 判断先手阵营
CurSkillPos[0] = 0 CurSkillPos[0] = 0
CurSkillPos[1] = 0 CurSkillPos[1] = 0
LogGreen(Language[10228]..CurRound)
-- --
BattleLogManager.Log( BattleLogManager.Log(
"Round Change", "Round Change",
@ -190,8 +207,6 @@ function BattleLogic.TurnRound(debugTurn)
return return
end end
LogGreen(Language[10229]..CurCamp)
-- --
BattleLogManager.Log( BattleLogManager.Log(
"Camp Change", "Camp Change",
@ -220,13 +235,11 @@ function BattleLogic.TurnRound(debugTurn)
end end
-- 如果找不到下一个人,直接交换阵营 -- 如果找不到下一个人,直接交换阵营
if not SkillRole then if not SkillRole then
LogGreen(Language[10230])
BattleLogManager.Log( "No Skill Position" ) BattleLogManager.Log( "No Skill Position" )
BattleLogic.TurnRoundNextFrame() BattleLogic.TurnRoundNextFrame()
return return
end end
LogGreen(Language[10231]..CurSkillPos[CurCamp])
-- --
BattleLogManager.Log( BattleLogManager.Log(
"Position Change", "Position Change",
@ -291,7 +304,18 @@ function BattleLogic.Update()
return return
end end
if CurRound > MaxRound then if CurRound > MaxRound then
BattleLogic.BattleEnd(0) if BattleLogic.Type==9 or BattleLogic.Type== 0 then
LogBattle("我方总输出"..allHeroDamage.."敌方总输出:"..allEnemyDamage)
if allHeroDamage>allEnemyDamage then
LogBattle("争霸赛我方胜")
BattleLogic.BattleEnd(1)
else
LogBattle("争霸赛敌方胜")
BattleLogic.BattleEnd(0)
end
else
BattleLogic.BattleEnd(0)
end
return return
end end
if roleResult == 1 then if roleResult == 1 then

View File

@ -282,7 +282,19 @@ function BattleUtil.PreCountShield(defRole, damage)
end end
return damage return damage
end end
--检测是否为boss
function BattleUtil.CheckIsBoss(role)
if not role then
return
end
if role.data.enemyType==EnemyType.Boss then
--弹免疫
role.Event:DispatchEvent(BattleEventName.ShowHintText,2, 12391)
return true
else
return false
end
end
-- 秒杀 -- 秒杀
function BattleUtil.Seckill(skill, atkRole, defRole) function BattleUtil.Seckill(skill, atkRole, defRole)
@ -352,9 +364,9 @@ end
--检测是否有是金翅大鹏有不灭效果 --检测是否有是金翅大鹏有不灭效果
function BattleUtil.CheckIsNoDead(target) function BattleUtil.CheckIsNoDead(target)
if target then if target then
return target:IsAssignHeroAndHeroStar(10086,10)==false and BattleLogic.BuffMgr:HasBuff(target,BuffName.NoDead)==false return target:IsAssignHeroAndHeroStar(10086,10) or BattleLogic.BuffMgr:HasBuff(target,BuffName.NoDead)
end end
return false return false
end end
--检测列表是否包含值 --检测列表是否包含值
@ -373,15 +385,15 @@ end
-- 根据id获取额外技能 -- 根据id获取额外技能
function BattleUtil.GetExtraSkillbyId(id) function BattleUtil.GetExtraSkillbyId(id)
if id==1 then if id==1 then
return ExtraReleaseSkill.skill1 return ExtraReleaseSkill.skill1
elseif id==2 then elseif id==2 then
return ExtraReleaseSkill.skill2 return ExtraReleaseSkill.skill2
elseif id==3 then elseif id==3 then
return ExtraReleaseSkill.skill3 return ExtraReleaseSkill.skill3
elseif id==4 then elseif id==4 then
return ExtraReleaseSkill.skill4 return ExtraReleaseSkill.skill4
end end
end end
function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType) function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType)
@ -562,8 +574,8 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
end end
castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat, baseTreat) castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat, baseTreat)
targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat) targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat)
--添加发送到battleLogic的治疗消息用于计算总的战斗伤害值
-- BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat)
BattleLogManager.Log( BattleLogManager.Log(
"Final Damage", "Final Damage",
"acamp", castRole.camp, "acamp", castRole.camp,

View File

@ -73,8 +73,6 @@ function RoleLogic:Init(uid, data, position)
BattleUtil.Passivity[id](self, args) BattleUtil.Passivity[id](self, args)
-- 加入被动列表 -- 加入被动列表
table.insert(self.passiveList, {id, args}) table.insert(self.passiveList, {id, args})
else
LogRed(Language[10232]..id..Language[10233])
end end
end end
end end
@ -162,7 +160,7 @@ end
function RoleLogic:AddRage(value, type) function RoleLogic:AddRage(value, type)
-- 角色身上有无敌盾,不扣除怒气 by:wangzhenxing 2020/08/10 14:56 -- 角色身上有无敌盾,不扣除怒气 by:wangzhenxing 2020/08/10 14:56
if (type==3 or type==4) and BattleLogic.BuffMgr:HasBuff(self, BuffName.Shield, function (buff) return buff.shieldType and buff.shieldType == ShieldTypeName.AllReduce end) then if (type==3 or type==4) and BattleLogic.BuffMgr:HasBuff(self, BuffName.Shield, function (buff) return buff.shieldType and buff.shieldType == ShieldTypeName.AllReduce end) then
LogError("角色身上有无敌盾,不扣除怒气") LogBattle("角色身上有无敌盾,不扣除怒气")
return return
end end
@ -431,18 +429,14 @@ function RoleLogic:CastSkill(func)
-- 没有沉默 -- 没有沉默
if not self.ctrl_slient and self.Rage >= self.SuperSkillRage then if not self.ctrl_slient and self.Rage >= self.SuperSkillRage then
-- 释放大技能 -- 释放大技能
LogBlue(Language[10234])
self:AddSkill(BattleSkillType.Special, true, false, nil) self:AddSkill(BattleSkillType.Special, true, false, nil)
return return
end end
-- 没有麻痹 释放普通技能 -- 没有麻痹 释放普通技能
if not self.ctrl_palsy then if not self.ctrl_palsy then
LogBlue(Language[10235])
self:AddSkill(BattleSkillType.Normal, true, false, nil) self:AddSkill(BattleSkillType.Normal, true, false, nil)
return return
end end
--
LogBlue(Language[10236])
end end
-- 强制释放技能,测试技能时使用 -- 强制释放技能,测试技能时使用
@ -460,10 +454,8 @@ function RoleLogic:ForceCastSkill(type, targets, func)
SkillManager.SetTurnRoundFunc(func) SkillManager.SetTurnRoundFunc(func)
-- 释放技能 -- 释放技能
if type == 1 and self.skill then if type == 1 and self.skill then
LogBlue(Language[10237])
self:AddSkill(BattleSkillType.Normal, true, false, nil) self:AddSkill(BattleSkillType.Normal, true, false, nil)
elseif type == 2 and self.superSkill then elseif type == 2 and self.superSkill then
LogBlue(Language[10238])
if self.Rage < self.SuperSkillRage then if self.Rage < self.SuperSkillRage then
self.Rage = self.SuperSkillRage self.Rage = self.SuperSkillRage
end end

View File

@ -6,6 +6,7 @@ local skillPool = BattleObjectPool.New(function ()
end) end)
-- --
this.DeadSkillList = {} -- 人物死亡后技能队列,死亡技能优先级最高
this.SkillList = {} this.SkillList = {}
this.IsSkilling = false this.IsSkilling = false
-- 初始化 -- 初始化
@ -17,18 +18,31 @@ end
function this.AddSkill(caster, effectData, type, targets, isAdd, isRage) function this.AddSkill(caster, effectData, type, targets, isAdd, isRage)
local skill = skillPool:Get() local skill = skillPool:Get()
skill:Init(caster, effectData, type, targets, isAdd, isRage) skill:Init(caster, effectData, type, targets, isAdd, isRage)
table.insert(this.SkillList, skill) if type == BattleSkillType.DeadSkill then -- 死亡技能加入单独的对列
table.insert(this.DeadSkillList, skill)
else
table.insert(this.SkillList, skill)
end
return skill return skill
end end
-- 插入技能到技能列表首位 -- 插入技能到技能列表首位
function this.InsertSkill(caster, effectData, type, targets, isAdd, isRage) function this.InsertSkill(caster, effectData, type, targets, isAdd, isRage)
local skill = skillPool:Get() local skill = skillPool:Get()
skill:Init(caster, effectData, type, targets, isAdd, isRage) skill:Init(caster, effectData, type, targets, isAdd, isRage)
table.insert(this.SkillList, 1, skill) if type == BattleSkillType.DeadSkill then -- 死亡技能加入单独的对列
table.insert(this.DeadSkillList, 1, skill)
else
table.insert(this.SkillList, 1, skill)
end
return skill return skill
end end
-- 获取是否拥有我的技能未释放 -- 获取是否拥有我的技能未释放
function this.HaveMySkill(role) function this.HaveMySkill(role)
for _, skill in ipairs(this.DeadSkillList) do
if skill.owner == role then
return true
end
end
for _, skill in ipairs(this.SkillList) do for _, skill in ipairs(this.SkillList) do
if skill.owner == role then if skill.owner == role then
return true return true
@ -46,6 +60,9 @@ function this.CheckTurnRound()
if this.IsSkilling then if this.IsSkilling then
return return
end end
if this.DeadSkillList and #this.DeadSkillList > 0 then
return
end
if this.SkillList and #this.SkillList > 0 then if this.SkillList and #this.SkillList > 0 then
return return
end end
@ -64,26 +81,51 @@ function this.Update()
if this.IsSkilling then if this.IsSkilling then
return return
end end
if not this.SkillList or #this.SkillList == 0 then
-- 判断是否有死亡技能
-- 跟佳琦对的是角色死后只有死亡后释放的技能才能释放(DeadSkill) by:王振兴 2020/09/02 18:53
if this.DeadSkillList and #this.DeadSkillList > 0 then
local skill = this.DeadSkillList[1]
table.remove(this.DeadSkillList, 1)
this.IsSkilling = true
if skill.owner:IsDead() then
skill.owner:SkillCast(skill, function()
skill:Dispose()
skillPool:Put(skill)
this.IsSkilling = false
-- 检测一下轮转
this.CheckTurnRound()
end)
else
this.IsSkilling = false
this.CheckTurnRound()
end
return return
end end
local skill = this.SkillList[1]
table.remove(this.SkillList, 1) -- 判断
this.IsSkilling = true if this.SkillList and #this.SkillList > 0 then
-- 检测技能释放 只有角色不是死亡状态或角色身上有不灭 或这释放的技能为死亡后才释放的技能
--跟佳琦对的是角色死后只有死亡后释放的技能才能释放(DeadSkill) by:王振兴 2020/09/02 18:53 local skill = this.SkillList[1]
if (not skill.owner:IsDead() or not BattleUtil.CheckIsNoDead(skill.owner)) or skill.type == BattleSkillType.DeadSkill then table.remove(this.SkillList, 1)
skill.owner:SkillCast(skill, function() this.IsSkilling = true
skill:Dispose() -- 检测技能释放 只有角色不是死亡状态或角色身上有不灭
skillPool:Put(skill) if (not skill.owner:IsDead() or BattleUtil.CheckIsNoDead(skill.owner)) then
skill.owner:SkillCast(skill, function()
skill:Dispose()
skillPool:Put(skill)
this.IsSkilling = false
-- 检测一下轮转
this.CheckTurnRound()
end)
else
this.IsSkilling = false this.IsSkilling = false
-- 检测一下轮转
this.CheckTurnRound() this.CheckTurnRound()
end) end
else
this.IsSkilling = false return
this.CheckTurnRound()
end end
end end

View File

@ -71,7 +71,7 @@ function RoleView.New(go, role, position, root)
role.Event:AddEvent(BattleEventName.BuffDurationChange, instance.OnBuffRoundChange, instance) role.Event:AddEvent(BattleEventName.BuffDurationChange, instance.OnBuffRoundChange, instance)
role.Event:AddEvent(BattleEventName.ShildTrigger, instance.OnShieldTrigger, instance) role.Event:AddEvent(BattleEventName.ShildTrigger, instance.OnShieldTrigger, instance)
role.Event:AddEvent(BattleEventName.ShowHintText,instance.OnShowHintText,instance)
instance.hpCache = instance.role:GetRoleData(RoleDataName.Hp) / instance.role:GetRoleData(RoleDataName.MaxHp) instance.hpCache = instance.role:GetRoleData(RoleDataName.Hp) / instance.role:GetRoleData(RoleDataName.MaxHp)
instance.hpSlider = Util.GetGameObject(go, "hpProgress/hp"):GetComponent("Image") instance.hpSlider = Util.GetGameObject(go, "hpProgress/hp"):GetComponent("Image")
instance.hpPassSlider = Util.GetGameObject(go, "hpProgress/hpPass"):GetComponent("Image") instance.hpPassSlider = Util.GetGameObject(go, "hpProgress/hpPass"):GetComponent("Image")
@ -353,6 +353,12 @@ local TextFloatingColor = {
Purple = 3, Purple = 3,
Green = 4, Green = 4,
} }
--单纯显示提示文字
function RoleView:OnShowHintText(type,LanguageIndex)
self:TextBuffFloating(type,Language[LanguageIndex])
end
function RoleView:TextBuffFloating(type, text) function RoleView:TextBuffFloating(type, text)
local color local color
if type == 1 then --蓝色 增益 效果抵抗 if type == 1 then --蓝色 增益 效果抵抗