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

80 lines
2.1 KiB
Lua
Raw Normal View History

2020-04-10 14:52:41 +08:00
-- 免疫效果
2019-03-26 17:03:23 +08:00
Immune = Buff:New()
2019-12-31 17:47:29 +08:00
local immune0 = function(buff)
return buff.type == BuffName.Control or buff.isDeBuff or buff.type == BuffName.DOT
end
2019-03-26 17:03:23 +08:00
local immune1 = function(buff)
return buff.type == BuffName.Control
end
local immune2 = function(buff)
return buff.type == BuffName.DOT
end
2020-05-06 16:49:24 +08:00
local immune3 = function(buff)
return buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.AllReduce
end
2019-03-26 17:03:23 +08:00
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Immune:SetData(...)
2020-04-10 14:52:41 +08:00
2019-03-26 17:03:23 +08:00
self.immuneType = ...
2019-10-23 13:40:57 +08:00
self.isBuff = true
2020-04-10 14:52:41 +08:00
-- 刷新排序等级
self.sort = 4
2019-03-26 17:03:23 +08:00
end
--初始化后调用一次
function Immune:OnStart()
2020-04-10 14:52:41 +08:00
2019-12-31 17:47:29 +08:00
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
self.target.buffFilter:Add(immune0)
elseif self.immuneType == 1 then --免疫控制状态
2019-03-26 17:03:23 +08:00
self.target.buffFilter:Add(immune1)
elseif self.immuneType == 2 then --免疫dot
self.target.buffFilter:Add(immune2)
2020-05-06 16:49:24 +08:00
elseif self.immuneType == 3 then --免疫无敌盾
self.target.buffFilter:Add(immune3)
2019-03-26 17:03:23 +08:00
end
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Immune:OnTrigger()
2020-04-10 14:52:41 +08:00
2019-03-26 17:03:23 +08:00
return true
end
--效果结束时调用一次
function Immune:OnEnd()
2020-04-10 14:52:41 +08:00
2019-03-26 17:03:23 +08:00
local immune
2019-12-31 17:47:29 +08:00
if self.immuneType == 0 then --免疫负面状态(控制状态、减益状态和持续伤害状态)
immune = immune0
elseif self.immuneType == 1 then --免疫控制状态
2019-03-26 17:03:23 +08:00
immune = immune1
elseif self.immuneType == 2 then --免疫dot
immune = immune2
2020-05-06 16:49:24 +08:00
elseif self.immuneType == 3 then --免疫无敌盾
immune = immune3
2019-03-26 17:03:23 +08:00
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)
2020-04-10 14:52:41 +08:00
2019-03-26 17:03:23 +08:00
return true
end
2020-04-23 20:08:25 +08:00
-- 比较buff
function Immune:OnCompare(buff)
return buff.immuneType == self.immuneType
end
2020-04-10 14:52:41 +08:00
return Immune