miduo_server/luafight/Modules/Battle/Logic/Buff/Control.lua

88 lines
2.6 KiB
Lua
Raw Normal View History

2019-03-12 14:05:45 +08:00
Control = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Control:SetData(...)
2020-04-10 14:52:41 +08:00
2019-03-26 15:11:47 +08:00
self.ctrlType = ...
2019-04-17 21:04:32 +08:00
self.cover = true --控制效果可被覆盖
2020-04-10 14:52:41 +08:00
-- 刷新排序等级
2021-01-22 18:11:30 +08:00
self.sort = 4
2019-03-12 14:05:45 +08:00
end
2023-06-28 16:34:13 +08:00
2019-03-12 14:05:45 +08:00
--初始化后调用一次
2021-01-22 18:11:30 +08:00
function Control:OnStart()
2023-06-28 16:34:13 +08:00
local lockTargetFun=function()
self.target.ctrl_slient = false
self.target.lockTarget=nil
self.disperse=true
end
2019-03-12 14:05:45 +08:00
if self.ctrlType == 1 then --眩晕
2020-04-16 15:10:04 +08:00
self.target.ctrl_dizzy = true
2019-03-12 14:05:45 +08:00
elseif self.ctrlType == 2 then --沉默
2019-04-17 21:04:32 +08:00
self.target.ctrl_slient = true
2019-10-23 13:40:57 +08:00
elseif self.ctrlType == 3 then --嘲讽(包括沉默)
2019-03-12 14:05:45 +08:00
self.target.lockTarget = self.caster
2023-06-28 16:34:13 +08:00
self.target.ctrl_lock = true
self.caster.Event:AddEvent(BattleEventName.RoleDead,lockTargetFun,nil,nil,self.target)
2019-03-12 14:05:45 +08:00
elseif self.ctrlType == 4 then --禁疗
2019-04-17 21:04:32 +08:00
self.target.ctrl_noheal = true
2019-03-12 14:05:45 +08:00
elseif self.ctrlType == 5 then --致盲
2019-04-17 21:04:32 +08:00
self.target.ctrl_blind = true
2020-04-10 14:52:41 +08:00
elseif self.ctrlType == 7 then --麻痹
self.target.ctrl_palsy = true
2020-12-24 17:14:38 +08:00
elseif self.ctrlType == 8 then --混乱
self.target.ctrl_chaos = true
2019-03-12 14:05:45 +08:00
end
2020-12-28 10:34:53 +08:00
2019-03-12 14:05:45 +08:00
end
2021-01-22 18:11:30 +08:00
2019-03-12 14:05:45 +08:00
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Control:OnTrigger()
2020-04-10 14:52:41 +08:00
2019-03-12 14:05:45 +08:00
return true
end
--效果结束时调用一次
function Control:OnEnd()
2021-04-06 16:46:38 +08:00
--如果还有同类型的控制效果,就返回
if BattleLogic.BuffMgr:HasBuff(self.target, BuffName.Control, function (buff) return buff~=self and buff.ctrlType == self.ctrlType end) then
return
end
2019-03-12 14:05:45 +08:00
if self.ctrlType == 1 then --眩晕
2020-04-16 15:10:04 +08:00
self.target.ctrl_dizzy = false
2019-03-12 14:05:45 +08:00
elseif self.ctrlType == 2 then --沉默
2019-04-17 21:04:32 +08:00
self.target.ctrl_slient = false
2019-10-23 13:40:57 +08:00
elseif self.ctrlType == 3 then --嘲讽(包括沉默)
2019-03-12 14:05:45 +08:00
self.target.lockTarget = nil
2023-06-28 16:34:13 +08:00
self.target.ctrl_lock = false
2019-03-12 14:05:45 +08:00
elseif self.ctrlType == 4 then --禁疗
2021-05-14 15:36:50 +08:00
local isHave=self.target:CheckHavePassive(315)
if not isHave then
self.target.ctrl_noheal = false
end
2019-03-12 14:05:45 +08:00
elseif self.ctrlType == 5 then --致盲
2020-12-28 10:34:53 +08:00
self.target.ctrl_blind = false
2020-04-10 14:52:41 +08:00
elseif self.ctrlType == 7 then --麻痹
self.target.ctrl_palsy = false
2020-12-24 17:14:38 +08:00
elseif self.ctrlType==8 then --混乱
self.target.ctrl_chaos = false
2019-03-12 14:05:45 +08:00
end
end
--只有当cover字段为true时触发返回true则被新效果覆盖
function Control:OnCover(newBuff)
2020-04-10 14:52:41 +08:00
2019-04-17 21:04:32 +08:00
return newBuff.ctrlType == self.ctrlType
2019-03-12 14:05:45 +08:00
end
2020-04-23 20:08:25 +08:00
-- 比较buff
function Control:OnCompare(buff)
return self.ctrlType == buff.ctrlType
end
2020-04-10 14:52:41 +08:00
return Control