changeset 0:f18f59592449

- Major bug fixes.
author Tercio
date Mon, 23 Feb 2015 13:27:32 -0300
parents
children 5d4efee0e528
files Hansgar_And_Franzok_Assist.lua Hansgar_And_Franzok_Assist.toc bar_skyline.tga border_2.tga
diffstat 4 files changed, 392 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hansgar_And_Franzok_Assist.lua	Mon Feb 23 13:27:32 2015 -0300
@@ -0,0 +1,386 @@
+local floor = floor
+local min = min
+local UnitExists = UnitExists
+local GetPlayerMapPosition = GetPlayerMapPosition
+local UnitHealth = UnitHealth
+
+local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
+f:SetFrameStrata ("DIALOG")
+
+f:SetSize (155, 156)
+f:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
+edgeFile = "Interface\\AddOns\\Hansgar_And_Franzok_Assist\\border_2", edgeSize = 8})
+f:SetPoint ("center", UIParent, "center")
+f:SetBackdropColor (0, 0, 0, 0)
+f:SetBackdropBorderColor (0, 0, 0, 1)
+f:SetMovable (true)
+f:EnableMouse (true)
+f:Hide()
+
+local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
+title:SetText ("Hansgar & Franzok Assist")
+title:SetPoint ("center", f, "center")
+title:SetPoint ("bottom", f, "top", 0, 2)
+
+--
+local frame_event = CreateFrame ("frame", "Hansgar_And_Franzok_AssistEvents", f)
+frame_event:RegisterEvent ("ENCOUNTER_START")
+frame_event:RegisterEvent ("ENCOUNTER_END")
+frame_event:RegisterEvent ("ADDON_LOADED")
+
+--
+local player_bar = CreateFrame ("statusbar", "Hansgar_And_Franzok_AssistPlayerBar", f)
+player_bar:SetPoint ("topleft", f, "bottomleft", 0, -3)
+player_bar:SetPoint ("topright", f, "bottomright", 0, -3)
+player_bar:SetHeight (14)
+player_bar:SetStatusBarColor (0, 0, 0, 0)
+player_bar:SetMinMaxValues (0, 100)
+player_bar:SetValue (0)
+f.player_bar = player_bar
+
+player_bar.texture = player_bar:CreateTexture (nil, "overlay")
+player_bar.texture:SetTexture ("Interface\\AddOns\\Hansgar_And_Franzok_Assist\\bar_skyline")
+player_bar:SetStatusBarTexture (player_bar.texture)
+
+--
+
+local db
+
+frame_event:SetFrameStrata ("FULLSCREEN")
+
+frame_event:SetScript ("OnEvent", function (self, event, ...)
+
+	if (event == "ADDON_LOADED" and select (1, ...) == "Hansgar_And_Franzok_Assist") then
+
+		db = Hansgar_And_Franzok_DB
+		if (not db) then
+			db = {}
+			Hansgar_And_Franzok_DB = db
+		end
+		db.STAMPERS_DELAY = db.STAMPERS_DELAY or 5
+		
+		SLASH_Hansgar_And_Franzok_Assist1, SLASH_Hansgar_And_Franzok_Assist2 = "/hansgar", "/franzok"
+		function SlashCmdList.Hansgar_And_Franzok_Assist (msg, editbox)
+		
+			local command, rest = msg:match ("^(%S*)%s*(.-)$")
+		
+			if (command == "delay") then
+				local t = tonumber (rest)
+				if (t) then
+					db.STAMPERS_DELAY = t
+					print ("|cFFFFAA00Hansgar and Franzok Assist|r delay set to: ", t)
+				else
+					print ("|cFFFFAA00Hansgar and Franzok Assist|r invalid time.", t)
+				end
+				
+			elseif (command == "test" or command == "show") then
+				if (f.StampersPhase) then
+					return f:StopTracking()
+				end
+				f:StartTracking()
+				
+			elseif (command == "hide") then
+				if (f.StampersPhase) then
+					return f:StopTracking()
+				end
+
+			else
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r Commands:")
+				print ("|cFFFFFF00/hansgar delay <time>|r: time in seconds until the percentage goes from 0 to 100.")
+				print ("|cFFFFFF00/hansgar test|r: active the addon on test mode.")
+				print ("|cFFFFFF00/hansgar show|r: show the window and start test mode.")
+				print ("|cFFFFFF00/hansgar hide|r: hide the window.")
+			end
+		end
+		
+	elseif (event == "ENCOUNTER_START" or event == "ENCOUNTER_END") then
+	
+		local encounterID, encounterName, difficultyID, raidSize = select (1, ...)
+		if (encounterID == 1693 and difficultyID == 16) then
+		
+			if (event == "ENCOUNTER_START") then
+			
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r: addon enabled, good look!")
+			
+				if (f.StampersPhase) then
+					f:StopTracking()
+				end
+				f:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
+				
+			elseif (event == "ENCOUNTER_END") then
+				f:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
+				
+				if (f.StampersPhase) then
+					f:StopTracking()
+				end
+			end
+		end
+	end
+
+end)
+
+--
+
+f:SetScript ("OnEvent", function (self, event, time, token, _, who_serial, who_name, who_flags, _, target_serial, target_name, target_flags, _, spellid, spellname, spellschool, buff_type, ...)
+
+	if (event == "SPELL_AURA_APPLIED" and spellid == 162124 and not f.StampersPhase) then
+		f:StartTracking()
+		
+	elseif (event == "SPELL_AURA_REMOVED" and spellid == 162124 and f.StampersPhase) then
+		f:StopTracking()
+		
+	end
+
+end)
+
+local frame_tracker = CreateFrame ("frame", "Hansgar_And_Franzok_AssistTracker", UIParent)
+local on_update_tracker = function (self, elapsed)
+	
+	for i = 1, GetNumGroupMembers() do
+		local x, y = GetPlayerMapPosition ("raid"..i)
+		if (UnitExists ("raid"..i) and UnitHealth ("raid"..i) > 1 and x and y) then
+			local block = f:WhichBlock (x, y)
+			if (block) then
+				if (not f.block_tracker [block]) then --> was a clear block
+					f.block_tracker [block] = GetTime()
+					f:Paint (f.all_blocks [block])
+				end
+			end
+		end
+	end
+	
+	local px, py = GetPlayerMapPosition ("player")
+	local player_block = f:WhichBlock (px, py)
+	if (player_block) then
+		
+		local time_limit_at = f.block_tracker [player_block] + db.STAMPERS_DELAY
+		local time_now = GetTime()
+		
+		f.player_bar:SetValue ((time_limit_at - time_now) / db.STAMPERS_DELAY * 100)
+		f.player_bar:Show()
+		
+		local block_frame = f.all_blocks [player_block]
+		f.player_loc_box:SetPoint ("center", block_frame, "center")
+		f.player_loc_box:Show()
+		player_bar:Show()
+	else
+		f.player_loc_box:Hide()
+		f.player_bar:Hide()
+	end
+end
+
+function f:StartTracking()
+
+	print ("|cFFFFAA00Hansgar and Franzok Assist|r: Smart Stampers phase started.")
+
+	f.StampersPhase = true
+
+	if (not f.frames_built) then
+		f:CreateWindow()
+	end
+	
+	f:ResetBlocks()
+	f.player_loc_box:Hide()
+
+	f.block_tracker = f.block_tracker or {}
+	table.wipe (f.block_tracker)
+	
+	SetMapToCurrentZone()
+	
+	frame_tracker:SetScript ("OnUpdate", on_update_tracker)
+	f:Show()
+end
+
+function f:StopTracking()
+
+	print ("|cFFFFAA00Hansgar and Franzok Assist|r: Smart Stampers phase ended.")
+
+	f.StampersPhase = false
+	frame_tracker:SetScript ("OnUpdate", nil)
+	table.wipe (f.block_tracker)
+	f.player_loc_box:Hide()
+	f:Hide()
+end
+
+local on_mouse_down = function (self)
+	if (not self.isMoving) then
+		self.isMoving = true
+		f:StartMoving()
+	end
+end
+local on_mouse_up = function (self)
+	if (self.isMoving) then
+		self.isMoving = nil
+		f:StopMovingOrSizing()
+	end
+end
+
+local painting = function (self, elapsed)
+	self.step = self.step + elapsed
+	self.total_time = self.total_time + elapsed
+	
+	if (self.step > 0.2) then
+		self.step = 0
+		local percent = self.total_time / db.STAMPERS_DELAY * 100
+		
+		percent = min (percent, 100)
+		
+		local r, g, b = f:percent_color (percent, true)
+		self:SetBackdropColor (r, g, b, 0.5)
+		
+		self.number:SetText (floor (percent) .. "%")
+		self.number:SetTextColor (1, 1, 1, 1)
+		
+		if (percent == 100) then
+			self:SetScript ("OnUpdate", nil)
+			self.stamper_icon:Show()
+			self.number:Hide()
+		end
+	end
+end
+function f:Paint (block)
+	block.step = 0
+	block.total_time = 0
+	block:SetScript ("OnUpdate", painting)
+end
+
+function f:ResetBlocks()
+	for _, block in ipairs (f.all_blocks) do
+		block:SetScript ("OnUpdate", nil)
+		block:SetBackdropColor (.8, .8, .8, 0.5)
+		block.number:SetText (block.id)
+		block.number:SetTextColor (1, 1, 1, 0.5)
+		block.number:Show()
+		block.stamper_icon:Hide()
+	end
+end
+
+function f:CreateWindow()
+	local x = 0
+	local y = 0
+	
+	f.player_loc_box = frame_event:CreateTexture (nil, "overlay")
+	f.player_loc_box:SetSize (32, 40)
+	f.player_loc_box:SetTexture ([[Interface\ContainerFrame\UI-Icon-QuestBorder]])
+	f.player_loc_box:Hide()
+	
+	f.all_blocks = {}
+	
+	for i = 1, 20 do
+		
+		local block = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_Block" .. i, f)
+		block:SetSize (30, 38)
+		block:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0},
+		})
+		block:SetBackdropBorderColor (0, 0, 0, 1)
+		block:SetBackdropColor (.8, .8, .8, 0.5)
+		block:SetPoint ("TopLeft", f, "TopLeft", x, y)
+		
+		block:SetScript ("OnMouseDown", on_mouse_down)
+		block:SetScript ("OnMouseUp", on_mouse_up)
+		
+		block.id = i
+		
+		local number = block:CreateFontString (nil, "artwork", "GameFontHighlight")
+		number:SetPoint ("center", block, "center")
+		number:SetText (i)
+		number:SetTextColor (1, 1, 1, 0.5)
+		block.number = number
+		
+		local stamper_icon = block:CreateTexture (nil, "overlay")
+		stamper_icon:SetTexture ([[Interface\ICONS\Warrior_talent_icon_LambsToTheSlaughter]])
+		stamper_icon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
+		stamper_icon:SetSize (24, 24)
+		stamper_icon:SetPoint ("center", block, "center")
+		stamper_icon:Hide()
+		block.stamper_icon = stamper_icon
+		
+		x = x + 31
+		if (x >= 155) then
+			x = 0
+			y = y - 40
+		end
+		
+		tinsert (f.all_blocks, block)
+		
+	end
+	
+	f.frames_built = true
+	
+end
+
+local locs = {
+	--block 1:
+	{x1 = 0.51104891300201, y1 = 0.70877063274384, x2 = 0.50024521350861, y2 = 0.73220580816269},
+	--block 2:
+	{x1 = 0.49676024913788, y1 = 0.70914703607559, x2 = 0.48485481739044, y2 = 0.73210543394089},
+	--block 3:
+	{x1 = 0.48142266273499, y1 = 0.70876735448837, x2 = 0.46925610303879, y2 = 0.73205661773682},
+	--block 4:
+	{x1 = 0.46603119373322, y1 = 0.70929777622223, x2 = 0.45397216081619, y2 = 0.73167610168457},
+	--block 5:
+	{x1 = 0.45079308748245, y1 = 0.70926278829575, x2 = 0.43927478790283, y2 = 0.73225915431976},
+
+	--block 6
+	{x1 = 0.51104187965393, y1 = 0.73422884941101, x2 = 0.49990028142929, y2 = 0.76343530416489},
+	--block 7
+	{x1 = 0.49673527479172, y1 = 0.73338270187378, x2 = 0.48483556509018, y2 = 0.76356953382492},
+	--block 8
+	{x1 = 0.48133307695389, y1 = 0.73373115062714, x2 = 0.46920585632324, y2 = 0.76366758346558},
+	--block 9
+	{x1 = 0.46568286418915, y1 = 0.73440700769424, x2 = 0.45381307601929, y2 = 0.76358675956726},
+	--block 10
+	{x1 = 0.45046973228455, y1 = 0.73361301422119, x2 = 0.43929302692413, y2 = 0.76388084888458},
+
+	--block 11
+	{x1 = 0.51104211807251, y1 = 0.76532691717148, x2 = 0.50021582841873, y2 = 0.79546189308167},
+	--block 12
+	{x1 = 0.4964514374733, y1 = 0.76603573560715, x2 = 0.48449218273163, y2 = 0.79527854919434},
+	--block 13
+	{x1 = 0.48101079463959, y1 = 0.76503103971481, x2 = 0.46944016218185, y2 = 0.79543298482895},
+	--block 14
+	{x1 = 0.46541726589203, y1 = 0.7654857635498, x2 = 0.45369201898575, y2 = 0.79529416561127},
+	--block 15
+	{x1 = 0.45051556825638, y1 = 0.76583826541901, x2 = 0.43931984901428, y2 = 0.79570162296295},
+
+	--block 16
+	{x1 = 0.51103663444519, y1 = 0.79726493358612, x2 = 0.50061076879501, y2 = 0.8241291642189},
+	--block 17
+	{x1 = 0.49670505523682, y1 = 0.79692482948303, x2 = 0.48469054698944, y2 = 0.82489335536957},
+	--block 18
+	{x1 = 0.48130965232849, y1 = 0.79742962121964, x2 = 0.46962946653366, y2 = 0.82453238964081},
+	--block 19
+	{x1 = 0.46575212478638, y1 = 0.79766929149628, x2 = 0.45400339365005, y2 = 0.82176661491394},
+	--block 20
+	{x1 = 0.45073217153549, y1 = 0.79751670360565, x2 = 0.43945103883743, y2 = 0.82504689693451},
+}
+
+function f:WhichBlock (x, y)
+	for i = 1, #locs do
+		local loc = locs [i]
+		if (x >= loc.x2 and x <= loc.x1 and y >= loc.y1 and y <= loc.y2) then
+			return i
+		end
+	end
+end
+
+function f:percent_color (value, inverted)
+	local r, g
+	if (value < 50) then
+		r = 255
+	else
+		r = floor ( 255 - (value * 2 - 100) * 255 / 100)
+	end
+	
+	if (value > 50) then
+		g = 255
+	else
+		g = floor ( (value * 2) * 255 / 100)
+	end
+	
+	if (inverted) then
+		return g/255, r/255, 0
+	else
+		return r/255, g/255, 0
+	end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hansgar_And_Franzok_Assist.toc	Mon Feb 23 13:27:32 2015 -0300
@@ -0,0 +1,6 @@
+## Interface: 60000
+## Title: Hansgar And Franzok Assist
+## Notes: Helps with Smart Stampers on Mythic during this encounter.
+## SavedVariables: Hansgar_And_Franzok_DB
+
+Hansgar_And_Franzok_Assist.lua
\ No newline at end of file
Binary file bar_skyline.tga has changed
Binary file border_2.tga has changed