LVBM.AddOns.Ragnaros = { 
	["Name"] = "Ragnaros",
	["Abbreviation1"] = "Ragna",
	["Abbreviation1"] = "Rag",
	["Version"] = "1.0",
	["Author"] = "La Vendetta|Nitram",
	["Description"] = LVBM_RAGNAROS_INFO,
	["Instance"] = LVBM_MC,
	["GUITab"] = LVBMGUI_TAB_MC,
	["Sort"] = 10,
	["Options"] = {  
		["Enabled"] = true,
		["Announce"] = false,
	},
	["InCombat"] = false,
	["Submerged"] = false,
	["Events"] = {
		["CHAT_MSG_MONSTER_YELL"] = true,
		["PLAYER_REGEN_DISABLED"] = true,
	},	
	["OnEvent"] = function(event, arg1) 
		if ( event == "PLAYER_REGEN_DISABLED" ) and ( GetRealZoneText() == LVBM_MC ) and ( not LVBM.AddOns.Ragnaros.InCombat ) then
			if LVBM.UnitExists("Ragnaros") then
				LVBM.Schedule(5, "LVBM.AddOns.Ragnaros.OnEvent", "ConfirmCombat");
			end
		elseif ( event == "ConfirmCombat" ) then
			if LVBM.DetectCombat("Ragnaros") then
				LVBM.AddOns.Ragnaros.InCombat = true;
				LVBM.AddOns.Ragnaros.Submerged = false;
				LVBM.Announce(LVBM_RAGNAROS_EMERGED);
				LVBM.Schedule(55, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 120);
				LVBM.Schedule(115, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 60);
				LVBM.Schedule(145, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 30);
				LVBM.Schedule(160, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 15);
				LVBM.StartStatusBarTimer(175, "Submerge");
			end
		elseif ( event == "ConfirmCombatEnd" ) then
			if ( not UnitAffectingCombat("player") ) and ( not UnitIsDeadOrGhost("player") ) then
				LVBM.AddOns.Ragnaros.InCombat = false;
				LVBM.AddOns.Ragnaros.Submerged = false;
				LVBM.UnSchedule("LVBM.AddOns.Ragnaros.OnEvent");
				LVBM.EndStatusBarTimer("Submerge");
				LVBM.EndStatusBarTimer("Emerge");
				LVBM.EndStatusBarTimer("Wrath of Ragnaros");
			end
		elseif ( event == "CHAT_MSG_MONSTER_YELL" ) then
			if ( arg1 == LVBM_RAGNAROS_WRATH ) then
				LVBM.Announce(LVBM_RAGNAROS_WRATH_WARN1);
				LVBM.EndStatusBarTimer("Wrath of Ragnaros");
				LVBM.StartStatusBarTimer(30, "Wrath of Ragnaros");
				LVBM.Schedule(25, "LVBM.AddOns.Ragnaros.OnEvent", "WrathWarning", 5);
			elseif ( arg1 == LVBM_RAGNAROS_SUBMERGE ) then
				LVBM.AddOns.Ragnaros.Submerged = true;
				LVBM.UnSchedule("LVBM.AddOns.Ragnaros.OnEvent", "WrathWarning", 5);
				LVBM.EndStatusBarTimer("Wrath of Ragnaros");
				LVBM.EndStatusBarTimer("Submerge");
				LVBM.StartStatusBarTimer(90, "Emerge");
				LVBM.Schedule(30, "LVBM.AddOns.Ragnaros.OnEvent", "EmergeWarning", 60);
				LVBM.Schedule(60, "LVBM.AddOns.Ragnaros.OnEvent", "EmergeWarning", 30);
				LVBM.Schedule(75, "LVBM.AddOns.Ragnaros.OnEvent", "EmergeWarning", 15);
			end
			if ( arg1 ~= LVBM_RAGNAROS_SUBMERGE ) and ( arg2 == "Ragnaros" ) and ( LVBM.AddOns.Ragnaros.Submerged ) then
				LVBM.AddOns.Ragnaros.OnEvent("Emerge");
			end
		elseif ( event == "Emerge" ) then
			LVBM.UnSchedule("LVBM.AddOns.Ragnaros.OnEvent", "Emerge");
			LVBM.UnSchedule("LVBM.AddOns.Ragnaros.OnEvent", "EmergeWarning", 60);
			LVBM.UnSchedule("LVBM.AddOns.Ragnaros.OnEvent", "EmergeWarning", 30);
			LVBM.UnSchedule("LVBM.AddOns.Ragnaros.OnEvent", "EmergeWarning", 15);
			LVBM.AddOns.Ragnaros.Submerged = false;
			LVBM.EndStatusBarTimer("Emerge");
			LVBM.Announce(LVBM_RAGNAROS_EMERGED);
			LVBM.Schedule(60, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 120);
			LVBM.Schedule(120, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 60);
			LVBM.Schedule(150, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 30);
			LVBM.Schedule(165, "LVBM.AddOns.Ragnaros.OnEvent", "SubmergeWarning", 15);
			LVBM.StartStatusBarTimer(180, "Submerge");
		elseif ( event == "WrathWarning" ) then
			if arg1 then
				LVBM.Announce(string.format(LVBM_RAGNAROS_WRATH_WARN2, arg1));
			end
		elseif ( event == "SubmergeWarning" ) then
			if type(arg1) == "number" then
				if arg1 > 60 then
					LVBM.Announce(string.format(LVBM_RAGNAROS_SUBMERGE_WARN, arg1/60, LVBM_MINUTES))
				elseif arg1 == 60 then
					LVBM.Announce(string.format(LVBM_RAGNAROS_SUBMERGE_WARN, arg1/60, LVBM_MINUTE))
				else
					LVBM.Announce(string.format(LVBM_RAGNAROS_SUBMERGE_WARN, arg1, LVBM_SECONDS))
				end
			end
		elseif ( event == "EmergeWarning" ) then
			if type(arg1) == "number" then
				if arg1 > 60 then
					LVBM.Announce(string.format(LVBM_RAGNAROS_EMERGE_WARN, arg1/60, LVBM_MINUTES))
				elseif arg1 == 60 then
					LVBM.Announce(string.format(LVBM_RAGNAROS_EMERGE_WARN, arg1/60, LVBM_MINUTE))
				else
					LVBM.Announce(string.format(LVBM_RAGNAROS_EMERGE_WARN, arg1, LVBM_SECONDS))
				end
			end
		end
	end,
	
	["OnUpdate"] = function(elapsed)
		if (LVBM.AddOns.Ragnaros.InCombat) and (not UnitAffectingCombat("player")) and (not UnitIsDeadOrGhost("player")) and (not LVBM.GetScheduleTimeLeft("LVBM.AddOns.Ragnaros.OnEvent", "ConfirmCombatEnd")) then
			LVBM.Schedule(10, "LVBM.AddOns.Ragnaros.OnEvent", "ConfirmCombatEnd");
			return;
		end
	end,
	["UpdateInterval"] = 3,
};
