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

56 lines
1.4 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.

require("Modules/Battle/Logic/Base/Buff")
Immune = Buff:New()
local immune1 = function(buff)
return buff.type == BuffName.Control
end
local immune2 = function(buff)
return buff.type == BuffName.DOT
end
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Immune:SetData(...)
--log("Immune:SetData")
self.immuneType = ...
end
--初始化后调用一次
function Immune:OnStart()
--log("Immune:OnStart")
if self.immuneType == 1 then --免疫控制状态
self.target.buffFilter:Add(immune1)
elseif self.immuneType == 2 then --免疫dot
self.target.buffFilter:Add(immune2)
end
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Immune:OnTrigger()
--log("Immune:OnTrigger")
return true
end
--效果结束时调用一次
function Immune:OnEnd()
--log("Immune:OnEnd")
local immune
if self.immuneType == 1 then --免疫控制状态
immune = immune1
elseif self.immuneType == 2 then --免疫dot
immune = immune2
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)
--log("Immune:OnCover")
return true
end
return Immune