战斗 修改

back_recharge
lvxinran 2020-04-16 16:27:42 +08:00
parent 9fb69b69bf
commit 079f317dec
5 changed files with 129 additions and 94 deletions

View File

@ -2113,19 +2113,17 @@ local effectList = {
-- 造成[a]%的[b]伤害然后对仇恨目标追加一次1技能追加的1技能不回怒气技能101的弹道特效版删除
-- a[float],b[伤害类型]
-- [112] = function(caster, target, args, interval, skill)
-- local f1 = args[1]
-- local dt = args[2]
-- caster.Event:DispatchEvent(BattleEventName.RoleViewBullet, skill, target)
-- BattleLogic.WaitForTrigger(interval, function ()
-- BattleUtil.CalDamage(skill, caster, target, dt, f1)
-- end)
-- -- 对仇恨目标追加一次技能
-- caster:AddSkill(BattleSkillType.Normal, false, true, {{target}})
-- end,
-- 自身[a]增加[b]%持续[c]回合,效果可叠加,[d]改变
-- a[属性]b[float]c[int]d[改变类型]
[112] = function(caster, target, args, interval, skill)
local pro = args[1]
local f1 = args[2]
local i1 = args[3]
local ct = args[4]
BattleLogic.WaitForTrigger(interval, function ()
caster:AddBuff(Buff.Create(caster, BuffName.PropertyChange, i1, propertyList[pro], f1, ct))
end)
end,
--造成[a]%的[b]伤害,对[c]有[d]%造成[e],持续[f]秒 技能21的弹道特效版
--a[float],b[伤害类型,]c[持续伤害状态],d[float],e[控制状态],f[int]
@ -2144,7 +2142,7 @@ local effectList = {
end
end)
end,
-- 造成[a]%的[b]伤害如目标[c]则本次技能暴击率提高[d]%
-- a[float]b[伤害类型]c[持续伤害状态]d[float]
[114] = function(caster, target, args, interval, skill)

View File

@ -1518,13 +1518,15 @@ local passivityList = {
role.data:CountValue(propertyList[pro], f1, ct)
end,
-- 技能伤害增加[a]
-- a[float]
-- 技能伤害增加[a]%[b]改变
-- a[float]b[改变类型]
[91] = function(role, args)
local f1 = args[1]
local ct = args[2]
local passivityDamaging = function(func, caster, damage)
if func then
func(-floor(BattleUtil.ErrorCorrection(damage*f1)))
local dd = BattleUtil.CountValue(damage, f1, ct) - damage
func(-floor(BattleUtil.ErrorCorrection(dd)))
end
end
local OnSkillCast = function(skill)
@ -1603,13 +1605,15 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.RoleTurnEnd, onTurnEnd)
end,
-- 普攻伤害增加[a]
-- a[float]
-- 普攻伤害增加[a]%[b]改变
-- a[float]b[改变类型]
[96] = function(role, args)
local f1 = args[1]
local ct = args[2]
local passivityDamaging = function(func, caster, damage)
if func then
func(-floor(BattleUtil.ErrorCorrection(damage*f1)))
local dd = BattleUtil.CountValue(damage, f1, ct) - damage
func(-floor(BattleUtil.ErrorCorrection(dd)))
end
end
local OnSkillCast = function(skill)
@ -1736,15 +1740,16 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd)
end,
-- 直接伤害每次击杀目标增加[a]%的[b]可叠加持续至战斗结束
-- a[float]b[属性]
-- 直接伤害每次击杀目标增加[a]%的[b]可叠加持续至战斗结束[c]改变
-- a[float]b[属性]c[改变类型]
[103] = function(role, args)
local f1 = args[1]
local pro = args[2]
local ct = args[3]
-- 释放技能后
local onRoleHit = function(defRole)
if defRole.isDead then
local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, CountTypeName.AddPencent)
local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, ct)
-- buff.cover = true
role:AddBuff(buff)
end
@ -1945,18 +1950,19 @@ local passivityList = {
end,
-- 战斗第[a]回合增加[b]%的[c],持续[d]回合
-- a[int]b[float]c[属性]d[int]
-- 战斗第[a]回合增加[b]%的[c],持续[d]回合,[f]改变
-- a[int]b[float]c[属性]d[int]f[改变类型]
[115] = function(role, args)
local i1 = args[1]
local f1 = args[2]
local pro = args[3]
local i2 = args[4] or 1
local ct = args[5]
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, function(curRound)
-- 第i1回合
if curRound == i1 then
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, i2, propertyList[pro], f1, CountTypeName.AddPencent))
role:AddBuff(Buff.Create(role, BuffName.PropertyChange, i2, propertyList[pro], f1, ct))
end
end)
end,
@ -1977,12 +1983,13 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
end,
-- 技能目标每[a]改变[b]个,技能伤害增加[c]%
-- a[改变类型]b[int]c[float]
-- 技能目标每[a]改变[b]个,技能伤害增加[c]%[d]改变
-- a[改变类型]b[int]c[float]d[改变类型]
[117] = function(role, args)
local ct = args[1] -- 对方阵营中死亡数量
local i1 = args[2]
local f1 = args[3]
local ct2 = args[4]
-- 每次释放技能时提前计算额外加成的伤害
@ -2001,7 +2008,8 @@ local passivityList = {
-- 如果是技能的伤害则判断加成
local onPassiveDamaging = function(func, target, damage, skill)
if skill and skill.type == BattleSkillType.Special then
if func then func(-floor(BattleUtil.ErrorCorrection(extra*damage))) end
local dd = BattleUtil.CountValue(damage, extra, ct2) - damage
if func then func(-floor(BattleUtil.ErrorCorrection(dd))) end
end
end
role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging)
@ -2009,33 +2017,31 @@ local passivityList = {
-- 每次释放技能,技能伤害增加[a]%,无限叠加释放普攻时清除加成
-- a[float]
-- 每次释放技能,技能伤害增加[a]%,无限叠加释放普攻时清除加成[b]改变
-- a[float]b[改变类型]
[118] = function(role, args)
local f1 = args[1]
local addList = {}
-- 释放技能后
local onSkillEnd = function(skill)
if skill.type == BattleSkillType.Special then
local addDamage = function(target, func)
if func then func(f1) end
end
role.Event:AddEvent(BattleEventName.RoleDamageBefore, addDamage)
-- 加入管理
table.insert(addList, {BattleEventName.RoleDamageBefore, addDamage})
end
end
local ct = args[2]
local af = 0
local onSkillCast = function(skill)
if skill.type == BattleSkillType.Normal then
-- 清除加成
for _, e in ipairs(addList) do
role.Event:RemoveEvent(e[1], e[2])
end
addList = {}
af = 0
elseif skill.type == BattleSkillType.Normal then
af = af + f1
end
end
role.Event:AddEvent(BattleEventName.SkillCastEnd, onSkillEnd)
role.Event:AddEvent(BattleEventName.SkillCast, onSkillCast)
-- 如果是技能的伤害则判断加成
local onPassiveDamaging = function(func, target, damage, skill)
if skill and skill.type == BattleSkillType.Special then
local dd = BattleUtil.CountValue(damage, af, ct) - damage
if func then func(-floor(BattleUtil.ErrorCorrection(dd))) end
end
end
role.Event:AddEvent(BattleEventName.PassiveDamaging, onPassiveDamaging)
end,
-- 普攻后[a]改变自身[b]%的[c]持续[d]回合可叠加
-- a[改变类型]b[float]c[属性]d[int]
@ -2161,7 +2167,6 @@ local passivityList = {
role.Event:AddEvent(BattleEventName.RoleHit, onRoleHit)
end,
-- TODO
-- 战斗中生命每减少[c]%[d]就[e]改变[f]%
-- c[float]d[属性]e[改变类型]f[float]
[126] = function(role, args)

View File

@ -54,7 +54,6 @@ local MyTeamSkillCastIndex
local EnemyTeamSkillCastIndex
-- local maxFrame --战斗最大用时,超时判负
local actionPool = BattleObjectPool.New(function ()
return { 0, 0 }
@ -73,7 +72,6 @@ function BattleLogic.Init(data, optionData)
record = {}
end
-- maxFrame = BattleLogic.GameFrameRate * maxTime
fightData = data
if optionData then
optionRecord = optionData
@ -520,10 +518,6 @@ end
function BattleLogic.Update()
curFrame = curFrame + 1
-- if curFrame > maxFrame then
-- BattleLogic.BattleEnd(0)
-- return
-- end
if bMyAllDead then
BattleLogic.BattleEnd(0)
return

View File

@ -41,11 +41,13 @@ BattleEventName = {
RoleTurnEnd = indexAdd(), -- 角色回合结束
RoleRageGrow = indexAdd(), -- 角色怒气成长
RoleRageCost = indexAdd(), -- 角色怒气消耗
RoleRageChange = indexAdd(), -- 角色怒气变化
RoleControl = indexAdd(), -- 角色释放控制技能
RoleBeControl = indexAdd(), -- 角色被控制
SkillCast = indexAdd(), -- 技能攻击前
SkillCastEnd = indexAdd(), -- 技能攻击结束
BeSkillCast = indexAdd(), -- 被技能攻击前
BeSkillCastEnd = indexAdd(), -- 被技能攻击结束
SkillRandomBuff = indexAdd(), -- 技能控制时
@ -54,6 +56,8 @@ BattleEventName = {
PassiveBeDamaging = indexAdd(),
PassiveDamaging = indexAdd(),
PassiveCriting = indexAdd(),
PassiveTreatingFactor = indexAdd(),
PassiveBeTreatedFactor = indexAdd(),
AOE = indexAdd(),
@ -133,8 +137,8 @@ BattleSkillType = {
CountTypeName = {
Add = 1,
AddPencent = 2,
Sub = 2,
SubPencent = 2,
Sub = 3,
SubPencent = 4,
}
ShieldTypeName = {

View File

@ -41,6 +41,9 @@ function BattleUtil.ChooseFRow(arr)
table.insert(tempArr, r)
end
end
table.sort(tempArr, function(a, b)
return a.position < b.position
end)
return tempArr
end
-- 选择后排
@ -51,6 +54,9 @@ function BattleUtil.ChooseBRow(arr)
table.insert(tempArr, r)
end
end
table.sort(tempArr, function(a, b)
return a.position < b.position
end)
return tempArr
end
-- 选择一列(col == 0 表示第三列哦)
@ -61,6 +67,9 @@ function BattleUtil.ChooseCol(arr, col)
table.insert(tempArr, role)
end
end
table.sort(tempArr, function(a, b)
return a.position < b.position
end)
return tempArr
end
-- 根据属性排序
@ -161,6 +170,8 @@ function BattleUtil.ChooseTarget(role, chooseId)
BattleUtil.SortByProp(arr, RoleDataName.MagicDefence, sort)
elseif chooseWeight == 7 then -- 对位及其相邻目标
arr = BattleLogic.GetNeighbor(role, chooseType)
elseif chooseWeight == 8 then -- 对位
arr = BattleLogic.GetArrAggroList(role, arr)
-- elseif chooseWeight == 9 then -- 展位距离
-- BattleUtil.Sort(arr, function(a, b)
-- local r1 = math.abs(role.position - a.position) * 10 + a.position
@ -168,7 +179,18 @@ function BattleUtil.ChooseTarget(role, chooseId)
-- if sort == 1 then return r1 > r2 else return r1 < r2 end
-- end)
end
return arr
local finalArr = {}
if num == 0 then
finalArr = arr
else
for i = 1, num do
if arr[i] then
table.insert(finalArr, arr[i])
end
end
end
return finalArr
end
@ -224,27 +246,27 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy
damageType = damageType or 0
isDot = isDot or false
if atkRole.isTeam then
--max技能基础伤害*1+已方异妖伤害加成-目标异妖伤害减免30%×技能基础伤害)
local arr = BattleLogic.Query(function (r) return r.camp == atkRole.camp end)
local n = 0
for i=1, #arr do
n = n + arr[i]:GetRoleData(RoleDataName.TeamDamageBocusFactor)
end
damage = floor(max(damage * (1 + n / #arr - defRole:GetRoleData(RoleDataName.TeamDamageReduceFactor)), 0.3 * damage))
end
-- if atkRole.isTeam then
-- --max技能基础伤害*1+已方异妖伤害加成-目标异妖伤害减免30%×技能基础伤害)
-- local arr = BattleLogic.Query(function (r) return r.camp == atkRole.camp end)
-- local n = 0
-- for i=1, #arr do
-- n = n + arr[i]:GetRoleData(RoleDataName.TeamDamageBocusFactor)
-- end
-- damage = floor(max(damage * (1 + n / #arr - defRole:GetRoleData(RoleDataName.TeamDamageReduceFactor)), 0.3 * damage))
-- end
--加入被动效果
local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end
atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage)
defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage)
atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage, skill)
defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage, skill)
-- 计算护盾减伤
damage = BattleUtil.CalShield(atkRole, defRole, damage)
if damage > 0 then
if damage >= 0 then
local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage)
if finalDmg > 0 then
if finalDmg >= 0 then
if defRole:GetRoleData(RoleDataName.Hp) <= 0 then
defRole.isDead = true
BattleLogic.BuffMgr:ClearBuff(defRole)
@ -258,12 +280,12 @@ function BattleUtil.ApplyDamage(skill, atkRole, defRole, damage, bCrit, damageTy
BattleLogic.Event:DispatchEvent(BattleEventName.RoleDamage, atkRole, defRole, damage, bCrit, finalDmg, damageType, isDot, skill)
BattleLogic.Event:DispatchEvent(BattleEventName.RoleBeDamaged, defRole, atkRole, damage, bCrit, finalDmg, damageType, isDot, skill)
if bCrit then
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole, damage, bCrit, finalDmg, damageType)
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole, damage, bCrit, finalDmg, damageType)
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole, damage, bCrit, finalDmg, damageType, skill)
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole, damage, bCrit, finalDmg, damageType, skill)
end
if not isDot then
atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType)
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType)
atkRole.Event:DispatchEvent(BattleEventName.RoleHit, defRole, damage, bCrit, finalDmg, damageType, skill)
defRole.Event:DispatchEvent(BattleEventName.RoleBeHit, atkRole, damage, bCrit, finalDmg, damageType, skill)
end
end
return finalDmg
@ -282,14 +304,16 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i
-- 计算技能额外伤害系数加成
baseFactor = baseFactor or 1
local factorFunc = function(exFactor) baseFactor = baseFactor + exFactor end
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageBefore, defRole, factorFunc, damageType)
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedBefore, atkRole, factorFunc, damageType)
atkRole.Event:DispatchEvent(BattleEventName.RoleDamageBefore, defRole, factorFunc, damageType, skill)
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedBefore, atkRole, factorFunc, damageType, skill)
baseFactor = BattleUtil.ErrorCorrection(baseFactor)
local bCrit = false
local baseDamage
-- 是否暴击: 暴击率 = 自身暴击率 - 对方抗暴率
bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit)-defRole:GetRoleData(RoleDataName.Tenacity), 0, 1)
local critRandom = Random.Range01()
local critCondition = clamp(atkRole:GetRoleData(RoleDataName.Crit)-defRole:GetRoleData(RoleDataName.Tenacity), 0, 1)
bCrit = critRandom <= critCondition
bCrit = bCrit or defRole.isFlagCrit == true -- 必定暴击
-- 防御(据伤害类型决定)
local defence = 0
@ -338,20 +362,23 @@ function BattleUtil.CalDamage(skill, atkRole, defRole, damageType, baseFactor, i
(1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor) - defRole:GetRoleData(elementDamageReduceFactor)))
--属性克制关系:光暗互克,火克风,风克地,地克水,水克火
local atkEle = atkRole.roleData.element
local defEle = defRole.roleData.element
local restrain = atkEle == 1 and defEle == 2 or
atkEle == 4 and defEle == 3 or
atkEle == 2 and defEle == 4 or
atkEle == 3 and defEle == 1 or
atkEle == 5 and defEle == 6 or
atkEle == 6 and defEle == 5
-- local atkEle = atkRole.roleData.element
-- local defEle = defRole.roleData.element
-- local restrain = atkEle == 1 and defEle == 2 or
-- atkEle == 4 and defEle == 3 or
-- atkEle == 2 and defEle == 4 or
-- atkEle == 3 and defEle == 1 or
-- atkEle == 5 and defEle == 6 or
-- atkEle == 6 and defEle == 5
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
-- 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
-- 计算
baseDamage = floor(max(baseDamage, BattleUtil.FP_Mul(0.1, attack)))
-- 计算额外伤害数值加成
local damageFunc = function(damage) baseDamage = damage end
@ -378,6 +405,13 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp)
local hp = targetRole:GetRoleData(RoleDataName.Hp)
-- 计算被动对治疗系数的影响
local treatFactorFunc = function(dt, df)
baseFactor = BattleUtil.CountValue(baseFactor, df, dt)
end
castRole.Event:DispatchEvent(BattleEventName.PassiveTreatingFactor, treatFactorFunc, targetRole)
targetRole.Event:DispatchEvent(BattleEventName.PassiveBeTreatedFactor, treatFactorFunc, castRole)
local factor = castRole.isTeam and 1 or castRole:GetRoleData(RoleDataName.TreatFacter) --释放者为team则不计算治疗加成属性
local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter)
local baseTreat = floor(BattleUtil.FP_Mul(value, baseFactor, factor, factor2) + 0.5)
@ -389,9 +423,9 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
local treat = min(baseTreat, maxHp - hp)
if treat > 0 then
targetRole.data:AddValue(RoleDataName.Hp, treat)
castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat)
targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat)
end
castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat, baseTreat)
targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat, baseTreat)
end
function BattleUtil.RandomAction(rand, action)