56 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
--make auto attack speed predictor thing please
 | 
						|
--COMBAT_LOG_EVENT_UNFILTERED PLAYER_REGEN_DISABLED PLAYER_REGEN_ENABLED
 | 
						|
function(allstates, e, ...)
 | 
						|
	if e == "COMBAT_LOG_EVENT_UNFILTERED" then
 | 
						|
		local time = debugprofilestop()
 | 
						|
		local subevent = select(2, ...)
 | 
						|
		if subevent == "SWING_DAMAGE" or subevent == "SWING_MISSED" then
 | 
						|
			local source = select(4, ...)
 | 
						|
			local destination = select(9, ...)
 | 
						|
			if source == UnitGUID("target") and destination == UnitName("player") then
 | 
						|
		        if #aura_env.swings == aura_env.lines * 2 then
 | 
						|
		        	for k,v in ipairs(aura_env.swings) do
 | 
						|
		        		if k > 1 then
 | 
						|
		        			aura_env.swings[k - 1] = v
 | 
						|
		        		end
 | 
						|
		        	end
 | 
						|
		            table.remove(aura_env.swings, (aura_env.lines * 2))
 | 
						|
	                table.insert(aura_env.swings, time)
 | 
						|
		        else
 | 
						|
		        	table.insert(aura_env.swings, time)
 | 
						|
		        end
 | 
						|
		        local avgTime = 0
 | 
						|
		        for k,v in ipairs(aura_env.swings) do
 | 
						|
		        	if k > 1 then
 | 
						|
		        		if avgTime == 0 then
 | 
						|
		        			avgTime = aura_env.swings[k] - aura_env.swings[k - 1]
 | 
						|
		        		else
 | 
						|
		        			avgTime = (avgTime + (aura_env.swings[k] - aura_env.swings[k - 1])) / 2
 | 
						|
		        		end
 | 
						|
		        	end
 | 
						|
		        end
 | 
						|
		        allstates[1] = {
 | 
						|
		        	show = true,
 | 
						|
		        	changed = true,
 | 
						|
		        	progressType = "timed",
 | 
						|
		        	avgTime = string.format("%.2f", avgTime / 1000),
 | 
						|
		        	expirationTime = GetTime() + (avgTime / 1000),
 | 
						|
					duration = avgTime / 1000,
 | 
						|
		        }
 | 
						|
		        print("return true", allstates[1].expirationTime, allstates[1].duration)
 | 
						|
		        return true
 | 
						|
			end
 | 
						|
		end
 | 
						|
	elseif e == "PLAYER_REGEN_DISABLED" or e == "PLAYER_REGEN_ENABLED" then
 | 
						|
		aura_env.swings = {}
 | 
						|
		if allstates[1] then
 | 
						|
			allstates[1].show = false
 | 
						|
			allstates[1].changed = true
 | 
						|
		end
 | 
						|
		return true
 | 
						|
	end
 | 
						|
end
 | 
						|
 | 
						|
--INIT
 | 
						|
aura_env.swings = {}
 | 
						|
aura_env.lines = 2 |