战斗逻辑

back_recharge
lvxinran 2019-11-13 19:06:21 +08:00
parent dd46d9e219
commit d7817a55a7
4 changed files with 87 additions and 43 deletions

View File

@ -96,7 +96,8 @@ local effectList = {
local f1 = args[2]
local f2 = args[3]
BattleLogic.WaitForTrigger(interval, function ()
target:AddBuff(Buff.Create(caster, BuffName.HOT, f2, 1, floor(caster:GetRoleData(propertyList[pro1]) * f1)))
local val = floor(BattleUtil.FP_Mul(f1, caster:GetRoleData(propertyList[pro1])))
target:AddBuff(Buff.Create(caster, BuffName.HOT, f2, 1, val))
end)
end,
--造成[a]到[b]次[c]%的[d]伤害
@ -156,7 +157,8 @@ local effectList = {
local f2 = args[3]
local f3 = args[4]
BattleLogic.WaitForTrigger(interval, function ()
target:AddBuff(Buff.Create(caster, BuffName.Shield, f2, floor(caster:GetRoleData(propertyList[pro1]) * f1), f3))
local val = floor(BattleUtil.FP_Mul(f1, caster:GetRoleData(propertyList[pro1])))
target:AddBuff(Buff.Create(caster, BuffName.Shield, f2, val, f3))
end)
end,
--造成[a]%的[b]伤害,自身恢复造成伤害[c]%的生命
@ -317,7 +319,7 @@ local effectList = {
local i1 = args[4]
if i1 == 0 then
i1 = floor(interval * BattleLogic.GameFrameRate)
i1 = floor(interval*BattleLogic.GameFrameRate)
end
local count = 1
while Random.Range01() <= f2 and count <= i1 do
@ -399,7 +401,8 @@ local effectList = {
local pro1 = args[1]
local f1 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.CalTreat(caster, target, floor(caster:GetRoleData(propertyList[pro1]) * f1))
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1]), f1))
BattleUtil.CalTreat(caster, target, val)
end)
end,
--对[a]的伤害[b]%,持续[c]秒
@ -798,7 +801,9 @@ local effectList = {
local d = args[2]
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.ApplyDamage(caster, target, min(floor(caster:GetRoleData(propertyList[pro])*d), floor(caster:GetRoleData(RoleDataName.Attack)*2.5)))
local v1 = BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro]), d)
local v2 = BattleUtil.FP_Mul(caster:GetRoleData(RoleDataName.Attack), 2.5)
BattleUtil.ApplyDamage(caster, target, floor(min(v1, v2)))
end)
end,
--造成[a]%的[b]伤害,提升自身下个技能[c]%的伤害
@ -906,7 +911,8 @@ local effectList = {
end
return b
end) then
BattleUtil.ApplyDamage(caster, target, floor(caster:GetRoleData(RoleDataName.Attack) * f2 * layer))
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(RoleDataName.Attack), f2, layer))
BattleUtil.ApplyDamage(caster, target, val)
brandBuff.disperse = true
if brandBuff.linkBuff1 then
brandBuff.linkBuff1.disperse = true
@ -939,7 +945,8 @@ local effectList = {
local f2 = args[4]
local ct = args[5]
BattleLogic.WaitForTrigger(interval, function ()
target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro2], floor(caster:GetRoleData(propertyList[pro1]) * f1), ct))
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1], f1)))
target:AddBuff(Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro2], val, ct))
end)
end,
--清除[a]状态
@ -977,7 +984,8 @@ local effectList = {
local i1 = args[2]
caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, interval, target)
BattleLogic.WaitForTrigger(interval, function ()
local damage = BattleUtil.ApplyDamage(caster, target, floor(target:GetRoleData(RoleDataName.Hp) * f1))
local val = floor(BattleUtil.FP_Mul(target:GetRoleData(RoleDataName.Hp), f1))
local damage = BattleUtil.ApplyDamage(caster, target, val)
local arr = BattleUtil.ChooseTarget(caster, 10110)
local count = min(#arr, i1)
local heal = floor(damage / count)
@ -1130,15 +1138,15 @@ local effectList = {
end)
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
damagingFunc(-floor(f2*factor*damage))
damagingFunc(-floor(BattleUtil.FP_Mul(f2, factor, damage)))
end
caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
BattleUtil.CalDamage(caster, target, dt, f1)
caster.Event:RemoveEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
end)
end,
--造成[a]%的[b]伤害,[c]的概率造成眩晕,持续[d]秒。若未造成眩晕则为随机1名敌人施加增伤印记。(减益印记,不可驱散)
--a[float],b[伤害类型],c[float],d[int]
--造成[a]%的[b]伤害,[c]的概率造成眩晕,持续[d]秒。若未造成眩晕则为随机1名敌人施加增伤印记。最大[e]层(减益印记,不可驱散)
--a[float],b[伤害类型],c[float],d[int],e[int]
[65] = function(caster, target, args, interval)
local f1 = args[1]
local dt = args[2]
@ -1185,7 +1193,7 @@ local effectList = {
return b
end) then
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
damagingFunc(-floor(f3*layer*damage))
damagingFunc(-floor(BattleUtil.FP_Mul(f3, layer, damage)))
end
caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
BattleUtil.CalDamage(caster, target, dt, f1)
@ -1229,7 +1237,8 @@ local effectList = {
local f3 = args[4]
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.CalDamage(caster, target, dt, f1)
local dot = Buff.Create(caster, BuffName.DOT, f3, 1, 0, floor(caster:GetRoleData(RoleDataName.MaxHp)*f2), 1)
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(RoleDataName.MaxHp), f2))
local dot = Buff.Create(caster, BuffName.DOT, f3, 1, 0, val, 1)
dot.isRealDamage = true
target:AddBuff(dot)
end)
@ -1240,7 +1249,7 @@ local effectList = {
local f1 = args[1]
local pro1 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
local hp = min(floor(target:GetRoleData(propertyList[pro1]) * f1), target:GetRoleData(RoleDataName.Hp)-1)
local hp = min(floor(BattleUtil.FP_Mul(target:GetRoleData(propertyList[pro1]), f1)), target:GetRoleData(RoleDataName.Hp)-1)
target.data:SubValue(RoleDataName.Hp, hp)
end)
end,
@ -1253,7 +1262,7 @@ local effectList = {
BattleLogic.WaitForTrigger(interval, function ()
local factor = 1 - BattleUtil.GetHPPencent(caster)
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
damagingFunc(-floor(f2*factor*damage))
damagingFunc(-floor(BattleUtil.FP_Mul(f2, factor, damage)))
end
caster.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
BattleUtil.CalDamage(caster, target, dt, f1)
@ -1332,7 +1341,8 @@ local effectList = {
local f1 = args[3]
BattleLogic.WaitForTrigger(interval, function ()
BattleUtil.RandomAction(f2, function ()
BattleUtil.CalTreat(caster, target, floor(caster:GetRoleData(propertyList[pro1]) * f1))
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1]), f1))
BattleUtil.CalTreat(caster, target, val)
end)
end)
end,
@ -1459,7 +1469,8 @@ local effectList = {
end
return b
end)
local shield = Buff.Create(caster, BuffName.Shield, f2, floor(caster:GetRoleData(propertyList[pro1])*f1*(1+layer*f3)), 0)
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1]), f1, 1+layer*f3))
local shield = Buff.Create(caster, BuffName.Shield, f2, val, 0)
target:AddBuff(shield)
local brand = Buff.Create(caster, BuffName.Brand, 0, "shieldLayerFlag")
@ -1482,7 +1493,8 @@ local effectList = {
BattleUtil.CalDamage(caster, target, dt, f1)
local OnBuffStart = function(buff)
if buff.type == BuffName.Control then
BattleUtil.CalTreat(buff.caster, buff.target, floor(buff.target:GetRoleData(propertyList[pro1]) * f2))
local val = floor(BattleUtil.FP_Mul(buff.target:GetRoleData(propertyList[pro1]), f2))
BattleUtil.CalTreat(buff.caster, buff.target, val)
end
end
caster.Event:AddEvent(BattleEventName.BuffStart, OnBuffStart)
@ -1560,12 +1572,15 @@ local effectList = {
local f2 = args[3]
local f3 = args[4]
BattleLogic.WaitForTrigger(interval, function ()
local shield = Buff.Create(caster, BuffName.Shield, f2, floor(caster:GetRoleData(propertyList[pro1])*f1), 0)
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1]), f1))
local shield = Buff.Create(caster, BuffName.Shield, f2, val, 0)
local OnBuffEnd = function(buff)
if buff == shield and buff.framePass < buff.frameDuration then --护盾被击破
local arr = BattleUtil.ChooseTarget(target, 20000)
for i=1, #arr do
BattleUtil.ApplyDamage(target, arr[i], min(floor(arr[i]:GetRoleData(RoleDataName.MaxHp)*f3), caster:GetRoleData(RoleDataName.Attack)*2.5))
local v1 = BattleUtil.FP_Mul(arr[i]:GetRoleData(RoleDataName.MaxHp), f3)
local v2 = BattleUtil.FP_Mul(caster:GetRoleData(RoleDataName.Attack),2.5)
BattleUtil.ApplyDamage(target, arr[i], floor(min(v1, v2)))
end
end
end
@ -1590,7 +1605,8 @@ local effectList = {
local f4 = args[8]
local ct2 = args[9]
BattleLogic.WaitForTrigger(interval, function ()
local shield = Buff.Create(caster, BuffName.Shield, f2, floor(caster:GetRoleData(propertyList[pro1]) * f1), 0)
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1]), f1))
local shield = Buff.Create(caster, BuffName.Shield, f2, val, 0)
local buff1 = Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro2], f3, ct1)
local buff2 = Buff.Create(caster, BuffName.PropertyChange, f2, propertyList[pro3], f4, ct2)
@ -1687,7 +1703,8 @@ local effectList = {
local f2 = args[4]
local f3 = args[5]
BattleLogic.WaitForTrigger(interval, function ()
buffRandomAction(f4, target, Buff.Create(caster, BuffName.HOT, f2, f2/f3, floor(caster:GetRoleData(propertyList[pro1])*f1)))
local val = floor(BattleUtil.FP_Mul(caster:GetRoleData(propertyList[pro1]), f1))
buffRandomAction(f4, target, Buff.Create(caster, BuffName.HOT, f2, f2/f3, val))
end)
end,
--造成[a]%的[b]伤害,如果击杀,则其他人受到[c]%的溢出伤害

View File

@ -109,7 +109,8 @@ local passivityList = {
BattleUtil.RandomAction(f1, function ()
local arr = BattleUtil.ChooseTarget(role, 10321)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.HOT, f3, 1, floor(role:GetRoleData(propertyList[pro]) * f2)))
local val = floor(BattleUtil.FP_Mul(f2, role:GetRoleData(propertyList[pro])))
arr[1]:AddBuff(Buff.Create(role, BuffName.HOT, f3, 1, val))
end
end)
end
@ -129,7 +130,8 @@ local passivityList = {
BattleUtil.RandomAction(f1, function ()
local arr = BattleUtil.ChooseTarget(role, 10001)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro2], floor(role:GetRoleData(propertyList[pro1]) * f2), 1))
local val = floor(BattleUtil.FP_Mul(f2, role:GetRoleData(propertyList[pro1])))
arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro2], val, 1))
end
end)
end
@ -159,7 +161,8 @@ local passivityList = {
local OnBeHit = function(treatingFunc)
BattleUtil.RandomAction(f1, function ()
BattleUtil.CalTreat(role, role, floor(role:GetRoleData(propertyList[pro]) * f2))
local val = floor(BattleUtil.FP_Mul(f2, role:GetRoleData(propertyList[pro])))
BattleUtil.CalTreat(role, role, val)
end)
end
role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
@ -219,7 +222,7 @@ local passivityList = {
local OnPassiveDamaging = function(damagingFunc, atkRole, damage)
BattleUtil.RandomAction(f1, function ()
damagingFunc(floor(role:GetRoleData(propertyList[pro]) * f2))
damagingFunc(floor(BattleUtil.FP_Mul(f2, role:GetRoleData(propertyList[pro]))))
end)
end
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, OnPassiveDamaging)
@ -271,7 +274,8 @@ local passivityList = {
BattleUtil.RandomAction(f1, function ()
local arr = BattleUtil.ChooseTarget(role, 20001)
if arr[1] then
BattleUtil.ApplyDamage(role, arr[1], floor(role:GetRoleData(propertyList[pro]) * f2))
local val = floor(BattleUtil.FP_Mul(f2, role:GetRoleData(propertyList[pro])))
BattleUtil.ApplyDamage(role, arr[1], val)
end
end)
lastTrigger = 0
@ -465,7 +469,8 @@ local passivityList = {
local OnDead = function(atkRole)
local arr = BattleUtil.ChooseTarget(role, 10000)
for i=1, #arr do
BattleUtil.CalTreat(role, arr[i], floor(role:GetRoleData(propertyList[pro]) * f1))
local val = floor(BattleUtil.FP_Mul(f1, role:GetRoleData(propertyList[pro])))
BattleUtil.CalTreat(role, arr[i], val)
end
end
role.Event:AddEvent(BattleEventName.RoleDead, OnDead)
@ -541,7 +546,8 @@ local passivityList = {
local OnRoleCrit = function(defRole)
BattleUtil.RandomAction(f1, function ()
BattleUtil.CalTreat(role, role, floor(role:GetRoleData(propertyList[pro]) * f2))
local val = floor(BattleUtil.FP_Mul(f2, role:GetRoleData(propertyList[pro])))
BattleUtil.CalTreat(role, role, val)
end)
end
role.Event:AddEvent(BattleEventName.RoleCrit, OnRoleCrit)
@ -995,7 +1001,8 @@ local passivityList = {
return
end
BattleUtil.RandomAction(f1, function ()
BattleUtil.ApplyDamage(role, defRole, floor(role:GetRoleData(RoleDataName.Attack) * f2))
local val = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Attack), f2))
BattleUtil.ApplyDamage(role, defRole, val)
end)
lastTrigger = 0
end
@ -1012,7 +1019,9 @@ local passivityList = {
if lastTrigger > 1 then --加入限定避免循环触发
return
end
BattleUtil.ApplyDamage(role, defRole, math.min(floor(defRole:GetRoleData(RoleDataName.MaxHp) * f1), floor(role:GetRoleData(RoleDataName.Attack)*2.5)))
local ar1 = BattleUtil.FP_Mul(defRole:GetRoleData(RoleDataName.MaxHp), f1)
local ar2 = BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Attack), 2.5)
BattleUtil.ApplyDamage(role, defRole, floor(math.min(ar1, ar2)))
lastTrigger = 0
end
role.Event:AddEvent(BattleEventName.RoleCrit, OnRoleCrit)
@ -1128,7 +1137,9 @@ local passivityList = {
local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType)
if not bCrit then
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, RoleDataName.Attack, math.min(floor(role:GetRoleData(RoleDataName.Attack) * f3), floor(damage * f1)), 1))
local ar1 = BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Attack), f3)
local ar2 = BattleUtil.FP_Mul(damage, f1)
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, RoleDataName.Attack, floor(math.min(ar1, ar2)), 1))
end
end
role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
@ -1145,7 +1156,8 @@ local passivityList = {
BattleUtil.RandomAction(f1, function ()
local list = BattleLogic.GetNeighbor(role, 1)
for i=1, #list do
list[i]:AddBuff(Buff.Create(role, BuffName.Shield, f3, floor(role:GetRoleData(propertyList[pro]) * f2), 0))
local val = floor(BattleUtil.FP_Mul(role:GetRoleData(propertyList[pro]), f2))
list[i]:AddBuff(Buff.Create(role, BuffName.Shield, f3, val, 0))
end
end)
end
@ -1165,7 +1177,8 @@ local passivityList = {
if skill.owner.camp == role.camp then
if BattleLogic.BuffMgr:HasBuff(role, BuffName.Shield, function (buff) return true end) then
BattleUtil.RandomAction(f1, function ()
BattleUtil.CalTreat(skill.owner, skill.owner, floor(role:GetRoleData(propertyList[pro1]) * f2))
local val = floor(BattleUtil.FP_Mul(role:GetRoleData(propertyList[pro1]), f2))
BattleUtil.CalTreat(skill.owner, skill.owner, val)
end)
end
end
@ -1177,7 +1190,7 @@ local passivityList = {
local f1 = args[1]
local OnPassiveDamaging = function(damagingFunc, atkRole, damage)
damagingFunc(floor(damage*f1*(1-BattleUtil.GetHPPencent(role))))
damagingFunc(floor(BattleUtil.FP_Mul(f1, damage,1-BattleUtil.GetHPPencent(role))))
end
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, OnPassiveDamaging)
end,
@ -1245,7 +1258,8 @@ local passivityList = {
local OnBeHit = function(atkRole, damage, bCrit, finalDmg, damageType)
BattleUtil.RandomAction(f1, function ()
role:AddBuff(Buff.Create(role, BuffName.Shield, f3, floor(role:GetRoleData(propertyList[pro1]) * f2), 0))
local val = floor(BattleUtil.FP_Mul(role:GetRoleData(propertyList[pro1]), f2))
role:AddBuff(Buff.Create(role, BuffName.Shield, f3, val, 0))
end)
end
role.Event:AddEvent(BattleEventName.RoleBeHit, OnBeHit)
@ -1264,10 +1278,13 @@ local passivityList = {
return
end
if bCrit then
BattleUtil.ApplyDamage(role, defRole, math.min(floor(defRole:GetRoleData(RoleDataName.MaxHp) * f1), floor(role:GetRoleData(RoleDataName.Attack)*2.5)))
local ar1 = BattleUtil.FP_Mul(defRole:GetRoleData(RoleDataName.MaxHp), f1)
local ar2 = BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Attack), 2.5)
BattleUtil.ApplyDamage(role, defRole, floor(math.min(ar1, ar2)))
else
BattleUtil.RandomAction(f2, function ()
BattleUtil.ApplyDamage(role, defRole, floor(role:GetRoleData(RoleDataName.Attack) * f3))
local val = floor(BattleUtil.FP_Mul(role:GetRoleData(RoleDataName.Attack), f3))
BattleUtil.ApplyDamage(role, defRole, val)
end)
end
lastTrigger = 0

View File

@ -188,7 +188,11 @@ function BattleLogic.StartOrder()
end
function BattleLogic.GetTeamSkill(camp, pos)
return camp == 0 and playerTeamSkillList[pos] or enemyTeamSkillList[pos]
if camp == 0 then
return playerTeamSkillList[pos]
else
return enemyTeamSkillList[pos]
end
end
function BattleLogic.GetTeamSkillCastSlider()
@ -536,12 +540,12 @@ function BattleLogic.RecordRoleProperty(uid, camp, name, value, delta)
end
--Record专用
function BattleLogic.RecordDamage(args)
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, damageArgs:%s", curFrame, str))
table.insert(record, string.format("frame:%d, mulArgs:%s", curFrame, str))
end
--Record专用

View File

@ -29,7 +29,7 @@ function BattleUtil.FP_Mul(...)
f = floor(f * v * 100000 + 0.5) / 100000
end
if BattleLogic.IsOpenBattleRecord then
BattleLogic.RecordDamage({...})
BattleLogic.RecordMul({...})
end
return f
end
@ -226,6 +226,7 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
local factorFunc = function(exFactor) baseFactor = baseFactor + exFactor end
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageBefore, defRole, factorFunc, damageType)
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedBefore, atkRole, factorFunc, damageType)
baseFactor = BattleUtil.ErrorCorrection(baseFactor)
local bCrit = false
local baseDamage
@ -279,7 +280,12 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
atkEle == 3 and defEle == 1 or
atkEle == 5 and defEle == 6 or
atkEle == 6 and defEle == 5
baseDamage = restrain and floor(max(baseDamage*1.25, 0.1*attack)) or floor(max(baseDamage, 0.1*attack))
if restrain then
baseDamage = floor(max(BattleUtil.FP_Mul(1.25, baseDamage), BattleUtil.FP_Mul(0.1, attack)))
else
baseDamage = floor(max(baseDamage, BattleUtil.FP_Mul(0.1, attack)))
end
for i=1, atkRole.exCalDmgList.size do
local func = atkRole.exCalDmgList.buffer[i]