战斗同步
parent
ea69d5b7e9
commit
9a5d7ba469
|
@ -32,7 +32,6 @@ require("Modules.Battle.Logic.Monster.MonsterManager")
|
|||
local BattleMain = {}
|
||||
local BattleLogic = BattleLogic
|
||||
local Random = Random
|
||||
local BattleRecord
|
||||
|
||||
local _BattleErrorCache = {}
|
||||
local _BattleErrorIndex = 0
|
||||
|
@ -140,75 +139,6 @@ local function addBattleData()
|
|||
_BattleErrorCache[_BattleErrorIndex] = str
|
||||
end
|
||||
|
||||
local function AddRecord(fightData)
|
||||
BattleRecord = {}
|
||||
BattleLogic.Event:AddEvent(BattleEventName.AddRole, function (role)
|
||||
local record = {}
|
||||
record.uid = role.uid
|
||||
record.camp = role.camp
|
||||
record.damage = 0
|
||||
role.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg)
|
||||
record.damage = record.damage + finalDmg
|
||||
end)
|
||||
BattleRecord[role.uid] = record
|
||||
end)
|
||||
|
||||
for i=1, #fightData.playerData.teamSkill do
|
||||
local teamCaster = BattleLogic.GetTeamSkillCaster(0)
|
||||
local teamSkill = fightData.playerData.teamSkill[i]
|
||||
local teamType = math.floor(teamSkill[1] / 100)
|
||||
|
||||
local str = "order:1".."camp:"..teamCaster.camp.." team"..teamSkill[1]
|
||||
|
||||
local record = {}
|
||||
record.uid = str
|
||||
record.camp = teamCaster.camp
|
||||
record.damage = 0
|
||||
record.order = 1
|
||||
|
||||
local curSkill
|
||||
teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill)
|
||||
if skill.owner.camp == record.camp then
|
||||
curSkill = skill
|
||||
end
|
||||
end)
|
||||
teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg)
|
||||
if curSkill and curSkill.teamSkillType == teamType then
|
||||
record.damage = record.damage + finalDmg
|
||||
end
|
||||
end)
|
||||
BattleRecord[str] = record
|
||||
end
|
||||
|
||||
for i=1, #fightData.enemyData do
|
||||
for j=1, #fightData.enemyData[i].teamSkill do
|
||||
local teamCaster = BattleLogic.GetTeamSkillCaster(1)
|
||||
local teamSkill = fightData.enemyData[i].teamSkill[j]
|
||||
local teamType = math.floor(teamSkill[1] / 100)
|
||||
|
||||
local str = "order:"..i.."camp:"..teamCaster.camp.." team"..teamSkill[1]
|
||||
|
||||
local record = {}
|
||||
record.uid = str
|
||||
record.camp = teamCaster.camp
|
||||
record.damage = 0
|
||||
record.order = i
|
||||
|
||||
local curSkill
|
||||
teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill)
|
||||
if skill.owner.camp == record.camp then
|
||||
curSkill = skill
|
||||
end
|
||||
end)
|
||||
teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg)
|
||||
if curSkill and curSkill.teamSkillType == teamType and record.order == BattleLogic.CurOrder then
|
||||
record.damage = record.damage + finalDmg
|
||||
end
|
||||
end)
|
||||
BattleRecord[str] = record
|
||||
end
|
||||
end
|
||||
end
|
||||
function BattleMain.Execute(args, fightData, optionData)
|
||||
_seed = args.seed
|
||||
_type = args.type
|
||||
|
@ -225,12 +155,6 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
Random.SetSeed(args.seed)
|
||||
BattleLogic.Init(fightData, optionData, _maxRound)
|
||||
BattleLogic.Type = _type
|
||||
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()
|
||||
|
@ -283,18 +207,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
local curRound, maxRound = BattleLogic.GetCurRound()
|
||||
if curRound > maxRound and _type == BATTLE_SERVER_TYPE.TOPFight then --巅峰赛超出最大回合要根据伤害量判断胜负
|
||||
local playerDamage=0
|
||||
local enemyDamage=0
|
||||
for k,v in pairs(BattleRecord)do
|
||||
if v.camp == 0 then
|
||||
playerDamage = playerDamage + v.damage
|
||||
else
|
||||
enemyDamage = enemyDamage + v.damage
|
||||
end
|
||||
end
|
||||
resultList.result = playerDamage > enemyDamage and 1 or 0
|
||||
elseif curRound > maxRound and _type == BATTLE_SERVER_TYPE.SenLuoHuanJing then -- 森罗幻境超时,返回两边血量,战斗结果为2
|
||||
if 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)
|
||||
|
@ -311,23 +224,20 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
else
|
||||
resultList.result = BattleLogic.Result
|
||||
end
|
||||
|
||||
local allHeroDamage, allEnemyDamage = BattleLogic.GetAllDamage()
|
||||
-- print(allHeroDamage, allEnemyDamage)
|
||||
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
|
||||
playerDamage = playerDamage + v.damage
|
||||
end
|
||||
end
|
||||
resultList.duration = playerDamage --TODO:公会boss的持续时间传递的是我方总伤害值
|
||||
resultList.duration = allHeroDamage --TODO:公会boss的持续时间传递的是我方总伤害值
|
||||
else
|
||||
resultList.duration = BattleLogic.CurFrame() / BattleLogic.GameFrameRate
|
||||
end
|
||||
|
||||
|
||||
addBattleData()
|
||||
|
||||
|
||||
return resultList
|
||||
end
|
||||
if isError then --捕获异常,并输出错误日志
|
||||
|
|
|
@ -32,7 +32,6 @@ require("Modules.Battle.Logic.Monster.MonsterManager")
|
|||
local BattleMain = {}
|
||||
local BattleLogic = BattleLogic
|
||||
local Random = Random
|
||||
local BattleRecord
|
||||
|
||||
local _BattleErrorCache = {}
|
||||
local _BattleErrorIndex = 0
|
||||
|
@ -140,75 +139,6 @@ local function addBattleData()
|
|||
_BattleErrorCache[_BattleErrorIndex] = str
|
||||
end
|
||||
|
||||
local function AddRecord(fightData)
|
||||
BattleRecord = {}
|
||||
BattleLogic.Event:AddEvent(BattleEventName.AddRole, function (role)
|
||||
local record = {}
|
||||
record.uid = role.uid
|
||||
record.camp = role.camp
|
||||
record.damage = 0
|
||||
role.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg)
|
||||
record.damage = record.damage + finalDmg
|
||||
end)
|
||||
BattleRecord[role.uid] = record
|
||||
end)
|
||||
|
||||
for i=1, #fightData.playerData.teamSkill do
|
||||
local teamCaster = BattleLogic.GetTeamSkillCaster(0)
|
||||
local teamSkill = fightData.playerData.teamSkill[i]
|
||||
local teamType = math.floor(teamSkill[1] / 100)
|
||||
|
||||
local str = "order:1".."camp:"..teamCaster.camp.." team"..teamSkill[1]
|
||||
|
||||
local record = {}
|
||||
record.uid = str
|
||||
record.camp = teamCaster.camp
|
||||
record.damage = 0
|
||||
record.order = 1
|
||||
|
||||
local curSkill
|
||||
teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill)
|
||||
if skill.owner.camp == record.camp then
|
||||
curSkill = skill
|
||||
end
|
||||
end)
|
||||
teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg)
|
||||
if curSkill and curSkill.teamSkillType == teamType then
|
||||
record.damage = record.damage + finalDmg
|
||||
end
|
||||
end)
|
||||
BattleRecord[str] = record
|
||||
end
|
||||
|
||||
for i=1, #fightData.enemyData do
|
||||
for j=1, #fightData.enemyData[i].teamSkill do
|
||||
local teamCaster = BattleLogic.GetTeamSkillCaster(1)
|
||||
local teamSkill = fightData.enemyData[i].teamSkill[j]
|
||||
local teamType = math.floor(teamSkill[1] / 100)
|
||||
|
||||
local str = "order:"..i.."camp:"..teamCaster.camp.." team"..teamSkill[1]
|
||||
|
||||
local record = {}
|
||||
record.uid = str
|
||||
record.camp = teamCaster.camp
|
||||
record.damage = 0
|
||||
record.order = i
|
||||
|
||||
local curSkill
|
||||
teamCaster.Event:AddEvent(BattleEventName.SkillCast, function (skill)
|
||||
if skill.owner.camp == record.camp then
|
||||
curSkill = skill
|
||||
end
|
||||
end)
|
||||
teamCaster.Event:AddEvent(BattleEventName.RoleDamage, function (defRole, damage, bCrit, finalDmg)
|
||||
if curSkill and curSkill.teamSkillType == teamType and record.order == BattleLogic.CurOrder then
|
||||
record.damage = record.damage + finalDmg
|
||||
end
|
||||
end)
|
||||
BattleRecord[str] = record
|
||||
end
|
||||
end
|
||||
end
|
||||
function BattleMain.Execute(args, fightData, optionData)
|
||||
_seed = args.seed
|
||||
_type = args.type
|
||||
|
@ -225,12 +155,6 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
Random.SetSeed(args.seed)
|
||||
BattleLogic.Init(fightData, optionData, _maxRound)
|
||||
BattleLogic.Type = _type
|
||||
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()
|
||||
|
@ -283,18 +207,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
local curRound, maxRound = BattleLogic.GetCurRound()
|
||||
if curRound > maxRound and _type == BATTLE_SERVER_TYPE.TOPFight then --巅峰赛超出最大回合要根据伤害量判断胜负
|
||||
local playerDamage=0
|
||||
local enemyDamage=0
|
||||
for k,v in pairs(BattleRecord)do
|
||||
if v.camp == 0 then
|
||||
playerDamage = playerDamage + v.damage
|
||||
else
|
||||
enemyDamage = enemyDamage + v.damage
|
||||
end
|
||||
end
|
||||
resultList.result = playerDamage > enemyDamage and 1 or 0
|
||||
elseif curRound > maxRound and _type == BATTLE_SERVER_TYPE.SenLuoHuanJing then -- 森罗幻境超时,返回两边血量,战斗结果为2
|
||||
if 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)
|
||||
|
@ -311,23 +224,20 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
else
|
||||
resultList.result = BattleLogic.Result
|
||||
end
|
||||
|
||||
local allHeroDamage, allEnemyDamage = BattleLogic.GetAllDamage()
|
||||
-- print(allHeroDamage, allEnemyDamage)
|
||||
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
|
||||
playerDamage = playerDamage + v.damage
|
||||
end
|
||||
end
|
||||
resultList.duration = playerDamage --TODO:公会boss的持续时间传递的是我方总伤害值
|
||||
resultList.duration = allHeroDamage --TODO:公会boss的持续时间传递的是我方总伤害值
|
||||
else
|
||||
resultList.duration = BattleLogic.CurFrame() / BattleLogic.GameFrameRate
|
||||
end
|
||||
|
||||
|
||||
addBattleData()
|
||||
|
||||
|
||||
return resultList
|
||||
end
|
||||
if isError then --捕获异常,并输出错误日志
|
||||
|
|
|
@ -2,10 +2,26 @@ Buff = {}
|
|||
local floor = math.floor
|
||||
local buffPoolList = {}
|
||||
|
||||
local BuffRegister = {
|
||||
[BuffName.PropertyChange] = "PropertyChange",
|
||||
[BuffName.Control] = "Control",
|
||||
[BuffName.DOT] = "DOT",
|
||||
[BuffName.HOT] = "HOT",
|
||||
[BuffName.Shield] = "Shield",
|
||||
[BuffName.Immune] = "Immune",
|
||||
[BuffName.Curse] = "Curse",
|
||||
[BuffName.KylinMark] = "KylinMark",
|
||||
[BuffName.Exile] = "Exile",
|
||||
[BuffName.NoDead] = "NoDead",
|
||||
[BuffName.Aura] = "Aura",
|
||||
[BuffName.Brand] = "Brand",
|
||||
}
|
||||
|
||||
|
||||
local getBuff = function(type)
|
||||
if not buffPoolList[type] then
|
||||
buffPoolList[type] = BattleObjectPool.New(function (type)
|
||||
return require("Modules/Battle/Logic/Buff/"..type):New()
|
||||
return require("Modules/Battle/Logic/Buff/"..BuffRegister[type]):New()
|
||||
end)
|
||||
end
|
||||
return buffPoolList[type]:Get(type)
|
||||
|
@ -152,6 +168,8 @@ function BuffManager:AddBuff(target, buff)
|
|||
buff.roundDuration = buff.duration
|
||||
buff.roundInterval = buff.interval
|
||||
buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff)
|
||||
-- 用于记录统计
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordBuff, buff.caster, buff.target, buff)
|
||||
end
|
||||
|
||||
function BuffManager:QueryBuff(target, checkFunc)
|
||||
|
|
|
@ -1932,7 +1932,7 @@ local effectList = {
|
|||
local i1 = args[2]
|
||||
-- caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target)
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
target:AddRage(i1, ct)
|
||||
BattleUtil.CalRage(caster, target, i1, ct)
|
||||
end)
|
||||
end,
|
||||
|
||||
|
@ -2259,7 +2259,7 @@ local effectList = {
|
|||
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
BattleUtil.RandomAction(f1, function()
|
||||
target:AddRage(i1, ct)
|
||||
BattleUtil.CalRage(caster, target, i1, ct)
|
||||
end)
|
||||
end)
|
||||
end,
|
||||
|
@ -2317,7 +2317,6 @@ local effectList = {
|
|||
if skill and skill:CheckTargetIsHit(target) then
|
||||
BattleUtil.RandomControl(pro1,ctrl, caster, target,r1)
|
||||
end
|
||||
caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
|
||||
end)
|
||||
end,
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ function EffectCaster:DoEffect(caster, target, eff, duration, skill)
|
|||
e = pe
|
||||
end
|
||||
end
|
||||
caster.Event:DispatchEvent(BattleEventName.SkillEffectBefore, skill, e, _PassiveCheck)
|
||||
caster.Event:DispatchEvent(BattleEventName.SkillEffectBefore, skill, e, _PassiveCheck,target,eff)
|
||||
target.Event:DispatchEvent(BattleEventName.BeSkillEffectBefore, skill, e, _PassiveCheck)
|
||||
|
||||
--
|
||||
|
@ -130,7 +130,7 @@ function EffectCaster:Cast()
|
|||
if arr[j] and not arr[j]:IsRealDead() then
|
||||
-- 检测是否命中
|
||||
if i == 1 then
|
||||
self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.skill.owner, arr[j])
|
||||
self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.skill.owner, arr[j],self.skill)
|
||||
end
|
||||
self:takeEffect(self.skill.owner, arr[j], effects, i, self.skill.hitTime, self.skill)
|
||||
end
|
||||
|
|
|
@ -1569,7 +1569,7 @@ local passivityList = {
|
|||
-- buff.clear = false -- 不可驱散
|
||||
-- role:AddBuff(buff)
|
||||
if skill and not skill.isAdd and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit)
|
||||
|
@ -1615,7 +1615,7 @@ local passivityList = {
|
|||
local i1 = args[1]
|
||||
-- 行动结束后
|
||||
local onTurnEnd = function()
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleTurnEnd, onTurnEnd)
|
||||
end,
|
||||
|
@ -1833,7 +1833,7 @@ local passivityList = {
|
|||
local list = RoleManager.Query(function(v) return v.camp == role.camp end)
|
||||
for i = 1, #list do
|
||||
local r = list[i]
|
||||
r:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, r, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1869,7 +1869,7 @@ local passivityList = {
|
|||
-- 释放技能后
|
||||
local onSkillEnd = function(skill)
|
||||
if skill.type == BattleSkillType.Special then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd)
|
||||
|
@ -1913,7 +1913,7 @@ local passivityList = {
|
|||
local onBeSkillCastEnd = function(skill)
|
||||
--同阵营普工加血不触发被动
|
||||
if skill.type == BattleSkillType.Normal and skill.owner and skill.owner.camp~=role.camp then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd)
|
||||
|
@ -1929,7 +1929,7 @@ local passivityList = {
|
|||
local list = skill:GetDirectTargetsNoMiss()
|
||||
if list then
|
||||
for i = 1, #list do
|
||||
list[i]:AddRage(i1, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, list[i], i1, CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2162,7 +2162,7 @@ local passivityList = {
|
|||
-- 释放技能后
|
||||
local onSkillEnd = function(skill)
|
||||
if skill.type == BattleSkillType.Normal then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd)
|
||||
|
@ -2221,7 +2221,7 @@ local passivityList = {
|
|||
if skill.type == BattleSkillType.Special then
|
||||
local list = RoleManager.Query(function(v) return v.position > 3 and v.camp==role.camp end)
|
||||
for _, r in ipairs(list) do
|
||||
r:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, r, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2283,7 +2283,7 @@ local passivityList = {
|
|||
local list = skill:GetDirectTargetsNoMiss()
|
||||
if list then
|
||||
for _, r in ipairs(list) do
|
||||
r:AddRage(i1, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, r, i1, CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2526,7 +2526,7 @@ local passivityList = {
|
|||
-- 技能后后
|
||||
local onSkillEnd = function(skill)
|
||||
if skill.type == BattleSkillType.Special then
|
||||
local list = skill:GetDirectTargetsNoMiss()
|
||||
local list = skill:GetDirectTargets()
|
||||
if list then
|
||||
local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro]) * f1))
|
||||
for _, r in ipairs(list) do
|
||||
|
@ -2615,7 +2615,9 @@ local passivityList = {
|
|||
end
|
||||
if curRound == i1 + 1 then
|
||||
if buff then
|
||||
buff.disperse = true
|
||||
if buff.caster==role then
|
||||
buff.disperse = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -2929,7 +2931,7 @@ local passivityList = {
|
|||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
-- 回血
|
||||
if p1 and v1 then
|
||||
local dd = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[p1])*v1))
|
||||
|
@ -2940,21 +2942,30 @@ local passivityList = {
|
|||
role.Event:AddEvent(BattleEventName.RoleHit, onHit)
|
||||
end,
|
||||
|
||||
-- 复活友方第[a]位阵亡的英雄并回复其[b]%的生命每场战斗触发[c]次
|
||||
-- a[int]b[float]c[int]
|
||||
-- 复活友方第[a]位阵亡的英雄并回复其[b]%的生命每场战斗触发[c]次;复活的如果是[d]阵营,回复[e]%
|
||||
-- a[int]b[float]c[int] d[int] e[float] (d,e不配就不会额外回复)
|
||||
[154] = function(role, args)
|
||||
local i1 = args[1]
|
||||
local f1 = args[2]
|
||||
local i2 = args[3]-- 无意义(第几个死亡的人只能有一个)
|
||||
|
||||
local ele = args[4]
|
||||
local v1 = args[5]
|
||||
local counter = 0
|
||||
local onRoleRealDead = function(deadRole)
|
||||
if deadRole.camp == role.camp then
|
||||
counter = counter + 1
|
||||
if counter == i1 then
|
||||
deadRole:SetRelive(f1)
|
||||
end
|
||||
if deadRole==role then
|
||||
return
|
||||
end
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () --延时一帧做处理,我方场上所有单位都结算死亡以后,再处理299被动回血
|
||||
if deadRole.camp == role.camp and not role:IsDead() then
|
||||
if ele and v1 and deadRole.element==ele then
|
||||
f1=v1
|
||||
end
|
||||
counter = counter + 1
|
||||
if counter == i1 then
|
||||
deadRole:SetRelive(f1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
BattleLogic.Event:AddEvent(BattleEventName.RoleRealDead, onRoleRealDead)
|
||||
end,
|
||||
|
@ -2983,7 +2994,7 @@ local passivityList = {
|
|||
local onBeSkillCastEnd = function(skill)
|
||||
--同阵营给自己普攻加血不扣除怒气
|
||||
if skill.owner.camp~=role.camp and skill.type == BattleSkillType.Normal then
|
||||
skill.owner:AddRage(i1, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, skill.owner, i1, CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd)
|
||||
|
@ -3016,7 +3027,7 @@ local passivityList = {
|
|||
end)
|
||||
for i= 1, #list do
|
||||
if list[i] and not list[i]:IsRealDead() then
|
||||
list[i]:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, list[i], i1, CountTypeName.Add)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -3227,7 +3238,7 @@ local passivityList = {
|
|||
local onSkillEnd = function(skill)
|
||||
local targets = skill:GetDirectTargets()
|
||||
if targets and #targets > i1 then
|
||||
role:AddRage(i2, 1)
|
||||
BattleUtil.CalRage(role, role, i2, 1)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd)
|
||||
|
@ -3489,7 +3500,7 @@ local passivityList = {
|
|||
-- 对每个目标附加减伤盾
|
||||
local targets = skill:GetDirectTargetsNoMiss()
|
||||
if targets and #targets == 1 then
|
||||
targets[1]:AddRage(i1, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, targets[1], i1, CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd)
|
||||
|
@ -3595,7 +3606,7 @@ local passivityList = {
|
|||
local targets = skill:GetDirectTargetsNoMiss()
|
||||
if targets then
|
||||
for _, r in ipairs(targets) do
|
||||
r:AddRage(i1, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, r, i1, CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3822,7 +3833,7 @@ local passivityList = {
|
|||
end,
|
||||
|
||||
-- 首回合免疫[a]效果
|
||||
-- a[控制状态]
|
||||
-- a[控制状态]b[控制状态]c[控制状态]
|
||||
[195] = function(role, args)
|
||||
local ctrl = args[1]
|
||||
local ctr2 = args[2]
|
||||
|
@ -3895,7 +3906,7 @@ local passivityList = {
|
|||
local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill)
|
||||
if skill and (skill.type == BattleSkillType.Special or skill.type==BattleSkillType.Extra) and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
BattleUtil.RandomAction(f1, function()
|
||||
role:AddRage(target.Rage, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, target.Rage, CountTypeName.Add)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -4062,7 +4073,7 @@ local passivityList = {
|
|||
local onRoleTurnEnd = function(target)
|
||||
if not target:IsDead() and BattleLogic.BuffMgr:HasBuff(target, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end) then
|
||||
BattleUtil.RandomAction(f1, function()
|
||||
target:AddRage(i2, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, target, i2, CountTypeName.Sub)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -4256,7 +4267,7 @@ local passivityList = {
|
|||
local i1 = args[1]
|
||||
local function onRoundChange(curRound)
|
||||
if curRound == 1 then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
-- BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, onRoundChange)
|
||||
end
|
||||
end
|
||||
|
@ -4726,7 +4737,7 @@ local passivityList = {
|
|||
local function _OnRoundChange(curRound)
|
||||
if role.element == ele then
|
||||
BattleUtil.RandomAction(f1, function()
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -4896,7 +4907,7 @@ local passivityList = {
|
|||
return
|
||||
end
|
||||
if skill and not skill.isAdd and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
if skill then
|
||||
-- skill.isTriggePassivity=true
|
||||
table.insert(skill.triggerPassivityId,id)
|
||||
|
@ -5091,7 +5102,7 @@ local passivityList = {
|
|||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
if skill then
|
||||
--skill.isTriggePassivity=true
|
||||
table.insert(skill.triggerPassivityId,id)
|
||||
|
@ -5163,7 +5174,7 @@ local passivityList = {
|
|||
end
|
||||
if skill and skill.type == BattleSkillType.Special and target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
BattleUtil.RandomAction(f1, function()
|
||||
role:AddRage(target.Rage, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, target.Rage, CountTypeName.Add)
|
||||
if skill then
|
||||
--skill.isTriggePassivity=true
|
||||
table.insert(skill.triggerPassivityId,id)
|
||||
|
@ -5238,7 +5249,7 @@ local passivityList = {
|
|||
local onPassiveDamaging = function(func, defRole, damage,skill)
|
||||
--如果是boss 并且额外伤害是根据最大生命则返回
|
||||
local isBoss=BattleUtil.CheckIsBoss(defRole)
|
||||
if isBoss and f1==12 then
|
||||
if isBoss and (f1==12 or f1==13) then
|
||||
return
|
||||
end
|
||||
if skill and skill.type == BattleSkillType.Normal and skill.isAdd and skill.owner==role then
|
||||
|
@ -5309,7 +5320,7 @@ local passivityList = {
|
|||
end
|
||||
end
|
||||
if num>0 then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5367,7 +5378,7 @@ local passivityList = {
|
|||
return
|
||||
end
|
||||
if skill and skill.owner==role and defRole.camp~=role.camp and skill.type~=BattleSkillType.Monster and skill.type~=BattleSkillType.Normal then
|
||||
defRole:AddRage(v2,CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, defRole, v2,CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.FinalDamage,onFinalBeDamage)
|
||||
|
@ -5441,7 +5452,7 @@ local passivityList = {
|
|||
for key, value in pairs(list) do
|
||||
local isHave=BattleLogic.BuffMgr:HasBuff(value, BuffName.Control, function(buff) return buff.ctrlType == dot and buff.caster==role and buff.startRound == BattleLogic.GetCurRound() end)
|
||||
if isHave then
|
||||
value:AddRage(i1, CountTypeName.Sub)
|
||||
BattleUtil.CalRage(role, value, i1, CountTypeName.Sub)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5546,7 +5557,7 @@ local passivityList = {
|
|||
return
|
||||
end
|
||||
if BattleLogic.BuffMgr:HasBuff(caster, BuffName.DOT, function(buff) return buff.damageType == dot end) then
|
||||
role:AddRage(f1,ct)
|
||||
BattleUtil.CalRage(role, role, f1, ct)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, onPassiveBeDamaging)
|
||||
|
@ -5681,7 +5692,7 @@ local passivityList = {
|
|||
end
|
||||
list = BattleUtil.SortByProp(list, BattlePropList[pro],0)
|
||||
if not list[1]:IsDead() then
|
||||
list[1]:AddRage(num,ct)
|
||||
BattleUtil.CalRage(role, list[1], num, ct)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5783,22 +5794,24 @@ local passivityList = {
|
|||
[281]=function(role,args)
|
||||
local ele=args[1]
|
||||
local onRoleCastSkillBrfore=function(caster)
|
||||
-- 施法者不是自身/自身不足已释放技能/不是己方英雄/不是a 阵营
|
||||
if caster==role or role.Rage <= role.SuperSkillRage or caster.camp~=role.camp or caster.element~=role.element then
|
||||
return
|
||||
end
|
||||
--释放者死亡或释放着被沉默
|
||||
if caster:IsDead() or caster.ctrl_slient then
|
||||
return
|
||||
end
|
||||
local moreRage=role.Rage-role.SuperSkillRage
|
||||
local lessRage=caster.SuperSkillRage-caster.Rage
|
||||
local num=moreRage-lessRage
|
||||
if num>=0 then
|
||||
--精卫转移怒气不算减怒
|
||||
role.Rage=role.Rage-lessRage
|
||||
caster:AddRage(lessRage, CountTypeName.Add)
|
||||
end
|
||||
-- 施法者不是自身/自身不足已释放技能/不是己方英雄/不是a 阵营
|
||||
if caster==role or role.Rage <= role.SuperSkillRage or caster.camp~=role.camp or caster.element~=role.element then
|
||||
return
|
||||
end
|
||||
--释放者死亡或释放着被沉默
|
||||
if caster:IsDead() or caster.ctrl_slient then
|
||||
return
|
||||
end
|
||||
local moreRage=role.Rage-role.SuperSkillRage
|
||||
local lessRage=caster.SuperSkillRage-caster.Rage
|
||||
local num=moreRage-lessRage
|
||||
if num>=0 then
|
||||
--精卫转移怒气不算减怒
|
||||
role.Rage=role.Rage-lessRage
|
||||
caster:AddRage(lessRage, CountTypeName.Add)
|
||||
-- 用于记录统计
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordTransRage, role, caster, lessRage)
|
||||
end
|
||||
end
|
||||
BattleLogic.Event:AddEvent(BattleEventName.RoleCastSkillBefore, onRoleCastSkillBrfore)
|
||||
end,
|
||||
|
@ -5854,7 +5867,7 @@ local passivityList = {
|
|||
return
|
||||
end
|
||||
list=BattleUtil.SortByRage(list,0)
|
||||
list[1]:AddRage(v1,ct)
|
||||
BattleUtil.CalRage(role, list[1], v1, ct)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillCastEnd)
|
||||
|
@ -6013,7 +6026,7 @@ local passivityList = {
|
|||
end
|
||||
end
|
||||
if num>0 then
|
||||
role:AddRage(i1*num, CountTypeName.Add)
|
||||
BattleUtil.CalRage(role, role, i1*num, CountTypeName.Add)
|
||||
if p1 and v1 then
|
||||
local dd = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[p1])*v1*num))
|
||||
BattleUtil.ApplyTreat(role, role, dd)
|
||||
|
@ -6081,6 +6094,190 @@ local passivityList = {
|
|||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillEffectBefore, onSkillEffectBefore)
|
||||
end,
|
||||
--如果被持续治疗的神将是[a]系神将,持续治疗效果[b]改变[c]回合,并添加免疫[d]的效果
|
||||
--a[int,角色职业] b[int,改变类型] c[int] d[int,控制类型]
|
||||
[294]=function(role,args,id,judge)
|
||||
local ele=args[1]
|
||||
local ct=args[2]
|
||||
local round=args[3]
|
||||
local immune=args[4]
|
||||
local onSkillCastEnd = function(skill)
|
||||
if not skill then
|
||||
return
|
||||
end
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () --延迟一帧移除事件,防止触发帧和结束帧为同一帧时,被动未移除
|
||||
local list=skill:GetDirectTargetsNoMiss()
|
||||
for _, role1 in ipairs(list) do
|
||||
if role1.roleData.element==ele then
|
||||
BattleLogic.BuffMgr:QueryBuff(role1, function(buff)
|
||||
if buff.type == BuffName.HOT and buff.caster == role and buff.roundDuration>1 and buff.startRound==BattleLogic.GetCurRound() then
|
||||
buff:ChangeBuffDuration(ct,round)
|
||||
local immune = function(buff)
|
||||
return buff.type == BuffName.Control and buff.ctrlType and buff.ctrlType==immune
|
||||
end
|
||||
local curBuff=Buff.Create(role, BuffName.Immune,buff.roundDuration,4,immune)
|
||||
role1:AddBuff(curBuff)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd,onSkillCastEnd)
|
||||
end,
|
||||
|
||||
--持续治疗效果结算时,回复被治疗的神将[a][b]%的血量
|
||||
-- a[int 属性类型] b[float]
|
||||
[295]=function(role,args)
|
||||
local pro=args[1]
|
||||
local v1=args[2]
|
||||
local OnBuffEnd=function(buff)
|
||||
if buff and buff.caster==role and buff.roundDuration>1 then
|
||||
local val = floor(BattleUtil.FP_Mul(v1, buff.target:GetRoleData(BattlePropList[pro])))
|
||||
BattleUtil.CalTreat(role,buff.target, val)
|
||||
end
|
||||
end
|
||||
BattleLogic.Event:AddEvent(BattleEventName.HotBuffEnd, OnBuffEnd)
|
||||
end,
|
||||
-- 每回合每追击[a]次,额外回复[b]点怒气
|
||||
--a[int],b[int]
|
||||
[296]=function(role,args,id,judge)
|
||||
local time=args[1]
|
||||
local num=args[2]
|
||||
local aa=0
|
||||
|
||||
local onSkillCast=function(skill)
|
||||
if skill and judge==1 and skill.isAdd and not skill.isTriggerJudge then
|
||||
return
|
||||
end
|
||||
|
||||
if skill and skill.isAdd then
|
||||
aa=aa+1
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast)
|
||||
|
||||
local onRoundChange=function()
|
||||
if aa>=time then
|
||||
local ange= floor(aa/time)
|
||||
role:AddRage(ange*num, CountTypeName.Add)
|
||||
aa=0
|
||||
end
|
||||
end
|
||||
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange,onRoundChange )
|
||||
end,
|
||||
|
||||
-- 如果技能目标有自己,回复[a]点怒气
|
||||
-- a[int]
|
||||
[297] = function(role,args,id,judge)
|
||||
local num = args[1]
|
||||
-- 技能后后
|
||||
local onSkillEnd = function(skill)
|
||||
if skill and judge==1 and not skill.isTriggerJudge then
|
||||
return
|
||||
end
|
||||
if skill.type == BattleSkillType.Special or skill.type==BattleSkillType.Extra then
|
||||
local list = skill:GetDirectTargetsNoMiss()
|
||||
if list then
|
||||
local isHave=false
|
||||
for key, value in pairs(list) do
|
||||
if value ==role then
|
||||
isHave= true
|
||||
end
|
||||
end
|
||||
if isHave then
|
||||
role:AddRage(num, CountTypeName.Add)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd)
|
||||
end,
|
||||
|
||||
-- 技能,普攻治疗治疗的目标为[a]阵营,资料量额外提升[b]%,并解除[c]效果
|
||||
-- a[int], b[flaot], c[持续伤害type类型]
|
||||
[298] = function(role, args,id,judge)
|
||||
local ele = args[1]
|
||||
local v1 = args[2]
|
||||
local type = args[3]
|
||||
local curSkill = nil
|
||||
local passiveTreating = function(func,target)
|
||||
if curSkill and curSkill.isTriggerJudge==false and judge==1 then
|
||||
return
|
||||
end
|
||||
if target and target.roleData.element ==ele then
|
||||
BattleLogic.BuffMgr:ClearBuff(target, function (buff)
|
||||
return buff.type == BuffName.DOT and buff.damageType==type
|
||||
end)
|
||||
if func then func(v1, CountTypeName.AddPencent) end
|
||||
end
|
||||
end
|
||||
local OnSkillCast = function(skill)
|
||||
curSkill=skill
|
||||
role.Event:AddEvent(BattleEventName.PassiveTreatingFactor, passiveTreating)
|
||||
end
|
||||
local OnSkillCastEnd = function(skill)
|
||||
curSkill=nil
|
||||
role.Event:RemoveEvent(BattleEventName.PassiveTreatingFactor, passiveTreating)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast)
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd)
|
||||
end,
|
||||
|
||||
--死亡时,立即回复己方全体自身[a]*[b]的血量。
|
||||
--a[属性],b[float]
|
||||
[299] = function(role, args)
|
||||
local pro = args[1]
|
||||
local f1 = args[2]
|
||||
|
||||
local OnDead = function(atkRole)
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () --延时一帧做处理,我方场上所有单位都结算死亡以后,再处理299被动回血
|
||||
local arr = BattleUtil.ChooseTarget(role, 100000)
|
||||
if arr==nil then
|
||||
return
|
||||
end
|
||||
for i=1, #arr do
|
||||
if not arr[i]:IsDead() then
|
||||
local val = floor(BattleUtil.FP_Mul(f1, arr[i]:GetRoleData(BattlePropList[pro])))
|
||||
BattleUtil.CalTreat(role, arr[i], val)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleDead, OnDead)
|
||||
end,
|
||||
|
||||
--修改持续效果的治疗值为[a]属性的[b]%
|
||||
--a[int] b[float]
|
||||
[300]=function(role,args,id,judge)
|
||||
local pro=args[1]
|
||||
local v1=args[2]
|
||||
|
||||
local onSkillCastEnd = function(skill)
|
||||
if not skill or skill.type~= BattleSkillType.Special then
|
||||
return
|
||||
end
|
||||
if skill and judge==1 and not skill.isTriggerJudge then
|
||||
return
|
||||
end
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function () --延迟一帧移除事件,才能抓到添加效果字典里面的效果
|
||||
local tv = floor(BattleUtil.ErrorCorrection(role:GetRoleData(BattlePropList[pro]) * v1))
|
||||
if tv and tv<=0 then
|
||||
return
|
||||
end
|
||||
local list=skill:GetDirectTargetsNoMiss()
|
||||
for _, role1 in ipairs(list) do
|
||||
BattleLogic.BuffMgr:QueryBuff(role1, function(buff)
|
||||
if buff.type == BuffName.HOT and buff.caster == role and buff.roundDuration>1 and buff.startRound==BattleLogic.GetCurRound() then
|
||||
buff:ChangeHealValue(tv)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCastEnd,onSkillCastEnd)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
return passivityList
|
|
@ -87,9 +87,10 @@ function this.PrintBattleTable(tb)
|
|||
end
|
||||
--
|
||||
this.logList = {}
|
||||
function this.Init(fightdata, userdata)
|
||||
function this.Init(fightdata, userdata, maxRound)
|
||||
this.timestamp = Random.GetSeed()
|
||||
this.fightdata = fightdata
|
||||
this.maxRound = maxRound
|
||||
if userdata then
|
||||
this.userId = userdata.uid
|
||||
end
|
||||
|
@ -108,7 +109,6 @@ function this.Log(...)
|
|||
local value = args[i + 1]
|
||||
log = log .. string.format("%s = %s, ", key, value)
|
||||
end
|
||||
LogBattle(log)
|
||||
table.insert(this.logList, log)
|
||||
-- 如果log大于100条写一便日志到文件
|
||||
if #this.logList > 100 then
|
||||
|
@ -155,6 +155,8 @@ function this.WriteFightDataToFile()
|
|||
file:write(this.PrintBattleTable(this.fightdata))
|
||||
file:write("\n\n")
|
||||
file:write("timeStamp: " .. this.timestamp)
|
||||
file:write("\n")
|
||||
file:write("maxRound: " .. this.maxRound)
|
||||
file:write("\n\n\n\n\n")
|
||||
io.close(file)
|
||||
end
|
||||
|
|
|
@ -66,7 +66,7 @@ function BattleLogic.Init(data, _userData, maxRound)
|
|||
BattleLogic.IsEnd = false
|
||||
BattleLogic.Result = -1
|
||||
-- 日志管理放到前面初始化
|
||||
BattleLogManager.Init(fightData, userData)
|
||||
BattleLogManager.Init(fightData, userData, maxRound)
|
||||
|
||||
MonsterManager.Init()
|
||||
RoleManager.Init()
|
||||
|
@ -95,6 +95,13 @@ function BattleLogic.Init(data, _userData, maxRound)
|
|||
end)
|
||||
|
||||
end
|
||||
|
||||
-- 获取双方所有血量
|
||||
function BattleLogic.GetAllDamage()
|
||||
return allHeroDamage, allEnemyDamage
|
||||
end
|
||||
|
||||
|
||||
-- 检测先手阵营
|
||||
function BattleLogic.CheckFirstCamp()
|
||||
-- 默认我方先手
|
||||
|
@ -429,11 +436,43 @@ function BattleLogic.BattleEnd(result)
|
|||
BattleLogic.IsEnd = true
|
||||
BattleLogic.Result = result
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result)
|
||||
|
||||
-- 打印结果
|
||||
BattleLogic.LogResult(result)
|
||||
-- 战斗日志写入
|
||||
if not BattleLogic.GetIsDebug() then
|
||||
BattleLogManager.WriteLogToFile()
|
||||
end
|
||||
end
|
||||
|
||||
-- 打印战斗结果
|
||||
function BattleLogic.LogResult(result)
|
||||
local allHeroDamage, allEnemyDamage = BattleLogic.GetAllDamage()
|
||||
|
||||
local heroHP = {0, 0, 0, 0, 0, 0}
|
||||
local arr = RoleManager.Query(function (r) return r.camp == 0 end, true)
|
||||
for i=1, #arr do
|
||||
local pos = arr[i].position
|
||||
heroHP[pos] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
local enemyHP = {0, 0, 0, 0, 0, 0}
|
||||
local arr = RoleManager.Query(function (r) return r.camp == 1 end, true)
|
||||
for i=1, #arr do
|
||||
local pos = arr[i].position
|
||||
enemyHP[pos] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
BattleLogManager.Log(
|
||||
"Battle Over!!!!!!!",
|
||||
"result", result,
|
||||
"allHeroDamage", allHeroDamage,
|
||||
"allEnemyDamage", allEnemyDamage,
|
||||
"duration", BattleLogic.CurFrame() / BattleLogic.GameFrameRate,
|
||||
"heroHP", BattleLogManager.PrintBattleTable(heroHP),
|
||||
"enemyHP", BattleLogManager.PrintBattleTable(enemyHP)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
function BattleLogic.Clear()
|
||||
-- 清空角色
|
||||
|
|
|
@ -6,12 +6,11 @@ function Control:SetData(...)
|
|||
self.ctrlType = ...
|
||||
self.cover = true --控制效果可被覆盖
|
||||
-- 刷新排序等级
|
||||
self.sort = 4
|
||||
self.sort = 4
|
||||
end
|
||||
|
||||
--初始化后调用一次
|
||||
function Control:OnStart()
|
||||
|
||||
function Control:OnStart()
|
||||
if self.ctrlType == 1 then --眩晕
|
||||
self.target.ctrl_dizzy = true
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
|
@ -31,6 +30,8 @@ function Control:OnStart()
|
|||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function Control:OnTrigger()
|
||||
|
||||
|
@ -39,7 +40,6 @@ end
|
|||
|
||||
--效果结束时调用一次
|
||||
function Control:OnEnd()
|
||||
|
||||
if self.ctrlType == 1 then --眩晕
|
||||
self.target.ctrl_dizzy = false
|
||||
elseif self.ctrlType == 2 then --沉默
|
||||
|
|
|
@ -10,12 +10,20 @@ function HOT:SetData(...)
|
|||
self.sort = 1 -- 最先计算回血
|
||||
end
|
||||
|
||||
|
||||
--初始化后调用一次
|
||||
function HOT:OnStart()
|
||||
|
||||
self.target.Event:DispatchEvent(BattleEventName.RoleBeHealed, self.caster)
|
||||
end
|
||||
|
||||
--修改持续加血效果的加血值
|
||||
function HOT:ChangeHealValue(newValue)
|
||||
if newValue then
|
||||
self.healValue=newValue
|
||||
end
|
||||
end
|
||||
|
||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||
function HOT:OnTrigger()
|
||||
|
||||
|
@ -27,7 +35,7 @@ end
|
|||
|
||||
--效果结束时调用一次
|
||||
function HOT:OnEnd()
|
||||
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.HotBuffEnd, self)
|
||||
end
|
||||
|
||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||
|
|
|
@ -153,6 +153,17 @@ BattleEventName = {
|
|||
RoleCastSkillBefore = indexAdd(),
|
||||
--护盾buff消失以后
|
||||
ShieldBuffEnd=indexAdd(),
|
||||
--治疗效果导入
|
||||
HotBuffEnd=indexAdd(),
|
||||
|
||||
-- 战斗记录用
|
||||
RecordDamage = indexAdd(), -- 伤害
|
||||
RecordTreat = indexAdd(), -- 治疗
|
||||
RecordRage = indexAdd(), -- 怒气
|
||||
RecordTransRage = indexAdd(), -- 转移怒气
|
||||
RecordBuff = indexAdd(), -- buff
|
||||
RecordSecKill = indexAdd(), -- 斩杀
|
||||
|
||||
}
|
||||
|
||||
BattleMaxFrame = 1000000
|
||||
|
@ -189,18 +200,18 @@ RoleDataName = {
|
|||
}
|
||||
|
||||
BuffName = {
|
||||
PropertyChange = "PropertyChange",
|
||||
HOT = "HOT",
|
||||
DOT = "DOT",
|
||||
Control = "Control",
|
||||
Aura = "Aura",
|
||||
Brand = "Brand",
|
||||
Shield = "Shield",
|
||||
Immune = "Immune",
|
||||
NoDead = "NoDead",
|
||||
Curse = "Curse",
|
||||
KylinMark = "KylinMark",
|
||||
Exile = "Exile",
|
||||
PropertyChange = 1,
|
||||
Control = 2,
|
||||
DOT = 3,
|
||||
HOT = 4,
|
||||
Shield = 5,
|
||||
Immune = 6,
|
||||
Curse = 7,
|
||||
KylinMark = 8,
|
||||
Exile = 9,
|
||||
NoDead = 10,
|
||||
Aura = 11,
|
||||
Brand = 12,
|
||||
}
|
||||
|
||||
DotType = {
|
||||
|
|
|
@ -384,10 +384,12 @@ function BattleUtil.Seckill(skill, atkRole, defRole)
|
|||
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, nil, finalDmg, nil, skill)
|
||||
end
|
||||
end
|
||||
-- 用于记录统计
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordSecKill, atkRole, defRole)
|
||||
end
|
||||
|
||||
-- 秒杀定额血量
|
||||
function BattleUtil.SeckillHP(skill, atkRole, defRole,pro)
|
||||
function BattleUtil.SeckillHP(skill, atkRole, defRole, pro)
|
||||
-- 灵兽无效
|
||||
if defRole.type == BattleUnitType.Monster then
|
||||
return
|
||||
|
@ -414,6 +416,8 @@ function BattleUtil.SeckillHP(skill, atkRole, defRole,pro)
|
|||
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, nil, finalDmg, nil, skill)
|
||||
end
|
||||
end
|
||||
-- 用于记录统计
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordSecKill, atkRole, defRole)
|
||||
end
|
||||
|
||||
-- 计算真实伤害
|
||||
|
@ -462,6 +466,23 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy
|
|||
end
|
||||
|
||||
|
||||
-- 怒气计算
|
||||
function BattleUtil.CalRage(caster, target, value, countType)
|
||||
|
||||
-- 角色身上有无敌盾,不扣除怒气 by:wangzhenxing 2020/08/10 14:56
|
||||
if (countType==3 or countType==4) -- 降怒
|
||||
and (target.isImmuneReduceRage -- 免疫降怒 或者 有无敌盾
|
||||
or BattleLogic.BuffMgr:HasBuff(target, BuffName.Shield, function (buff) return buff.shieldType and buff.shieldType == ShieldTypeName.AllReduce end))
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
-- 操作怒气
|
||||
local deltaRage = target:AddRage(value, countType)
|
||||
-- 用于记录统计
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordRage, caster, target, deltaRage)
|
||||
end
|
||||
|
||||
--检测是否有是金翅大鹏有不灭效果
|
||||
function BattleUtil.CheckIsNoDead(target)
|
||||
if target then
|
||||
|
@ -470,6 +491,7 @@ function BattleUtil.CheckIsNoDead(target)
|
|||
return false
|
||||
end
|
||||
|
||||
|
||||
--检测列表是否包含值
|
||||
function BattleUtil.ChecklistIsContainValue(_list,_value)
|
||||
if _list and _value then
|
||||
|
@ -532,6 +554,8 @@ function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageTy
|
|||
end
|
||||
end
|
||||
|
||||
-- 战斗记录用
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordDamage, atkRole, defRole, damage)
|
||||
--
|
||||
BattleLogManager.Log(
|
||||
"Final Damage",
|
||||
|
@ -717,6 +741,8 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamag
|
|||
targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat)
|
||||
--添加发送到battleLogic的治疗消息,用于计算总的战斗伤害值
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat)
|
||||
-- 战斗记录用
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordTreat, castRole, targetRole, baseTreat)
|
||||
BattleLogManager.Log(
|
||||
"Final Treat",
|
||||
"acamp", castRole.camp,
|
||||
|
|
|
@ -74,6 +74,7 @@ function RoleLogic:Init(uid, data, position)
|
|||
self.isExile = false --是否放逐
|
||||
self.reliveFilter = true -- 控制复活的标志位,置为false角色将不再享受复活效果
|
||||
self.reliveHPF = 1
|
||||
self.reliveCaster = nil
|
||||
|
||||
self.IsCanAddSkill = true -- 是否可以追加技能
|
||||
self.mustHit=false --必定命中
|
||||
|
@ -159,11 +160,6 @@ end
|
|||
|
||||
-- 改变怒气值
|
||||
function RoleLogic:AddRage(value, type)
|
||||
-- 角色身上有无敌盾,不扣除怒气 by:wangzhenxing 2020/08/10 14:56
|
||||
if (type==3 or type==4) and (self.isImmuneReduceRage or BattleLogic.BuffMgr:HasBuff(self, BuffName.Shield, function (buff) return buff.shieldType and buff.shieldType == ShieldTypeName.AllReduce end)) then
|
||||
return
|
||||
end
|
||||
|
||||
local delta = 0
|
||||
if type == 1 then --加算
|
||||
delta = value
|
||||
|
@ -177,6 +173,8 @@ function RoleLogic:AddRage(value, type)
|
|||
self.Event:DispatchEvent(BattleEventName.RoleRageChange, delta)
|
||||
--怒气值不可为负值
|
||||
self.Rage = max(self.Rage + delta, 0)
|
||||
|
||||
return delta
|
||||
end
|
||||
|
||||
function RoleLogic:GetRoleData(property)
|
||||
|
@ -537,10 +535,13 @@ function RoleLogic:Relive()
|
|||
self.isDead = false
|
||||
self.isRealDead = false
|
||||
local maxHp = self.data:GetData(RoleDataName.MaxHp)
|
||||
self.data:SetValue(RoleDataName.Hp, floor(self.reliveHPF * maxHp))
|
||||
local reHp = floor(self.reliveHPF * maxHp)
|
||||
self.data:SetValue(RoleDataName.Hp, reHp)
|
||||
-- 发送复活事件
|
||||
self.Event:DispatchEvent(BattleEventName.RoleRelive, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RoleRelive, self)
|
||||
--BattleLogic.Event:DispatchEvent(BattleEventName.RoleRelive, self)
|
||||
-- 复活的血量算做加血
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.RecordTreat, self.reliveCaster or self, self, reHp)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
@ -550,10 +551,11 @@ function RoleLogic:SetReliveFilter(filter)
|
|||
self.reliveFilter = filter
|
||||
end
|
||||
--,hpf 复活时拥有的血量的百分比
|
||||
function RoleLogic:SetRelive(hpf)
|
||||
function RoleLogic:SetRelive(hpf, caster)
|
||||
-- 判断是否可以复活
|
||||
if self:IsCanRelive() then
|
||||
self.reliveHPF = hpf or 1
|
||||
self.reliveCaster = caster
|
||||
RoleManager.AddReliveRole(self)
|
||||
end
|
||||
return false
|
||||
|
|
|
@ -23,7 +23,7 @@ function Skill:Init(role, effectData, type, targets, isAdd, isRage) --type 0 异
|
|||
self.isKill = false --是否技能击杀目标
|
||||
self.isAdd = isAdd
|
||||
self.isRage = isRage
|
||||
|
||||
self.isTriggerJudge = true
|
||||
-- 初始化
|
||||
local effects = {}
|
||||
for i=5, #effectData do
|
||||
|
|
Loading…
Reference in New Issue