zvodd
5/16/2014 - 3:50 AM

FlashCheck.lua

local enemies = {}
local SumSpell = "SummonerFlash"

function onLoad()
	for i, heroObj in pairs(GetEnemyHeroes()) do
        if heroObj and heroObj.valid then
        	local curflash
			if hero:GetSpellData(SUMMONER_1).name:find(SumSpell) then curflash = SUMMONER_1 end
			if hero:GetSpellData(SUMMONER_2).name:find(SumSpell) then curflash = SUMMONER_2 end
        	enemies[heroObj.charName] = {curflash, nil}
        end
    end
end

function OnProcessSpell(unit, spell)
	if unit and unit.valid and unit.team == TEAM_ENEMY and unit.type == "obj_AI_Hero" then
		if spell.name == SumSpell then
			local hero = nil
			-- find the rigth hero
			for i=1, heroManager.iCount, 1 do
				local ihero = heroManager:getHero(i)
				if ihero.charName == unit.charName
					hero = ihero
				end
			end

			local cd = hero:GetSpellData(curflash).currentCd
			enemies[unit.charName][2] = os.clock() + cd 
			print unit.charName.." cast flash"
		end
	end
end

function OnTick()
	for k,spell_cd in pairs(enemies) do
		local cd =	spell_cd[2]
		if cd[2] ~= nil and cd[2] < (os.clock() + 5) then

			print k.." flash up in 5"
			enemies[k][2] = nil
		end
	end