dillyn

die Core.Lua (deDE)

core.lua

leider noch viele bugs vorhanden.

dillyn = LibStub("AceAddon-3.0"):NewAddon("dillyn", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0");
local L = LibStub("AceLocale-3.0"):GetLocale("dillyn", true);
local AceConfig = LibStub("AceConfig-3.0");
local AceConfigDialog = LibStub("AceConfigDialog-3.0");

local debug = false;

function dillyn:OnInitialize()
	-- wird geladen beim einloggen
	--if (debug) then dillyn:Print("OnInitialize") end
	dillyn:loadSavedVariables();
	dillyn:Optionen();
	dillyn:initializeVars();
end

function dillyn:OnEnable()
	-- wird geladen wenn das addon aktiviert ist
	--if (debug) then dillyn:Print("OnEnable") end

	-- erstellen der statusbars
	dillyn:erstelleStatusBar(53563); -- bol
	dillyn:erstelleStatusBar(20186); -- Judgements
	dillyn:erstelleStatusBar(53655); -- Judgement of the Pure
	dillyn:erstelleStatusBar(53601); -- Sacred Shield
	dillyn:bewegeBars(dillyn.maxBars);
	
	dillyn:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED","CombatLogEvents");
	--dillyn:Print("EVENTS");
end

function dillyn:OnDisable()
	-- wird geladen wenn das addon deaktiviert ist
	if (debug) then dillyn:Print("OnDisable") end
end

function dillyn:initializeVars()
	dillyn.statusBarTarget = {};	
	dillyn.statusbar = {};
	dillyn.statusbaricon = {};
	dillyn.statusbaricontex = {};
	dillyn.statusbarBorderFrame = {};
	dillyn.statusbartext = {};
	dillyn.duration = {};
	dillyn.stoptime = {};
	dillyn.BarUpdateSperre = {};
	dillyn.StatusBarWertUpdater = {};
	dillyn.StatusBarTextUpdater = {};
	dillyn.StatusBarAusLaufen = {};
	dillyn.StatusBarLaufend = {};
	dillyn.maxBars = 4;	
end

function dillyn:CombatLogEvents(...)
	local date, timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId = select(1, ...);
	
	if ((eventtype == "SPELL_AURA_APPLIED") or (eventtype == "SPELL_AURA_REFRESH")) then -- buffcheck gucken ob noch gebraucht weil benutzt nun den richtigen clog eintrag für erhalten und nicht nur gecastet !
		if (srcName == UnitName("player")) then
   		if (not(dillyn.db.global.spellIdsWhisper[spellId] == nil)) then
   			local parent =  dillyn.db.global.spellIdsWhisper[spellId].childOf;
   			if (dillyn.db.global.spellIdsWhisper[parent].enable) then
  				dillyn:Whisper(spellId, dstName);
  			end
  		elseif (not(dillyn.db.global.spellIdsStatusBar[spellId] == nil)) then  
  			local parent = dillyn.db.global.spellIdsStatusBar[spellId].childOf;
  			local bar = dillyn.db.global.statusbar[parent].position;
  			if (dillyn.db.global.spellIdsStatusBar[parent].enable) then
		  		if ((dillyn.BarUpdateSperre[bar] + 1) < GetTime()) then
		  			dillyn.BarUpdateSperre[bar] = GetTime();
		  			dillyn.statusBarTarget[bar] = dstName;
		  			dillyn:StarteStatusBar(spellId, bar);
		  			-- völlig rnd zwei identische clog einträge für die selbe sache vorhanden -.-
		  			-- 5/17 04:55:43.358  SPELL_AURA_REFRESH,0x0300000001D383CA,"Dillyna",0x511,0x0300000001D383CA,"Dillyna",0x511,54153,"Judgements of the Pure",0x2,BUFF
						-- 5/17 04:55:43.363  SPELL_AURA_REFRESH,0x0300000001D383CA,"Dillyna",0x511,0x0300000001D383CA,"Dillyna",0x511,54153,"Judgements of the Pure",0x2,BUFF
		  		end
		  	end
			end
		end
	elseif (eventtype == "SPELL_AURA_REMOVED") then
		if (srcName == UnitName("player")) then -- blöde selbst tests wenn scrname und dstname immer gleich sind -.-
			if (not(dillyn.db.global.spellIdsStatusBar[spellId] == nil)) then
				local parent = dillyn.db.global.spellIdsStatusBar[spellId].childOf;
  			local bar = dillyn.db.global.statusbar[parent].position;
  			if (dillyn.db.global.spellIdsStatusBar[parent].enable) then
					if (dstName == dillyn.statusBarTarget[bar]) then
						local barIdAndSpellId = {bar, spellId};
    				dillyn:Buffweg(barIdAndSpellId);
    			end
    		end
    	end
 	 end
	elseif (eventtype == "SPELL_CAST_START") then
		if (srcName == UnitName("player")) then
			if not(dillyn.db.global.spellIdsRezz[spellId] == nil) then 
				local parent = dillyn.db.global.spellIdsRezz[spellId].childOf;
				if (dillyn.db.global.spellIdsRezz[parent].enable) then
					if not(UnitName("target") == nil) then
						--dillyn:Print("starte ressAnsage");
						dstName = UnitName("target"); -- dstName bei SPELL_CAST_START ist immer NIL deswegen über UnitName gesetzt jedoch ist das nicht immer richtig
						if not(UnitIsDeadOrGhost(dstName) == nil) then -- kein spam wenn man jemanden rezzt der freigelassen hat und deswegen man grad jemand anderen im target hat
							dillyn:rezzAnsage(spellId, dstName);
						end
					end
				end
			end
		end 
	end	
end	

function dillyn:loadSavedVariables()
	local defaults = {
 					global = {
    				statusbar = {
    					Xachse = 200,
    					Yachse = 200,
    					breite = 200,
    					hoehe = 16,
    					abstand = 4,
    					nachOben = true, -- ausrichtung
    					gesperrt = false,
    					--textur
    					--font 
    					--pulse = true,
    					[53563] = { 
    						position = 1,
    						endSound = {
    							enable = true,
    							datei = "Interface\\Addons\\dillyn\\sound\\alarm1.wav",
    						}
    					},
    					[20186] = { 
    						position = 2,
    						endSound = {
    							enable = false,
    							datei = "Interface\\Addons\\dillyn\\sound\\alarm1.wav",
    						}
    					},
    					[53655] = { 
    						position = 3,
    						endSound = {
    							enable = false,
    							datei = "Interface\\Addons\\dillyn\\sound\\alarm1.wav",
    						}
    					},
    					[53601] = { 
    						position = 4,
    						endSound = {
    							enable = false,
    							datei = "Interface\\Addons\\dillyn\\sound\\alarm1.wav",
   		 					}
   					 	}
    				},
  				  whisper = {
    					enable = true,
   					},
   				 	rezzAnnounce = {
    					enable = true,
   					},
   					spellIdsStatusBar = {
   						[53563] = {-- Beacon of Light
   							childOf = 53563,
   							enable = true,
   						},
   						[20186] = {-- Judgement of Wisdom
   							childOf = 20186,
   							enable = true,
   						},
   						[20185] = {-- Judgement of Light
   							childOf = 20186,
   						},
   						[20184] = {-- Judgement of Justice
   							childOf = 20186,
   						},
   						[53655] = {-- Judgement of the Pure R1
   							childOf = 53655,
   							enable = true,
   						},
   						[53656] = {-- Judgement of the Pure R2
   							childOf = 53655,
   						},
   						[53657] = {-- Judgement of the Pure R3
   							childOf = 53655,
   						},
   						[54153] = {-- Judgement of the Pure R4
   							childOf = 53655,
   						},
   						[53601] = {-- Judgement of the Pure R5
   							childOf = 53655,
   						},
   						[53601] = {-- Sacred Shield
   							childOf = 53601,
   							enable = true,
   						}
   					},
   					spellIdsWhisper = {
   						[1044] = {-- Hand of Freedom
   							childOf = 1044,
   							enable = true,
   						},
   						[1044] = {-- Hand of Protection R1 
   							childOf = 1044,
   							enable = true,
   						},
   						[1044] = {-- Hand of Protection R2
   							childOf = 1044,
   						},
   						[1044] = {-- Hand of Protection R3 
   							childOf = 1044,
   						},
   						[1044] = {-- Hand of Sacrifice
   							childOf = 1044,
   							enable = true,
   						},
   						[1044] = {-- Hand of Salvation
   							childOf = 1044,
   							enable = true,
   						},
   						[1044] = {-- Divine Intervention 
   							childOf = 1044,
   							enable = true,
   						},
   					},
   					spellIdsRezz = {
   						[7328] = {-- Redemption R1
   							childOf = 7328,
   							enable = true,
   						},
   						[10322] = {-- Redemption R2
   							childOf = 7328,
   						},
   						[10324] = {-- Redemption R3
   							childOf = 7328,
   						},
   						[20772] = {-- Redemption R4
   							childOf = 7328,
   						},
   						[20773] = {-- Redemption R5
   							childOf = 7328,
   						},
   						[48949] = {-- Redemption R6
   							childOf = 7328,
   						},
   						[48950] = {-- Redemption R7
   							childOf = 7328,
   						},--http://www.youtube.com/watch?v=l0ncybXLBo0
   					}
  				}
				}

 dillyn.db = LibStub("AceDB-3.0"):New("dillynDB", defaults, true);
end

function dillyn:erstelleStatusBar(_spellId)
	local i = dillyn.db.global.statusbar[_spellId].position;

	dillyn.statusBarTarget[i] = "";
	dillyn.BarUpdateSperre[i] = GetTime();
		
	local	spellName, spellRank, spellIcon = GetSpellInfo(_spellId);

	dillyn.statusbar[i] = CreateFrame("Statusbar", "dillynTimerStatusBar", UIParent, "TextStatusBar");
	dillyn.statusbar[i]:SetWidth(dillyn.db.global.statusbar.breite);
	dillyn.statusbar[i]:SetHeight(dillyn.db.global.statusbar.hoehe);
	
	dillyn.statusbar[i]:EnableMouse(false);
	dillyn.statusbar[i]:SetMovable(false);

	dillyn.statusbar[i]:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar");
	dillyn.statusbar[i]:SetOrientation("HORIZONTAL");
	dillyn.statusbar[i]:Show();

	dillyn.statusbaricon[i] = CreateFrame("Frame","dillynTimerIconFrame",dillyn.statusbar[i]);
	dillyn.statusbaricontex[i] = dillyn.statusbaricon[i]:CreateTexture(nil,"BORDER");
	dillyn.statusbaricontex[i]:SetTexture(spellIcon);
	dillyn.statusbaricon[i]:SetWidth(dillyn.db.global.statusbar.hoehe + 3);
	dillyn.statusbaricon[i]:SetHeight(dillyn.db.global.statusbar.hoehe + 3);
	dillyn.statusbaricon[i]:SetPoint("RIGHT",dillyn.statusbar[i],"LEFT",-3,0);
	dillyn.statusbaricontex[i]:SetAllPoints();
	
	dillyn.statusbarBorderFrame[i] = CreateFrame("Frame","dillynTimerStatusBarBorder",dillyn.statusbar[i]);
	dillyn.statusbarBorderFrame[i]:SetPoint("TOPLEFT",dillyn.statusbar[i],"TOPLEFT",-3,3);
	dillyn.statusbarBorderFrame[i]:SetPoint("BOTTOMRIGHT",dillyn.statusbar[i],"BOTTOMRIGHT",3,-3);
	dillyn.statusbarBorderFrame[i]:SetFrameStrata("BACKGROUND");
	dillyn.statusbarBorderFrame[i]:SetBackdrop({bgFile="Interface\\Tooltips\\UI-Tooltip-Background",
	      edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",
	      tile=1, tileSize=1,edgeSize=10,
	      insets={left=3,right=3,top=3,bottom=3}});
	dillyn.statusbarBorderFrame[i]:SetBackdropColor(.5,.5,.5,.8);
	dillyn.statusbarBorderFrame[i]:Show();
	
	dillyn.statusbartext[i] = dillyn.statusbar[i]:CreateFontString("dillynTimerStatusBar","ARTWORK","GameFontNormal");
	dillyn.statusbartext[i]:SetText(L["No Target"]);
	dillyn.statusbartext[i]:SetAllPoints();
	
	dillyn.statusbar[i]:SetAlpha(.4);
end

		
function dillyn:StarteStatusBar(_spellId, _barId)
	--if (debug) then dillyn.Print("StartStatusBar") end
	local i = _barId;
	local temptime = GetTime(); 		
	local spellName, spellRank, spellIcon= GetSpellInfo(_spellId);
	local auraName, auraRank, auraIcon, auraCount, auraDebuffType, auraDuration, auraExpirationTime = UnitAura(dillyn.statusBarTarget[i], spellName, spellRank, "Helpful");
	
	if (auraName == nil) then 
		--auraName, auraRank, auraIcon, auraCount, auraDebuffType, auraDuration, auraExpirationTime = UnitAura(dillyn.statusBarTarget[i], spellName, spellRank, "Harmful")
		--dillyn:Print("name war nil");
		auraDuration = 20; 
		auraExpirationTime = temptime + auraDuration;
	end;

	dillyn.statusbaricontex[i]:SetTexture(spellIcon);
	dillyn.duration[i] = auraDuration;
	dillyn.stoptime[i] = auraExpirationTime;
	dillyn.statusbar[i]:SetMinMaxValues(0, auraDuration);
	dillyn.statusbar[i]:SetValue(auraDuration);
	dillyn.statusbar[i]:SetAlpha(1);
	dillyn.StatusBarLaufend[i] = true;	
	
	dillyn:CancelTimer(dillyn.StatusBarTextUpdater[i], true); -- wipe timer bevor ein neuer erstellt wird
	dillyn:CancelTimer(dillyn.StatusBarWertUpdater[i], true); -- wipe timer bevor ein neuer erstellt wird
	dillyn:CancelTimer(dillyn.StatusBarAusLaufen[i], true);
	
	dillyn.StatusBarWertUpdater[i] = dillyn:ScheduleRepeatingTimer("StatusBarWertAnimation", .25, i);
	dillyn.StatusBarTextUpdater[i] = dillyn:ScheduleRepeatingTimer("StatusBarTextAnimation", .5, i);
	local barIdAndSpellId = {_barId ,_spellId};
	dillyn.StatusBarAusLaufen[i] = dillyn:ScheduleTimer("Buffweg", auraDuration, barIdAndSpellId)
end

function dillyn:StatusBarWertAnimation(_barId, _spellId)
	local i = _barId;
	local temptime = GetTime();
	
	if (temptime < dillyn.stoptime[i]) then
		dillyn.statusbar[i]:SetValue(dillyn.stoptime[i] - temptime);
	end
end

function dillyn:StatusBarTextAnimation(_barId, _spellId)
	local i = _barId;
	local temptime = GetTime();
	
	if (temptime < dillyn.stoptime[i]) then 
		local statusBarTimeLeft = dillyn.stoptime[i] - temptime;
		local statusBarTimeLeftSec = floor(statusBarTimeLeft);
		local statusBarTimeLeftMins = floor(statusBarTimeLeft / 60);
		local colorPro = (floor((statusBarTimeLeftSec / dillyn.duration[i]) * 100) / 100);
		
		if	((statusBarTimeLeftSec <= 60) and (statusBarTimeLeftSec >= 0)) then
			dillyn.statusbartext[i]:SetText(dillyn.statusBarTarget[i] .. " " .. statusBarTimeLeftSec .. " sec");
		else
			dillyn.statusbartext[i]:SetText(dillyn.statusBarTarget[i] .. " ".. statusBarTimeLeftMins .. " : " .. statusBarTimeLeftSec .. " min");
		end
		if ((colorPro <= 1) and (colorPro >= 0)) then
			local colorGreen = colorPro;
			local colorRed = 1 - colorPro;
			
			dillyn.statusbar[i]:SetStatusBarColor(colorRed,colorGreen,.0);
		end
	end
end

function dillyn:Buffweg(_barIdAndSpellId)
	local i = _barIdAndSpellId[1];
	local spellId = _barIdAndSpellId[2];
	if (dillyn.StatusBarLaufend[i]) then
			
		dillyn:CancelTimer(dillyn.StatusBarTextUpdater[i], true);
		dillyn:CancelTimer(dillyn.StatusBarWertUpdater[i], true);
		dillyn:CancelTimer(dillyn.StatusBarAusLaufen[i], true);
		
		dillyn.statusbar[i]:SetAlpha(.4); 
		dillyn.statusbartext[i]:SetText(L["fades from"] .." " .. dillyn.statusBarTarget[i] .. " !!!"); 
		dillyn.statusbar[i]:SetStatusBarColor(1,.0,.0); 
		dillyn.statusbar[i]:SetValue(60); 
	
		dillyn:PlayEndSound(spellId);
		
		dillyn.StatusBarLaufend[i] = false;
	end
end

function dillyn:Whisper(_spellId, _Target)
	if (dillyn.db.global.whisper.enable) then
		if ((not(UnitAffectingCombat("player") == nil) or (_spellId == 19753)) and (not(UnitInParty(_Target) == nil) or not(UnitInRaid(_Target) == nil))) then
			-- whispert nur wenn man im kampf ist und nicht an leute außerhalb der gruppe / pets !
			local spellName = GetSpellInfo(_spellId);
			local msg;
		 
			if (UnitSex("player") == 3) then
				msg = spellName .. " " .. L["on you"] .." :)"; -- (c) by karo ^^
			else
				msg = spellName .. " " .. L["on you"];
			end
		
			SendChatMessage(msg, "WHISPER", nil, _Target);
		end
	end
end

function dillyn:PlayEndSound(_spellId)
	local parent = dillyn.db.global.spellIdsStatusBar[_spellId].childOf;
	if (dillyn.db.global.statusbar[parent].endSound.enable) then
		PlaySoundFile(dillyn.db.global.statusbar[parent].endSound.datei);
	end
end

function dillyn:bewegeBars(_barAnzahl)
	local i, richtung;
	local barIndex = 1;
	local barAnzahl = _barAnzahl;
	
	if (dillyn.db.global.statusbar.nachOben) then
		richtung = 1;
	else
		richtung = -1;
	end
	
	for i = 1, barAnzahl, 1 do
		dillyn.statusbar[i]:SetPoint("BOTTOMLEFT",UIParent,"BOTTOMLEFT",dillyn.db.global.statusbar.Xachse, dillyn.db.global.statusbar.Yachse + ((dillyn.db.global.statusbar.hoehe + dillyn.db.global.statusbar.abstand) * (i - 1) * richtung));
		dillyn:CancelAllTimers(); -- wipe bars if move me
	end
	
	if not(dillyn.db.global.statusbar.gesperrt) then 
		dillyn.statusbartext[barIndex]:SetText(L["move me"]);
		dillyn.statusbar[barIndex]:SetStatusBarColor(1,.0,.0);
		
		dillyn.statusbar[barIndex]:EnableMouse(true);
		dillyn.statusbar[barIndex]:SetMovable(true);		
		dillyn.statusbar[barIndex]:SetScript("OnMouseDown",function() 
			dillyn.statusbar[barIndex]:StartMoving() 
		end);
		dillyn.statusbar[barIndex]:SetScript("OnMouseUp",function() 
			dillyn.statusbar[barIndex]:StopMovingOrSizing() 
			dillyn.db.global.statusbar.Xachse = dillyn.statusbar[barIndex]:GetLeft() 
			dillyn.db.global.statusbar.Yachse = dillyn.statusbar[barIndex]:GetBottom() 
			for i = (barIndex + 1), barAnzahl, 1 do
				dillyn.statusbar[i]:SetPoint("BOTTOMLEFT",UIParent,"BOTTOMLEFT",dillyn.db.global.statusbar.Xachse, dillyn.db.global.statusbar.Yachse + ((dillyn.db.global.statusbar.hoehe + dillyn.db.global.statusbar.abstand) * (i - 1) * richtung));
 	  	end
		end);		
	else 
		dillyn.statusbar[barIndex]:EnableMouse(false);
		dillyn.statusbar[barIndex]:SetMovable(false);
		dillyn.statusbartext[barIndex]:SetText(L["No Target"]);
		dillyn.statusbar[barIndex]:SetStatusBarColor(1,1,1);
	end	 --http://www.youtube.com/watch?v=SlRlzmmVfzI& !!!
end

function dillyn:Optionen()
	local myOptions = {
  	type = "group",
  	args = {
			lock = {
				name = L["lock"],
      	desc = L["locked / unlocked the statusbars"],
      	type = "toggle",
      	set = function(info,val)
      		dillyn.db.global.statusbar.gesperrt = val 
      		dillyn:bewegeBars(dillyn.maxBars)
      		end,
      	get = function(info) 
      		return dillyn.db.global.statusbar.gesperrt 
      	end
			},
    	alignment={
      	name = L["alignment"],
      	desc = L["toggle the alignment for the statusbars. toggle --> form top to buttom."],
      	type = "toggle",
      	set = function(info,val) 
      		dillyn.db.global.statusbar.nachOben = val 
      		dillyn:bewegeBars(dillyn.maxBars)
      		end,
      	get = function(info) 
      		return dillyn.db.global.statusbar.nachOben 
      	end
      },
      alarmSoundBoL={
      	name = L["alarm sound"] .. " " .. L["for"] .. " " .. L["Beacon of Light"],
      	desc = L["enabled / disabled the"] .. " " .. L["alarm sound"] .. " " .. L["for"] .. " " .. L["Beacon of Light"],
      	type = "toggle",
      	set = function(info,val) 
      		dillyn.db.global.statusbar[53563].endSound.enable = val 
      		end,
      	get = function(info) 
      		return dillyn.db.global.statusbar[53563].endSound.enable 
      	end
      },
      whisper={
      	name = L["whisper"],
      	desc = L["enabled / disabled the"] .. " " .. L["whispers for some hand casts"],
      	type = "toggle",
      	set = function(info,val) 
      		dillyn.db.global.whisper.enable = val 
      		end,
      	get = function(info) 
      		return dillyn.db.global.whisper.enable
      	end
      },
      rezzAnnounce={
      	name = L["resuscitation announce"],
      	desc = L["enabled / disabled the"] .. " " .. L["resuscitation announce"],
      	type = "toggle",
      	set = function(info,val) 
      		dillyn.db.global.rezzAnnounce.enable = val 
      		end,
      	get = function(info) 
      		return dillyn.db.global.rezzAnnounce.enable 
      	end
    	}
		}
	};
	
	AceConfig:RegisterOptionsTable("dillyn", myOptions);
	AceConfigDialog:AddToBlizOptions("dillyn", L["dillyn options"]);
	--dillyn:RegisterChatCommand("dillyn", "OpenConfig")
end

--function dillyn:OpenConfig()
	--InterfaceOptionsFrame_OpenToCategory(optionFrames.globals);
--end

function dillyn:rezzAnsage(_spellId, _Target)
	if (dillyn.db.global.rezzAnnounce.enable) then
		local spellName, spellRank, spellIcon, spellCost, spellIsFunnel, spellPowerType, spellCastTime = GetSpellInfo(_spellId);
		local msg;
		
		spellCastTime = floor(spellCastTime / 100);
		spellCastTime = spellCastTime / 10;
		
		msg = L["casting"] .. " " .. spellName .. " " .. L["in"] .. " " .. spellCastTime .. " " .. L["secs"] .. " " .. L["on"] .. " >>> " .. _Target .. " <<<";
		
		SendChatMessage(msg, "SAY", nil);
	end
end

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of laroawen laroawen Fri, 15 May 2009 13:44:02
    	SendChatMessage(msg, "WHISPER", "Common", _Target);
    

    You should not use "Common" here. A better version would be:

    SendChatMessage(msg, "WHISPER",nil, _Target);
    

    With your version, only alliance players can use this. With nil as language, the client automatically chooses the faction language of your character.

  • 1 comment

Facts

Date created
15 May 2009
Last updated
25 May 2009

Author