miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Buff/Immune.lua

100 lines
2.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 免疫效果
Immune = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Immune:SetData(type,func)
self.immuneType = type
self.immune4 = func
self.isBuff = true
-- 刷新排序等级
self.sort = 4
end
local immune0 = nil
local immune1 = nil
local immune2 = nil
local immune3 = nil
--免疫控制不免疫禁疗
local immune5 = nil
--初始化后调用一次
function Immune:OnStart()
immune0=function(buff)
return buff.type == BuffName.Control or buff.isDeBuff or buff.type == BuffName.DOT,self.caster
end
immune1=function(buff)
return buff.type == BuffName.Control,self.caster
end
immune2 = function(buff)
return buff.type == BuffName.DOT,self.caster
end
immune3 = function(buff)
return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce,self.caster
end
immune5 =function(buff)
return buff.type == BuffName.Control and buff.ctrlType and buff.ctrlType~=4,self.caster
end
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
self.target.buffFilter:Add(immune0)
elseif self.immuneType == 1 then --免疫控制状态
self.target.buffFilter:Add(immune1)
elseif self.immuneType == 2 then --免疫dot
self.target.buffFilter:Add(immune2)
elseif self.immuneType == 3 then --免疫无敌盾
self.target.buffFilter:Add(immune3)
elseif self.immuneType==4 then--自定义免疫
if self.immune4 then
self.target.buffFilter:Add(self.immune4)
end
elseif self.immuneType==5 then--免疫控制 不免疫禁疗
self.target.buffFilter:Add(immune5)
end
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Immune:OnTrigger()
return true
end
--效果结束时调用一次
function Immune:OnEnd()
local immune
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
immune = immune0
elseif self.immuneType == 1 then --免疫控制状态
immune = immune1
elseif self.immuneType == 2 then --免疫dot
immune = immune2
elseif self.immuneType == 3 then --免疫无敌盾
immune = immune3
elseif self.immuneType == 4 then--自定义免疫
immune = self.immune4
end
for i = 1, self.target.buffFilter.size do
if self.target.buffFilter.buffer[i] == immune then
self.target.buffFilter:Remove(i)
break
end
end
end
--只有当cover字段为true时触发返回true则被新效果覆盖
function Immune:OnCover(newBuff)
return true
end
-- 比较buff
function Immune:OnCompare(buff)
return buff.immuneType == self.immuneType
end
return Immune