战斗逻辑同步
parent
3810fc2da1
commit
0baed21bf6
|
@ -2240,7 +2240,7 @@ local effectList = {
|
|||
--如果身上有不灭效果就不会加普攻,兼容金翅大鹏10星天赋 by:王振兴
|
||||
if not BattleLogic.BuffMgr:HasBuff(caster,BuffName.NoDead) then
|
||||
BattleLogic.WaitForTrigger(0.5, function ()
|
||||
caster:InsertSkill(BattleSkillType.Normal, false, false, nil)
|
||||
caster:InsertSkill(BattleSkillType.Normal, false, true, nil)
|
||||
end)
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -2031,8 +2031,6 @@ local passivityList = {
|
|||
end)
|
||||
end,
|
||||
|
||||
|
||||
|
||||
-- 直接伤害击杀目标回复自身[a]%的[b]
|
||||
-- a[float]
|
||||
[116] = function(role, args)
|
||||
|
@ -2093,9 +2091,7 @@ local passivityList = {
|
|||
[118] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local ct = args[2]
|
||||
|
||||
local af = 0
|
||||
|
||||
local onSkillCast = function(skill)
|
||||
if skill.type == BattleSkillType.Normal and not skill.isAdd then
|
||||
af = 0
|
||||
|
@ -2107,7 +2103,7 @@ local passivityList = {
|
|||
|
||||
-- 如果是技能的伤害则判断加成
|
||||
local onPassiveDamaging = function(func, target, damage, skill)
|
||||
if skill and skill.type == BattleSkillType.Special then
|
||||
if skill and (skill.type == BattleSkillType.Special or skill.type==BattleSkillType.Extra) then
|
||||
local dd = BattleUtil.CountValue(damage, af, ct) - damage
|
||||
if func then func(-floor(BattleUtil.ErrorCorrection(dd))) end
|
||||
end
|
||||
|
@ -3210,7 +3206,9 @@ local passivityList = {
|
|||
local onSkillEnd = function(skill)
|
||||
if skill.type == BattleSkillType.Special then
|
||||
local list = RoleManager.Query(function(v) return v.camp == role.camp end)
|
||||
BattleUtil.SortByProp(list, RoleDataName.Hp, 1)
|
||||
--生命最少改成生命百分比最少 2020/09/29 by:王振兴
|
||||
--BattleUtil.SortByProp(list, RoleDataName.Hp, 1)
|
||||
BattleUtil.SortByHpFactor(list, 1)
|
||||
local index = 0
|
||||
for i = 1, #list do
|
||||
if not list[i]:IsRealDead() and index < 2 then
|
||||
|
@ -3865,7 +3863,7 @@ local passivityList = {
|
|||
end
|
||||
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.FinalBeDamage, onFinalBeDamage)
|
||||
role.Event:AddEvent(BattleEventName.FinalBeDamageEnd, onFinalBeDamage)
|
||||
end,
|
||||
|
||||
|
||||
|
@ -3875,14 +3873,14 @@ local passivityList = {
|
|||
local f1 = args[1]
|
||||
|
||||
local onFinalDamage = function(damagingFunc, atkRole, defRole, damage, skill, dotType, bCrit, damageType)
|
||||
if skill and role.position ~= defRole.position and defRole.camp == role.camp and defRole.element == role.element then
|
||||
if not role:IsDead() and skill and role.position ~= defRole.position and defRole.camp == role.camp and defRole.element == role.element then
|
||||
local shareDamage = floor(BattleUtil.ErrorCorrection(damage * f1))
|
||||
-- 被攻击武将自身伤害
|
||||
if damagingFunc then
|
||||
damagingFunc(shareDamage)
|
||||
end
|
||||
-- 分担伤害
|
||||
BattleUtil.ApplyDamage(nil, atkRole, role, shareDamage)
|
||||
BattleUtil.ApplyDamage(nil, atkRole, role, shareDamage,bCrit,damageType,dotType,true)
|
||||
end
|
||||
end
|
||||
BattleLogic.Event:AddEvent(BattleEventName.FinalDamage, onFinalDamage)
|
||||
|
@ -4779,5 +4777,272 @@ local passivityList = {
|
|||
role.data.enemyType=f1
|
||||
BattleUtil.CheckIsBoss(role)
|
||||
end,
|
||||
-- (直接伤害(目前没有明确定义直接伤害))直接伤害击杀目标自身增加[a]点怒气 重写92被动效果 每次释放技能只触发一次
|
||||
-- a[int]
|
||||
[245] = function(role, args)
|
||||
local i1 = args[1]
|
||||
local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if skill and not skill.isAdd and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit)
|
||||
end,
|
||||
|
||||
-- 直接伤害每次击杀目标增加[a]%的[b]可叠加持续至战斗结束[c]改变 重写103效果 每次释放技能只触发一次
|
||||
-- a[float]b[属性]c[改变类型]
|
||||
[246] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local pro = args[2]
|
||||
local ct = args[3]
|
||||
-- 释放技能后
|
||||
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
|
||||
local buff = Buff.Create(role, BuffName.PropertyChange, 0, BattlePropList[pro], f1, ct)
|
||||
-- buff.cover = true
|
||||
role:AddBuff(buff)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
-- 直接伤害击杀目标后追加[a]次普攻 重写114 一次技能只触发一次被动
|
||||
-- a[int]
|
||||
[247] = function(role, args)
|
||||
local i1 = args[1]
|
||||
-- 释放技能后
|
||||
local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
for i = 1, i1 do
|
||||
role:AddSkill(BattleSkillType.Normal, false, true, nil)
|
||||
end
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 直接伤害击杀目标回复自身[a]%的[b] 重写116 一次技能只触发一次被动
|
||||
-- a[float]
|
||||
[248] = function(role, args)
|
||||
local f1 = args[1]
|
||||
-- 释放技能后
|
||||
local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
local treat = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.MaxHp), f1))
|
||||
BattleUtil.CalTreat(role, role, treat)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 直接伤害击杀目标下回合攻击[a]%暴击(TODO:目前为增加[a]%) 重写125 一次技能只触发一次被动
|
||||
-- a[float]
|
||||
[249] = function(role, args)
|
||||
local f1 = args[1]
|
||||
-- 释放技能后
|
||||
local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
local buff = Buff.Create(role, BuffName.PropertyChange, 1, RoleDataName.Crit, f1, CountTypeName.Add)
|
||||
role:AddBuff(buff)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 直接伤害每次击杀目标增加自身伤害[a]%,[b]改变,可叠加持续至战斗结束 重写132 一次技能只触发一次被动
|
||||
-- a[float]b[改变类型]
|
||||
[250] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local ct = args[2]
|
||||
|
||||
local killNum = 0
|
||||
local extra = 0
|
||||
|
||||
-- 击杀数量累加
|
||||
local OnRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if skill and defRole:IsDead() and not BattleUtil.CheckIsNoDead(defRole) then
|
||||
killNum = killNum + 1
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, OnRoleHit)
|
||||
|
||||
|
||||
-- 释放技能时计算额外伤害
|
||||
local OnSkillCast = function(skill)
|
||||
if skill then
|
||||
extra = f1 * killNum
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast)
|
||||
|
||||
|
||||
-- 造成伤害时判断额外伤害
|
||||
local passivityDamaging = function(func, caster, damage, skill)
|
||||
if skill then
|
||||
if func then
|
||||
local dd = BattleUtil.CountValue(damage, extra, ct) - damage
|
||||
func(-floor(BattleUtil.ErrorCorrection(dd)))
|
||||
end
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, passivityDamaging)
|
||||
end,
|
||||
|
||||
-- 直接伤害击杀[a]目标回复[b]%的最大生命 重写148 一次技能只触发一次被动
|
||||
-- a[持续伤害状态]b[float]
|
||||
[251] = function(role, args)
|
||||
local dot = args[1]
|
||||
local f1 = args[2]
|
||||
local function onHit(target, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
local maxHp = role:GetRoleData(RoleDataName.MaxHp)
|
||||
local value = floor(BattleUtil.ErrorCorrection(maxHp* f1))
|
||||
BattleUtil.ApplyTreat(role, role, value)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
role.Event:RemoveEvent(BattleEventName.RoleHit, onHit)
|
||||
end
|
||||
local onDamaging = function(func, target)
|
||||
if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function(buff) return buff.damageType == dot end) then
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onHit)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, onDamaging)
|
||||
end,
|
||||
|
||||
-- 直接伤害击杀目标回复自身[a]点怒气 重写153 一次技能只触发一次被动
|
||||
-- a[int]
|
||||
[252] = function(role, args)
|
||||
local i1 = args[1]
|
||||
local onHit = function(target, damage, bCrit, finalDmg,damageType,skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
role:AddRage(i1, CountTypeName.Add)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onHit)
|
||||
end,
|
||||
|
||||
-- 击杀目标后对敌方血量百分比最低两名角色造成[a]%[b]伤害 重写170 一次技能只触发一次被动
|
||||
-- a[float]b[伤害类型]
|
||||
[253] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
-- 直接伤害后
|
||||
local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
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)
|
||||
BattleUtil.SortByHpFactor(list, 1)
|
||||
local index = 0
|
||||
for i = 1, #list do
|
||||
if not list[i]:IsDead() and index < 2 then
|
||||
index = index + 1
|
||||
BattleUtil.CalDamage(nil, role, list[i], dt, f1)
|
||||
end
|
||||
end
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 直接伤害击杀目标对仇恨目标造成[a]%物理伤害 重写185 一次技能只触发一次被动
|
||||
-- a[float]
|
||||
[254] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local onRoleHit = function(target,damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) then
|
||||
local target = RoleManager.GetAliveAggro(role)
|
||||
BattleUtil.CalDamage(nil, role, target, 1, f1)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 技能直接击杀敌方目标时有[a]%概率获得目标剩余所有怒气(输出武将佩戴)重写197 一次技能只触发一次被动
|
||||
-- a[float]
|
||||
[255] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
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)
|
||||
skill.isTriggePassivity=true
|
||||
end)
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
|
||||
-- 直接伤害击杀目标释放[a]技能。 重新243 一次技能只触发一次被动
|
||||
-- a[float]
|
||||
[256] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2=args[2]
|
||||
local onRoleHit = function(target, damage, bCrit, finalDmg, damageType, skill)
|
||||
--如果是技能并且这个被动已经被触发过 return
|
||||
if skill and skill.isTriggePassivity then
|
||||
return
|
||||
end
|
||||
if target:IsDead() and not BattleUtil.CheckIsNoDead(target) and not role:IsDead() then
|
||||
-- local target = RoleManager.GetAliveAggro(role)
|
||||
--BattleUtil.CalDamage(nil, role, target, 1, f1)
|
||||
--加一个延时操作,防止有的英雄有死亡后再释放一次技能的被动 by:王振兴
|
||||
role:InsertExtraSkill(f1,f2)
|
||||
skill.isTriggePassivity=true
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
end,
|
||||
}
|
||||
return passivityList
|
|
@ -35,11 +35,11 @@ function Skill:Init(role, effectData, type, targets, isAdd, isRage) --type 0 异
|
|||
self.hitTime = effectData[2] -- 效果命中需要的时间
|
||||
self.continueTime = effectData[3] -- 命中后伤害持续时间
|
||||
self.attackCount = effectData[4] -- 伤害持续时间内伤害次数
|
||||
|
||||
self.isTriggePassivity = false -- 是否一个技能只触发一次被动 true:每次释放技能只会触发一次
|
||||
self.targets = targets or {}
|
||||
self.isAdd = isAdd
|
||||
self.isRage = isRage
|
||||
|
||||
self.isKill = false --是否技能击杀目标
|
||||
for i=5, #effectData do
|
||||
local v = effectData[i]
|
||||
local effectGroup = effectGroupPool:Get() -- chooseId, {effect1, effect2, ...}
|
||||
|
@ -120,6 +120,7 @@ function Skill:Cast(func)
|
|||
self.castDoneFunc = func
|
||||
self.effectTargets = {}
|
||||
self.targetIsHit = {}
|
||||
self.isTriggePassivity=false
|
||||
-- 先计算出技能的目标
|
||||
for i=1, self.effectList.size do
|
||||
-- 是否重新选择目标
|
||||
|
@ -218,6 +219,8 @@ function Skill:Cast(func)
|
|||
end
|
||||
-- 技能结束
|
||||
self:EndSkill()
|
||||
--技能消息发送完后 iskill 设置为false
|
||||
self.isKill=false
|
||||
end)
|
||||
|
||||
end
|
||||
|
@ -257,6 +260,7 @@ function Skill:EndSkill()
|
|||
-- 技能结束后摇后结束技能释放
|
||||
BattleLogic.WaitForTrigger(0.3, function()
|
||||
-- 结束回调
|
||||
self.isTriggePassivity=false
|
||||
if self.castDoneFunc then self.castDoneFunc() end
|
||||
|
||||
end)
|
||||
|
|
|
@ -94,6 +94,7 @@ function this.Init(fightdata, userdata)
|
|||
end
|
||||
|
||||
this.logList = {}
|
||||
this.WriteFightDataToFile()
|
||||
end
|
||||
|
||||
function this.Log(...)
|
||||
|
@ -107,12 +108,14 @@ function this.Log(...)
|
|||
log = log .. string.format("%s = %s, ", key, value)
|
||||
end
|
||||
table.insert(this.logList, log)
|
||||
-- 打印一下
|
||||
LogBattle(log)
|
||||
-- 如果log大于100条写一便日志到文件
|
||||
if #this.logList > 100 then
|
||||
this.WriteLogToFile()
|
||||
end
|
||||
end
|
||||
|
||||
function this.WriteFile()
|
||||
if not isLog then return end
|
||||
|
||||
function this.GetFile(wType)
|
||||
local time = string.format("%d-%d-%d-%d-%d-%d",
|
||||
os.date("%Y"),
|
||||
os.date("%m"),
|
||||
|
@ -124,29 +127,44 @@ function this.WriteFile()
|
|||
local platform
|
||||
-- linux
|
||||
if not file then
|
||||
file = io.open("../luafight/BattleRecord/log-"..(this.userId or time)..".txt", "w")
|
||||
file = io.open("../luafight/BattleRecord/log-"..(this.userId or time)..".txt", wType)
|
||||
platform = "Linux"
|
||||
end
|
||||
-- local window server
|
||||
if not file then
|
||||
file = io.open("luafight/BattleRecord/log-"..(this.userId or time)..".txt", "w")
|
||||
file = io.open("luafight/BattleRecord/log-"..(this.userId or time)..".txt", wType)
|
||||
platform = "Local Windows Server"
|
||||
end
|
||||
-- local
|
||||
if not file then
|
||||
file = io.open("BattleRecord/log-"..(this.userId or time)..".txt", "w")
|
||||
file = io.open("BattleRecord/log-"..(this.userId or time)..".txt", wType)
|
||||
platform = "Local"
|
||||
end
|
||||
return file, platform
|
||||
end
|
||||
|
||||
|
||||
-- 将战斗数据写入log
|
||||
function this.WriteFightDataToFile()
|
||||
if not isLog then return end
|
||||
local file, platform = this.GetFile("w")
|
||||
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)
|
||||
file:write("\n\n\n\n\n")
|
||||
io.close(file)
|
||||
end
|
||||
|
||||
-- 将日志写入log
|
||||
function this.WriteLogToFile()
|
||||
if not isLog then return end
|
||||
local file, platform = this.GetFile("a")
|
||||
for i = 1, #this.logList do
|
||||
file:write(this.logList[i].."\n")
|
||||
end
|
||||
this.logList = {}
|
||||
io.close(file)
|
||||
end
|
||||
|
||||
|
|
|
@ -69,37 +69,34 @@ function BattleLogic.Init(data, _userData, maxRound)
|
|||
BattleLogic.IsEnd = false
|
||||
BattleLogic.Result = -1
|
||||
|
||||
-- log初始化应该在上面
|
||||
BattleLogManager.Init(fightData, userData)
|
||||
|
||||
--
|
||||
RoleManager.Init()
|
||||
SkillManager.Init()
|
||||
OutDataManager.Init(fightData)
|
||||
PassiveManager.Init()
|
||||
BattleLogManager.Init(fightData, userData)
|
||||
|
||||
--监听英雄受到治疗
|
||||
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.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)
|
||||
--我方阵营总攻击
|
||||
if atkRole.camp==0 then
|
||||
allHeroDamage=allHeroDamage+damage
|
||||
LogBattle("我方 英雄攻击"..damage)
|
||||
--敌方阵营
|
||||
else
|
||||
allEnemyDamage=allEnemyDamage+damage
|
||||
LogBattle("敌方 英雄攻击"..damage)
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
-- 检测先手阵营
|
||||
|
@ -200,18 +197,25 @@ function BattleLogic.TurnRound(debugTurn)
|
|||
)
|
||||
-- 轮数变化
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoundChange, CurRound)
|
||||
--轮数变化后延时0.2秒用于初始化监听回合数被动的初始化
|
||||
BattleLogic.WaitForTrigger(0.2,function()
|
||||
BattleLogic.CheckBattleLogic()
|
||||
end)
|
||||
else
|
||||
-- 切换阵营
|
||||
CurCamp = (CurCamp + 1) % 2
|
||||
BattleLogic.CheckBattleLogic()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--检测战斗逻辑
|
||||
function BattleLogic.CheckBattleLogic()
|
||||
-- 这里再检测一次战斗结束
|
||||
if CurRound > MaxRound then
|
||||
return
|
||||
end
|
||||
|
||||
--
|
||||
BattleLogManager.Log(
|
||||
BattleLogManager.Log(
|
||||
"Camp Change",
|
||||
"camp", CurCamp
|
||||
)
|
||||
|
@ -280,7 +284,6 @@ function BattleLogic.TurnRound(debugTurn)
|
|||
end)
|
||||
end
|
||||
|
||||
|
||||
function BattleLogic.WaitForTrigger(delayTime, action)
|
||||
delayTime = BattleUtil.ErrorCorrection(delayTime)
|
||||
local delayFrame = floor(delayTime * BattleLogic.GameFrameRate + 0.5)
|
||||
|
@ -374,7 +377,7 @@ function BattleLogic.BattleEnd(result)
|
|||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleEnd, result)
|
||||
-- 战斗日志写入
|
||||
if not BattleLogic.GetIsDebug() then
|
||||
BattleLogManager.WriteFile()
|
||||
BattleLogManager.WriteLogToFile("a")
|
||||
end
|
||||
end
|
||||
--
|
||||
|
|
|
@ -49,7 +49,7 @@ BattleEventName = {
|
|||
RoleRelive = indexAdd(), -- 角色复活了
|
||||
FinalDamage = indexAdd(),
|
||||
FinalBeDamage = indexAdd(),
|
||||
|
||||
FinalBeDamageEnd = indexAdd(), --最后被攻击结束
|
||||
HitMiss = indexAdd(),
|
||||
BeHitMiss = indexAdd(),
|
||||
|
||||
|
@ -200,7 +200,11 @@ EnemyType={
|
|||
normal = 0,
|
||||
--boss
|
||||
Boss = 1,
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
CountTypeName = {
|
||||
Add = 1,
|
||||
AddPencent = 2,
|
||||
|
|
|
@ -323,7 +323,7 @@ function BattleUtil.Seckill(skill, atkRole, defRole)
|
|||
end
|
||||
|
||||
-- 计算真实伤害
|
||||
function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType)
|
||||
function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect)
|
||||
bCrit = bCrit or false
|
||||
damageType = damageType or 0
|
||||
|
||||
|
@ -354,10 +354,11 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy
|
|||
end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.FinalDamage, damagingFunc, defRole, damage, skill, dotType, bCrit, damageType)
|
||||
defRole.Event:DispatchEvent(BattleEventName.FinalBeDamage, damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType)
|
||||
defRole.Event:DispatchEvent(BattleEventName.FinalBeDamageEnd, damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.FinalDamage, damagingFunc, atkRole, defRole, damage, skill, dotType, bCrit, damageType)
|
||||
|
||||
--
|
||||
return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType)
|
||||
return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect)
|
||||
end
|
||||
|
||||
|
||||
|
@ -396,7 +397,7 @@ function BattleUtil.GetExtraSkillbyId(id)
|
|||
end
|
||||
end
|
||||
|
||||
function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType)
|
||||
function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType,isDirect)
|
||||
if damage < 0 then damage = 0 end
|
||||
local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage)
|
||||
if finalDmg >= 0 then
|
||||
|
@ -419,6 +420,11 @@ function BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageTy
|
|||
atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
end
|
||||
--如果不是技能带的伤害,并且是直接伤害就,,,,,
|
||||
--用于处理不触发特性并且是直接伤害的伤害 isDirect 暂时先为bool值,后期可根据需求做修改扩展 by:王振兴 2020/10/12 16:18
|
||||
if isDirect and not skill then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
|
@ -529,11 +535,26 @@ function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor)
|
|||
if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血
|
||||
return
|
||||
end
|
||||
-- 是否暴击: 暴击率 = 自身暴击率 - 对方抗暴率
|
||||
local bCrit = false
|
||||
local critRandom = Random.Range01()
|
||||
local critCondition = castRole:GetRoleData(RoleDataName.Crit)
|
||||
bCrit = critRandom <= critCondition
|
||||
bCrit = bCrit or targetRole.isFlagCrit == true -- 必定暴击
|
||||
-- 计算暴伤害系数
|
||||
local critDamageFactor = 1
|
||||
--计算暴击
|
||||
if bCrit then
|
||||
--伤害有个+1.3 不知道干什么用的就给去了 by:wangxhenxing 2020/10/10 18:46
|
||||
critDamageFactor = 1.3 + castRole:GetRoleData(RoleDataName.CritDamageFactor)
|
||||
end
|
||||
-- 基础伤害增加系数
|
||||
local addDamageFactor = 1 + castRole:GetRoleData(RoleDataName.DamageBocusFactor)
|
||||
targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole)
|
||||
BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
||||
BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor)
|
||||
end
|
||||
|
||||
function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
||||
function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor,critDamageFactor,addDamageFactor)
|
||||
if targetRole.ctrl_noheal or targetRole:IsDead() then --禁疗和死亡无法加血
|
||||
return
|
||||
end
|
||||
|
@ -550,7 +571,7 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
|||
|
||||
local factor = castRole.isTeam and 1 or castRole:GetRoleData(RoleDataName.TreatFacter) --释放者为team则不计算治疗加成属性
|
||||
local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter)
|
||||
local baseTreat = BattleUtil.FP_Mul(value, baseFactor, factor, factor2)
|
||||
local baseTreat = BattleUtil.FP_Mul(value, baseFactor, factor, factor2,critDamageFactor,addDamageFactor)
|
||||
|
||||
--加入被动效果
|
||||
local cl = {}
|
||||
|
|
|
@ -24,6 +24,7 @@ function RoleLogic.New()
|
|||
end
|
||||
|
||||
function RoleLogic:Init(uid, data, position)
|
||||
data.star = data.star or 1
|
||||
self.uid = uid
|
||||
self.position = position
|
||||
self.roleData = data
|
||||
|
|
|
@ -78,6 +78,10 @@ end
|
|||
|
||||
--
|
||||
function this.Update()
|
||||
-- 如果正在引导战斗
|
||||
if BattleManager and BattleManager.IsGuidePause() then
|
||||
return
|
||||
end
|
||||
--
|
||||
if this.IsSkilling then
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue