战斗逻辑
parent
754bdf965b
commit
824c8239c5
|
|
@ -200,7 +200,6 @@ local function AddRecord(fightData)
|
|||
end
|
||||
end
|
||||
function BattleMain.Execute(args, fightData, optionData)
|
||||
print("trfghjdfgucvhbjnfdcgvj")
|
||||
_seed = args.seed
|
||||
_type = args.type
|
||||
_fightData = fightData
|
||||
|
|
@ -234,7 +233,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量
|
||||
local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true)
|
||||
local arr = RoleManager.Query(function (r) return r.camp == 1 end, true)
|
||||
for i=1, #arr do
|
||||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
|
|
@ -250,7 +249,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
-- print("hp:"..resultList[i])
|
||||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
local curRound, maxRound = BattleLogic.GetCurRound()
|
||||
local curRound, maxRound = BattleLogic.GetCurRound()
|
||||
if curRound > maxRound and _type == 9 then
|
||||
local playerDamage=0
|
||||
local enemyDamage=0
|
||||
|
|
|
|||
|
|
@ -200,7 +200,6 @@ local function AddRecord(fightData)
|
|||
end
|
||||
end
|
||||
function BattleMain.Execute(args, fightData, optionData)
|
||||
print("trfghjdfgucvhbjnfdcgvj")
|
||||
_seed = args.seed
|
||||
_type = args.type
|
||||
_fightData = fightData
|
||||
|
|
@ -234,7 +233,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量
|
||||
local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true)
|
||||
local arr = RoleManager.Query(function (r) return r.camp == 1 end, true)
|
||||
for i=1, #arr do
|
||||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
|
|
@ -250,7 +249,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
-- print("hp:"..resultList[i])
|
||||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
local curRound, maxRound = BattleLogic.GetCurRound()
|
||||
local curRound, maxRound = BattleLogic.GetCurRound()
|
||||
if curRound > maxRound and _type == 9 then
|
||||
local playerDamage=0
|
||||
local enemyDamage=0
|
||||
|
|
|
|||
|
|
@ -2068,6 +2068,9 @@ local effectList = {
|
|||
|
||||
local OnBeHit = function()
|
||||
if not target:IsDead() and BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
|
||||
-- 检测被动技能对秒杀参数得影响
|
||||
f2, f3 = BattleUtil.CheckSeckill(f2, f3, caster, target)
|
||||
--
|
||||
local ft = target:GetRoleData(RoleDataName.Hp)/target:GetRoleData(RoleDataName.MaxHp)
|
||||
if ft < f2 then
|
||||
BattleUtil.RandomAction(f3, function()
|
||||
|
|
|
|||
|
|
@ -2807,9 +2807,12 @@ local passivityList = {
|
|||
local onRoleHit = function(defRole, damage, bCrit, finalDmg, damageType, skill)
|
||||
if skill and skill.type == BattleSkillType.Normal then
|
||||
if BattleLogic.BuffMgr:HasBuff(defRole, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then
|
||||
-- 检测被动技能对秒杀参数得影响
|
||||
local bf, kf = BattleUtil.CheckSeckill(f1, f2, caster, target)
|
||||
--
|
||||
local ft = defRole:GetRoleData(RoleDataName.Hp)/defRole:GetRoleData(RoleDataName.MaxHp)
|
||||
if ft < f1 then
|
||||
BattleUtil.RandomAction(f2, function()
|
||||
if ft < bf then
|
||||
BattleUtil.RandomAction(kf, function()
|
||||
-- 秒杀
|
||||
BattleUtil.Seckill(skill, role, defRole)
|
||||
end)
|
||||
|
|
@ -2981,8 +2984,39 @@ local passivityList = {
|
|||
role.Event:AddEvent(BattleEventName.BeSkillCastEnd, onBeSkillCastEnd)
|
||||
end,
|
||||
|
||||
-- 攻击目标时目标身上每有1种异常状态(包括麻痹、眩晕、沉默、灼烧、中毒)都会使对其造成的直接伤害提高,异常状态数量乘以[a]%。
|
||||
-- a[float]
|
||||
[161] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local function onPassiveDamaging(damagingFunc, target, damage)
|
||||
local list = BattleLogic.BuffMgr:QueryBuff(target, function(buff)
|
||||
return buff.type == BuffName.DOT or buff.type == BuffName.Control
|
||||
end)
|
||||
if list and damagingFunc then
|
||||
local num = #list
|
||||
local dd = BattleUtil.CountValue(damage, f1 * num, CountTypeName.AddPencent) - damage
|
||||
damagingFunc(-floor(BattleUtil.ErrorCorrection(dd)))
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging)
|
||||
end,
|
||||
|
||||
|
||||
-- 爆伤减免增加[a]%,[b]改变
|
||||
-- a[float]b[改变类型]
|
||||
[164] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local ct = args[2]
|
||||
|
||||
local function onPassiveBeDamaging(damagingFunc, target, damage, skill, dotType, bCrit)
|
||||
if bCrit then
|
||||
local dd = damage - BattleUtil.CountValue(damage, f1, CountTypeName.SubPencent)
|
||||
damagingFunc(floor(BattleUtil.ErrorCorrection(dd)))
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, onPassiveBeDamaging)
|
||||
end,
|
||||
|
||||
-- 战斗中生命每减少[a]%,自身伤害就[b]改变[c]%,减少为[d]改变
|
||||
-- a[float]b[改变类型]c[float]d[改变类型]
|
||||
[165] = function(role, args)
|
||||
|
|
@ -3634,6 +3668,90 @@ local passivityList = {
|
|||
end,
|
||||
|
||||
|
||||
--每回合最多受到自身生命上限[a]%的伤害(该伤害为来自武将的直接伤害)
|
||||
--a[float]
|
||||
[199] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local curDamage = 0
|
||||
local function onBattleRoundChange()
|
||||
curDamage = 0
|
||||
end
|
||||
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onBattleRoundChange)
|
||||
|
||||
|
||||
local function onFinalBeDamage(damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType)
|
||||
local maxDamage = role:GetRoleData(RoleDataName.MaxHp) * f1
|
||||
curDamage = curDamage + damage
|
||||
if curDamage < maxDamage then
|
||||
if damagingFunc then damagingFunc(damage) end
|
||||
else
|
||||
-- 计算免除的伤害值
|
||||
local md = curDamage - maxDamage
|
||||
if md > damage then
|
||||
md = damage
|
||||
end
|
||||
if damagingFunc then damagingFunc(md) end
|
||||
end
|
||||
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.FinalBeDamage, onFinalBeDamage)
|
||||
end,
|
||||
|
||||
|
||||
-- 初始怒气增加[a]点并且目标血量低于[b]%时即有概率秒杀(对应秒杀技能)
|
||||
-- a[int]b[float]
|
||||
[200] = function(role, args)
|
||||
local i1 = args[1]
|
||||
local f1 = args[2]
|
||||
role.data:CountValue(RoleDataName.InitRage, i1, CountTypeName.Add)
|
||||
|
||||
local function onPassiveSeckill(func)
|
||||
if func then func(f1, CountTypeName.Cover) end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveSeckill, onPassiveSeckill)
|
||||
end,
|
||||
|
||||
-- 秒杀概率增加[a]%直接伤害击杀的[b]目标有[c]%概率无法复活触发秒杀的目标[d]%无法复活,秒杀概率[e]改变
|
||||
-- a[float]b[持续伤害状态]c[float]d[float]e[改变类型]
|
||||
[201] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local dot = args[2]
|
||||
local f2 = args[3]
|
||||
local f3 = args[4]
|
||||
local ct = args[5]
|
||||
|
||||
-- 秒杀概率增加
|
||||
local function onPassiveSeckill(func)
|
||||
if func then func(nil, nil, f1, ct) end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveSeckill, onPassiveSeckill)
|
||||
|
||||
-- 直接伤害概率无法复活
|
||||
local function onRoleHit(target)
|
||||
if target:IsDead() then
|
||||
if not BattleLogic.BuffMgr:HasBuff(role, BuffName.DOT, function (buff) return buff.dotType == dot or dot == 0 end) then
|
||||
BattleUtil.RandomAction(f2, function()
|
||||
target:SetReliveFilter(false)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
|
||||
|
||||
|
||||
|
||||
-- 秒杀概率无法复活
|
||||
local function onSecKill(target)
|
||||
BattleUtil.RandomAction(f3, function()
|
||||
target:SetReliveFilter(false)
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.Seckill, onSecKill)
|
||||
|
||||
end,
|
||||
|
||||
|
||||
|
||||
|
||||
-- 伤害增加[a]%,[b]改变
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ BattleEventName = {
|
|||
PassiveSkillDamageHeal = indexAdd(),
|
||||
PassiveBeSkillDamageHeal = indexAdd(),
|
||||
|
||||
PassiveSeckill = indexAdd(),
|
||||
PassiveBeSeckill = indexAdd(),
|
||||
Seckill = indexAdd(),
|
||||
BeSeckill = indexAdd(),
|
||||
|
||||
PassiveDamageShare = indexAdd(),
|
||||
PassiveDamageBeShare = indexAdd(),
|
||||
|
||||
|
|
@ -172,6 +177,7 @@ CountTypeName = {
|
|||
AddPencent = 2,
|
||||
Sub = 3,
|
||||
SubPencent = 4,
|
||||
Cover = 5,
|
||||
}
|
||||
|
||||
ShieldTypeName = {
|
||||
|
|
|
|||
|
|
@ -288,6 +288,10 @@ function BattleUtil.Seckill(skill, atkRole, defRole)
|
|||
defRole.Event:DispatchEvent(BattleEventName.RoleDead, atkRole)
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleKill, defRole)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole, atkRole)
|
||||
|
||||
atkRole.Event:DispatchEvent(BattleEventName.SecKill, defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.BeSecKill, atkRole)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.SecKill, atkRole, defRole)
|
||||
end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, false, finalDmg, 0, false, skill)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, false, finalDmg, 0, false, skill)
|
||||
|
|
@ -315,8 +319,8 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy
|
|||
local damagingFunc = function(dmgDeduction)
|
||||
damage = damage - dmgDeduction
|
||||
end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill, dotType)
|
||||
defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill, dotType)
|
||||
atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill, dotType, bCrit)
|
||||
defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill, dotType, bCrit)
|
||||
|
||||
-- 计算护盾减伤
|
||||
damage = BattleUtil.CalShield(atkRole, defRole, damage)
|
||||
|
|
@ -625,6 +629,8 @@ function BattleUtil.CountValue(v1, v2, ct)
|
|||
v = v - v2
|
||||
elseif ct == 4 then --乘减算(百分比属性减算)
|
||||
v = v * (1 - v2)
|
||||
elseif ct == 5 then -- 覆盖
|
||||
v = v2
|
||||
end
|
||||
-- 做一个正确性检测
|
||||
-- v = BattleUtil.ErrorCorrection(v)
|
||||
|
|
@ -635,6 +641,7 @@ end
|
|||
function BattleUtil.CountChangeList(v, changeList)
|
||||
local aplist = {}
|
||||
local splist = {}
|
||||
local cplist = {}
|
||||
local fv = v
|
||||
-- 先算绝对值
|
||||
for _, change in ipairs(changeList) do
|
||||
|
|
@ -647,6 +654,8 @@ function BattleUtil.CountChangeList(v, changeList)
|
|||
table.insert(aplist, change)
|
||||
elseif ct == 4 then
|
||||
table.insert(splist, change)
|
||||
elseif ct == 5 then
|
||||
table.insert(cplist, change)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -662,7 +671,12 @@ function BattleUtil.CountChangeList(v, changeList)
|
|||
local ct = change[2]
|
||||
fv = BattleUtil.CountValue(fv, cv, ct)
|
||||
end
|
||||
|
||||
-- 覆盖
|
||||
for _, change in ipairs(cplist) do
|
||||
local cv = change[1]
|
||||
local ct = change[2]
|
||||
fv = BattleUtil.CountValue(fv, cv, ct)
|
||||
end
|
||||
return fv
|
||||
end
|
||||
|
||||
|
|
@ -681,3 +695,26 @@ function BattleUtil.CheckSkillDamageHeal(f, caster, target)
|
|||
|
||||
return f
|
||||
end
|
||||
|
||||
-- 检测技能伤害治疗加乘
|
||||
function BattleUtil.CheckSeckill(bf, kf, caster, target)
|
||||
|
||||
local bcl = {}
|
||||
local kcl = {}
|
||||
local function _CallBack(bv, bct, kv, kct)
|
||||
if v then
|
||||
if bv and bct then
|
||||
table.insert(bcl, {bv, bct})
|
||||
end
|
||||
if kv and kct then
|
||||
table.insert(kcl, {kv, kct})
|
||||
end
|
||||
end
|
||||
end
|
||||
caster.Event:DispatchEvent(BattleEventName.PassiveSeckill, _CallBack)
|
||||
target.Event:DispatchEvent(BattleEventName.PassiveBeSeckill, _CallBack)
|
||||
bf = BattleUtil.CountChangeList(bf, bcl)
|
||||
kf = BattleUtil.CountChangeList(kf, kcl)
|
||||
|
||||
return bf, kf
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue