战斗同步
parent
dec66f3ee5
commit
fe32e26bfc
|
@ -1557,12 +1557,12 @@ local passivityList = {
|
||||||
[92] = function(role, args)
|
[92] = function(role, args)
|
||||||
local i1 = args[1]
|
local i1 = args[1]
|
||||||
|
|
||||||
local OnRoleHit = function(defRole)
|
local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||||
-- local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], i1, 1)
|
-- local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], i1, 1)
|
||||||
-- buff.cover = true -- 可以叠加
|
-- buff.cover = true -- 可以叠加
|
||||||
-- buff.clear = false -- 不可驱散
|
-- buff.clear = false -- 不可驱散
|
||||||
-- role:AddBuff(buff)
|
-- role:AddBuff(buff)
|
||||||
if defRole:IsDead() then
|
if skill and not skill.isAdd and defRole:IsDead() then
|
||||||
role:AddRage(i1, CountTypeName.Add)
|
role:AddRage(i1, CountTypeName.Add)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2088,7 +2088,7 @@ local passivityList = {
|
||||||
local af = 0
|
local af = 0
|
||||||
|
|
||||||
local onSkillCast = function(skill)
|
local onSkillCast = function(skill)
|
||||||
if skill.type == BattleSkillType.Normal then
|
if skill.type == BattleSkillType.Normal and not skill.isAdd then
|
||||||
af = 0
|
af = 0
|
||||||
elseif skill.type == BattleSkillType.Special then
|
elseif skill.type == BattleSkillType.Special then
|
||||||
af = af + f1
|
af = af + f1
|
||||||
|
@ -3109,7 +3109,7 @@ local passivityList = {
|
||||||
local f1 = args[1]
|
local f1 = args[1]
|
||||||
local ct = args[2]
|
local ct = args[2]
|
||||||
local f2 = args[3]
|
local f2 = args[3]
|
||||||
local ct2 = args[4]
|
local ct2 = args[4] -- 废物参数
|
||||||
|
|
||||||
-- 释放技能后
|
-- 释放技能后
|
||||||
local onPassiveDamaging = function(damagingFunc, defRole, damage, skill)
|
local onPassiveDamaging = function(damagingFunc, defRole, damage, skill)
|
||||||
|
@ -4363,7 +4363,7 @@ local passivityList = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- 我方武将造成伤害时,[a]概率附加[b]效果,每回合造成攻击[c]%的伤害,持续[d]秒。
|
-- 普攻时,[a]概率附加[b]效果,每回合造成攻击[c]%的伤害,持续[d]秒。
|
||||||
-- a[float],b[持续伤害效果],c[float],d[int]
|
-- a[float],b[持续伤害效果],c[float],d[int]
|
||||||
[223] = function(role, args)
|
[223] = function(role, args)
|
||||||
local rand = args[1]
|
local rand = args[1]
|
||||||
|
@ -4371,11 +4371,13 @@ local passivityList = {
|
||||||
local f1 = args[3]
|
local f1 = args[3]
|
||||||
local i1 = args[3]
|
local i1 = args[3]
|
||||||
|
|
||||||
local function _OnRoleHit(target)
|
local function _OnRoleHit(target, damage, _, finalDmg, _, skill)
|
||||||
-- BattleUtil.RandomDot(rand, dot, role, target, i1, 1, )
|
-- BattleUtil.RandomDot(rand, dot, role, target, i1, 1, )
|
||||||
BattleUtil.RandomAction(rand, function()
|
if skill and skill.type == BattleSkillType.Normal then
|
||||||
target:AddBuff(Buff.Create(role, BuffName.DOT, i1, 1, dot, 2, f1))
|
BattleUtil.RandomAction(rand, function()
|
||||||
end)
|
target:AddBuff(Buff.Create(role, BuffName.DOT, i1, 1, dot, 2, f1))
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
|
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
|
||||||
end,
|
end,
|
||||||
|
@ -4395,6 +4397,10 @@ local passivityList = {
|
||||||
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
|
role.Event:AddEvent(BattleEventName.RoleHit, _OnRoleHit)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
--
|
||||||
|
[225] = function()
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
-- 斩杀生命低于[a]的敌人
|
-- 斩杀生命低于[a]的敌人
|
||||||
-- a[float]
|
-- a[float]
|
||||||
|
|
|
@ -38,9 +38,9 @@ end
|
||||||
--随机0-1
|
--随机0-1
|
||||||
function Random.Range01()
|
function Random.Range01()
|
||||||
local var = random() / 2147483647
|
local var = random() / 2147483647
|
||||||
if BattleLogic.IsOpenBattleRecord then
|
BattleLogManager.Log(
|
||||||
BattleLogic.RecordSeed(seed)
|
"random",
|
||||||
end
|
"seed", seed)
|
||||||
return var
|
return var
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,12 @@ function RoleData:SetValue(name, value)
|
||||||
delta = value - delta
|
delta = value - delta
|
||||||
if delta ~= 0 then
|
if delta ~= 0 then
|
||||||
self.role.Event:DispatchEvent(BattleEventName.RolePropertyChanged, name, value, delta)
|
self.role.Event:DispatchEvent(BattleEventName.RolePropertyChanged, name, value, delta)
|
||||||
if BattleLogic.IsOpenBattleRecord then
|
BattleLogManager.Log(
|
||||||
BattleLogic.RecordRoleProperty(self.role.uid, self.role.camp, name, value, delta)
|
"property change",
|
||||||
end
|
"camp", self.role.camp,
|
||||||
|
"position", self.role.position,
|
||||||
|
"propId", name,
|
||||||
|
"value", value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,9 +91,13 @@ local function takeEffect(caster, target, effects, duration, skill)
|
||||||
--
|
--
|
||||||
if effect[e.type] then
|
if effect[e.type] then
|
||||||
effect[e.type](caster, target, e.args, duration, skill)
|
effect[e.type](caster, target, e.args, duration, skill)
|
||||||
if BattleLogic.IsOpenBattleRecord then
|
|
||||||
BattleLogic.RecordEffect(caster, target, e.type, e.args, duration)
|
BattleLogManager.Log(
|
||||||
end
|
"Take Effect",
|
||||||
|
"tcamp", target.camp,
|
||||||
|
"tpos", target.position,
|
||||||
|
"type", e.type
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -131,6 +135,15 @@ function Skill:Cast(func)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Cast Skill",
|
||||||
|
"camp", self.owner.camp,
|
||||||
|
"pos", self.owner.position,
|
||||||
|
"type", self.type,
|
||||||
|
"isRage", tostring(self.isRage),
|
||||||
|
"isAdd", tostring(self.isAdd)
|
||||||
|
)
|
||||||
|
|
||||||
-- 对目标造成相应的效果
|
-- 对目标造成相应的效果
|
||||||
for i=1, self.effectList.size do
|
for i=1, self.effectList.size do
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
BattleLogManager = {}
|
||||||
|
local this = BattleLogManager
|
||||||
|
local isLog = true
|
||||||
|
|
||||||
|
local function pairsByKeys(t)
|
||||||
|
local a = {}
|
||||||
|
for n in pairs(t) do
|
||||||
|
if n then
|
||||||
|
a[#a+1] = n
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(a, function( op1, op2 )
|
||||||
|
local type1, type2 = type(op1), type(op2)
|
||||||
|
local num1, num2 = tonumber(op1), tonumber(op2)
|
||||||
|
|
||||||
|
if ( num1 ~= nil) and (num2 ~= nil) then
|
||||||
|
return num1 < num2
|
||||||
|
elseif type1 ~= type2 then
|
||||||
|
return type1 < type2
|
||||||
|
elseif type1 == "string" then
|
||||||
|
return op1 < op2
|
||||||
|
elseif type1 == "boolean" then
|
||||||
|
return op1
|
||||||
|
-- 以上处理: number, string, boolean
|
||||||
|
else -- 处理剩下的: function, table, thread, userdata
|
||||||
|
return tostring(op1) < tostring(op2) -- tostring后比较字符串
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
local i = 0
|
||||||
|
return function()
|
||||||
|
i = i + 1
|
||||||
|
return a[i], t[a[i]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function this.PrintBattleTable(tb)
|
||||||
|
local indent_str = "{"
|
||||||
|
local count = 0
|
||||||
|
for k,v in pairs(tb) do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
for k=1, #tb do
|
||||||
|
local v = tb[k]
|
||||||
|
if type(v) == "table" then
|
||||||
|
indent_str = indent_str .. this.PrintBattleTable(v)
|
||||||
|
elseif type(v) == "string" then
|
||||||
|
indent_str = indent_str .. "\""..tostring(v) .. "\""
|
||||||
|
else
|
||||||
|
indent_str = indent_str .. tostring(v)
|
||||||
|
end
|
||||||
|
if k < count then
|
||||||
|
indent_str = indent_str..","
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local index = 0
|
||||||
|
for k,v in pairsByKeys(tb) do
|
||||||
|
index = index + 1
|
||||||
|
if type(k) ~= "number" then
|
||||||
|
if type(v) == "table" then
|
||||||
|
indent_str = string.format("%s%s=%s", indent_str, tostring(k), this.PrintBattleTable(v))
|
||||||
|
elseif type(v) == "string" then
|
||||||
|
indent_str = string.format("%s%s=\"%s\"", indent_str, tostring(k), tostring(v))
|
||||||
|
else
|
||||||
|
indent_str = string.format("%s%s=%s", indent_str, tostring(k), tostring(v))
|
||||||
|
end
|
||||||
|
if index < count then
|
||||||
|
indent_str = indent_str .. ","
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
indent_str = indent_str .. "}"
|
||||||
|
return indent_str
|
||||||
|
end
|
||||||
|
--
|
||||||
|
function this.Init(fightdata)
|
||||||
|
this.timestamp = Random.GetSeed()
|
||||||
|
this.fightdata = fightdata
|
||||||
|
this.logList = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.Log(...)
|
||||||
|
if not isLog then return end
|
||||||
|
local args = {...}
|
||||||
|
local log = args[1] .. ":\n"
|
||||||
|
log = log .. string.format("%s = %s, ", "frame", BattleLogic.CurFrame())
|
||||||
|
for i = 2, #args, 2 do
|
||||||
|
local key = args[i]
|
||||||
|
local value = args[i + 1]
|
||||||
|
log = log .. string.format("%s = %s, ", key, value)
|
||||||
|
end
|
||||||
|
table.insert(this.logList, log)
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.WriteFile()
|
||||||
|
if not isLog then return end
|
||||||
|
local time = string.format("%d-%d-%d-%d-%d-%d",
|
||||||
|
os.date("%Y"),
|
||||||
|
os.date("%m"),
|
||||||
|
os.date("%d"),
|
||||||
|
os.date("%H"),
|
||||||
|
os.date("%M"),
|
||||||
|
os.date("%S"))
|
||||||
|
local file
|
||||||
|
local platform
|
||||||
|
-- linux
|
||||||
|
if not file then
|
||||||
|
file = io.open("../luafight/BattleRecord/log-"..time..".txt", "a")
|
||||||
|
platform = "Linux"
|
||||||
|
end
|
||||||
|
-- local window server
|
||||||
|
if not file then
|
||||||
|
file = io.open("luafight/BattleRecord/log-"..time..".txt", "a")
|
||||||
|
platform = "Local Windows Server"
|
||||||
|
end
|
||||||
|
-- local
|
||||||
|
if not file then
|
||||||
|
file = io.open("BattleRecord/log-"..time..".txt", "a")
|
||||||
|
platform = "Local"
|
||||||
|
end
|
||||||
|
|
||||||
|
file:write(platform..":\n\n\n")
|
||||||
|
for i = 1, #this.logList do
|
||||||
|
file:write(this.logList[i].."\n")
|
||||||
|
end
|
||||||
|
file:write("\n\n\n\n\n")
|
||||||
|
file:write("fightData:\n")
|
||||||
|
file:write(this.PrintBattleTable(this.fightdata))
|
||||||
|
file:write("\n\n")
|
||||||
|
file:write("timeStamp: " .. this.timestamp)
|
||||||
|
io.close(file)
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleLogManager
|
|
@ -1,10 +1,3 @@
|
||||||
|
|
||||||
require("Modules.Battle.Logic.SkillManager")
|
|
||||||
require("Modules.Battle.Logic.RoleManager")
|
|
||||||
require("Modules.Battle.Logic.OutDataManager")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BattleLogic = {}
|
BattleLogic = {}
|
||||||
|
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
|
@ -88,6 +81,7 @@ function BattleLogic.Init(data, optionData, maxRound)
|
||||||
SkillManager.Init()
|
SkillManager.Init()
|
||||||
OutDataManager.Init(fightData)
|
OutDataManager.Init(fightData)
|
||||||
PassiveManager.Init()
|
PassiveManager.Init()
|
||||||
|
BattleLogManager.Init(fightData)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleLogic.StartOrder()
|
function BattleLogic.StartOrder()
|
||||||
|
@ -165,6 +159,11 @@ function BattleLogic.TurnRound(debugTurn)
|
||||||
CurCamp = 0
|
CurCamp = 0
|
||||||
CurSkillPos[0] = 0
|
CurSkillPos[0] = 0
|
||||||
CurSkillPos[1] = 0
|
CurSkillPos[1] = 0
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Round Change",
|
||||||
|
"round", CurRound
|
||||||
|
)
|
||||||
-- 轮数变化
|
-- 轮数变化
|
||||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound)
|
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound)
|
||||||
else
|
else
|
||||||
|
@ -172,6 +171,11 @@ function BattleLogic.TurnRound(debugTurn)
|
||||||
CurCamp = (CurCamp + 1) % 2
|
CurCamp = (CurCamp + 1) % 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Camp Change",
|
||||||
|
"camp", CurCamp
|
||||||
|
)
|
||||||
-- 当前阵营下一释放技能的位置
|
-- 当前阵营下一释放技能的位置
|
||||||
local cpos = CurSkillPos[CurCamp] + 1
|
local cpos = CurSkillPos[CurCamp] + 1
|
||||||
-- 找到下一个释放技能的人
|
-- 找到下一个释放技能的人
|
||||||
|
@ -195,10 +199,16 @@ function BattleLogic.TurnRound(debugTurn)
|
||||||
end
|
end
|
||||||
-- 如果找不到下一个人,直接交换阵营
|
-- 如果找不到下一个人,直接交换阵营
|
||||||
if not SkillRole then
|
if not SkillRole then
|
||||||
|
BattleLogManager.Log( "No Skill Position" )
|
||||||
BattleLogic.TurnRoundNextFrame()
|
BattleLogic.TurnRoundNextFrame()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Position Change",
|
||||||
|
"position", CurSkillPos[CurCamp]
|
||||||
|
)
|
||||||
|
|
||||||
-- 如果角色无法释放技能
|
-- 如果角色无法释放技能
|
||||||
if not SkillRole:IsAvailable() then
|
if not SkillRole:IsAvailable() then
|
||||||
|
@ -239,9 +249,6 @@ function BattleLogic.WaitForTrigger(delayTime, action)
|
||||||
item[1] = curFrame + delayFrame
|
item[1] = curFrame + delayFrame
|
||||||
item[2] = action
|
item[2] = action
|
||||||
tbActionList:Add(item)
|
tbActionList:Add(item)
|
||||||
if BattleLogic.IsOpenBattleRecord then
|
|
||||||
BattleLogic.RecordDelayTrigger(delayTime, curFrame + delayFrame)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -308,11 +315,14 @@ end
|
||||||
function BattleLogic.BattleEnd(result)
|
function BattleLogic.BattleEnd(result)
|
||||||
--
|
--
|
||||||
BattleLogic.Event:DispatchEvent(BattleEventName.BeforeBattleEnd, result)
|
BattleLogic.Event:DispatchEvent(BattleEventName.BeforeBattleEnd, result)
|
||||||
|
|
||||||
--
|
--
|
||||||
BattleLogic.IsEnd = true
|
BattleLogic.IsEnd = true
|
||||||
BattleLogic.Result = result
|
BattleLogic.Result = result
|
||||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result)
|
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result)
|
||||||
|
-- 战斗日志写入
|
||||||
|
if not BattleLogic.GetIsDebug() then
|
||||||
|
BattleLogManager.WriteFile()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
function BattleLogic.Clear()
|
function BattleLogic.Clear()
|
||||||
|
@ -324,75 +334,3 @@ function BattleLogic.Clear()
|
||||||
tbActionList:Remove(tbActionList.size)
|
tbActionList:Remove(tbActionList.size)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-------++++++++++++++++++++++++++++ 战斗记录相关
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.GetRecord()
|
|
||||||
return record
|
|
||||||
end
|
|
||||||
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.RecordSeed(seed)
|
|
||||||
table.insert(record, string.format("frame:%d, seed:%d", curFrame, seed))
|
|
||||||
end
|
|
||||||
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.RecordRoleProperty(uid, camp, name, value, delta)
|
|
||||||
table.insert(record, string.format("frame:%d, uid:%d, camp:%d, name:%s, value:%d, delta:%d", curFrame, uid, camp, name, value, delta))
|
|
||||||
end
|
|
||||||
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.RecordMul(args)
|
|
||||||
local str = ""
|
|
||||||
for i=1, #args do
|
|
||||||
str = str..tostring(args[i]) .. (i == #args and "" or "#")
|
|
||||||
end
|
|
||||||
table.insert(record, string.format("frame:%d, mulArgs:%s", curFrame, str))
|
|
||||||
end
|
|
||||||
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.RecordEffect(caster, target, type, args, interval)
|
|
||||||
local cUid = tostring(caster.uid) or "cTeam"
|
|
||||||
local tUid = tostring(target.uid) or "tTeam"
|
|
||||||
local str = ""
|
|
||||||
for i=1, #args do
|
|
||||||
str = str..tostring(args[i]) .. (i == #args and "" or "#")
|
|
||||||
end
|
|
||||||
table.insert(record, string.format("frame:%d, caster:%s, target:%s, effectType:%d, args:%s, interval:%d", curFrame, cUid, tUid, type, str, interval))
|
|
||||||
end
|
|
||||||
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.RecordDelayTrigger(delayFrame, triggerFrame)
|
|
||||||
table.insert(record, string.format("frame:%d, delayTime:%f, triggerFrame:%d", curFrame, delayFrame, triggerFrame))
|
|
||||||
end
|
|
||||||
|
|
||||||
--Record专用
|
|
||||||
function BattleLogic.GenerateRecordFile()
|
|
||||||
local time = string.format("%d-%d-%d-%d-%d-%d",
|
|
||||||
os.date("%Y"),
|
|
||||||
os.date("%m"),
|
|
||||||
os.date("%d"),
|
|
||||||
os.date("%H"),
|
|
||||||
os.date("%M"),
|
|
||||||
os.date("%S"))
|
|
||||||
local file = io.open("BattleRecord/"..time..".txt", "a")
|
|
||||||
for i=1, #record do
|
|
||||||
file:write(record[i].."\n")
|
|
||||||
end
|
|
||||||
io.close(file)
|
|
||||||
end
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ function NoDead:OnStart()
|
||||||
self.target:SetDeadFilter(false)
|
self.target:SetDeadFilter(false)
|
||||||
|
|
||||||
self.target:SetReliveFilter(self.isCanRelive)
|
self.target:SetReliveFilter(self.isCanRelive)
|
||||||
|
|
||||||
|
self.target:SetIsCanAddSkill(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd
|
||||||
|
@ -36,6 +38,8 @@ end
|
||||||
function NoDead:OnEnd()
|
function NoDead:OnEnd()
|
||||||
self.target.Event:AddEvent(BattleEventName.PassiveDamaging, self.onPassiveDamaging, self)
|
self.target.Event:AddEvent(BattleEventName.PassiveDamaging, self.onPassiveDamaging, self)
|
||||||
self.target:SetDeadFilter(true)
|
self.target:SetDeadFilter(true)
|
||||||
|
|
||||||
|
-- self.target:SetIsCanAddSkill(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
--只有当cover字段为true时触发,返回true则被新效果覆盖
|
||||||
|
|
|
@ -27,9 +27,6 @@ function BattleUtil.FP_Mul(...)
|
||||||
for i, v in ipairs{...} do
|
for i, v in ipairs{...} do
|
||||||
f = floor(f * v * 100000 + 0.5) / 100000
|
f = floor(f * v * 100000 + 0.5) / 100000
|
||||||
end
|
end
|
||||||
if BattleLogic.IsOpenBattleRecord then
|
|
||||||
BattleLogic.RecordMul({...})
|
|
||||||
end
|
|
||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -227,6 +224,11 @@ function BattleUtil.ChooseTarget(role, chooseId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- table.sort(finalArr, function(a, b)
|
||||||
|
-- return a.position < b.position
|
||||||
|
-- end)
|
||||||
|
|
||||||
return finalArr
|
return finalArr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -363,6 +365,18 @@ function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageTy
|
||||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill)
|
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Final Damage",
|
||||||
|
"acamp", atkRole.camp,
|
||||||
|
"apos", atkRole.position,
|
||||||
|
"tcamp", defRole.camp,
|
||||||
|
"tpos", defRole.position,
|
||||||
|
"damage", damage,
|
||||||
|
"dotType", tostring(dotType)
|
||||||
|
)
|
||||||
|
|
||||||
return finalDmg
|
return finalDmg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -438,6 +452,10 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i
|
||||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageAfter, defRole, damageFunc, fixDamage)
|
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageAfter, defRole, damageFunc, fixDamage)
|
||||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedAfter, atkRole, damageFunc, fixDamage)
|
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedAfter, atkRole, damageFunc, fixDamage)
|
||||||
|
|
||||||
|
|
||||||
|
fixDamage = max(floor(attack * 0.1), fixDamage)
|
||||||
|
|
||||||
|
|
||||||
local finalDmg = 0 --计算实际造成的扣血
|
local finalDmg = 0 --计算实际造成的扣血
|
||||||
if not defRole:IsRealDead() then
|
if not defRole:IsRealDead() then
|
||||||
finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, fixDamage, bCrit, damageType, dotType)
|
finalDmg = BattleUtil.ApplyDamage(skill, atkRole, defRole, fixDamage, bCrit, damageType, dotType)
|
||||||
|
@ -494,6 +512,16 @@ 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)
|
||||||
|
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Final Damage",
|
||||||
|
"acamp", castRole.camp,
|
||||||
|
"apos", castRole.position,
|
||||||
|
"tcamp", targetRole.camp,
|
||||||
|
"tpos", targetRole.position,
|
||||||
|
"value", value
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -713,9 +741,9 @@ end
|
||||||
-- 根据位置类型获取数据
|
-- 根据位置类型获取数据
|
||||||
function BattleUtil.GetRoleListByPosType(camp, posType)
|
function BattleUtil.GetRoleListByPosType(camp, posType)
|
||||||
if posType == 1 then
|
if posType == 1 then
|
||||||
return RoleManager.Query(function (r) return r.camp ~= camp and r.position <= 3 end)
|
return RoleManager.Query(function (r) return r.camp == camp and r.position <= 3 end)
|
||||||
elseif posType == 2 then
|
elseif posType == 2 then
|
||||||
return RoleManager.Query(function (r) return r.camp ~= camp and r.position > 3 end)
|
return RoleManager.Query(function (r) return r.camp == camp and r.position > 3 end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
--战斗外数据管理、
|
--战斗外数据管理、
|
||||||
OutDataManager = {}
|
OutDataManager = {}
|
||||||
local this = OutDataManager
|
local this = OutDataManager
|
||||||
--
|
|
||||||
|
|
||||||
local function _Split(input, delimiter)
|
local function _Split(input, delimiter)
|
||||||
input = tostring(input)
|
input = tostring(input)
|
||||||
|
|
|
@ -18,7 +18,7 @@ function RoleLogic.New()
|
||||||
exCalDmgList=BattleList.New(),
|
exCalDmgList=BattleList.New(),
|
||||||
proTranList=BattleList.New(),
|
proTranList=BattleList.New(),
|
||||||
buffFilter=BattleList.New(),
|
buffFilter=BattleList.New(),
|
||||||
Event=BattleEvent:New(),passiveList={},isDead=false,IsDebug=false}
|
Event = BattleEvent:New(),passiveList={},isDead=false,IsDebug=false}
|
||||||
setmetatable(instance, RoleLogic)
|
setmetatable(instance, RoleLogic)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
@ -36,6 +36,7 @@ function RoleLogic:Init(uid, data, position)
|
||||||
self.name = data.name
|
self.name = data.name
|
||||||
self.element = data.element
|
self.element = data.element
|
||||||
self.professionId = data.professionId
|
self.professionId = data.professionId
|
||||||
|
self.star = data.star or 1
|
||||||
|
|
||||||
self.shield:Clear() --护盾列表
|
self.shield:Clear() --护盾列表
|
||||||
self.exCalDmgList:Clear() --额外计算伤害列表
|
self.exCalDmgList:Clear() --额外计算伤害列表
|
||||||
|
@ -100,6 +101,8 @@ function RoleLogic:Init(uid, data, position)
|
||||||
|
|
||||||
self.reliveFilter = true -- 控制复活的标志位,置为false角色将不再享受复活效果
|
self.reliveFilter = true -- 控制复活的标志位,置为false角色将不再享受复活效果
|
||||||
self.reliveHPF = 1
|
self.reliveHPF = 1
|
||||||
|
|
||||||
|
self.IsCanAddSkill = true -- 是否可以追加技能
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 添加一个被动技能
|
-- 添加一个被动技能
|
||||||
|
@ -350,13 +353,39 @@ end
|
||||||
-- isAdd 是否是追加技能
|
-- isAdd 是否是追加技能
|
||||||
-- isRage 是否正常操作怒气值
|
-- isRage 是否正常操作怒气值
|
||||||
function RoleLogic:AddSkill(type, isRage, isAdd, targets)
|
function RoleLogic:AddSkill(type, isRage, isAdd, targets)
|
||||||
|
if not self.IsCanAddSkill and isAdd then return end
|
||||||
local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill
|
local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill
|
||||||
SkillManager.AddSkill(self, effectData, type, targets, isAdd, isRage)
|
SkillManager.AddSkill(self, effectData, type, targets, isAdd, isRage)
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Add Skill",
|
||||||
|
"camp", self.camp,
|
||||||
|
"pos", self.position,
|
||||||
|
"type", type,
|
||||||
|
"isRage", tostring(isRage),
|
||||||
|
"isAdd", tostring(isAdd),
|
||||||
|
"targets", targets and #targets or "0"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
-- 插入一个技能
|
-- 插入一个技能
|
||||||
function RoleLogic:InsertSkill(type, isRage, isAdd, targets)
|
function RoleLogic:InsertSkill(type, isRage, isAdd, targets)
|
||||||
|
if not self.IsCanAddSkill and isAdd then return end
|
||||||
local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill
|
local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill
|
||||||
SkillManager.InsertSkill(self, effectData, type, targets, isAdd, isRage)
|
SkillManager.InsertSkill(self, effectData, type, targets, isAdd, isRage)
|
||||||
|
--
|
||||||
|
BattleLogManager.Log(
|
||||||
|
"Insert Skill",
|
||||||
|
"camp", self.camp,
|
||||||
|
"pos", self.position,
|
||||||
|
"type", type,
|
||||||
|
"isRage", tostring(isRage),
|
||||||
|
"isAdd", tostring(isAdd),
|
||||||
|
"targets", targets and #targets or "0"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
-- 设置是否可以追加技能
|
||||||
|
function RoleLogic:SetIsCanAddSkill(isCan)
|
||||||
|
self.IsCanAddSkill = isCan
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,9 @@ function RoleManager.Query(func, inCludeDeadRole)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.sort(list, function(a, b)
|
||||||
|
return a.position < b.position
|
||||||
|
end)
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -245,6 +248,9 @@ function this.GetArrAggroList(role, arr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.sort(targetList, function(a, b)
|
||||||
|
return a.position < b.position
|
||||||
|
end)
|
||||||
return targetList
|
return targetList
|
||||||
end
|
end
|
||||||
--获取对位相邻站位的人 chooseType 1 我方 2 敌方(对位的敌人受到嘲讽的影响,若对位的敌人死亡,则选取相邻最近的作为目标)
|
--获取对位相邻站位的人 chooseType 1 我方 2 敌方(对位的敌人受到嘲讽的影响,若对位的敌人死亡,则选取相邻最近的作为目标)
|
||||||
|
@ -272,6 +278,9 @@ function this.GetNeighbor(role, chooseType)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.sort(posList, function(a, b)
|
||||||
|
return a.position < b.position
|
||||||
|
end)
|
||||||
return posList
|
return posList
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue