-- Setup required stuff

	-- Create the countdown vairable
	local timey = 0

	-- Create varriables needed to check for buffs
	local n,s,_

	-- Create a binary varriable to determine if you have a bloodlust or not
	local bloodlust,bloodlustbefore = 0

	-- Create a binary varriable to determine if you have a speedboost or not
	local dash,dashbefore = 0

	-- Create a binary varriable to determine if you have [Starfall]/[Astral Communion] or not
	local starfall,starfallbefore = 0

	-- Create a binary varriable to determine if you have [Celestial Alignment]/[Incarnation: Chosen of Elune] or not
	local celestial,celestialbefore = 0

	-- Create a binary varriable to determine if you have [Barkskin] or not
	local barkskin,barkskinbefore = 0

	-- Create a binary varriable to determine if you have [Incarnation: Tree of Life] or not
	local treeoflife,treeoflifebefore = 0

	-- Create a binary varriable to determine if you have [Moonkin Form] or not
	local moonkinform,moonkinformbefore = 0

	-- Create the sound function
	local frame = CreateFrame("FRAME", "StarDruid")
	frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
	frame:RegisterEvent("PLAYER_DEAD")
	frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
	frame:RegisterEvent("PLAYER_REGEN_DISABLED")

-- FYI, do   /eventtrace   to monitor events in wow!


-- The function that plays the sound
local function eventHandler(self, event, unitID, spell, sourceName, type, ...)
if (UnitClass("player")) == "Druid" then

	local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...)






	-- Play a sound on healing spell cast
	if ( (event == "UNIT_SPELLCAST_SUCCEEDED") and (unitID == "player") and ((spell == "Healing Touch") or (spell == "Rejuvenation") or (spell == "Regrowth") or (spell == "Swiftmend")) and (timey <= 0)) then
		-- Check the player's gender, then play the appropriate voice-over
		if ((UnitSex("player") == 3) and (math.random() > 0.85)) then
			PlaySoundKitID(GetRandomArgument(7221,25972),"Master")
			-- Set the countdown to 10 seconds before anouther sound can be played
			timey = 10
		else
			-- male sounds here
		end
	end



	-- Play a sound on [Tranquility]
	if ( (event == "UNIT_SPELLCAST_SUCCEEDED") and (unitID == "player") and (spell == "Tranquility") and (timey <= 0)) then
		-- Set the countdown to 10 seconds before anouther sound can be played
		timey = 10
		-- Check the player's gender, then play the appropriate voice-over
		if ((UnitSex("player") == 3) and (math.random() > 0.3)) then
			PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\S06Tyrande57.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande23.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandePissed3.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande24.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande25.mp3"),"Master")
		else
			if (UnitSex("player") == 3) then
				PlaySoundKitID(GetRandomArgument(11062,11063,11064),"Master")
			end
			-- male sounds here
		end
	end



	-- Play a sound on [Nature's Swiftness]
	if ( (event == "UNIT_SPELLCAST_SUCCEEDED") and (unitID == "player") and (spell == "Ironbark") and (timey <= 0)) then
		-- Set the countdown to 10 seconds before anouther sound can be played
		timey = 10
		-- Check the player's gender, then play the appropriate voice-over
		if (UnitSex("player") == 3) then
			PlaySoundKitID(GetRandomArgument(11062,11063,11064),"Master")
		else
			-- male sounds here
		end
	end


	-- Play a sound on [Innervate] spell cast
	if ( (event == "UNIT_SPELLCAST_SUCCEEDED") and (unitID == "player") and (spell == "Innervate") and (timey <= 0)) then
		-- Check the player's gender, then play the appropriate voice-over
		if (UnitSex("player") == 3) then
			PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat2.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat4.mp3"),"Master")
			-- Set the countdown to 10 seconds before anouther sound can be played
			timey = 10
		else
			-- male sounds here
		end
	end




	-- Play a sound on dispell
	if ( (event == "UNIT_SPELLCAST_SUCCEEDED") and (unitID == "player") and ((spell == "Remove Corruption") or (spell == "Nature's Cure")) and (timey <= 0)) then
		-- Check the player's gender, then play the appropriate voice-over
		if ((UnitSex("player") == 3) and (math.random() > 0.65)) then
			PlaySoundKitID(25982,"Master")
			-- Set the countdown to 10 seconds before anouther sound can be played
			timey = 10
		else
			if (math.random() > 0.5) then
				PlaySoundFile("Interface\\Addons\\Priestess_of_the_Moon\\N05Tyrande16.mp3","Master")
				-- Set the countdown to 10 seconds before anouther sound can be played
				timey = 10
			end
			-- male sounds here
		end

	end





	-- Play a sound on entering combat
	if ( (event == "PLAYER_REGEN_DISABLED") and (timey <= 0)) then
		-- Check the player's gender, then play the appropriate voice-over
		if ((UnitSex("player") == 3) and (math.random() > 0.35)) then
			PlaySoundKitID(GetRandomArgument(25977,25978,25979,25980,25981),"Master")
			-- Set the countdown to 10 seconds before anouther sound can be played
			timey = 10
		else
			if ((UnitSex("player") == 3) and (math.random() > 0.5)) then
				-- these would be kill sounds if i could get them to work...
				PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\N06Tyrande35.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat3.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandePissed4.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYesAttack1.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYesAttack2.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYesAttack3.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYesAttack4.mp3"), "Master")
			end
			-- male sounds here
		end

	end





	-- Play a random sound when you and only YOU have died
	if ( (event == "PLAYER_DEAD") and (timey <= 0)) then
		-- Check the player's gender, then play the appropriate voice-over
		if (UnitSex("player") == 3) then
			PlaySoundKitID(GetRandomArgument(25992,25973,25974,25975,25976,11067,11068),"Master")
		else
			-- male sounds
		end
		-- Set the countdown to 10 seconds before anouther sound can be played
		timey = 10

	end


	-- Check buffs before playing sounds
		bloodlust = 0
		dash = 0
		starfall = 0
		celestial = 0
		barkskin = 0
		treeoflife = 0
		moonkinform = 0
		for i=1,40 do n,_,_,_,_,_,_,_,s=UnitAura("player",i)

			-- Count the number of bloodlusts present
				if ((n == "Berserk") or (n == "Heart of the Wild") or (n == "Bloodlust") or (n == "Heroism") or (n == "Time Warp") or (n == "Ancient Hysteria") or (n == "Drums of Fury")) then
				bloodlust = bloodlust + 1
				end
	
			-- Count the number of speed boosts present
				if ((n == "Dash") or (n == "Nitro Boosts") or (n == "Stampeding Roar") or (n == "Darkflight") or (n == "Speed") or (n == "Draenic Swiftness Potion") or (n == "Swim Speed") or (n == "Darkwater Potion")) then
					dash = dash + 1
				end

			-- Count the number of [Starfall]/[Astral Communion] present
				if ((n == "Starfall") or (n == "Astral Communion")) then
					starfall = starfall + 1
				end

			-- Count the number of [Celestial Alignment]/[Incarnation: Chosen of Elune] present
				if ((n == "Celestial Alignment") or (n == "Incarnation: Chosen of Elune")) then
					celestial = celestial + 1
				end


			-- Count the number of [Prowl] present
				if ((n == "Prowl") or (n == "Shadowmeld")) then
					barkskin = barkskin + 1
				end

			-- Count the number of [Incarnation: Tree of Life] present
				if ((n == "Incarnation: Tree of Life") or (n == "Incarnation")) then
					treeoflife = treeoflife + 1
				end

			-- Count the number of [moonkinform Instincts] present
				if (n == "Moonkin Form") then
					moonkinform = moonkinform + 1
				end

		end
	

	-- If no other sound has been played within 5 seconds and you just got a DPS buff, play an 'enrage' RP sound
	-- Otherwise, reset the 'before' variable to zero
		if ((bloodlust > 0) and (bloodlustbefore == 0) and (timey <= 0)) then
			bloodlustbefore = 1
			timey = 5
			-- Check the player's gender, then play the appropriate voice-over
			if ((UnitSex("player") == 3) and (math.random() > 0.5)) then
				PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\only_the_goddess.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande05.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWarcry1.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat1.mp3"),"Master")
			else
				if (UnitSex("player") == 3) then
					PlaySoundKitID(GetRandomArgument(25984,25983,11066),"Master")
				end
				-- male sounds
			end

		end
		if (bloodlust == 0) then
			bloodlustbefore = 0
		end


	-- If no other sound has been played within 5 seconds and you just got a speed boost, play a sound
	-- Otherwise, reset the 'before' variable to zero
		if ((dash > 0) and (dashbefore == 0) and (timey <= 0)) then
			dashbefore = 1
			timey = 5
			-- Check the player's gender, then play the appropriate voice-over
			if ((UnitSex("player") == 3) and (math.random() > 0.35)) then
				PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\N01Tyrande34.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S04Tyrande31.mp3"),"Master")
			else
				if (UnitSex("player") == 3) then
					PlaySoundKitID(11065,"Master")
				end
				-- male sounds
			end
		end
		if (dash == 0) then
			dashbefore = 0
		end


	-- If no other sound has been played within 5 seconds and you just got [Starfall]/[Astral Communion], play a sound
	-- Otherwise, reset the 'before' variable to zero
		if ((starfall > 0) and (starfallbefore == 0) and (timey <= 0)) then
			starfallbefore = 1
			timey = 5

				PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\only_the_goddess.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande05.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWarcry1.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat1.mp3"),"Master")

		end
		if (starfall == 0) then
			starfallbefore = 0
		end


	-- If no other sound has been played within 5 seconds and you just got [Celestial Alignment]/[Incarnation: Chosen of Elune], play a sound
	-- Otherwise, reset the 'before' variable to zero
		if ((celestial > 0) and (celestialbefore == 0) and (timey <= 0)) then
			celestialbefore = 1
			timey = 5
			PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\N01Tyrande27.mp3","Interface\\Addons\\Priestess_of_the_Moon\\N01Tyrande29.mp3","Interface\\Addons\\Priestess_of_the_Moon\\the_responcibility_is_mine.mp3","Interface\\Addons\\Priestess_of_the_Moon\\these_foul_beasts.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYes1.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYes2.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYes3.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeYes4.mp3"), "Master")
		end
		if (celestial == 0) then
			celestialbefore = 0
		end


	-- If no other sound has been played within 5 seconds and you just got [Moonkin Form], play a sound
	-- Otherwise, reset the 'before' variable to zero
		if ((moonkinform > 0) and (moonkinformbefore == 0) and (timey <= 0)) then
			moonkinformbefore = 1
			timey = 5
				PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat2.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandeWhat4.mp3"),"Master")
		end
		if (moonkinform == 0) then
			moonkinformbefore = 0
		end


	-- If no other sound has been played within 5 seconds and you just got [Savage Defense], play a sound
	-- Otherwise, reset the 'before' variable to zero
		if ((barkskin > 0) and (barkskinbefore == 0) and (timey <= 0)) then
			barkskinbefore = 1
			timey = 5
				PlaySoundFile("Interface\\Addons\\Priestess_of_the_Moon\\N02Tyrande10.mp3","Master")
		end
		if (barkskin == 0) then
			barkskinbefore = 0
		end


	-- If no other sound has been played within 5 seconds and you just got [Incarnation: Tree of Life], play a sound
	-- Otherwise, reset the 'before' variable to zero
		if ((treeoflife > 0) and (treeoflifebefore == 0) and (timey <= 0)) then
			treeoflifebefore = 1
			timey = 5
			-- Check the player's gender, then play the appropriate voice-over
			if ((UnitSex("player") == 3) and (math.random() > 0.35)) then
				PlaySoundFile(GetRandomArgument("Interface\\Addons\\Priestess_of_the_Moon\\S06Tyrande57.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande23.mp3","Interface\\Addons\\Priestess_of_the_Moon\\TyrandePissed3.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande24.mp3","Interface\\Addons\\Priestess_of_the_Moon\\S08Tyrande25.mp3"),"Master")
			else
				if (UnitSex("player") == 3) then
					PlaySoundKitID(GetRandomArgument(11062,11063,11064),"Master")
				-- male sounds
				end
			end
		end
		if (treeoflife == 0) then
			treeoflifebefore = 0
		end

end
end




-- The function that runs the delay in between sounds
local function timeycountdowns(self,elapsed)
if (UnitClass("player")) == "Druid" then

	if (timey > 0) then
		timey = timey - elapsed
	end

end
end




















-- Run the function

frame:SetScript("OnEvent", eventHandler);
frame:SetScript("OnUpdate", timeycountdowns);

