Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Buff Type]]
- _G.BUFF_NONE = 0
- _G.BUFF_GLOBAL = 1
- _G.BUFF_BASIC = 2
- _G.BUFF_DEBUFF = 3
- _G.BUFF_STUN = 5
- _G.BUFF_STEALTH = 6
- _G.BUFF_SILENCE = 7
- _G.BUFF_TAUNT = 8
- _G.BUFF_SLOW = 10
- _G.BUFF_ROOT = 11
- _G.BUFF_DOT = 12
- _G.BUFF_REGENERATION = 13
- _G.BUFF_SPEED = 14
- _G.BUFF_MAGIC_IMMUNE = 15
- _G.BUFF_PHYSICAL_IMMUNE = 16
- _G.BUFF_IMMUNE = 17
- _G.BUFF_Vision_Reduce = 19
- _G.BUFF_FEAR = 21
- _G.BUFF_CHARM = 22
- _G.BUFF_POISON = 23
- _G.BUFF_SUPPRESS = 24
- _G.BUFF_BLIND = 25
- _G.BUFF_STATS_INCREASE = 26
- _G.BUFF_STATS_DECREASE = 27
- _G.BUFF_FLEE = 28
- _G.BUFF_KNOCKUP = 29
- _G.BUFF_KNOCKBACK = 30
- _G.BUFF_DISARM = 31
- class 'BuffExplorer'
- function BuffExplorer:__init()
- __BuffExplorer = true
- self.Heroes = {}
- self.Buffs = {}
- self.RemoveBuffCallback = {}
- self.UpdateBuffCallback = {}
- for i = 1, Game.HeroCount() do
- local hero = Game.Hero(i)
- table.insert(self.Heroes, hero)
- self.Buffs[hero.networkID] = {}
- end
- Callback.Add("Tick", function () self:Tick() end)
- print("BuffExplorer Loaded")
- end
- function BuffExplorer:RemoveBuff(unit,buff)
- for i, cb in pairs(self.RemoveBuffCallback) do
- cb(unit,buff)
- end
- end
- function BuffExplorer:UpdateBuff(unit,buff)
- for i, cb in pairs(self.UpdateBuffCallback) do
- cb(unit,buff)
- end
- end
- function BuffExplorer:Tick()
- for _, hero in pairs(self.Heroes) do
- for i = 0, hero.buffCount do
- local buff = hero:GetBuff(i)
- if self:Valid(buff) then
- if not self.Buffs[hero.networkID][buff.name] or (self.Buffs[hero.networkID][buff.name] and self.Buffs[hero.networkID][buff.name].expireTime ~= buff.expireTime) then
- self.Buffs[hero.networkID][buff.name] = {expireTime = buff.expireTime, sent = true, networkID = buff.sourcenID, buff = buff}
- self:UpdateBuff(hero,buff)
- end
- end
- end
- end
- for _, hero in pairs(self.Heroes) do
- for buffname,buffinfo in pairs(self.Buffs[hero.networkID]) do
- if buffinfo.expireTime < Game.Timer() then
- self:RemoveBuff(hero,buffinfo.buff)
- self.Buffs[hero.networkID][buffname] = nil
- end
- end
- end
- end
- function BuffExplorer:Valid(buff)
- return buff and buff.name and #buff.name > 0 and buff.startTime <= Game.Timer() and buff.expireTime > Game.Timer()
- end
- if not __BuffExplorer_Loaded then
- _G.BuffExplorer = BuffExplorer()
- end
- OnUpdateBuff = function(cb)
- table.insert(BuffExplorer.UpdateBuffCallback,cb)
- end
- OnRemoveBuff = function(cb)
- table.insert(BuffExplorer.RemoveBuffCallback,cb)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement