function PVPSound_OnLoad()
	frame:RegisterEvent("PLAYER_ENTERING_WORLD");
	frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
	frame:RegisterEvent("PLAYER_DEAD");	
	frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
	frame:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL");
	frame:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE");
	frame:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE");
	frame:RegisterEvent("CHAT_MSG_MONSTER_YELL");
	frame:RegisterEvent("UPDATE_BATTLEFIELD_SCORE");
	frame:RegisterEvent("WORLD_MAP_UPDATE");
	frame:RegisterEvent("WORLD_STATE_UI_TIMER_UPDATE");

	 -- Slash Commands
	SlashCmdList["PVPSound"] = PVPSound_Command;
	SLASH_PVPSound1 = "/pvpsound";
	SLASH_PVPSound2 = "/ps";
end

	frame = CreateFrame("FRAME", "PVPSound_Frame");
	local PS_showemote = true;
	local PS_pvpmode = true;
	local PS_timer_reset = false;
	local PS_reset_time = 1800;
	local PS_mkill_time = 60;
	local PS_kills = 0;
	local myfaction = "NotYet";
	local mygender = "NotYet"
	local AllianceScore = "NotYet";
	local HordeScore = "NotYet";
	local TbActive = "NotYet";
	local TbAttacker = "NotYet";
	local TbBuildingsCaptured = "NotYet";
	local TbTimeRemaining = "NotYet";
	local WgActive = "NotYet";
	local WgAttacker = "NotYet";
	local WgTimeRemaining = "NotYet";
	local SotaAttacker = "NotYet";
	local SotaAttackerYell = "NotYet";

	local ABobjectives = {Farm = 0,	GoldMine = 0, LumberMill = 0, Stables = 0, Blacksmith = 0}

	local function ABget_objective(id)
		if id >=16 and id <=20 then return "GoldMine"
		elseif id >= 21 and id <= 25 then return "LumberMill"
		elseif id >= 26 and id <= 30 then return "Blacksmith"
		elseif id >= 31 and id <= 35 then return "Farm"
		elseif id >= 36 and id <= 40 then return "Stables"
		else return false
		end
	end

	local function ABobj_state(id)
		if id == 18 or id == 23 or id == 28 or id == 33 or id == 38 then
		return 1 -- Alliance
		elseif id == 20 or id == 25 or id == 30 or id == 35 or id == 40 then
		return 2 -- Horde
		elseif id == 17 or id == 22 or id == 27 or id == 32 or id == 37 then
		return 3 -- Alliance trys to capture from Horde
		elseif id == 19 or id == 24 or id == 29 or id == 34 or id == 39 then
		return 4 -- Horde trys to capture from Alliance
		else return 0 -- Noone controling
		end
	end

	local TBFGobjectives = {Lighthouse = 0,	Mines = 0, Waterworks = 0}
	
	local function TBFGget_objective(id)
		if id >=6 and id <=12 then return "Lighthouse"
		elseif id >= 16 and id <= 20 then return "Mines"
		elseif id >= 26 and id <= 30 then return "Waterworks"
		else return false
		end
	end

	local function TBFGobj_state(id)
		if id == 11 or id == 18 or id == 28 then
		return 1 -- Alliance
		elseif id == 10 or id == 20 or id == 30 then
		return 2 -- Horde
		elseif id == 9 or id == 17 or id == 27 then
		return 3 -- Alliance trys to capture from Horde
		elseif id == 12 or id == 19 or id == 29 then
		return 4 -- Horde trys to capture from Alliance
		else return 0 -- Noone controling
		end
	end

	local IOCobjectives = {Quarry = 0, Workshop = 0, Hangar = 0, Docks = 0, Refinerie = 0}

	local function IOCget_objective(id)
		if id >= 16 and id <= 20 then return "Quarry"
		elseif id >= 135 and id <= 139 then return "Workshop"
		elseif id >= 140 and id <= 144 then return "Hangar"
		elseif id >= 145 and id <= 149 then return "Docks"
		elseif id >= 150 and id <= 154 then return "Refinerie"
		elseif id >= 9 and id <= 12	then return "Keep"
		else return false
		end
	end

	local function IOCobj_state(id)
		if id == 18 or id == 136 or id == 141 or id == 146 or id == 151 then
		return 1 -- Alliance
		elseif id == 20 or id == 138 or id == 143 or id == 148 or id == 153 then
		return 2 -- Horde	
		elseif id == 17 or id == 137 or id == 142 or id == 147 or id == 152 then
		return 3 -- Alliance trys to capture from Horde
		elseif id == 19 or id == 139 or id == 144 or id == 149 or id == 154 then
		return 4 -- Horde trys to capture from Alliance
		else return 0 -- Noone controling
		end
	end

	local SOTAobjectives = {}

	local function SOTAget_objective(id)
		if id >= 13 and id <= 15 then return "South_Graveyard"
		elseif id >= 46 and id <= 46 then return "The_Frostbreaker"
		elseif id >= 48 and id <= 48 then return "The_Blightbringer"
		elseif id >= 77 and id <= 79 then return "Gate_of_the_Red_Sun"
		elseif id >= 80 and id <= 82 then return "Gate_of_the_Blue_Sapphire"
		elseif id >= 102 and id <= 104	then return "Gate_of_the_Yellow_Moon"
		elseif id >= 105 and id <= 107	then return "Gate_of_the_Purple_Amethyst"
		elseif id >= 108 and id <= 110	then return "Gate_of_the_Green_Emerald"
		else return false
		end
	end

	local function SOTAobj_state(id)
		if id == 15 then
		return 1 -- Alliance
		elseif id == 13 then
		return 2 -- Horde
		elseif id == 46 then
		return 3 -- Alliance attacking
		elseif id == 48 then
		return 4 -- Horde attacking
		else return 0 -- Noone controling
		end
	end
	
	local TBobjectives = {Ironclad_Garrison = 0, Slagworks = 0, Wardens_Vigil = 0, East_Spire = 0, South_Spire = 0, West_Spire = 0, Baradin_Hold = 1}

	local function TBget_objective(id)
		if id >= 9 and id <= 12 then return "Ironclad_Garrison"
		elseif id >= 27 and id <= 30 then return "Slagworks"
		elseif id >= 109 and id <= 112 then return "Wardens_Vigil"
		elseif id >= 210 and id <= 255 then return "East_Spire"
		elseif id >= 310 and id <= 355 then return "South_Spire"
		elseif id >= 410 and id <= 455 then return "West_Spire"
		elseif id >= 46 and id <= 48 then return "Baradin_Hold"
		else return false
		end
	end

	local function TBobj_state(id)
		if id == 11 or id == 28 or id == 48 or id == 111 or id == 211 or id == 311 or id == 411 then
		return 1 -- Alliance
		elseif id == 10 or id == 30 or id == 46 or id == 110 or id == 210 or id == 310 or id == 410 then
		return 2 -- Horde
		elseif id == 9 or id == 27 or id == 109 then
		return 3 -- Alliance trys to capture from Horde
		elseif id == 12 or id == 29 or id == 112 then
		return 4 -- Horde trys to capture from Alliance
		elseif id == 250 or id == 350 or id == 450 then
		return 5 -- Alliance Tower Heavily Damaged
		elseif id == 252 or id == 352 or id == 452 then
		return 6 -- Horde Tower Heavily Damaged
		elseif id == 55 or id == 355 or id == 455 then
		return 7 -- Tower Destroyed
		else return 0 -- Noone controling
		end
	end

	local WGobjectives = {Broken_Temple_Vehicle_Workshop = 0, Sunken_Ring_Vehicle_Workshop = 0, Westspark_Vehicle_Workshop = 0, Eastspark_Vehicle_Workshop = 0, Wintergrasp_Fortress_Tower_NE = 0, Shadowsight_Tower = 0, Winters_Edge_Tower = 0, Flamewatch_Tower = 0}

	local function WGget_objective(id)
		if id >= 68 and id <= 71 then return "Broken_Temple_Vehicle_Workshop"
		elseif id >= 168 and id <= 171 then return "Sunken_Ring_Vehicle_Workshop"
		elseif id >= 268 and id <= 271 then return "Westspark_Vehicle_Workshop"
		elseif id >= 368 and id <= 371 then return "Eastspark_Vehicle_Workshop"
		elseif id >= 10 and id <= 55 then return "Shadowsight_Tower"
		elseif id >= 110 and id <= 155 then return "Winters_Edge_Tower"
		elseif id >= 210 and id <= 255 then return "Flamewatch_Tower"
		elseif id >= 310 and id <= 355 then return "Wintergrasp_Fortress_Tower_NE"
		else return false
		end
	end

	local function WGobj_state(id)
		if id == 11 or id == 71 or id == 111 or id == 171 or id == 211 or id >= 311 or id == 271 or id == 371 then
		return 1 -- Alliance
		elseif id == 10 or id == 68 or id == 110 or id == 168 or id == 210 or id >= 310 or id == 268 or id == 368 then
		return 2 -- Horde
		elseif id == 50 or id == 150 or id == 250 or id >= 350 then
		return 3 -- Alliance Tower Heavily Damaged
		elseif id == 52  or id == 152 or id == 252 or id >= 352 then
		return 4 -- Horde Tower Heavily Damaged
		elseif id == 51  or id == 151 or id == 251 or id >= 351 then
		return 5 -- Alliance Tower Destroyed
		elseif id == 53  or id == 153 or id == 253 or id >= 353 then
		return 6 -- Horde Tower Destroyed
		elseif id == 6 then
		return 7 -- Uncontrolled Tower
		elseif id == 55 then
		return 8 -- Uncontrolled Tower Destroyed
		else return 0
		end
	end

function PVPSound_OnEvent(self, event, ...)
	local player = UnitGUID("player")
	local arg1, eventType, srcGUID, srcName, _, _, dstName, dstFlags  = select(1, ...)
	local CombatLog_Object_IsA = CombatLog_Object_IsA
	local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE
	local PS_COMBATLOG_FILTER_ENEMY_PLAYERS = bit.bor (COMBATLOG_OBJECT_AFFILIATION_MASK,COMBATLOG_OBJECT_REACTION_MASK,COMBATLOG_OBJECT_CONTROL_PLAYER,COMBATLOG_OBJECT_TYPE_PLAYER);
	local PS_COMBATLOG_FILTER_ENEMY_NPC = bit.bor (COMBATLOG_OBJECT_AFFILIATION_MASK,COMBATLOG_OBJECT_REACTION_MASK,COMBATLOG_OBJECT_CONTROL_PLAYER,COMBATLOG_OBJECT_TYPE_PLAYER,COMBATLOG_OBJECT_CONTROL_NPC,COMBATLOG_OBJECT_TYPE_NPC);
	local PS_msg = "";

	Winner = "";
	GameWinner = "";
	WinAnnounce = "";

	CurrentZone = GetRealZoneText();
	if CurrentZone == BG_WSG  then
		MyZone = "Zone_WarsongGulch";
	elseif CurrentZone == BG_AB then
		MyZone = "Zone_ArathiBasin";
	elseif CurrentZone == BG_AV then
		MyZone = "Zone_AlteracValley";
	elseif CurrentZone == BG_EOTS then
		MyZone = "Zone_EyeoftheStorm";
	elseif CurrentZone == BG_IOC then
		MyZone = "Zone_IsleofConquest";
	elseif CurrentZone == BG_SOTA then
		MyZone = "Zone_StrandoftheAncients";
	elseif CurrentZone == BG_TP then
		MyZone = "Zone_TwinPeaks";
	elseif CurrentZone == BG_TBFG then
		MyZone = "Zone_TheBattleforGilneas";
	elseif CurrentZone == BG_TB then
		MyZone = "Zone_TolBarad";
	elseif CurrentZone == BG_WG then
		MyZone = "Zone_Wintergrasp";	
	end

	if (event == "PLAYER_ENTERING_WORLD") then
		myfaction = UnitFactionGroup("player");
		if (UnitSex("player") == 1) then
			mygender = "Unknown"
		elseif (UnitSex("player") == 2) then
			mygender = "Male"
		elseif (UnitSex("player") == 3) then
			mygender = "Female"
		end
	end
	
	if (event == "PLAYER_DEAD") then
		PS_timer_reset = true;
	end

	-- PlaySounds
	if (event == "ZONE_CHANGED_NEW_AREA") then
		local PS_zone = GetRealZoneText();
		if (PS_zone == BG_WSG or PS_zone == BG_EOTS or PS_zone == BG_AB or PS_zone == BG_AV or PS_zone == BG_IOC or PS_zone == BG_SOTA or PS_zone == BG_TP or PS_zone == BG_TBFG) and (myfaction == "Horde") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\PlayRed.mp3");
		elseif (PS_zone == BG_WSG or PS_zone == BG_EOTS or PS_zone == BG_AB or PS_zone == BG_AV or PS_zone == BG_IOC or PS_zone == BG_SOTA or PS_zone == BG_TP or PS_zone == BG_TBFG) and (myfaction == "Alliance") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\PlayBlue.mp3");
		elseif (PS_zone == AR_ROL or PS_zone == AR_BEA or PS_zone == AR_NA or PS_zone == AR_DA or PS_zone == AR_TROV) then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\PrepareForBattle.mp3");
		end
		PS_timer_reset = true;
	end

	if (event == "CHAT_MSG_BG_SYSTEM_NEUTRAL") then
		if (strfind(arg1,BG_ALLIANCE_WINS)) then
			Winner = "Alliance";
			WinAnnounce = "Yes";
		elseif (strfind(arg1,BG_HORDE_WINS)) then
			Winner = "Horde";
			WinAnnounce = "Yes";
		 -- Waronsg Gulch and Twin Peaks
		elseif (strfind(arg1,BG_VULNERABLE)) then
			if (MyZone == "Zone_WarsongGulch"  or MyZone == "Zone_TwinPeaks") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Overtime.mp3");
			end
		 -- Strand of the Ancients
		elseif (strfind(arg1,BG_SOTA_ROUND_ONE)) or (strfind(arg1,BG_SOTA_ROUND_TWO)) then
			if (MyZone == "Zone_StrandoftheAncients") then
				for i=10, 10, 1 do
					local name, _, textureIndex = GetMapLandmarkInfo(i)
					if name and textureIndex then
						if (name == "The Frostbreaker") then
							SOTAobjectives = {South_Graveyard = 2}
							SotaAttacker = "Alliance"
						elseif (name == "The Blightbringer") then
							SOTAobjectives = {South_Graveyard = 1}
							SotaAttacker = "Horde"
						end
					end
				end

				if (SotaAttacker == "Alliance" and (myfaction == "Alliance")) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_AttackTheEnemyCore.mp3");
				elseif (SotaAttacker == "Alliance" and (myfaction == "Horde")) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_DefendYourCore.mp3");
				elseif (SotaAttacker == "Horde" and (myfaction == "Alliance")) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_DefendYourCore.mp3");
				elseif (SotaAttacker == "Horde" and (myfaction == "Horde")) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_AttackTheEnemyCore.mp3");
				end
			end
		end

		if (WinAnnounce == "Yes") then
			if (myfaction == Winner) then
				GameWinner = "Us";
			else
				GameWinner = "Them";
			end

			if (GameWinner == "Us") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\"..Winner.."_Wins.mp3");
			elseif (GameWinner == "Them") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\"..Winner.."_Wins.mp3");
			end
		end

	elseif (event == "CHAT_MSG_BG_SYSTEM_ALLIANCE") or (event == "CHAT_MSG_BG_SYSTEM_HORDE") then
		-- Waronsg Gulch and Twin Peaks
		if (strfind(arg1,BG_ALLIANCE_WINS)) then
			Winner = "Alliance";
			WinAnnounce = "Yes";
		elseif (strfind(arg1,BG_HORDE_WINS)) then
			Winner = "Horde";
			WinAnnounce = "Yes";
		elseif (strfind(arg1,BG_PICKED)) then
			if (MyZone == "Zone_WarsongGulch" or MyZone == "Zone_TwinPeaks") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Flag_Taken.mp3");
			end
		elseif (strfind(arg1,BG_DROPPED)) then
			if (MyZone == "Zone_WarsongGulch" or MyZone == "Zone_TwinPeaks") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Flag_Dropped.mp3");
			end
		elseif (strfind(arg1,BG_RETURNED)) then
			if (MyZone == "Zone_WarsongGulch" or MyZone == "Zone_TwinPeaks") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Flag_Returned.mp3");
			end
		elseif (strfind(arg1,BG_CAPTURED)) then
			if (MyZone == "Zone_WarsongGulch" or MyZone == "Zone_TwinPeaks") then
				_, _, AllianceScore = GetWorldStateUIInfo(2); -- Alliance score
				_, _, HordeScore = GetWorldStateUIInfo(3); -- Horde score
				if (AllianceScore == "1/3") and (HordeScore == "0/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Takes_Lead.mp3");
				elseif (AllianceScore == "0/3") and (HordeScore == "1/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Takes_Lead.mp3");
				elseif (AllianceScore == "2/3") and (HordeScore == "1/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Score.mp3");
				elseif (AllianceScore == "1/3") and (HordeScore == "2/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Score.mp3");
				elseif (AllianceScore == "1/3") and (HordeScore == "1/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Score.mp3");
				elseif (AllianceScore == "2/3") and (HordeScore == "2/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Score.mp3");
				elseif (AllianceScore == "0/3") and (HordeScore == "2/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Inc_Lead.mp3");
				elseif (AllianceScore == "2/3") and (HordeScore == "0/3") then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Inc_Lead.mp3");
				end
			end

		 -- Eye of the Storm
		elseif (strfind(arg1,BG_EOTS_CONTROL)) then
			if (MyZone == "Zone_EyeoftheStorm") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Defence.mp3");
			end
		elseif (strfind(arg1,BG_EOTS_LOST_CONTROL)) then
			if (MyZone == "Zone_EyeoftheStorm") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Offence.mp3");
			end
		 -- Isle of Conquest Vulnerable
		elseif (strfind(arg1,BG_IOC_GATE_DOWN)) then
			if (MyZone == "Zone_IsleofConquest") then
			PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_Vulnerable.mp3");
			end
		end

		if (WinAnnounce == "Yes") then
			if (myfaction == Winner) then
				GameWinner = "Us";
			else
				GameWinner = "Them";
			end

			if (GameWinner == "Us") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\"..Winner.."_Wins.mp3");
			elseif (GameWinner == "Them") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\"..Winner.."_Wins.mp3");
			end
		end

	elseif (event == "CHAT_MSG_MONSTER_YELL") then
		-- Alterac Valley
		if (MyZone == "Zone_AlteracValley") then
			if (strfind(arg1,BG_HASDESTROYED)) then
				if (strfind(arg1,FACTION_HORDE)) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
				elseif (strfind(arg1,FACTION_ALLIANCE)) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
				end
			elseif (strfind(arg1,BG_HASTAKEN) or strfind(arg1,BG_TAKEN)) then
				if (strfind(arg1,FACTION_HORDE)) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
				elseif (strfind(arg1,FACTION_ALLIANCE)) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
				end
			elseif (strfind(arg1,BG_WILLDESTROYIT) or strfind(arg1,BG_WILLCAPTUREIT)) then
				if (strfind(arg1,FACTION_HORDE)) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offense.mp3");
				elseif (strfind(arg1,FACTION_ALLIANCE)) then
					PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offense.mp3");
				end
			elseif (strfind(arg1,BG_WINS)) then
					if (strfind(arg1,FACTION_HORDE)) then
						Winner = "Horde";
						WinAnnounce = "Yes";
					elseif (strfind(arg1,FACTION_ALLIANCE)) then
						Winner = "Alliance";
						WinAnnounce = "Yes";
					end
				if (WinAnnounce == "Yes") then
					if (myfaction == Winner) then
						GameWinner = "Us";
					else
						GameWinner = "Them";
					end

					if (GameWinner == "Us") then
						PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\"..Winner.."_Wins.mp3");
					elseif (GameWinner == "Them") then
						PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\"..Winner.."_Wins.wav");
					end
				end
			end
		 -- Strand of the Ancients
		elseif (MyZone == "Zone_StrandoftheAncients") then
			for i=10, 10, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if (name == "The Frostbreaker") then
						SotaAttackerYell = "Alliance"
					elseif (name == "The Blightbringer") then
						SotaAttackerYell = "Horde"
					end
				end
			end

			if (strfind(arg1,BG_SOTA_VEHICLE_EAST)) then
				if (SotaAttackerYell == "Alliance") then
					local name, _, textureIndex = GetMapLandmarkInfo(2)
					if name and textureIndex then
						if ((textureIndex == 15) and (name == "East Graveyard") and (SotaAttackerYell == "Alliance")) then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						end
					end
				elseif (SotaAttackerYell == "Horde") then
					local name, _, textureIndex = GetMapLandmarkInfo(3)
					if name and textureIndex then
						if ((textureIndex == 13) and (name == "East Graveyard") and (SotaAttackerYell == "Horde")) then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
					end
				end
			elseif (strfind(arg1,BG_SOTA_VEHICLE_WEST)) then
				if (SotaAttackerYell == "Alliance") then
					local name, _, textureIndex = GetMapLandmarkInfo(12)
					if name and textureIndex then
						if ((textureIndex == 15) and (name == "West Graveyard") and (SotaAttackerYell == "Alliance")) then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						end
					end
				elseif (SotaAttackerYell == "Horde") then
					local name, _, textureIndex = GetMapLandmarkInfo(12)
					if name and textureIndex then
						if ((textureIndex == 13) and (name == "West Graveyard") and (SotaAttackerYell == "Horde")) then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
					end
				end
			end
		end

	elseif (event == "WORLD_MAP_UPDATE") then
		-- Arathi Basin
		if (MyZone == "Zone_ArathiBasin") then
			for i=1, GetNumMapLandmarks(), 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = ABget_objective(textureIndex)
					if typ then
						if ABobj_state(ABobjectives[typ]) == 0 and ABobj_state(textureIndex) > 2 then
						elseif ABobj_state(ABobjectives[typ]) == 1 and ABobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif ABobj_state(ABobjectives[typ]) == 2 and ABobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif ABobj_state(ABobjectives[typ]) == 3 and ABobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif ABobj_state(ABobjectives[typ]) == 4 and ABobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif ABobj_state(ABobjectives[typ]) == 3 and ABobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						elseif ABobj_state(ABobjectives[typ]) == 4 and ABobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
						ABobjectives[typ] = textureIndex
					end
				end
			end
		 -- The Battle for Gilneas
		elseif (MyZone == "Zone_TheBattleforGilneas") then
			for i=1, GetNumMapLandmarks(), 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = TBFGget_objective(textureIndex)
					if typ then
						if TBFGobj_state(TBFGobjectives[typ]) == 0 and TBFGobj_state(textureIndex) > 2 then
						elseif TBFGobj_state(TBFGobjectives[typ]) == 1 and TBFGobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBFGobj_state(TBFGobjectives[typ]) == 2 and TBFGobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBFGobj_state(TBFGobjectives[typ]) == 3 and TBFGobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBFGobj_state(TBFGobjectives[typ]) == 4 and TBFGobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBFGobj_state(TBFGobjectives[typ]) == 3 and TBFGobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						elseif TBFGobj_state(TBFGobjectives[typ]) == 4 and TBFGobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
						TBFGobjectives[typ] = textureIndex
					end
				end
			end
		 -- Strand of the Ancients, South Graveyard
		elseif (MyZone == "Zone_StrandoftheAncients") then
			for i=9, 9, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = SOTAget_objective(textureIndex)
					if typ then
						if (SOTAobj_state(SOTAobjectives[typ]) == 2 and SOTAobj_state(textureIndex) == 1 and (name == "South Graveyard")  and (SotaAttacker == "Alliance")) then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\CHAT_MSG_MONSTER_YELL_ALLIANCE_Defence.mp3");
						elseif (SOTAobj_state(SOTAobjectives[typ]) == 1 and SOTAobj_state(textureIndex) == 2 and (name == "South Graveyard") and (SotaAttacker == "Horde")) then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\CHAT_MSG_MONSTER_YELL_HORDE_Defence.mp3");
						end
						SOTAobjectives[typ] = textureIndex
					end
				end
			end
		 -- Isle of Conquest
		elseif (MyZone == "Zone_IsleofConquest") then
			for i=1, GetNumMapLandmarks(), 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = IOCget_objective(textureIndex)
					if typ then
						if IOCobj_state(IOCobjectives[typ]) == 0 and IOCobj_state(textureIndex) > 2 then
						elseif IOCobj_state(IOCobjectives[typ]) == 1 and IOCobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif IOCobj_state(IOCobjectives[typ]) == 2 and IOCobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif IOCobj_state(IOCobjectives[typ]) == 3 and IOCobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif IOCobj_state(IOCobjectives[typ]) == 4 and IOCobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif IOCobj_state(IOCobjectives[typ]) == 3 and IOCobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						elseif IOCobj_state(IOCobjectives[typ]) == 4 and IOCobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
						IOCobjectives[typ] = textureIndex
					end
				end
			end
		 -- Tol Barad
		elseif (MyZone == "Zone_TolBarad") then
			_, _, TbBuildingsCaptured = GetWorldStateUIInfo(8);
			_, _, TbTimeRemaining = GetWorldStateUIInfo(9);
			for i=1, 1, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if ((name == "Baradin Hold") and (textureIndex == 48)) then
						TbAttacker = "Alliance"
					elseif ((name == "Baradin Hold") and (textureIndex == 46)) then	
						TbAttacker = "Horde"
					end
				end
			end

			local _, localizedName, isActive, canQueue, enterTime, canEnter = GetWorldPVPAreaInfo(2)
			if isActive == true then
				TbActive = "Active"
			elseif isActive == false then
				TbActive = "NotActive"
			end
			-- Baradin Hold
			for i=1, 1, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = TBget_objective(textureIndex)
					if typ then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Horde_Wins.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Alliance_Wins.mp3");
						end
						TBobjectives[typ] = textureIndex
					end
				end
			end
			-- Bases
			for i=3, 3, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = TBget_objective(textureIndex)
					if typ and not (TbBuildingsCaptured == "Buildings Captured: 3 of 3") then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 3 and TBobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 4 and TBobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 3 and TBobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 4 and TBobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
						TBobjectives[typ] = textureIndex
					end
				end
			end
			for i=4, 4, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = TBget_objective(textureIndex)
					if typ and not (TbBuildingsCaptured == "Buildings Captured: 3 of 3") then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 3 and TBobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 4 and TBobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 3 and TBobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 4 and TBobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
						TBobjectives[typ] = textureIndex
					end
				end
			end
			for i=6, 6, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+100
					local typ = TBget_objective(faketextureIndex)
					if typ and not (TbBuildingsCaptured == "Buildings Captured: 3 of 3") then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(faketextureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(faketextureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 3 and TBobj_state(faketextureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 4 and TBobj_state(faketextureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Offence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 3 and TBobj_state(faketextureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 4 and TBobj_state(faketextureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						end
						TBobjectives[typ] = faketextureIndex
					end
				end
			end
			-- Towers
			for i=2, 2, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+200
					local typ = TBget_objective(faketextureIndex)
					if typ then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(faketextureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_HeavilyDamaged.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(faketextureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_HeavilyDamaged.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 5 and TBobj_state(faketextureIndex) == 7 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 6 and TBobj_state(faketextureIndex) == 7 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
						end
						TBobjectives[typ] = faketextureIndex
					end
				end
			end
			for i=5, 5, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+300
					local typ = TBget_objective(faketextureIndex)
					if typ then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(faketextureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_HeavilyDamaged.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(faketextureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_HeavilyDamaged.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 5 and TBobj_state(faketextureIndex) == 7 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 6 and TBobj_state(faketextureIndex) == 7 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
						end
						TBobjectives[typ] = faketextureIndex
					end
				end
			end
			for i=7, 7, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+400
					local typ = TBget_objective(faketextureIndex)
					if typ then
						if TBobj_state(TBobjectives[typ]) == 1 and TBobj_state(faketextureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_HeavilyDamaged.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 2 and TBobj_state(faketextureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_HeavilyDamaged.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 5 and TBobj_state(faketextureIndex) == 7 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
						elseif TBobj_state(TBobjectives[typ]) == 6 and TBobj_state(faketextureIndex) == 7 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
						end
						TBobjectives[typ] = faketextureIndex
					end
				end
			end
		 -- Wintergrasp
		elseif (MyZone == "Zone_Wintergrasp") then
			for i=7, 7, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if ((name == "Fortress Vehicle Workshop (E)") and (textureIndex == 68)) then
						WgAttacker = "Alliance"
					elseif ((name == "Fortress Vehicle Workshop (E)") and (textureIndex == 71)) then	
						WgAttacker = "Horde"
					end
				end
			end

			local _, localizedName, isActive, canQueue, enterTime, canEnter = GetWorldPVPAreaInfo(1)
			if isActive == true then
				WgActive = "Active"
			elseif isActive == false then
				WgActive = "NotActive"
			end
			-- Workshops
			for i=3, 3, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = WGget_objective(textureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(textureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(textureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						end
						WGobjectives[typ] = textureIndex
					end
				end
			end
			for i=13, 13, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+100
					local typ = WGget_objective(faketextureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(faketextureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(faketextureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						end
						WGobjectives[typ] = faketextureIndex
					end
				end
			end
			for i=14, 14, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+200
					local typ = WGget_objective(faketextureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(faketextureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(faketextureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						end
						WGobjectives[typ] = faketextureIndex
					end
				end
			end
			for i=4, 4, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+300
					local typ = WGget_objective(faketextureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(faketextureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Defence.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(faketextureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Defence.mp3");
						end
						WGobjectives[typ] = faketextureIndex
					end
				end
			end
			-- Towers
			for i=9, 9, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local typ = WGget_objective(textureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(textureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_HeavilyDamaged.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(textureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_HeavilyDamaged.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 3 and WGobj_state(textureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 4 and WGobj_state(textureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
						end
						WGobjectives[typ] = textureIndex
					end
				end
			end
			for i=15, 15, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+100
					local typ = WGget_objective(faketextureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(faketextureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_HeavilyDamaged.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(faketextureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_HeavilyDamaged.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 3 and WGobj_state(faketextureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 4 and WGobj_state(faketextureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
						end
						WGobjectives[typ] = faketextureIndex
					end
				end
			end
			for i=5, 5, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+200
					local typ = WGget_objective(faketextureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(faketextureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_HeavilyDamaged.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(faketextureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_HeavilyDamaged.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 3 and WGobj_state(faketextureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_ALLIANCE_Destroyed.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 4 and WGobj_state(faketextureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_HORDE_Destroyed.mp3");
						end
						WGobjectives[typ] = faketextureIndex
					end
				end
			end
			for i=18, 18, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					local faketextureIndex = textureIndex+300
					local typ = WGget_objective(faketextureIndex)
					if typ then
						if WGobj_state(WGobjectives[typ]) == 1 and WGobj_state(faketextureIndex) == 2 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Horde_Wins.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 3 and WGobj_state(faketextureIndex) == 4 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Horde_Wins.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 5 and WGobj_state(faketextureIndex) == 6 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Horde_Wins.mp3");	
						elseif WGobj_state(WGobjectives[typ]) == 2 and WGobj_state(faketextureIndex) == 1 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Alliance_Wins.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 4 and WGobj_state(faketextureIndex) == 3 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Alliance_Wins.mp3");
						elseif WGobj_state(WGobjectives[typ]) == 6 and WGobj_state(faketextureIndex) == 5 then
							PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Alliance_Wins.mp3");
						end
						WGobjectives[typ] = faketextureIndex
					end
				end
			end
		end

	elseif (event == "UPDATE_BATTLEFIELD_SCORE") then
		-- Isle of Conquest Countdown
		if (MyZone == "Zone_IsleofConquest") then
			_, _, AllianceScore = GetWorldStateUIInfo(1); -- Alliance score
			_, _, HordeScore = GetWorldStateUIInfo(2); -- Horde score
			if (HordeScore == "Reinforcements: 10") and (myfaction == "Alliance") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\TenKillsRemains.mp3");
			elseif (AllianceScore == "Reinforcements: 10") and (myfaction == "Horde") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\TenKillsRemains.mp3");
			elseif (HordeScore == "Reinforcements: 5") and (myfaction == "Alliance") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\FiveKillsRemains.mp3");
			elseif (AllianceScore == "Reinforcements: 5") and (myfaction == "Horde") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\FiveKillsRemains.mp3");
			elseif (HordeScore == "Reinforcements: 1") and (myfaction == "Alliance") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\OneKillRemains.mp3");
			elseif (AllianceScore == "Reinforcements: 1") and (myfaction == "Horde") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\OneKillRemains.mp3");
			end
		 -- Alterac Valley Countdown
		elseif (MyZone == "Zone_AlteracValley") then
			_, _, AllianceScore = GetWorldStateUIInfo(1); -- Alliance score
			_, _, HordeScore = GetWorldStateUIInfo(2); -- Horde score
			if (HordeScore == "Reinforcements: 10") and (myfaction == "Alliance") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\TenKillsRemains.mp3");
			elseif (AllianceScore == "Reinforcements: 10") and (myfaction == "Horde") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\TenKillsRemains.mp3");
			elseif (HordeScore == "Reinforcements: 5") and (myfaction == "Alliance") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\FiveKillsRemains.mp3");
			elseif (AllianceScore == "Reinforcements: 5") and (myfaction == "Horde") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\FiveKillsRemains.mp3");
			elseif (HordeScore == "Reinforcements: 1") and (myfaction == "Alliance") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\OneKillRemains.mp3");
			elseif (AllianceScore == "Reinforcements: 1") and (myfaction == "Horde") then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\CountDown\\OneKillRemains.mp3");
			end
		end

	elseif (event == "WORLD_STATE_UI_TIMER_UPDATE") then
		-- Tol Barad WinSounds
		if (MyZone == "Zone_TolBarad") then
			_, _, TbTimeRemaining = GetWorldStateUIInfo(9);
			for i=1, 1, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if ((name == "Baradin Hold") and (textureIndex == 48)) then
						TbAttacker = "Alliance"
					elseif ((name == "Baradin Hold") and (textureIndex == 46)) then	
						TbAttacker = "Horde"
					end
				end
			end

			local _, localizedName, isActive, canQueue, enterTime, canEnter = GetWorldPVPAreaInfo(2)
			if isActive == true then
				TbActive = "Active"
			elseif isActive == false then
				TbActive = "NotActive"
			end

			if ((TbActive == "Active") and (TbAttacker == "Alliance") and (TbTimeRemaining == "Time Remaining: 00:00")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Horde_Wins.mp3");
			elseif ((TbActive == "Active") and (TbAttacker == "Horde") and (TbTimeRemaining == "Time Remaining: 00:00")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Alliance_Wins.mp3");
			end
		 -- Wintergrasp WinSounds
		elseif (MyZone == "Zone_Wintergrasp") then
			_, _, WgTimeRemaining = GetWorldStateUIInfo(7);
			for i=7, 7, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if ((name == "Fortress Vehicle Workshop (E)") and (textureIndex == 68)) then
						WgAttacker = "Alliance"
					elseif ((name == "Fortress Vehicle Workshop (E)") and (textureIndex == 71)) then	
						WgAttacker = "Horde"
					end
				end
			end

			local _, localizedName, isActive, canQueue, enterTime, canEnter = GetWorldPVPAreaInfo(1)
			if isActive == true then
				WgActive = "Active"
			elseif isActive == false then
				WgActive = "NotActive"
			end
			
			if ((WgActive == "Active") and (WgAttacker == "Alliance") and (WgTimeRemaining == "Time Remaining: 00:00")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Horde_Wins.mp3");
			elseif ((WgActive == "Active") and (WgAttacker == "Horde") and (WgTimeRemaining == "Time Remaining: 00:00")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\GameStatus\\Alliance_Wins.mp3");
			end
		end
	end	

	if (event == "ZONE_CHANGED_NEW_AREA") then
		-- Tol Barad PlaySounds
		if (MyZone == "Zone_TolBarad") then
			for i=1, 1, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if ((name == "Baradin Hold") and (textureIndex == 48)) then
						TbAttacker = "Alliance"
					elseif ((name == "Baradin Hold") and (textureIndex == 46)) then	
						TbAttacker = "Horde"
					end
				end
			end

			local _, localizedName, isActive, canQueue, enterTime, canEnter = GetWorldPVPAreaInfo(2)
			if isActive == true then
				TbActive = "Active"
			elseif isActive == false then
				TbActive = "NotActive"
			end

			if ((TbActive == "Active") and (TbAttacker == "Horde") and (myfaction == "Horde")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayRedAttackCore.mp3");
			elseif ((TbActive == "Active") and (TbAttacker == "Horde") and (myfaction == "Alliance")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayBlueDefendCore.mp3");
			elseif ((TbActive == "Active") and (TbAttacker == "Alliance") and (myfaction == "Alliance")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayBlueAttackCore.mp3");
			elseif ((TbActive == "Active") and (TbAttacker == "Alliance") and (myfaction == "Horde")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayRedDefendCore.mp3");
			end
		 -- Wintergrasp PlaySounds
		elseif (MyZone == "Zone_Wintergrasp") then
			for i=7, 7, 1 do
				local name, _, textureIndex = GetMapLandmarkInfo(i)
				if name and textureIndex then
					if ((name == "Fortress Vehicle Workshop (E)") and (textureIndex == 68)) then
						WgAttacker = "Alliance"
					elseif ((name == "Fortress Vehicle Workshop (E)") and (textureIndex == 71)) then
						WgAttacker = "Horde"
					end
				end
			end

			local _, localizedName, isActive, canQueue, enterTime, canEnter = GetWorldPVPAreaInfo(1)
			if isActive == true then
				WgActive = "Active"
			elseif isActive == false then
				WgActive = "NotActive"
			end

			if ((WgActive == "Active") and (WgAttacker == "Horde") and (myfaction == "Horde")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayRedAttackCore.mp3");
			elseif ((WgActive == "Active") and (WgAttacker == "Horde") and (myfaction == "Alliance")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayBlueDefendCore.mp3");
			elseif ((WgActive == "Active") and (WgAttacker == "Alliance") and (myfaction == "Alliance")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayBlueAttackCore.mp3");
			elseif ((WgActive == "Active") and (WgAttacker == "Alliance") and (myfaction == "Horde")) then
				PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\"..MyZone.."\\"..event.."_PlayRedDefendCore.mp3");
			end
		end
	end

	 -- See if its to an enemy
	local toEnemy
	local toEnemyPlayer
	local toEnemyNPC
	if (dstName and not CombatLog_Object_IsA(dstFlags, COMBATLOG_OBJECT_NONE)) then
		toEnemyPlayer = CombatLog_Object_IsA(dstFlags, PS_COMBATLOG_FILTER_ENEMY_PLAYERS)
		toEnemyNPC = CombatLog_Object_IsA(dstFlags, PS_COMBATLOG_FILTER_ENEMY_NPC)
	end

	if PS_pvpmode == true then
		toEnemy = toEnemyPlayer;
	else
		toEnemy = toEnemyNPC;
	end

	 -- If not from a event type we care about, then end
	if (eventType == "PARTY_KILL" and srcGUID == player and toEnemy) then
		-- Killing
		if (not PS_lastkill or (GetTime() - PS_lastkill > PS_reset_time) or PS_timer_reset) then
			PS_file = "First Blood.mp3";
			if (mygender == "Male") then
				PS_msg = MSG_FirstBloodMale;
			elseif (mygender == "Female") then
				PS_msg = MSG_FirstBloodFemale;
			end			
			PS_kills = 1;
			PS_mkills = 1;
			PS_timer_reset = false;
		elseif (GetTime() - PS_lastkill <= PS_reset_time) then
			PS_kills = PS_kills + 1;
			 -- Multikilling
			if (GetTime() - PS_lastkill <= PS_mkill_time) then
				PS_firstmkill = PS_lastkill;
				if (GetTime() - PS_firstmkill <= PS_mkill_time) then
					PS_mkills = PS_mkills + 1;
					if (PS_mkills == 2) then
						PS_file = "Killing Spree.mp3";
						PS_msg = MSG_KillingSpree;
					elseif (PS_mkills == 3) then
						PS_file = "Rampage.mp3";
						PS_msg = MSG_Rampage;
					elseif (PS_mkills == 4) then
						PS_file = "Dominating.mp3";
						PS_msg = MSG_Dominating;
					elseif (PS_mkills == 5) then
						PS_file = "Unstoppable.mp3";
						PS_msg = MSG_Unstopable;
					elseif (PS_mkills == 6) then
						PS_file = "Godlike.mp3";
						PS_msg = MSG_Godlike;
					elseif (PS_mkills > 6) then
						PS_file = "Massacre.mp3";
						PS_msg = MSG_Massacre;
					end
				end
			end
		end
		PlaySoundFile("Interface\\AddOns\\PVPSound\\Sounds\\Spree\\"..PS_file);
		if PS_mkills >= 1000 then
			PS_mkills_msg = "[x" .. PS_mkills .. "]";
		else
			PS_mkills_msg = "";
		end
		if PS_showemote == true then
			SendChatMessage(PS_msg .. PS_mkills_msg, "EMOTE");
		elseif (PS_showemote == false and PS_kills ~= 1) then
			DEFAULT_CHAT_FRAME:AddMessage(srcName .." " ..PS_msg..PS_mkills_msg,1,1,0);
		end
		PS_lastkill = GetTime();
	end
end

frame:SetScript("OnEvent", PVPSound_OnEvent);

function PVPSound_Command(arg1)
	arg1 = strlower(arg1)
	if arg1 == "emote" then
		PS_showemote = not PS_showemote;
		if PS_showemote == true then
			DEFAULT_CHAT_FRAME:AddMessage(Opt_ShowEmote .. ": " .. Opt_Enable,1,1,0);
		else
			DEFAULT_CHAT_FRAME:AddMessage(Opt_ShowEmote .. ": " .. Opt_Disable,1,1,0);
		end
	elseif arg1 == "pvp" then
		PS_pvpmode = not PS_pvpmode;
		if PS_pvpmode == true then
			DEFAULT_CHAT_FRAME:AddMessage(Opt_PVPMode,1,1,0);
		else
			DEFAULT_CHAT_FRAME:AddMessage(Opt_PVEMode,1,1,0);
		end
	elseif arg1 == "reset" then
		PS_timer_reset = true;
		DEFAULT_CHAT_FRAME:AddMessage(Opt_reset,1,1,0);
	elseif arg1 == "help" then
		DEFAULT_CHAT_FRAME:AddMessage("PVPSound v" .. GetAddOnMetadata("PVPSound", "Version") .. " " .. Opt_cmdlist,0,1,0);
		DEFAULT_CHAT_FRAME:AddMessage("/ps			———>" .. Opt_helpstatus,1,1,0);
		DEFAULT_CHAT_FRAME:AddMessage("/ps PVP		———>" .. Opt_helpmode,1,1,0);
		DEFAULT_CHAT_FRAME:AddMessage("/ps Emote	———>" .. Opt_helpshowemote,1,1,0);
		DEFAULT_CHAT_FRAME:AddMessage("/ps Reset	———>" .. Opt_helpreset,1,1,0);
		DEFAULT_CHAT_FRAME:AddMessage("/ps Help		———>" .. Opt_helpcmdlist,1,1,0);
	else
		DEFAULT_CHAT_FRAME:AddMessage("PVPSound v" .. GetAddOnMetadata("PVPSound", "Version") .. " " .. Opt_helpinput,0,1,0);
		DEFAULT_CHAT_FRAME:AddMessage(Opt_kills .. ": "..PS_kills,1,1,0);
		if PS_pvpmode == true then
			DEFAULT_CHAT_FRAME:AddMessage(Opt_PVPMode,1,1,0);
		else
			DEFAULT_CHAT_FRAME:AddMessage(Opt_PVEMode,1,1,0);
		end
		if PS_showemote == true then
			DEFAULT_CHAT_FRAME:AddMessage(Opt_ShowEmote .. ": " .. Opt_Enable,1,1,0);
		else
			DEFAULT_CHAT_FRAME:AddMessage(Opt_ShowEmote .. ": " .. Opt_Disable,1,1,0);
		end
	end
end