战斗逻辑

back_recharge
lvxinran 2020-05-07 15:53:26 +08:00
parent 824c8239c5
commit 8abd2af09c
6 changed files with 95 additions and 3 deletions

View File

@ -2110,6 +2110,19 @@ local effectList = {
end)
end,
-- 给目标附加一个印记,印记效果是己方武将直接攻击敌方非该印记状态的目标时所造成的伤害的[a]会额外再平分给敌方所有处于该印记状态的目标,持续[b]回合
-- a[float]b[int]
[110] = function(caster, target, args, interval, skill)
local f1 = args[1]
local i1 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
local buff = Buff.Create(caster, BuffName.Curse, i1, CurseTypeName.ShareDamage, f1)
target:AddBuff(buff)
end)
end,
-- [a]%概率造成[b],每回合造成[c]%自身[d]的伤害,持续[e]回合
-- a[float]b[持续伤害状态].c[float],d[属性]e[int]
@ -2178,6 +2191,16 @@ local effectList = {
end
end)
end,
-- 回复自身最大生命值的[a]%
-- a[float]
[115] = function(caster, target, args, interval, skill)
local f1 = args[1]
BattleLogic.WaitForTrigger(interval, function ()
local v = floor(BattleUtil.ErrorCorrection(target:GetRoleData(RoleDataName.MaxHp)*f1))
BattleUtil.ApplyTreat(caster, target, v)
end)
end,
}
return effectList

View File

@ -54,7 +54,7 @@ local rolePool = BattleObjectPool.New(function ()
return RoleLogic.New()
end)
function BattleLogic.Init(data, optionData)
function BattleLogic.Init(data, optionData, maxRound)
if BattleLogic.IsOpenBattleRecord then
record = {}
end
@ -74,6 +74,7 @@ function BattleLogic.Init(data, optionData)
curFrame = 0
CurRound = 0
MaxRound = maxRound or 20
_IsDebug = false
@ -250,7 +251,7 @@ function BattleLogic.Update()
BattleLogic.BattleEnd(0)
return
end
if CurRound > 20 then
if CurRound > MaxRound then
BattleLogic.BattleEnd(0)
return
end

View File

@ -0,0 +1,62 @@
Curse = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Curse:SetData(curseType, ...)
self.curseType = curseType
self.args = {...} --标记,结束回调
self.cover = true
-- 刷新排序等级
self.sort = 4
end
--
function Curse:ShareDamageTrigger(atkRole, defRole, damage, skill, dotType, bCrit, damageType)
if skill and defRole.camp == self.target.camp then
-- 没有此印记的队友收到伤害
if not BattleLogic.BuffMgr:HasBuff(defRole, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end) then
-- 计算拥有此印记人的数量
local sdList = RoleManager.Query(function(role)
return role.camp == self.target.camp and BattleLogic.BuffMgr:HasBuff(role, BuffName.Curse, function(buff) return buff.curseType == CurseTypeName.ShareDamage end)
end)
if sdList and #sdList ~= 0 then
-- 计算收到的伤害
local f1 = self.args[1] --平分伤害的百分比
local sd = math.floor(BattleUtil.ErrorCorrection(damage * f1 / #sdList))
BattleUtil.ApplyDamage(nil, atkRole, self.target, sd)
end
end
end
end
--初始化后调用一次
function Curse:OnStart()
if self.curseType == CurseTypeName.ShareDamage then
BattleLogic.Event:AddEvent(BattleEventName.FinalDamage, self.ShareDamageTrigger, self)
end
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Curse:OnTrigger()
return true
end
--效果结束时调用一次
function Curse:OnEnd()
if self.curseType == CurseTypeName.ShareDamage then
BattleLogic.Event:RemoveEvent(BattleEventName.FinalDamage, self.ShareDamageTrigger, self)
end
end
--只有当cover字段为true时触发返回true则被新效果覆盖
function Curse:OnCover(newBuff)
return self.curseType == newBuff.curseType
end
-- 比较buff
function Curse:OnCompare(buff)
return self.curseType == newBuff.curseType
end
return Curse

View File

@ -147,6 +147,7 @@ BuffName = {
Shield = "Shield",
Immune = "Immune",
NoDead = "NoDead",
Curse = "Curse",
}
DotType = {
@ -205,4 +206,8 @@ BattlePropList = {
RoleDataName.CureFacter,
RoleDataName.Tenacity,
RoleDataName.InitRage,
}
CurseTypeName = {
ShareDamage = 1,
}

View File

@ -332,6 +332,7 @@ 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)
BattleLogic.Event:DispatchEvent(BattleEventName.FinalDamage, atkRole, defRole, damage, skill, dotType, bCrit, damageType)
--
return BattleUtil.FinalDamage(skill, atkRole, defRole, damage, bCrit, damageType, dotType)

View File

@ -234,7 +234,7 @@ function this.GetNeighbor(role, chooseType)
if not list[i]:IsRealDead() then
if list[i].position == target.position + 3 -- 后排的人
or list[i].position == target.position - 3 -- 前排的人
or (math.abs(target.position - list[i].position) <= 1 and floor((target.position-1)/3) == floor((list[i].position-1)/3)) then -- 旁边的人和自己
or (math.abs(target.position - list[i].position) <= 1 and math.floor((target.position-1)/3) == math.floor((list[i].position-1)/3)) then -- 旁边的人和自己
table.insert(posList, list[i])
end
end