	-- Spider Wing
tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_AnubRekhan_OnLoad");
tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Faerlina_OnLoad");
tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Maexxna_OnLoad");

	-- Necro Wing
tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Noth_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Heigan_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Loatheb_OnLoad");

	-- Deathknight Wing
tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Razuvious_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Gothik_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Korthazz_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Blaumeux_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Mograine_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Zeliek_OnLoad");

	-- Abomination Wing
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Patchwerk_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Grobbulus_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Gluth_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Thaddius_OnLoad");

	-- Frostwyrm Lair
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_Sapphiron_OnLoad");
--tinsert(CT_RABoss_ModsToLoad, "CT_RABoss_KelThuzad_OnLoad");




-- Anub'Rekhan
function CT_RABoss_AnubRekhan_End()
	CT_RABoss_UnSchedule("CT_RABoss_AnubRekhan_EventHandler");
	CT_RABoss_UnSchedule("CT_RABoss_AnubRekhan_EventHandler");
	CT_RABoss_UnSchedule("CT_RABoss_AnubRekhan_EventHandler");

	CT_RABoss_Mods["AnubRekhan"]["fight"] = nil;
	CT_RABoss_Mods["AnubRekhan"]["lastAction"] = nil;

	CT_RABoss_VisualTimer.removeTimer("AnubLocustSwarm");
end

function CT_RABoss_AnubRekhan_OnLoad()
	CT_RABoss_AddMod("AnubRekhan", CT_RABOSS_ANUBREKHAN_INFO, 1, CT_RABOSS_LOCATIONS_NAXXRAMAS);
	
	CT_RABoss_AddEvent("AnubRekhan", "CHAT_MSG_COMBAT_FRIENDLY_DEATH", CT_RABoss_AnubRekhan_EventHandler);
	CT_RABoss_AddEvent("AnubRekhan", "CHAT_MSG_COMBAT_HOSTILE_DEATH", CT_RABoss_AnubRekhan_EventHandler);
	CT_RABoss_AddEvent("AnubRekhan", "CHAT_MSG_MONSTER_YELL", CT_RABoss_AnubRekhan_EventHandler);
	CT_RABoss_AddEvent("AnubRekhan", "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS", CT_RABoss_AnubRekhan_EventHandler);
	CT_RABoss_AddEvent("AnubRekhan", "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE", CT_RABoss_AnubRekhan_EventHandler);
	CT_RABoss_AddEvent("AnubRekhan", "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF", CT_RABoss_AnubRekhan_EventHandler);
 
	CT_RABoss_AddDropDownButton("AnubRekhan", { CT_RABOSS_ANNOUNCE, CT_RABOSS_ANNOUNCE_INFO .. CT_RABOSS_REQ_LEADER_OR_PROM }, "CT_RABoss_ModInfo", "announce", "CT_RABoss_SetInfo");
	CT_RABoss_AddDropDownButton("AnubRekhan", { CT_RABOSS_ANUBREKHAN_DEATH, CT_RABOSS_ANUBREKHAN_DEATH_INFO}, "CT_RABoss_ModInfo", "playerDeath", "CT_RABoss_SetInfo");

	CT_RA_RegisterSlashCmd("/anubstop", CT_RABOSS_CMD_ANUBSTOP, 30, "ANUBSTOP", function()
		CT_RABoss_AnubRekhan_End();
	end, "/anubstop");

	CT_RABoss_Mods["AnubRekhan"]["fight"] = nil;
	CT_RABoss_Mods["AnubRekhan"]["lastAction"] = nil;

end

function CT_RABoss_AnubRekhan_LocustSwarm()
	CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SWARM_PREALERT, "90", "100"), CT_RABoss_Mods["AnubRekhan"]["announce"]);
	CT_RABoss_PlaySound(2);

	CT_RABoss_Mods["AnubRekhan"]["fight"] = 1;
	CT_RABoss_Mods["AnubRekhan"]["lastAction"] = GetTime();

	CT_RABoss_Schedule("CT_RABoss_AnubRekhan_EventHandler", 60, "locustSwarmPreWarn30");
	CT_RABoss_Schedule("CT_RABoss_AnubRekhan_EventHandler", 75, "locustSwarmPreWarn15");
	CT_RABoss_Schedule("CT_RABoss_AnubRekhan_EventHandler", 85, "locustSwarmPreWarn5");
end

function CT_RABoss_AnubRekhan_EventHandler(event)
	if ( not CT_RABoss_Mods["AnubRekhan"] or not CT_RABoss_Mods["AnubRekhan"]["status"] or not CT_RABoss_Mods["AnubRekhan"].enabled ) then
		return;
	end

	if ( event == "CHAT_MSG_MONSTER_YELL" and arg2 == CT_RABOSS_NAMES["AnubRekhan"] ) then
		if ( string.find(arg1, CT_RABOSS_ANUBREKHAN_YELL1_DETECT) or string.find(arg1, CT_RABOSS_ANUBREKHAN_YELL2_DETECT) or string.find(arg1, CT_RABOSS_ANUBREKHAN_YELL3_DETECT) ) then
			CT_RABoss_AnubRekhan_LocustSwarm();
		end

	elseif ( (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE" or event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF") and string.find(arg1, CT_RABOSS_ANUBREKHAN_SWARM_CAST_DETECT) ) then
		CT_RABoss_Announce(CT_RABOSS_ANUBREKHAN_SWARM_IMMINENT_ALERT, CT_RABoss_Mods["AnubRekhan"]["announce"]);
		CT_RABoss_PlaySound(3);
		CT_RABoss_VisualTimer.addTimer("AnubLocustSwarm", 23, CT_RABOSS_ANUBREKHAN_SWARMEND_TIMER);

		CT_RABoss_UnSchedule("CT_RABoss_AnubRekhan_EventHandler", "locustSwarmPreWarn30");
		CT_RABoss_UnSchedule("CT_RABoss_AnubRekhan_EventHandler", "locustSwarmPreWarn15");
		CT_RABoss_UnSchedule("CT_RABoss_AnubRekhan_EventHandler", "locustSwarmPreWarn5");
		CT_RABoss_Schedule("CT_RABoss_AnubRekhan_EventHandler", 13, "locustSwarmEndWarn10");
		CT_RABoss_Schedule("CT_RABoss_AnubRekhan_EventHandler", 20, "locustSwarmEndWarn3");

		CT_RABoss_AnubRekhan_LocustSwarm();

	elseif ( event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and string.find(arg1, CT_RABOSS_ANUBREKHAN_SWARM_GAIN_DETECT) ) then
		CT_RABoss_Announce(CT_RABOSS_ANUBREKHAN_SWARM_ALERT, CT_RABoss_Mods["AnubRekhan"]["announce"]);
		CT_RABoss_Mods["AnubRekhan"]["lastAction"] = GetTime();
		CT_RABoss_PlaySound(3);

	elseif ( event == "locustSwarmPreWarn30" ) then
		CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SWARM_PREALERT, "30", "40"), CT_RABoss_Mods["AnubRekhan"]["announce"]);

	elseif ( event == "locustSwarmPreWarn15" ) then
		CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SWARM_PREALERT, "15", "25"), CT_RABoss_Mods["AnubRekhan"]["announce"]);

	elseif ( event == "locustSwarmPreWarn5" ) then
		CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SWARM_PREALERT, "5", "15"), CT_RABoss_Mods["AnubRekhan"]["announce"]);
		CT_RABoss_PlaySound(1);

	elseif ( event == "locustSwarmEndWarn10" ) then
		CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SWARM_END_PREALERT, "10"), CT_RABoss_Mods["AnubRekhan"]["announce"]);

	elseif ( event == "locustSwarmEndWarn3" ) then
		CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SWARM_END_PREALERT, "3"), CT_RABoss_Mods["AnubRekhan"]["announce"]);
		CT_RABoss_PlaySound(1);

	end

	if ( event == "CHAT_MSG_COMBAT_FRIENDLY_DEATH" and CT_RABoss_Mods["AnubRekhan"]["playerDeath"] and CT_RABoss_Mods["AnubRekhan"]["fight"] ) then
		if ( not CT_RABoss_Mods["AnubRekhan"]["lastAction"] or (GetTime() - CT_RABoss_Mods["AnubRekhan"]["lastAction"] > 120) ) then
			CT_RABoss_AnubRekhan_End();
			return;
		end

		local _, _, nameSelf = string.find(arg1, CT_RABOSS_ANUBREKHAN_DEATHSELF_DETECT);
		local _, _, name = string.find(arg1, CT_RABOSS_ANUBREKHAN_DEATHPLAYER_DETECT);

		if ( name ~= nil ) then
			CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SCARAB_SPAWN_ALERT, name), CT_RABoss_Mods["AnubRekhan"]["announce"]);

		elseif ( nameSelf == CT_RABOSS_SELF1 ) then
			name = UnitName("player");
			CT_RABoss_Announce(format(CT_RABOSS_ANUBREKHAN_SCARAB_SPAWN_ALERT, name), CT_RABoss_Mods["AnubRekhan"]["announce"]);
		end
	end

	if ( event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" and string.find(arg1, CT_RABOSS_ANUBREKHAN_DEATH_DETECT) ) then
		CT_RABoss_AnubRekhan_End();
	end

end



-- Faerlina
function CT_RABoss_Faerlina_Reset()
	CT_RABoss_Mods["Faerlina"]["engaged"] = nil;
	CT_RABoss_Mods["Faerlina"]["enraged"] = nil;
	CT_RABoss_Mods["Faerlina"]["silenced"] = nil;
	CT_RABoss_Mods["Faerlina"]["lastAction"] = nil;
end

function CT_RABoss_Faerlina_OnLoad()
	CT_RABoss_AddMod("Faerlina", CT_RABOSS_FAERLINA_INFO, 1, CT_RABOSS_LOCATIONS_NAXXRAMAS);
	CT_RABoss_AddEvent("Faerlina", "CHAT_MSG_MONSTER_YELL", CT_RABoss_Faerlina_EventHandler);
	CT_RABoss_AddEvent("Faerlina", "CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF", CT_RABoss_Faerlina_EventHandler);
	CT_RABoss_AddEvent("Faerlina", "CHAT_MSG_SPELL_PARTY_BUFF", CT_RABoss_Faerlina_EventHandler);
	CT_RABoss_AddEvent("Faerlina", "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE", CT_RABoss_Faerlina_EventHandler);

	CT_RABoss_AddDropDownButton("Faerlina", { CT_RABOSS_ANNOUNCE, CT_RABOSS_ANNOUNCE_INFO .. CT_RABOSS_REQ_LEADER_OR_PROM }, "CT_RABoss_ModInfo", "announce", "CT_RABoss_SetInfo");

	CT_RA_RegisterSlashCmd("/faerlinareset", "Faerlina Reset", 30, "FAERLINARESET", function()
		CT_RABoss_Faerlina_Reset();
	end, "/faerlinareset");

	CT_RABoss_Mods["Faerlina"]["lastAction"] = nil;
end

function CT_RABoss_Faerlina_UnSchedule()
	CT_RABoss_UnSchedule("CT_RABoss_Faerlina_EventHandler", "enragePreWarn30");
	CT_RABoss_UnSchedule("CT_RABoss_Faerlina_EventHandler", "enragePreWarn15");
	CT_RABoss_UnSchedule("CT_RABoss_Faerlina_EventHandler", "enragePreWarn5");
	CT_RABoss_UnSchedule("CT_RABoss_Faerlina_EventHandler", "enrageWarn");
end

function CT_RABoss_Faerlina_Schedule(totalTime)
	CT_RABoss_Mods["Faerlina"]["lastAction"] = GetTime();

	CT_RABoss_Schedule("CT_RABoss_Faerlina_EventHandler", totalTime-30, "enragePreWarn30");
	CT_RABoss_Schedule("CT_RABoss_Faerlina_EventHandler", totalTime-15, "enragePreWarn15");
	CT_RABoss_Schedule("CT_RABoss_Faerlina_EventHandler", totalTime-5, "enragePreWarn5");
	CT_RABoss_Schedule("CT_RABoss_Faerlina_EventHandler", totalTime, "enrageWarn");
end

function CT_RABoss_Faerlina_EventHandler(event)
	if ( not CT_RABoss_Mods["Faerlina"] or not CT_RABoss_Mods["Faerlina"]["status"] or not CT_RABoss_Mods["Faerlina"].enabled ) then
		return;
	end

	if ( event == "CHAT_MSG_MONSTER_YELL" and arg2 == CT_RABOSS_NAMES["Faerlina"] ) then
		if ( not CT_RABoss_Mods["Faerlina"]["lastAction"] or (GetTime() - CT_RABoss_Mods["Faerlina"]["lastAction"] > 90) ) then
			CT_RABoss_Faerlina_Reset();
		end

		if ( string.find(arg1, CT_RABOSS_FAERLINA_YELL1_DETECT) or string.find(arg1, CT_RABOSS_FAERLINA_YELL2_DETECT) or string.find(arg1, CT_RABOSS_FAERLINA_YELL3_DETECT) or string.find(arg1, CT_RABOSS_FAERLINA_YELL4_DETECT) ) then
			if ( not CT_RABoss_Mods["Faerlina"]["engaged"] ) then
				CT_RABoss_Faerlina_Schedule(60);
				CT_RABoss_VisualTimer.addTimer("FaerlinaEnrage", 60, CT_RABOSS_FAERLINA_ENRAGE_TIMER, "red");

				CT_RABoss_Mods["Faerlina"]["engaged"] = 1;
				CT_RABoss_Mods["Faerlina"]["enraged"] = nil;
				CT_RABoss_Mods["Faerlina"]["silenced"] = nil;

			else
				CT_RABoss_Announce(CT_RABOSS_FAERLINA_ENRAGE_ALERT, CT_RABoss_Mods["Faerlina"]["announce"]);
				CT_RABoss_PlaySound(2);

				CT_RABoss_Mods["Faerlina"]["enrageTimer"] = GetTime();
				CT_RABoss_Mods["Faerlina"]["enraged"] = 1;
				CT_RABoss_Mods["Faerlina"]["silenced"] = nil;

				CT_RABoss_Faerlina_UnSchedule();
			end
		end
	
	elseif ( event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE" and string.find(arg1, CT_RABOSS_FAERLINA_EMBRACE_DETECT) ) then
		if ( not CT_RABoss_Mods["Faerlina"]["silenced"] ) then
			CT_RABoss_Schedule("CT_RABoss_Faerlina_EventHandler", 5, "silence");

			local enrageDiff = 60;

			CT_RABoss_Mods["Faerlina"]["silenced"] = 1;
			CT_RABoss_Mods["Faerlina"]["engaged"] = 1;

			if ( CT_RABoss_Mods["Faerlina"]["enraged"] ) then
				enrageDiff = 60 - (GetTime() - CT_RABoss_Mods["Faerlina"]["enrageTimer"]);

				CT_RABoss_Announce(CT_RABOSS_FAERLINA_ENRAGE_SILENCED_ALERT, CT_RABoss_Mods["Faerlina"]["announce"]);

				CT_RABoss_Faerlina_Schedule(enrageDiff);
				CT_RABoss_VisualTimer.addTimer("FaerlinaEnrage", enrageDiff, CT_RABOSS_FAERLINA_ENRAGE_TIMER, "red");

				CT_RABoss_PlaySound(3);
				CT_RABoss_Mods["Faerlina"]["enraged"] = nil;

			else
				CT_RABoss_Announce(CT_RABOSS_FAERLINA_SILENCED_ALERT, CT_RABoss_Mods["Faerlina"]["announce"]);
				CT_RABoss_PlaySound(3);	

				CT_RABoss_Faerlina_UnSchedule()
				CT_RABoss_Faerlina_Schedule(30);
				CT_RABoss_VisualTimer.addTimer("FaerlinaEnrage", 30, CT_RABOSS_FAERLINA_ENRAGE_TIMER, "red");
			end
		end

	elseif ( event == "silence") then
		CT_RABoss_Mods["Faerlina"]["silenced"] = nil;

	elseif ( event == "enragePreWarn30") then
		CT_RABoss_Announce(format(CT_RABOSS_FAERLINA_ENRAGE_PREALERT, "30"), CT_RABoss_Mods["Faerlina"]["announce"]);
		CT_RABoss_PlaySound(3);

	elseif ( event == "enragePreWarn15") then
		CT_RABoss_Announce(format(CT_RABOSS_FAERLINA_ENRAGE_PREALERT, "15"), CT_RABoss_Mods["Faerlina"]["announce"]);
		CT_RABoss_PlaySound(3);

	elseif ( event == "enragePreWarn5") then
		CT_RABoss_Announce(format(CT_RABOSS_FAERLINA_ENRAGE_PREALERT, "5"), CT_RABoss_Mods["Faerlina"]["announce"]);
		CT_RABoss_PlaySound(3);

	elseif ( event == "enrageWarn" ) then
		CT_RABoss_Announce(CT_RABOSS_FAERLINA_ENRAGEEND_ALERT, CT_RABoss_Mods["Faerlina"]["announce"]);
		CT_RABoss_PlaySound(3);
	end
end


-- Maexxna
function CT_RABoss_Maexxna_Stop()
	CT_RABoss_Mods["Maexxna"]["engaged"] = nil;
	CT_RABoss_Mods["Maexxna"]["lastAction"] = nil;
	CT_RABoss_Mods["Maexxna"]["sPlayers"] = "";
	CT_RABoss_Mods["Maexxna"]["nbWebWrap"] = 0;

	CT_RABoss_UnSchedule("CT_RABoss_Maexxna_EventHandler");
	CT_RABoss_UnSchedule("CT_RABoss_Maexxna_EventHandler");
end

function CT_RABoss_Maexxna_OnLoad()
	CT_RABoss_AddMod("Maexxna", CT_RABOSS_MAEXXNA_INFO, 1, CT_RABOSS_LOCATIONS_NAXXRAMAS);

	CT_RABoss_AddEvent("Maexxna", "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE", CT_RABoss_Maexxna_EventHandler);
	CT_RABoss_AddEvent("Maexxna", "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE", CT_RABoss_Maexxna_EventHandler);
	CT_RABoss_AddEvent("Maexxna", "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE", CT_RABoss_Maexxna_EventHandler);
	CT_RABoss_AddEvent("Maexxna", "CHAT_MSG_MONSTER_EMOTE", CT_RABoss_Maexxna_EventHandler);
	CT_RABoss_AddEvent("Maexxna", "PLAYER_REGEN_DISABLED", CT_RABoss_Maexxna_EventHandler);
	CT_RABoss_AddEvent("Maexxna", "UNIT_HEALTH", CT_RABoss_Huhuran_EventHandler);

	CT_RABoss_AddDropDownButton("Maexxna", { CT_RABOSS_ANNOUNCE, CT_RABOSS_ANNOUNCE_INFO .. CT_RABOSS_REQ_LEADER_OR_PROM }, "CT_RABoss_ModInfo", "announce", "CT_RABoss_SetInfo");

	CT_RABoss_Mods["Maexxna"]["engaged"] = nil;
	CT_RABoss_Mods["Maexxna"]["lastAction"] = nil;
	CT_RABoss_Mods["Maexxna"]["healthLow"] = 33;
	CT_RABoss_Mods["Maexxna"]["sPlayers"] = "";
	CT_RABoss_Mods["Maexxna"]["nbWebWrap"] = 0;

	CT_RA_RegisterSlashCmd("/maexxnastop", "Maexxna Reset", 30, "MAEXXNARESET", function()
		CT_RABoss_Maexxna_Stop();
	end, "/maexxnastop");

end
	
function CT_RABoss_Maexxna_EventHandler(event)
	if ( not CT_RABoss_Mods["Maexxna"] or not CT_RABoss_Mods["Maexxna"]["status"] or not CT_RABoss_Mods["Maexxna"].enabled ) then
		return;
	end

	if ( event == "PLAYER_REGEN_DISABLED" ) then
		if ( not CT_RABoss_Mods["Maexxna"]["engaged"] ) then
			CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 5, "checkStart");
		end

	elseif ( event == "checkStart" ) then
		if ( UnitName("target") and UnitName("target") == CT_RABOSS_NAMES["Maexxna"] and UnitAffectingCombat("target") ) then
			CT_RABoss_Mods["Maexxna"]["engaged"] = 1;
			CT_RABoss_Mods["Maexxna"]["nbWebWrap"] = 0;
			CT_RABoss_Mods["Maexxna"]["lastAction"] = GetTime();

			CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 5, "webWrapWarn5");
			CT_RABoss_VisualTimer.addTimer("MaexxnaWebWrap", 10, CT_RABOSS_MAEXXNA_WEBWRAP_TIMER, "yellow");
			CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 17, "spiderWarn5");
			CT_RABoss_VisualTimer.addTimer("MaexxnaSpider", 22, CT_RABOSS_MAEXXNA_SPIDER_TIMER, "orange");
			CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 27, "webSprayWarn5");
			CT_RABoss_VisualTimer.addTimer("MaexxnaWebSpray", 32, CT_RABOSS_MAEXXNA_WEBSPRAY_TIMER, "green");
		end
	end

	if ( event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE" ) then
		-- Web Spray
		if ( string.find(arg1, CT_RABOSS_MAEXXNA_WEBSPRAY_DETECT) ) then
			if ( not CT_RABoss_Mods["Maexxna"]["webSprayTrip"] ) then
				CT_RABoss_Mods["Maexxna"]["webSprayTrip"] = 1;
				CT_RABoss_Mods["Maexxna"]["lastAction"] = GetTime();

				CT_RABoss_Announce(CT_RABOSS_MAEXXNA_WEBBED_ALERT, CT_RABoss_Mods["Maexxna"]["announce"]);

				CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 35, "webSprayWarn5");
				CT_RABoss_VisualTimer.addTimer("MaexxnaWebSpray", 40, CT_RABOSS_MAEXXNA_WEBSPRAY_TIMER, "green");
			end
		end


		-- Web Wrap
		local _, _, sPlayer, sType = string.find(arg1, CT_RABOSS_MAEXXNA_WEBWRAP_DETECT);

		if ( sPlayer and sType ) then
			if ( not CT_RABoss_Mods["Maexxna"]["webWrapTrip"] ) then
				CT_RABoss_Mods["Maexxna"]["sPlayers"] = "";
				CT_RABoss_Mods["Maexxna"]["nbWebWrap"] = 0;
				CT_RABoss_Mods["Maexxna"]["webWrapTrip"] = 1;
				CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 35, "webWrapWarn5");
				CT_RABoss_VisualTimer.addTimer("MaexxnaWebWrap", 40, CT_RABOSS_MAEXXNA_WEBWRAP_TIMER, "yellow");
			end

			CT_RABoss_Mods["Maexxna"]["lastAction"] = GetTime();
			CT_RABoss_Mods["Maexxna"]["nbWebWrap"] = CT_RABoss_Mods["Maexxna"]["nbWebWrap"] + 1;

			if ( sPlayer == CT_RABOSS_SELF1 and sType == CT_RABOSS_SELF2 )then
				sPlayer = UnitName("player");
			end
			
			CT_RABoss_Mods["Maexxna"]["sPlayers"] = CT_RABoss_Mods["Maexxna"]["sPlayers"] .. " " .. sPlayer;

			if ( CT_RABoss_Mods["Maexxna"]["nbWebWrap"] == 3 ) then
				CT_RABoss_Announce(format(CT_RABOSS_MAEXXNA_WEBWRAP_ALERT, CT_RABoss_Mods["Maexxna"]["sPlayers"]), CT_RABoss_Mods["Maexxna"]["announce"]);
			end
		end

	elseif ( event == "webWrapWarn5" ) then
		CT_RABoss_Mods["Maexxna"]["webWrapTrip"] = nil;
		CT_RABoss_Announce(format(CT_RABOSS_MAEXXNA_WEBWRAP_PREALERT, "5"), CT_RABoss_Mods["Maexxna"]["announce"]);

	elseif ( event == "spiderWarn5" ) then
		CT_RABoss_Announce(format(CT_RABOSS_MAEXXNA_SPIDER_PREALERT, "5"), CT_RABoss_Mods["Maexxna"]["announce"]);
		CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 5, "spiderWarn");

	elseif ( event == "spiderWarn" ) then
		CT_RABoss_Announce(CT_RABOSS_MAEXXNA_SPIDERPOP_ALERT, CT_RABoss_Mods["Maexxna"]["announce"]);
		CT_RABoss_Schedule("CT_RABoss_Maexxna_EventHandler", 35, "spiderWarn5");
		CT_RABoss_VisualTimer.addTimer("MaexxnaSpider", 40, CT_RABOSS_MAEXXNA_SPIDER_TIMER, "orange");

	elseif ( event == "webSprayWarn5" ) then
		CT_RABoss_Announce(format(CT_RABOSS_MAEXXNA_WEBSPRAY_PREALERT, "5"), CT_RABoss_Mods["Maexxna"]["announce"]);
		CT_RABoss_Mods["Maexxna"]["webSprayTrip"] = nil;

	end

	-- Enrage pre-alert
	if ( UnitName("target") == CT_RABOSS_NAMES["Maexxna"] ) then
		local targetHealth = UnitHealth("target");
		
		-- Alert near Enrage event
		if ( targetHealth <= CT_RABoss_Mods["Maexxna"]["healthLow"] and targetHealth > 30 and not CT_RABoss_Mods["Maexxna"]["priorWarning"] ) then
			CT_RABoss_Announce(CT_RABOSS_MAEXXNA_ENRAGE_PREALERT, CT_RABoss_Mods["Maexxna"]["announce"]);
			CT_RABoss_Mods["Maexxna"]["priorWarning"] = true;
		
		-- Enrage pre-alert deactivation
		elseif ( targetHealth <= 30 ) then
			CT_RABoss_Mods["Maexxna"]["priorWarning"] = false;
		end

	-- Enrage alert
	elseif ( event == "CHAT_MSG_MONSTER_EMOTE" and arg2 == CT_RABOSS_NAMES["Maexxna"] and string.find(arg1, CT_RABOSS_MAEXXNA_ENRAGE_DETECT) ) then
		CT_RABoss_Mods["Maexxna"]["lastAction"] = GetTime();

		CT_RABoss_Announce(CT_RABOSS_MAEXXNA_ENRAGE_ALERT, CT_RABoss_Mods["Maexxna"]["announce"]);
	end

	if ( CT_RABoss_Mods["Maexxna"]["lastAction"] and (GetTime() - CT_RABoss_Mods["Maexxna"]["lastAction"]) > 60 ) then
		CT_RABoss_Maexxna_Stop();
	end
end


-- Instructor Razuvious
function CT_RABoss_Razuvious_Stop()
	CT_RABoss_Mods["Razuvious"]["combat"] = nil;
	CT_RABoss_Mods["Razuvious"]["lastAction"] = nil;

	CT_RABoss_UnSchedule("CT_RABoss_Razuvious_EventHandler");
end

function CT_RABoss_Razuvious_OnLoad()
	CT_RABoss_AddMod("Razuvious", CT_RABOSS_RAZUVIOUS_INFO, 1, CT_RABOSS_LOCATIONS_NAXXRAMAS);
	
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_COMBAT_CREATURE_VS_PARTY_HITS", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_MONSTER_YELL", CT_RABoss_Razuvious_EventHandler);
	CT_RABoss_AddEvent("Razuvious", "CHAT_MSG_COMBAT_HOSTILE_DEATH", CT_RABoss_Razuvious_EventHandler);
	
	CT_RABoss_AddDropDownButton("Razuvious", { CT_RABOSS_ANNOUNCE, CT_RABOSS_ANNOUNCE_INFO .. CT_RABOSS_REQ_LEADER_OR_PROM }, "CT_RABoss_ModInfo", "announce", "CT_RABoss_SetInfo");

	CT_RA_RegisterSlashCmd("/razustop", CT_RABOSS_CMD_RAZUSTOP, 30, "RAZUSTOP", function()
		CT_RABoss_Razuvious_Stop();
	end, "/razustop");
end

function CT_RABoss_Razuvious_ShoutCast()
	CT_RABoss_Schedule("CT_RABoss_Razuvious_EventHandler", 15, "shoutPreWarn10");

	CT_RABoss_Announce(format(CT_RABOSS_RAZUVIOUS_SHOUT_PREALERT, "25"), CT_RABoss_Mods["Razuvious"]["announce"]);
	CT_RABoss_PlaySound(2);
	CT_RABoss_Mods["Razuvious"]["combat"] = 1;
end

function CT_RABoss_Razuvious_EventHandler(event)
	if ( not CT_RABoss_Mods["Razuvious"] or not CT_RABoss_Mods["Razuvious"]["status"] or not CT_RABoss_Mods["Razuvious"].enabled ) then
		return;
	end

	-- Encounter begin
	if ( event == "CHAT_MSG_MONSTER_YELL" and arg2 == CT_RABOSS_NAMES["Razuvious"] and not CT_RABoss_Mods["Razuvious"]["combat"] ) then
		if ( string.find(arg1, CT_RABOSS_RAZUVIOUS_YELL1_DETECT) or string.find(arg1, CT_RABOSS_RAZUVIOUS_YELL2_DETECT) or string.find(arg1, CT_RABOSS_RAZUVIOUS_YELL3_DETECT) or string.find(arg1, CT_RABOSS_RAZUVIOUS_YELL4_DETECT) ) then
			CT_RABoss_Mods["Razuvious"]["lastAction"] = GetTime();
			CT_RABoss_Razuvious_ShoutCast();
		end
	end
	
	-- Disrupting Shout detected
	if ( event == "CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE" or event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE" or event == "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE" ) then
		if ( string.find(arg1, CT_RABOSS_RAZUVIOUS_SHOUT_DETECT) and not CT_RABoss_Mods["Razuvious"]["shoutTrip"] ) then
			CT_RABoss_Mods["Razuvious"]["shoutTrip"] = 1;
			CT_RABoss_Mods["Razuvious"]["lastAction"] = GetTime();

			CT_RABoss_UnSchedule("CT_RABoss_Razuvious_EventHandler", "shoutPreWarn10");
			CT_RABoss_UnSchedule("CT_RABoss_Razuvious_EventHandler", "shoutPreWarn5");
			CT_RABoss_UnSchedule("CT_RABoss_Razuvious_EventHandler", "shoutWarn");

			CT_RABoss_Razuvious_ShoutCast();
		end

	-- Disrupting Shout 10sec pre-alert
	elseif ( event == "shoutPreWarn10" ) then
		CT_RABoss_Mods["Razuvious"]["shoutTrip"] = nil;
		CT_RABoss_Schedule("CT_RABoss_Razuvious_EventHandler", 5, "shoutPreWarn5");
		CT_RABoss_Announce(format(CT_RABOSS_RAZUVIOUS_SHOUT_PREALERT, "10"), CT_RABoss_Mods["Razuvious"]["announce"]);

	-- Disrupting Shout 5sec pre-alert
	elseif ( event == "shoutPreWarn5" ) then
		CT_RABoss_Schedule("CT_RABoss_Razuvious_EventHandler", 5, "shoutWarn");
		CT_RABoss_Announce(format(CT_RABOSS_RAZUVIOUS_SHOUT_PREALERT, "5"), CT_RABoss_Mods["Razuvious"]["announce"]);

	-- Disrupting Shout alert
	elseif ( event == "shoutWarn" ) then
		CT_RABoss_Razuvious_ShoutCast();
	end

	-- Encounter end
	if ( event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" and string.find(arg1, CT_RABOSS_RAZUVIOUS_DEATH_DETECT) ) then
		CT_RABoss_Razuvious_Stop();
	end

	if ( event == "CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS" or event == "CHAT_MSG_COMBAT_CREATURE_VS_PARTY_HITS" or event == "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS" ) then
		if ( string.find(arg1, CT_RABOSS_NAMES["Razuvious"]) or string.find(arg1, CT_RABOSS_RAZUVIOUS_STUDENT_NAME) ) then
			CT_RABoss_Mods["Razuvious"]["lastAction"] = GetTime();
		end
	end

	if ( CT_RABoss_Mods["Razuvious"]["lastAction"] and (GetTime() - CT_RABoss_Mods["Razuvious"]["lastAction"]) > 20 ) then
		CT_RABoss_Razuvious_Stop();
	end
end



-- Noth The Plaguebringer
function CT_RABoss_Noth_Stop()
	CT_RABoss_UnSchedule("CT_RABoss_Noth_EventHandler");
end

function CT_RABoss_Noth_OnLoad()
	CT_RABoss_AddMod("Noth", CT_RABOSS_NOTH_INFO, 1, CT_RABOSS_LOCATIONS_NAXXRAMAS);

	CT_RABoss_AddEvent("Noth", "CHAT_MSG_MONSTER_YELL", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_COMBAT_CREATURE_VS_PARTY_HITS", CT_RABoss_Noth_EventHandler);
	CT_RABoss_AddEvent("Noth", "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS", CT_RABoss_Noth_EventHandler);
	
	CT_RABoss_AddDropDownButton("Noth", { CT_RABOSS_ANNOUNCE, CT_RABOSS_ANNOUNCE_INFO .. CT_RABOSS_REQ_LEADER_OR_PROM }, "CT_RABoss_ModInfo", "announce", "CT_RABoss_SetInfo");

	CT_RA_RegisterSlashCmd("/nothstop", "Noth stop", 30, "NOTHSTOP", function()
		CT_RABoss_Noth_Stop();
	end, "/nothstop");
end

function CT_RABoss_Noth_EventHandler(event)
	if ( not CT_RABoss_Mods["Noth"] or not CT_RABoss_Mods["Noth"]["status"] or not CT_RABoss_Mods["Noth"].enabled ) then
		return;
	end

	if ( event == "CHAT_MSG_MONSTER_YELL" ) then
		-- Encounter begin
		if ( string.find(arg1, CT_RABOSS_NOTH_YELL1_DETECT) or string.find(arg1, CT_RABOSS_NOTH_YELL2_DETECT) or string.find(arg1, CT_RABOSS_NOTH_YELL3_DETECT) ) then
			CT_RABoss_Mods["Noth"]["lastAction"] = GetTime();

			CT_RABoss_Mods["Noth"]["balconyTime"] = 70;
			CT_RABoss_Mods["Noth"]["roomTime"] = 90;
			CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", (CT_RABoss_Mods["Noth"]["roomTime"]-10), "teleportPreWarn");
			CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", (CT_RABoss_Mods["Noth"]["roomTime"]), "teleport");
			CT_RABoss_VisualTimer.addTimer("NothRoom", CT_RABoss_Mods["Noth"]["roomTime"], CT_RABOSS_NOTH_ROOM_TIMER, "blue");

		-- Encounter end
		elseif ( string.find(arg1, CT_RABOSS_NOTH_YELL_DEAD_DETECT) ) then
			CT_RABoss_Noth_Stop();
		end
	
	-- Blink detect
	elseif ( event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and string.find(arg1, CT_RABOSS_NOTH_BLINK_DETECT) ) then
		CT_RABoss_Announce(CT_RABOSS_NOTH_BLINK_ALERT, CT_RABoss_Mods["Noth"]["announce"]);
		CT_RABoss_PlaySound(2);

		CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", 28, "blinkWarn");
		CT_RABoss_Mods["Noth"]["lastAction"] = GetTime();

	-- AE Curse detect
	elseif ( (event == "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE") and string.find(arg1, CT_RABOSS_NOTH_CURSE_DETECT) )  then
		if ( not CT_RABoss_Mods["Noth"]["curseTrip"] ) then
			CT_RABoss_Mods["Noth"]["curseTrip"] = 1;
			CT_RABoss_Mods["Noth"]["lastAction"] = GetTime();

			CT_RABoss_Announce(CT_RABOSS_NOTH_CURSE_ALERT, CT_RABoss_Mods["Noth"]["announce"]);
			CT_RABoss_PlaySound(2);

			CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", 5, "preCurse");
		end	

	-- Noth back in room
	elseif ( event == "backWarn" ) then
		CT_RABoss_Announce(format(CT_RABOSS_NOTH_BACK_ALERT, CT_RABoss_Mods["Noth"]["roomTime"]), CT_RABoss_Mods["Noth"]["announce"]);
		CT_RABoss_PlaySound(2);

		CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", (CT_RABoss_Mods["Noth"]["roomTime"]-10), "teleportPreWarn");
		CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", (CT_RABoss_Mods["Noth"]["roomTime"]), "teleport");
		CT_RABoss_VisualTimer.addTimer("NothRoom", CT_RABoss_Mods["Noth"]["roomTime"], CT_RABOSS_NOTH_ROOM_TIMER, "blue");

	-- Teleport event
	elseif ( event == "teleport" ) then
		CT_RABoss_UnSchedule("CT_RABoss_Noth_EventHandler", "blinkWarn");

		CT_RABoss_Announce(format(CT_RABOSS_NOTH_TELEPORT_ALERT, CT_RABoss_Mods["Noth"]["balconyTime"]), CT_RABoss_Mods["Noth"]["announce"]);
		CT_RABoss_PlaySound(2);

		CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", (CT_RABoss_Mods["Noth"]["balconyTime"]-10), "backWarn10");
		CT_RABoss_Schedule("CT_RABoss_Noth_EventHandler", CT_RABoss_Mods["Noth"]["balconyTime"], "backWarn");
		CT_RABoss_VisualTimer.addTimer("NothBalcony", CT_RABoss_Mods["Noth"]["balconyTime"], CT_RABOSS_NOTH_BALCONY_TIMER, "orange");

		if ( CT_RABoss_Mods["Noth"]["balconyTime"] == 70 ) then
			CT_RABoss_Mods["Noth"]["balconyTime"] = 95;
			CT_RABoss_Mods["Noth"]["roomTime"] = 110;

		elseif ( CT_RABoss_Mods["Noth"]["balconyTime"] == 95 ) then
			CT_RABoss_Mods["Noth"]["balconyTime"] = 120;
			CT_RABoss_Mods["Noth"]["roomTime"] = 180;
		end
	elseif ( event == "preCurse" ) then
		CT_RABoss_Mods["Noth"]["curseTrip"] = nil;

	-- Blink alert
	elseif ( event == "blinkWarn" ) then
		CT_RABoss_Announce(CT_RABOSS_NOTH_BLINK_PREALERT, CT_RABoss_Mods["Noth"]["announce"]);
		CT_RABoss_PlaySound(3);

	-- Teleport pre-alert
	elseif ( event == "teleportPreWarn" ) then
		CT_RABoss_Announce(format(CT_RABOSS_NOTH_TELEPORT_PREALERT, "10"), CT_RABoss_Mods["Noth"]["announce"]);
		CT_RABoss_PlaySound(3);

	-- Bakc in room pre-alert
	elseif ( event == "backWarn10" ) then
		CT_RABoss_Announce(format(CT_RABOSS_NOTH_BACK_PREALERT, "10"), CT_RABoss_Mods["Noth"]["announce"]);
		CT_RABoss_PlaySound(3);

	end

	if ( event == "CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS" or event == "CHAT_MSG_COMBAT_CREATURE_VS_PARTY_HITS" or event == "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS" ) then
		if ( string.find(arg1, CT_RABOSS_NAMES["Noth"]) or string.find(arg1, CT_RABOSS_NOTH_WARRIOR_NAME) or string.find(arg1, CT_RABOSS_NOTH_CHAMPION_NAME) or string.find(arg1, CT_RABOSS_NOTH_GUARDIAN_NAME) ) then
			CT_RABoss_Mods["Noth"]["lastAction"] = GetTime();
		end

	elseif ( CT_RABoss_Mods["Noth"]["lastAction"] and (GetTime() - CT_RABoss_Mods["Noth"]["lastAction"]) > 30 ) then
		CT_RABoss_Noth_Stop();
	end
end


-- Heigan the Unclean
function CT_RABoss_Heigan_Stop()
	CT_RABoss_UnSchedule("CT_RABoss_Heigan_EventHandler");
	CT_RABoss_Mods["Heigan"]["engaged"] = nil;
	CT_RABoss_Mods["Heigan"]["lastAction"] = nil;
end

function CT_RABoss_Heigan_OnLoad()
	CT_RABoss_AddMod("Heigan", CT_RABOSS_HEIGAN_INFO, 1, CT_RABOSS_LOCATIONS_NAXXRAMAS);

	CT_RABoss_AddEvent("Heigan", "CHAT_MSG_MONSTER_YELL", CT_RABoss_Heigan_EventHandler);
	CT_RABoss_AddEvent("Heigan", "CHAT_MSG_MONSTER_EMOTE", CT_RABoss_Heigan_EventHandler);

	CT_RABoss_AddDropDownButton("Heigan", { CT_RABOSS_ANNOUNCE, CT_RABOSS_ANNOUNCE_INFO .. CT_RABOSS_REQ_LEADER_OR_PROM }, "CT_RABoss_ModInfo", "announce", "CT_RABoss_SetInfo");

	CT_RA_RegisterSlashCmd("/heiganstop", "Heigan Stop", 30, "HEIGANSTOP", function()
		CT_RABoss_Heigan_Stop();
	end, "/heiganstop");

	CT_RABoss_Mods["Heigan"]["engaged"] = nil;
	CT_RABoss_Mods["Heigan"]["lastAction"] = nil;
end

function CT_RABoss_Heigan_EventHandler(event)
	if ( not CT_RABoss_Mods["Heigan"] or not CT_RABoss_Mods["Heigan"]["status"] or not CT_RABoss_Mods["Heigan"].enabled ) then
		return;
	end

	if ( event == "CHAT_MSG_MONSTER_YELL" ) then
		-- Yell when begin fight
		if ( string.find(arg1, CT_RABOSS_HEIGAN_PHASE1_YELL1_DETECT) or string.find(arg1, CT_RABOSS_HEIGAN_PHASE1_YELL2_DETECT) or string.find(arg1, CT_RABOSS_HEIGAN_PHASE1_YELL3) ) then
			CT_RABoss_Schedule("CT_RABoss_Heigan_EventHandler", 10, "checkStart");

		-- Yell when Heigan teleport
		elseif ( string.find(arg1, CT_RABOSS_HEIGAN_PHASE2_YELL_DETECT) ) then
			CT_RABoss_Announce(format(CT_RABOSS_HEIGAN_TELEPORT_ALERT, "45"), CT_RABoss_Mods["Heigan"]["announce"]);
			CT_RABoss_PlaySound(2);

			CT_RABoss_UnSchedule("CT_RABoss_Heigan_EventHandler", "teleportPreWarn");
			CT_RABoss_Schedule("CT_RABoss_Heigan_EventHandler", 35, "backPreWarn");
			CT_RABoss_Schedule("CT_RABoss_Heigan_EventHandler", 45, "back");
			CT_RABoss_VisualTimer.addTimer("HeiganBack", 45, CT_RABOSS_HEIGAN_BACK_TIMER, "red");

			CT_RABoss_Mods["Heigan"]["lastAction"] = GetTime();

		end

	-- Check if we have engaged fight against Heigan
	elseif ( event == "checkStart" and not CT_RABoss_Mods["Heigan"]["engaged"] ) then
		if ( UnitName("target") and UnitName("target") == CT_RABOSS_NAMES["Heigan"] and UnitAffectingCombat("target") ) then
			CT_RABoss_Announce(format(CT_RABOSS_HEIGAN_TELEPORT_PREALERT, "90"), CT_RABoss_Mods["Heigan"]["announce"]);
			CT_RABoss_PlaySound(3);

			CT_RABoss_UnSchedule("CT_RABoss_Heigan_EventHandler");
			CT_RABoss_Schedule("CT_RABoss_Heigan_EventHandler", 70, "teleportPreWarn");
			CT_RABoss_VisualTimer.addTimer("HeiganTeleport", 80, CT_RABOSS_HEIGAN_TELEPORT_TIMER, "orange");

			CT_RABoss_Mods["Heigan"]["lastAction"] = GetTime();
			CT_RABoss_Mods["Heigan"]["engaged"] = 1;

		end

	-- Heigan is back
	elseif ( event == "back" ) then
		CT_RABoss_Announce(CT_RABOSS_HEIGAN_BACK_ALERT, CT_RABoss_Mods["Heigan"]["announce"]);
		CT_RABoss_PlaySound(2);
		CT_RABoss_Schedule("CT_RABoss_Heigan_EventHandler", 80, "teleportPreWarn");
		CT_RABoss_VisualTimer.addTimer("HeiganTeleport", 90, CT_RABOSS_HEIGAN_TELEPORT_TIMER, "orange");

	-- Teleport in 10 sec
	elseif ( event == "teleportPreWarn" ) then
		CT_RABoss_Announce(format(CT_RABOSS_HEIGAN_TELEPORT_PREALERT, "10"), CT_RABoss_Mods["Heigan"]["announce"]);
		CT_RABoss_PlaySound(3);

	-- Heigan is back in 10 sec
	elseif ( event == "backPreWarn" ) then
		CT_RABoss_Announce(format(CT_RABOSS_HEIGAN_BACK_PREALERT, "10"), CT_RABoss_Mods["Heigan"]["announce"]);
		CT_RABoss_PlaySound(3);

	-- Heigan Death
	elseif ( event == "CHAT_MSG_MONSTER_EMOTE" and arg2 == CT_RABOSS_NAMES["Heigan"] and string.find(arg1, CT_RABOSS_HEIGAN_DEAD_DETECT) ) then
		CT_RABoss_Heigan_Stop();

	end
end