AQW_CONFIG_LOADED = false;
AQW_HUHURAN_BERSERK_ANNOUNCED = false;
AQW_ANUB_THUNDERCLAP_ANNOUNCED = false;
AQW_ANUB_SUMMON_ANNOUNCED = false;
AQW_ANUB_STORM_ANNOUNCED = false;
AQW_ANUB_METEOR_ANNOUNCED = false;
AQW_TWINS_SUPREME_RUNNING = false;
AQW_TWINS_HEAL_ANNOUNCED = false;
AQW_CTHUN_PHASE_2 = false;

-- Sounds
AQW_SND = {
    "Sound\\Doodad\\BellTollHorde.wav",
    "Sound\\Doodad\\BellTollAlliance.wav",
    "Sound\\Doodad\\BellTollNightElf.wav",
};

-- WoW Events
AQW_EVENTS = {
    "ADDON_LOADED",
    "CHAT_MSG_COMBAT_HOSTILE_DEATH",
    "CHAT_MSG_MONSTER_EMOTE",
    "CHAT_MSG_MONSTER_YELL",
    "CHAT_MSG_SPELL_AURA_GONE_OTHER",
    "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF",
    "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE",
    "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS",
    "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE",
    "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE",
    "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE",
    "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE",
    "PLAYER_ALIVE",
    "PLAYER_LEAVE_COMBAT",
    "UNIT_HEALTH",
    "VARIABLES_LOADED"
}

-- Commands
AQW_CMD = 
    {
        INFO = "info",
        STOP = "stop",
        START = "start",
        DEBUG = "debug",
        CTHUN = "cthun",
        RESET = "reset"
    };

--**********************************
--*                                *
--*       Initialisation           *
--*                                *
--**********************************
function AQWarner_OnLoad()
    SlashCmdList["AQWARNER"] = AQWarner_Command;
    SLASH_AQWARNER1 = "/aqwarner";  
    SLASH_AQWARNER2 = "/aqw"; 
    
--    AQWarner_SetOptions();
    AQWarner_Register();
    AQWarner_myAddOnsSupport();
end

--**********************************
--*                                *
--*      Set Default Options       *
--*                                *
--**********************************
function AQWarner_SetOptions()
    -- General Options
    AQW_OPTIONS.ENABLED = true;
    AQW_OPTIONS.STARS = true;
    AQW_OPTIONS.RAID = true;
    AQW_OPTIONS.SOUND = true;
    AQW_OPTIONS.SEND_TELLS = true;
    AQW_OPTIONS.SELF_MESSAGE = true;
    AQW_OPTIONS.MINIMAP_BUTTON_POSITION = 90;
    AQW_OPTIONS.MINIMAP_BUTTON = true;
    AQW_OPTIONS.DEBUG = false;
    AQW_OPTIONS.CURRENT_SELECT = 3;
    -- Skeram
    AQW_OPTIONS.SKERAM_AE = true;
    AQW_OPTIONS.SKERAM_MC = true;
    AQW_OPTIONS.SKERAM_SPLIT = true;
    -- Vem/Yauj/Kri
    AQW_OPTIONS.TRIO_YAUJ_HEAL = true;
    -- Fankriss
    AQW_OPTIONS.FANKRISS_SUMMON = true;
    -- Sartura
    AQW_OPTIONS.SARTURA_WHIRL = true;
    AQW_OPTIONS.SARTURA_ENRAGE = true;
    AQW_OPTIONS.SARTURE_SUPREME = true;
    -- Huhuran
    AQW_OPTIONS.HUHURAN_FRENZY = false;
    AQW_OPTIONS.HUHURAN_BERSERK_IMMINENT = true;
    AQW_OPTIONS.HUHURAN_BERSERK_LIMIT = 33;
    AQW_OPTIONS.HUHURAN_STING = true;
    AQW_OPTIONS.HUHURAN_SUPREME = true;
    -- Anubisath
    AQW_OPTIONS.ANUB_SUMMON = true;
    AQW_OPTIONS.ANUB_PLAGUE = true;
    AQW_OPTIONS.ANUB_METEOR = true;
    AQW_OPTIONS.ANUB_THUNDERCLAP = true;
    AQW_OPTIONS.ANUB_STORM = true;
    AQW_OPTIONS.ANUB_EXPLODE = true;
    AQW_OPTIONS.ANUB_ENRAGE = true;
    -- Twins
    AQW_OPTIONS.TWINS_PORT = false;
    AQW_OPTIONS.TWINS_PREWARN_INTERVAL = 5;
    AQW_OPTIONS.TWINS_HEAL = true;
    AQW_OPTIONS.TWINS_HEAL_ANNOUNCE_INTERVAL = 10;
    AQW_OPTIONS.TWINS_BUG_EXPLODE = true;
    AQW_OPTIONS.TWINS_SUPREME = true;
    -- Qiraji Slayer
    AQW_OPTIONS.SLAYER_FRENZY = false;
    AQW_OPTIONS.SLAYER_WHIRL = false;
    -- Qiraji Champion
    AQW_OPTIONS.CHAMP_ENRAGE = false;
    -- Anubisath Warder
    AQW_OPTIONS.WARDER_ROOTS = false;
    AQW_OPTIONS.WARDER_FEAR = false;
    AQW_OPTIONS.WARDER_BLASTWAVE = false;
    AQW_OPTIONS.WARDER_DUSTCLOUD = false;
    AQW_OPTIONS.WARDER_SILENCE = false;
    -- Obsidian Nullifier
    AQW_OPTIONS.NULLIFIER_NULLIFY = false;
		-- C'Thun
		AQW_OPTIONS.CTHUN_GLARE = true;
		AQW_OPTIONS.CTHUN_GLARE_PREWARN = 5;
		AQW_OPTIONS.CTHUN_EYETENT = true;
		AQW_OPTIONS.CTHUN_EYETENT_PREWARN = 5;
		AQW_OPTIONS.CTHUN_CLAWTENT = true;
		AQW_OPTIONS.CTHUN_STOMACH = true;
		AQW_OPTIONS.CTHUN_EYEBEAM = true;
--
-- AQ20
--
    -- Rajaxx
    AQW_OPTIONS.RAJAXX_WAVES = true;
    -- Buru
    AQW_OPTIONS.BURU_EYES = true;
    -- Ossirian
    AQW_OPTIONS.OSSIRIAN_SUPREME = true;
    AQW_OPTIONS.OSSIRIAN_SUPREME_IMMINENT = true;
    AQW_OPTIONS.OSSIRIAN_WEAKNESS = true;
    -- Moam
    AQW_OPTIONS.MOAM_ADDS = true;
    -- Ayamiss
    AQW_OPTIONS.AYAMISS_SACRIFICE = true;
    -- Anubisath Guardian
    AQW_OPTIONS.ANUB_AQ20_SUMMON = true;
    AQW_OPTIONS.ANUB_AQ20_PLAGUE = true;
    AQW_OPTIONS.ANUB_AQ20_METEOR = true;
    AQW_OPTIONS.ANUB_AQ20_THUNDERCLAP = true;
    AQW_OPTIONS.ANUB_AQ20_STORM = true;
    AQW_OPTIONS.ANUB_AQ20_EXPLODE = true;
    AQW_OPTIONS.ANUB_AQ20_ENRAGE = true;
end

--**********************************
--*                                *
--*       Command Parsing          *
--*                                *
--**********************************
function AQWarner_ParseCommand(msg)
    firstSpace = string.find(msg, " ", 1, true);
    
    if (firstSpace) then
        
        local command = string.sub(msg, 1, firstSpace-1);
        local args = string.sub(msg, firstSpace+1);
        
      
        return string.lower(command), args;

    end

    return string.lower(msg), "";
end

--**********************************
--*                                *
--*         myAddOns Info          *
--*                                *
--**********************************
function AQWarner_myAddOnsSupport()
    AQWarnerDetails = {
        name          = "AQWarner",
        description   = AQW_MSG.MYADDONDESC,
        version       = "2.2",
        releaseDate   = "04/27/2006",
        author        = "Stabya",
        email         = "stabya@power.ms",
        website       = "http://www.black-hand.net.tf",
        category      = MYADDONS_CATEGORY_COMBAT,
        frame         = "AQWarnerFrame"
    };
end

--**********************************
--*                                *
--*       Command Handling         *
--*                                *
--**********************************
function AQWarner_Command(msg)
    local command, arg1 = AQWarner_ParseCommand(msg);
    
    if (command == AQW_CMD.INFO) then
        AQWarner_DisplayStatus();
    elseif (command == AQW_CMD.STOP) then
        AQWarner_CmdStop(arg1);
    elseif (command == AQW_CMD.START) then
        AQWarner_CmdPortAnnounce();
    elseif (command == AQW_CMD.DEBUG) then
        AQWarner_CmdDebug();
    elseif (command == AQW_CMD.CTHUN) then
    		AQWarner_CmdCThun();
    elseif (command == AQW_CMD.RESET) then
    		AQWarner_ConfigToDefault();
    else
        AQWarner_OnShow();
    end
    
end

--**********************************
--*                                *
--*         Display Help           *
--*                                *
--**********************************
function AQWarner_DisplayHelp()
    AQWarner_AddMessage(AQW_COLORS.YELLOW.."/aqw"..AQW_COLORS.WHITE.." - Open Config");
    AQWarner_AddMessage(AQW_COLORS.YELLOW.."/aqw start"..AQW_COLORS.WHITE.." - Start Twins events");
    AQWarner_AddMessage(AQW_COLORS.YELLOW.."/aqw cthun"..AQW_COLORS.WHITE.." - Start C'Thun event");
    AQWarner_AddMessage(AQW_COLORS.YELLOW.."/aqw stop [moam/ossirian/sartura/twins/cthun]"..AQW_COLORS.WHITE.." - Stop appropriate events");
    AQWarner_AddMessage(AQW_COLORS.YELLOW.."/aqw reset"..AQW_COLORS.WHITE.." - Reset AQWarner Configuration");
end

--**********************************
--*                                *
--*        Reset Schedules         *
--*                                *
--**********************************
function AQWarner_CmdStop(arg1)

    if (arg1 == nil) then
        AQWarner_DisplayHelp();
    elseif (arg1 == "moam") then
        AQWarner_UnscheduleMoam();
        AQWarner_AddMessage("Moam Schedule stopped!");
    elseif (arg1 == "ossirian") then
        AQWarner_UnscheduleOssirian();
        AQWarner_AddMessage("Ossirian Schedule stopped!");
    elseif (arg1 == "sartura") then
        AQWarner_UnscheduleSartura();
        AQWarner_AddMessage("Sartura Schedule stopped!");
    elseif (arg1 == "twins") then
        AQWarner_UnscheduleTwins();
        AQWarner_UnscheduleTwinsSupreme();
        AQWarner_AddMessage("Twins Schedule stopped!");
    elseif (arg1 == "all") then
        AQWarner_UnscheduleMoam();
        AQWarner_UnscheduleOssirian();
        AQWarner_UnscheduleSartura();
        AQWarner_UnscheduleTwins();
        AQWarner_UnscheduleTwinsSupreme();
        AQWarner_AddMessage("All Schedules stopped!");
    elseif (arg1 == "cthun") then
    		AQWarner_UnscheduleCThun();
    		AQWarner_AddMessage("C'Thun Schedules stopped!");
    else
        AQWarner_DisplayHelp();
    end
    
end

--**********************************
--*                                *
--*       Turn Debug ON/OFF        *
--*                                *
--**********************************
function AQWarner_CmdDebug()

    if (UnitName("player") ~= "Stabya") then
        return;
    end

    if (AQW_OPTIONS.DEBUG) then
        AQW_OPTIONS.DEBUG = false;
        AQWarner_AddMessage(AQW_MSG.DEBUG_DISABLED);
    else
        AQW_OPTIONS.DEBUG = true;
        AQWarner_AddMessage(AQW_MSG.DEBUG_ENABLED);
    end

end

--**********************************
--*                                *
--*       Turn AddOn ON/OFF        *
--*                                *
--**********************************
function AQWarner_CmdToggle()

    if (AQW_OPTIONS.ENABLED) then
        AQW_OPTIONS.ENABLED = false;
        AQWarner_AddMessage(AQW_MSG.DISABLED);
    else
        AQW_OPTIONS.ENABLED = true;
        AQWarner_AddMessage(AQW_MSG.ENABLED);
    end
        
end

--**********************************
--*                                *
--*       Start C'Thun event       *
--*                                *
--**********************************
function AQWarner_CmdCThun()
    local prewarnTimeGlare = 40 - AQW_OPTIONS.CTHUN_GLARE_PREWARN;
    local prewarnTimeEyeTent = 45 - AQW_OPTIONS.CTHUN_EYETENT_PREWARN;

    AQWarner_UnscheduleCThun();
    AQWarner_Message(AQW_MSG.CTHUN_ENGAGED, true);
    AQWarner_PlaySound(2, true);        

		AQWarner_CThunGlare(prewarnTimeGlare);
		AQWarner_CThunEyeTent(prewarnTimeEyeTent);
		AQWarner_CThunClawTent();
end

-- *********************************
-- *															 *
-- *       Schedule Glare          *
-- *															 *
-- *********************************
function AQWarner_CThunGlare(prewarnTimeGlare)
		AQWarner_UnscheduleGlare();
	
    Chronos.scheduleByName("GLARE_IMMINENT", prewarnTimeGlare, AQWarner_Message, string.format(AQW_MSG.CTHUN_GLARE_INC, AQW_OPTIONS.CTHUN_GLARE), AQW_OPTIONS.CTHUN_GLARE);
    Chronos.scheduleByName("GLARE_IMMINENT_SOUND", prewarnTimeGlare, AQWarner_PlaySound, 3, AQW_OPTIONS.CTHUN_GLARE);
		Chronos.scheduleByName("GLARE_NEXT", 40, AQWarner_CThunGlare);
end

-- *********************************
-- *															 *
-- *       Unschedule Glare        *
-- *															 *
-- *********************************
function AQWarner_UnscheduleGlare()

    if (Chronos.isScheduledByName("GLARE_IMMINENT")) then
        Chronos.unscheduleByName("GLARE_IMMINENT");
    end

    if (Chronos.isScheduledByName("GLARE_IMMINENT_SOUND")) then
        Chronos.unscheduleByName("GLARE_IMMINENT_SOUND");
    end

    if (Chronos.isScheduledByName("GLARE_NEXT")) then
        Chronos.unscheduleByName("GLARE_NEXT");
    end

end

-- *********************************
-- *															 *
-- *    Schedule Eye Tentacles     *
-- *															 *
-- *********************************
function AQWarner_CThunEyeTent(prewarnTimeEyeTent)
		local eyeTentTime = 45;
		AQWarner_UnscheduleEyeTent();
		
		if (AQW_CTHUN_PHASE_2) then
				eyeTentTime = 30;
		end

    Chronos.scheduleByName("EYETENT_IMMINENT", prewarnTimeEyeTent, AQWarner_Message, string.format(AQW_MSG.CTHUN_EYETENT_INC, AQW_OPTIONS.CTHUN_EYETENT_PREWARN), AQW_OPTIONS.CTHUN_EYETENT);
    Chronos.scheduleByName("EYETENT_IMMINENT_SOUND", prewarnTimeEyeTent, AQWarner_PlaySound, 3, AQW_OPTIONS.CTHUN_EYETENT);
		Chronos.scheduleByName("EYETENT_NEXT", eyeTentTime, AQWarner_CThunEyeTent, prewarnTimeEyeTent);
end

-- *********************************
-- *															 *
-- *    Unschedule Eye Tentacles   *
-- *															 *
-- *********************************
function AQWarner_UnscheduleEyeTent()

    if (Chronos.isScheduledByName("EYETENT_IMMINENT")) then
        Chronos.unscheduleByName("EYETENT_IMMINENT");
    end

    if (Chronos.isScheduledByName("EYETENT_IMMINENT_SOUND")) then
        Chronos.unscheduleByName("EYETENT_IMMINENT_SOUND");
    end

    if (Chronos.isScheduledByName("EYETENT_NEXT")) then
        Chronos.unscheduleByName("EYETENT_NEXT");
    end

end

-- *********************************
-- *															 *
-- *    Schedule Claw Tentacles    *
-- *															 *
-- *********************************
function AQWarner_CThunClawTent()
		AQWarner_UnscheduleClawTent();

		Chronos.scheduleByName("CLAWTENT", 8, AQWarner_Message, AQW_MSG.CTHUN_CLAWTENT, AQW_OPTIONS.CTHUN_CLAWTENT);
		Chronos.scheduleByName("CLAWTENT_SOUND", 8, AQWarner_PlaySound, 1, AQW_OPTIONS.CTHUN_CLAWTENT);
		Chronos.scheduleByName("CLAWTENT_NEXT", 8, AQWarner_CThunClawTent);
end

-- *********************************
-- *															 *
-- *   Unschedule Claw Tentacles   *
-- *															 *
-- *********************************
function AQWarner_UnscheduleClawTent()
		
    if (Chronos.isScheduledByName("CLAWTENT")) then
        Chronos.unscheduleByName("CLAWTENT");
    end

    if (Chronos.isScheduledByName("CLAWTENT_SOUND")) then
        Chronos.unscheduleByName("CLAWTENT_SOUND");
    end

    if (Chronos.isScheduledByName("CLAWTENT_NEXT")) then
        Chronos.unscheduleByName("CLAWTENT_NEXT");
    end

end

--**********************************
--*                                *
--*        Event Handling          *
--*                                *
--**********************************
function AQWarner_OnEvent(event)

    if (event == "ADDON_LOADED") then
        
        if (myAddOnsFrame_Register) then            
            myAddOnsFrame_Register(AQWarnerDetails);
        end
        
        if (arg1 == "AQWarner") then
            AQWarner_AddMessage(AQW_MSG.ADDON_LOADED);
            AQWarner_AddMessage(AQW_MSG.USE);
            AQWarnerFrame:AddMessage(AQW_MSG.ADDON_LOADED, 1, 1, 1, 1, 3);
            AQW_CONFIG_LOADED = true;
        end
        
        if (not AQW_OPTIONS.ENABLED) then
            AQWarner_Unregister();
        end
        
        return;

    elseif (event == "VARIABLES_LOADED") then
        local playerName = UnitName("player");
        
        if (playerName ~= UNKNOWNBEING and playerName ~= "Unknown Entity") then
        
            if (AQW_OPTIONS.MINIMAP_BUTTON) then
                AQWarner_ChangeMinimapPosition(AQW_OPTIONS.MINIMAP_BUTTON_POSITION);
            else
                AQWMinimapButton:Hide();
            end
        end

    end
    
    local showMe = false;
    
    if (not AQW_OPTIONS.ENABLED) then
        return;
    end

    if (GetRealZoneText() == AQW_EVENT.AQ) then
    
-- THE PROPHET SKERAM - ARCANE EXPLOSION
        if (arg1 == AQW_EVENT.SKERAM_ARCANE) then
            
            if (AQW_OPTIONS.DEBUG) then
                AQWarner_AddMessage("Event: "..event.." for >>"..AQW_EVENT.SKERAM_ARCANE.."<<");
            end
            
            AQWarner_Message(AQW_MSG.SKERAM_AE, AQW_OPTIONS.SKERAM_AE);
            AQWarner_PlaySound(3, AQW_OPTIONS.SKERAM_AE);
            
-- THE PROPHET SKERAM - TRUE FULFILLMENT
        elseif (arg1 == AQW_EVENT.SKERAM_MC) then
            
            if (AQW_OPTIONS.DEBUG) then
                AQWarner_AddMessage("Event: "..event.." for >>"..AQW_EVENT.SKERAM_MC.."<<");
            end
            
            AQWarner_Message(AQW_MSG.SKERAM_MC, AQW_OPTIONS.SKERAM_MC);
            AQWarner_PlaySound(2, AQW_OPTIONS.SKERAM_MC);
    
-- THE PROPHET SKERAM - SUMMON EFFIGY
        elseif (arg1 == AQW_EVENT.SKERAM_SPLIT) then
            
            if (AQW_OPTIONS.DEBUG) then
                AQWarner_AddMessage("Event: "..event.." for >>"..AQW_EVENT.SKERAM_SPLIT.."<<");
            end
            
            AQWarner_Message(AQW_MSG.SKERAM_SPLIT, AQW_OPTIONS.SKERAM_SPLIT);
            AQWarner_PlaySound(1, AQW_OPTIONS.SKERAM_SPLIT);

        elseif (event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE" or (event == "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE") or event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE") then
            local _, _, sPlayer1, sType1 = string.find(arg1, AQW_EVENT.SKERAM_MC_PLAYER);
            local _, _, sPlayer2, sType2 = string.find(arg1, AQW_EVENT.ANUB_PLAGUE);
            local _, _, sPlayer3, sType3 = string.find(arg1, AQW_EVENT.HUHURAN_STING);
  
-- THE PROPHET SKERAM - TRUE FULFILLMENT
            if (sPlayer1 and sType1) then
        
                if (sPlayer1 == AQW_EVENT.YOU and sType1 == AQW_EVENT.ARE) then
                    AQWarner_SelfAfflictedMessage(AQW_MSG.SKERAM_MC_YOU, AQW_OPTIONS.SKERAM_MC);
                    AQWarner_Message(string.format(AQW_MSG.SKERAM_MC_PLAYER, UnitName("Player")), AQW_OPTIONS.SKERAM_MC);
                    AQWarner_PlaySound(2, AQW_OPTIONS.SKERAM_MC);
                else
          
                    if (AQW_OPTIONS.SEND_TELLS) then
                        SendChatMessage(AQW_MSG.SKERAM_MC_YOU, "WHISPER", nil, sPlayer1);
                    end
                
                    if (UnitClass("Player") == AQW_EVENT.MAGE) then
                        AQWarner_SelfAfflictedMessage(string.format(AQW_MSG.SKERAM_MC_MAGES, sPlayer1), AQW_OPTIONS.SKERAM_MC);
                    end
                  
                    if (UnitClass("Player") == AQW_EVENT.DRUID) then
                        AQWarner_SelfAfflictedMessage(string.format(AQW_MSG.SKERAM_MC_DRUID, sPlayer1), AQW_OPTIONS.SKERAM_MC);
                    end
            
                    AQWarner_Message(string.format(AQW_MSG.SKERAM_MC_PLAYER, sPlayer1), AQW_OPTIONS.SKERAM_MC);
                    AQWarner_PlaySound(3, AQW_OPTIONS.SKERAM_MC);

                end
            
-- ANUBISATH DEFENDER - PLAGUE
            elseif (sPlayer2 and sType2) then
            
                if (sPlayer2 == AQW_EVENT.YOU and sType2 == AQW_EVENT.ARE) then
                    sPlayer2 = UnitName("Player");
                    AQWarner_SelfAfflictedMessage(AQW_MSG.ANUB_PLAGUE_YOU, AQW_OPTIONS.ANUB_PLAGUE);
                else
                
                    if (AQW_OPTIONS.SEND_TELLS) then
                        SendChatMessage(AQW_MSG.ANUB_PLAGUE_YOU, "WHISPER", nil, sPlayer2);
                    end
                
                    AQWarner_Message(string.format(AQW_MSG.ANUB_PLAGUE_PLAYER, sPlayer2), AQW_OPTIONS.ANUB_PLAGUE);
                    AQWarner_PlaySound(3, AQW_OPTIONS.ANUB_PLAGUE);
                
                end

-- PRINCESS HUHURAN - WYVERN STING
            elseif (sPlayer3 and sType3) then
                AQWarner_Message(AQW_MSG.HUHURAN_STING, AQW_OPTIONS.HUHURAN_STING);
                AQWarner_PlaySound(2, AQW_OPTIONS.HUHURAN_STING);
              
                Chronos.scheduleByName(AQW_EVENT.HUHURAN, 22, AQWarner_Message, AQW_MSG.HUHURAN_STING_IMMINENT, AQW_OPTIONS.HUHURAN_STING);
                Chronos.scheduleByName(AQW_EVENT.HUHURAN_STING, 22, AQWarner_PlaySound, 3, AQW_OPTIONS.HUHURAN_STING);

-- ANUBISATH DEFENDER - THUNDERCLAP
            elseif (string.find(arg1, AQW_EVENT.ANUB_THUNDERCLAP) or string.find(arg1, AQW_EVENT.ANUB_THUNDERCLAP2)) then
                
                if (not AQW_ANUB_THUNDERCLAP_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.ANUB_THUNDERCLAP, AQW_OPTIONS.ANUB_THUNDERCLAP);
                    AQWarner_PlaySound(2, AQW_OPTIONS.ANUB_THUNDERCLAP);
                    AQW_ANUB_THUNDERCLAP_ANNOUNCED = true;
                end
            
-- ANUBISATH DEFENDER - SHADOW STORM
            elseif (string.find(arg1, AQW_EVENT.ANUB_STORM) or string.find(arg1, AQW_EVENT.ANUB_STORM2)) then
                
                if (not AQW_ANUB_STORM_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.ANUB_STORM, AQW_OPTIONS.ANUB_STORM);
                    AQWarner_PlaySound(2, AQW_OPTIONS.ANUB_STORM);
                    AQW_ANUB_STORM_ANNOUNCED = true;
                end
              
-- ANUBISATH DEFENDER - METEOR
            elseif (string.find(arg1, AQW_EVENT.ANUB_METEOR) or string.find(arg1, AQW_EVENT.ANUB_METEOR2)) then
                
                if (not AQW_ANUB_METEOR_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.ANUB_METEOR, AQW_OPTIONS.ANUB_METEOR);
                    AQWarner_PlaySound(2, AQW_OPTIONS.ANUB_METEOR);
                    AQW_ANUB_METEOR_ANNOUNCED = true;
                end
              
            end
        
-- PRINCESS YAUJ - GREATER HEAL
        elseif (arg1 ~= nil and string.find(arg1, AQW_EVENT.TRIO_YAUJ_HEAL)) then
            
            if (AQW_OPTIONS.DEBUG) then
                AQWarner_AddMessage("Event: "..event.." for >>"..AQW_EVENT.AQW_EVENT.TRIO_YAUJ_HEAL.."<<");
            end
            
            AQWarner_Message(AQW_MSG.TRIO_YAUJ_HEAL, AQW_OPTIONS.TRIO_YAUJ_HEAL);
            AQWarner_PlaySound(2, AQW_OPTIONS.TRIO_YAUJ_HEAL);
  
-- BATTLEGUARD SARTURA - WHIRLWIND
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.SARTURA_WHIRLWIND) then
            AQWarner_Message(AQW_MSG.SARTURA_WHIRL, AQW_OPTIONS.SARTURA_WHIRL);
            AQWarner_PlaySound(3, AQW_OPTIONS.SARTURA_WHIRL);
        
-- BATTLEGUARD SARTURA - WHIRLWIND FADE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.SARTURA_WHIRLWIND_FADE) then    
            AQWarner_Message(AQW_MSG.SARTURA_STUN, AQW_OPTIONS.SARTURA_WHIRL);
            AQWarner_PlaySound(1, SARTURA_WHIRL);
        
-- BATTLEGUARD SARTURA - ENRAGE
        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and string.find(arg1, AQW_EVENT.SARTURA_ENRAGE) and arg2 == AQW_EVENT.SARTURA) then
            AQWarner_UnscheduleSartura();
            AQWarner_Message(AQW_MSG.SARTURA_ENRAGE, AQW_OPTIONS.SARTURA_ENRAGE);
            AQWarner_PlaySound(2, AQW_OPTIONS.SARTURA_ENRAGE);
            
-- BATTLEGUARD SARTURA - ENGAGE
        elseif (event == "CHAT_MSG_MONSTER_YELL" and arg1 == AQW_EVENT.SARTURA_ENGAGE) then
            AQWarner_UnscheduleSartura();
            AQWarner_Message(AQW_MSG.SARTURA_ENGAGE, AQW_OPTIONS.SARTURA_SUPREME);
            AQWarner_PlaySound(1, AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_5MINS", 300, AQWarner_Message, string.format(AQW_MSG.SARTURA_ENRAGE_INC, 5, AQW_MSG.MINUTES), AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_5MINS_SOUND", 300, AQWarner_PlaySound, 1, AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_1MIN", 540, AQWarner_Message, string.format(AQW_MSG.SARTURA_ENRAGE_INC, 1, AQW_MSG.MINUTES), AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_1MIN_SOUND", 540, AQWarner_PlaySound, 1, AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_30SECS", 570, AQWarner_Message, string.format(AQW_MSG.SARTURA_ENRAGE_INC, 30, AQW_MSG.SECONDS), AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_30SECS_SOUND", 570, AQWarner_PlaySound, 2, AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_15SECS", 585, AQWarner_Message, string.format(AQW_MSG.SARTURA_ENRAGE_INC, 15, AQW_MSG.SECONDS), AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_15SECS_SOUND", 585, AQWarner_PlaySound, 2, AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_5SECS", 595, AQWarner_Message, string.format(AQW_MSG.SARTURA_ENRAGE_INC, 30, AQW_MSG.SECONDS), AQW_OPTIONS.SARTURA_SUPREME);
            Chronos.scheduleByName("SARTURA_ENRAGE_5SECS_SOUND", 595, AQWarner_PlaySound, 3, AQW_OPTIONS.SARTURA_SUPREME);
            
-- BATTLEGUARD SARTURA - DEATH
        elseif (event == "CHAT_MSG_MONSTER_YELL" and arg1 == AQW_EVENT.SARTURA_DEATH) then
            AQWarner_UnscheduleSartura();
            
-- FANKRISS THE UNYIELDING - SUMMON WORM
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and arg1 == AQW_EVENT.FANKRISS_SUMMON) then
            AQWarner_Message(AQW_MSG.FANKRISS_SUMMON, AQW_OPTIONS.FANKRISS_SUMMON);
            AQWarner_PlaySound(1, AQW_OPTIONS.FANKRISS_SUMMON);
            
-- PRINCESS HUHURAN - FRENZY
        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and string.find(arg1, AQW_EVENT.HUHURAN_FRENZY) and arg2 == AQW_EVENT.HUHURAN) then
            AQWarner_Message(AQW_MSG.HUHURAN_FRENZY, AQW_OPTIONS.HUHURAN_FRENZY);
            AQWarner_PlaySound(3, AQW_OPTIONS.HUHURAN_FRENZY);
        
-- PRINCESS HUHURAN - BERSERKER
        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and string.find(arg1, AQW_EVENT.HUHURAN_BERSERK) and arg2 == AQW_EVENT.HUHURAN) then
            AQWarner_Message(AQW_MSG.HUHURAN_BERSERK, AQW_OPTIONS.HUHURAN_BERSERK);
            AQWarner_PlaySound(1, AQW_OPTIONS.HUHURAN_BERSERK);
            
-- PRINCESS HUHURAN - BERSERKER IMMINENT
        elseif (event == "UNIT_HEALTH") then
        
            if (UnitName("target") == AQW_EVENT.HUHURAN) then
                local targetHealth = UnitHealth("target");
                
                if (targetHealth <= AQW_OPTIONS.HUHURAN_BERSERK_LIMIT and targetHealth > 30) and (not AQW_HUHURAN_BERSERK_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.HUHURAN_BERSERK_IMMINENT, AQW_OPTIONS.HUHURAN_BERSERK_IMMINENT);
                    AQWarner_PlaySound(2, AQW_OPTIONS.HUHURAN_BERSERK_IMMINENT);
                    AQW_HUHURAN_BERSERK_ANNOUNCED = true;
                elseif (targetHealth > 40 and (AQW_EVENT.BERSERK_ANNOUNCED or AQW_HUHURAN_BERSERK_ANNOUNCED)) then
                    AQW_EVENT.BERSERK_ANNOUNCED = false;
                    AQW_HUHURAN_BERSERK_ANNOUNCED = false;
                end

            elseif (UnitName("targettarget") == AQW_EVENT.HUHURAN) then                   
                local targetHealth = UnitHealth("targettarget");
                
                if (targetHealth <= AQW_OPTIONS.HUHURAN_BERSERK_LIMIT and targetHealth > 30) and (not AQW_EVENT.BERSERK_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.HUHURAN_BERSERK_IMMINENT, AQW_OPTIONS.HUHURAN_BERSERK_IMMINENT);
                    AQWarner_PlaySound(2, AQW_OPTIONS.HUHURAN_BERSERK_IMMINENT);
                    AQW_EVENT.BERSERK_ANNOUNCED = true;
                elseif (targetHealth > 40 and (AQW_EVENT.BERSERK_ANNOUNCED or AQW_HUHURAN_BERSERK_ANNOUNCED)) then
                    AQW_HUHURAN_BERSERK_ANNOUNCED = false;
                    AQW_EVENT.BERSERK_ANNOUNCED = false;
                end
            
            end
            
-- ANUBISATH DEFENDER - SUMMON SWARMGUARD
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and arg1 == AQW_EVENT.ANUB_SUMMON_GUARD) then
            showMe = AQW_OPTIONS.ANUB_SUMMON and AQW_ANUB_SUMMON_ANNOUNCED;
            AQWarner_SmallMessage(AQW_MSG.ANUB_SUMMON_GUARD, showMe);
            AQWarner_PlaySound(1, showMe);
            AQW_ANUB_SUMMON_ANNOUNCED = true;
    
-- ANUBISATH DEFENDER - SUMMON WARRIOR
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and arg1 == AQW_EVENT.ANUB_SUMMON_WARRIOR) then
            
            if (not AQW_ANUB_SUMMON_ANNOUNCED) then
                AQWarner_SmallMessage(AQW_MSG.ANUB_SUMMON_WARRIOR, AQW_OPTIONS.ANUB_SUMMON);
                AQWarner_PlaySound(1, AQW_OPTIONS.ANUB_SUMMON);
                AQW_ANUB_SUMMON_ANNOUNCED = true;
            end
            
-- ANUBISATH DEFENDER - EXPLODE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.ANUB_EXPLODE) then
            AQWarner_Message(AQW_MSG.ANUB_EXPLODE, AQW_OPTIONS.ANUB_EXPLODE);
            AQWarner_PlaySound(3, AQW_OPTIONS.ANUB_EXPLODE);
            
-- ANUBISATH DEFENDER - ENRAGE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.ANUB_ENRAGE and arg2 == AQW_EVENT.ANUB) then
            AQWarner_Message(AQW_MSG.ANUB_ENRAGE, AQW_OPTIONS.ANUB_ENRAGE);
            AQWarner_PlaySound(3, AQW_OPTIONS.ANUB_ENRAGE);
            
-- ANUBISATH DEFENDER - DEATH
        elseif (event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" and (string.find(arg1, AQW_EVENT.ANUB) or 
                                                              string.find(arg1, AQW_EVENT.ANUB_AQ20))) then
            AQWarner_AnubDeath();

-- TWIN EMPERORS - TELEPORT
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE" and (string.find(arg1, AQW_EVENT.TWINS_VEKLOR_PORT) or 
                                                                           string.find(arg1, AQW_EVENT.TWINS_VEKNILASH_PORT))) then
            AQWarner_UnscheduleTwins();
            AQWarner_TraceTwinsPort();
        
-- TWIN EMPERORS - EXPLODE BUG
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and string.find(arg1, AQW_EVENT.TWINS_BUG_EXPLODE)) then
            AQWarner_SmallMessage(AQW_MSG.TWINS_BUG_EXPLODE, AQW_OPTIONS.TWINS_BUG_EXPLODE);
            AQWarner_PlaySound(2, AQW_OPTIONS.TWINS_BUG_EXPLODE);
        
-- TWIN EMPERORS - HEAL BROTHER
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and (string.find(arg1, AQW_EVENT.TWINS_VEKLOR_HEAL) or 
                                                                         string.find(arg1, AQW_EVENT.TWINS_VEKLOR_HEAL2) or 
                                                                         string.find(arg1, AQW_EVENT.TWINS_VEKNILASH_HEAL)or
                                                                         string.find(arg1, AQW_EVENT.TWINS_VEKNILASH_HEAL2))) then
                                                                         
            if (not AQW_EVENT.TWINS_HEAL_ANNOUNCED) then
                AQWarner_Message(AQW_MSG.TWINS_HEAL, AQW_OPTIONS.TWINS_HEAL);
                AQWarner_PlaySound(2, AQW_OPTIONS.TWINS_HEAL);
                AQW_EVENT.TWINS_HEAL_ANNOUNCED = true;
                Chronos.scheduleByName("TWINS_HEAL", AQW_OPTIONS.TWINS_HEAL_ANNOUNCE_INTERVAL, AQWarner_ResetHealAnnounced);
            end

-- TWIN EMPERORS - SUPREME MODE (BOTH)
        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and string.find(arg1, AQW_EVENT.TWINS_SUPREME) and (arg2 == AQW_EVENT.TWINS_VEKLOR or arg2 == AQW_EVENT.TWINS_VEKNILASH)) then
            AQWarner_Message(AQW_MSG.TWINS_SUPREME, AQW_OPTIONS.TWINS_SUPREME);
            AQWarner_PlaySound(3, AQW_OPTIONS.TWINS_SUPREME);

-- TWIN EMPERORS - SUPREME MODE (VEKLOR)
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.TWINS_VEKLOR_SUPREME) then
            AQWarner_Message(AQW_MSG.TWINS_SUPREME, AQW_OPTIONS.TWINS_SUPREME);
            AQWarner_PlaySound(3, AQW_OPTIONS.TWINS_SUPREME);

-- TWIN EMPERORS - SUPREME MODE (VEKNILASH)
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.TWINS_VEKNILASH_SUPREME) then
            AQWarner_Message(AQW_MSG.TWINS_SUPREME, AQW_OPTIONS.TWINS_SUPREME);
            AQWarner_PlaySound(3, AQW_OPTIONS.TWINS_SUPREME);
            
-- QIRAJI SLAYER - FRENZY
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.SLAYER_FRENZY) then
                AQWarner_Message(AQW_MSG.SLAYER_FRENZY, AQW_OPTIONS.SLAYER_FRENZY);
                AQWarner_PlaySound(1, AQW_OPTIONS.SLAYER_FRENZY);

-- QIRAJI SLAYER - WHIRLWIND
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.SLAYER_WHIRL) then
            AQWarner_Message(AQW_MSG.SLAYER_WHIRL, AQW_OPTIONS.SLAYER_WHIRL);
            AQWarner_PlaySound(3, AQW_OPTIONS.SLAYER_WHIRL);
        
-- QIRAJI SLAYER - WHIRLWIND FADE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.SLAYER_WHIRL_FADE) then   
            AQWarner_Message(AQW_MSG.SLAYER_WHIRL_FADE, AQW_OPTIONS.SLAYER_WHIRL);
            AQWarner_PlaySound(1, AQW_OPTIONS.SLAYER_WHIRL);
            
-- QIRAJI CHAMPION - VENGEANCE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.CHAMP_VENGEANCE) then
            AQWarner_Message(AQW_MSG.CHAMP_ENRAGE, AQW_OPTIONS.CHAMP_ENRAGE);
            AQWarner_PlaySound(2, AQW_OPTIONS.CHAMP_ENRAGE);
        
-- C'THUN - PHASE2
        elseif (event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" and arg1 == AQW_EVENT.CTHUN_PHASE_2) then
        		AQW_CTHUN_PHASE_2 = true;
        		AQWarner_UnscheduleGlare();
        		AQWarner_CThunEyeTent(30 - AQW_OPTIONS.CTHUN_EYETENT_PREWARN);
        		AQWarner_UnscheduleClawTent();
				
-- C'THUN - STOMACH PORT
				elseif (event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" and arg1 == AQW_EVENT.CTHUN_STOMACH) then
						AQWarner_Message(AQW_MSG.CTHUN_STOMACH, AQW_OPTIONS.CTHUN_STOMACH);
						AQWarner_PlaySound(2, AQW_OPTIONS.CTHUN_STOMACH);
						
-- C'THUN - EYE BEAM
				elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and arg1 == AQW_EVENT.CTHUN_EYEBEAM) then
						AQWarner_Message(AQW_MSG.CTHUN_EYEBEAM, AQW_OPTIONS.CTHUN_EYEBEAM);
						AQWarner_PlaySound(1, AQW_OPTIONS.CTHUN_EYEBEAM);
				
				end
--
-- AQ20
--
    elseif (GetRealZoneText() == AQW_EVENT.AQ20) then
        
        if (event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE" or event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE") then
            local _, _, sPlayer2, sType2 = string.find(arg1, AQW_EVENT.ANUB_PLAGUE);
            local _, _, sPlayer4, sType4 = string.find(arg1, AQW_EVENT.AYAMISS_SACRIFICE);

-- ANUBISATH GUARDIAN - PLAGUE
            if (sPlayer2 and sType2) then
                
                if (sPlayer2 == AQW_EVENT.YOU and sType2 == AQW_EVENT.ARE) then
                    sPlayer2 = UnitName("Player");
                    AQWarner_SelfAfflictedMessage(AQW_MSG.ANUB_PLAGUE_YOU, AQW_OPTIONS.ANUB_AQ20_PLAGUE);
                else
                
                    if (AQW_OPTIONS.SEND_TELLS) then
                        SendChatMessage(AQW_MSG.ANUB_PLAGUE_YOU, "WHISPER", nil, sPlayer2);
                    end
                    
                end
                
                AQWarner_Message(string.format(AQW_MSG.ANUB_PLAGUE_PLAYER, sPlayer2), AQW_OPTIONS.ANUB_AQ20_PLAGUE);
                AQWarner_PlaySound(3, AQW_OPTIONS.ANUB_AQ20_PLAGUE);

-- AYAMISS THE HUNTER - SACRIFICE
            elseif (sPlayer4 and sType4) then
            
                if (sPlayer4 == AQW_EVENT.YOU and sType4 == AQW_EVENT.ARE) then
                    sPlayer4 = UnitName("player");
                end
                
                AQWarner_Message(string.format(AQW_MSG.AYAMISS_WARNING, sPlayer4), AQW_OPTIONS.AYAMISS_SACRIFICE);
                AQWarner_PlaySound(2, AQW_OPTIONS.AYAMISS_SACRIFICE);
                
-- ANUBISATH GUARDIAN - SHADOW STORM
            elseif (string.find(arg1, AQW_EVENT.ANUB_AQ20_STORM) or string.find(arg1, AQW_EVENT.ANUB_AQ20_STORM2)) then
                
                if (not AQW_ANUB_STORM_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.ANUB_STORM, AQW_OPTIONS.ANUB_AQ20_STORM);
                    AQWarner_PlaySound(2, AQW_OPTIONS.ANUB_AQ20_STORM);
                    AQW_ANUB_STORM_ANNOUNCED = true;
                end
            
-- ANUBISATH GUARDIAN - THUNDERCLAP
            elseif (string.find(arg1, AQW_EVENT.ANUB_AQ20_THUNDERCLAP) or string.find(arg1, AQW_EVENT.ANUB_AQ20_THUNDERCLAP2)) then
                
                if (not AQW_ANUB_THUNDERCLAP_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.ANUB_THUNDERCLAP, AQW_OPTIONS.ANUB_AQ20_THUNDERCLAP);
                    AQWarner_PlaySound(2, AQW_OPTIONS.ANUB_AQ20_THUNDERCLAP);
                    AQW_ANUB_THUNDERCLAP_ANNOUNCED = true;
                end
                
-- ANUBISATH GUARDIAN - METEOR
            elseif (string.find(arg1, AQW_EVENT.ANUB_AQ20_METEOR) or string.find(arg1, AQW_EVENT.ANUB_AQ20_METEOR2)) then
                
                if (not AQW_ANUB_METEOR_ANNOUNCED) then
                    AQWarner_Message(AQW_MSG.ANUB_METEOR, AQW_OPTIONS.ANUB_AQ20_METEOR);
                    AQWarner_PlaySound(2, AQW_OPTIONS.ANUB_AQ20_METEOR);
                    AQW_ANUB_METEOR_ANNOUNCED = true;
                end
                
            end
            
-- ANUBISATH GUARDIAN - SUMMON SWARMGUARD
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and arg1 == AQW_EVENT.ANUB_AQ20_SUMMON_GUARD) then
            showMe = AQW_OPTIONS.ANUB_AQ20_SUMMON and AQW_ANUB_SUMMON_ANNOUNCED;
            AQWarner_SmallMessage(AQW_MSG.ANUB_SUMMON_GUARD, showMe);
            AQWarner_PlaySound(1, showMe);
            AQW_ANUB_SUMMON_ANNOUNCED = true;
        
-- ANUBISATH GUARDIAN - SUMMON WARRIOR
        elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" and arg1 == AQW_EVENT.ANUB_AQ20_SUMMON_WARRIOR) then
            showMe = AQW_OPTIONS.ANUB_AQ20_SUMMON and AQW_ANUB_SUMMON_ANNOUNCED;
            AQWarner_SmallMessage(AQW_MSG.ANUB_SUMMON_WARRIOR, showMe);
            AQWarner_PlaySound(1, showMe);
            AQW_ANUB_SUMMON_ANNOUNCED = true;
            
-- ANUBISATH GUARDIAN - EXPLODE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.ANUB_AQ20_EXPLODE) then
            AQWarner_Message(AQW_MSG.ANUB_EXPLODE, AQW_OPTIONS.ANUB_AQ20_EXPLODE);
            AQWarner_Message(3, AQW_OPTIONS.ANUB_AQ20_EXPLODE);
            
-- ANUBISATH GUARDIAN - ENRAGE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and arg1 == AQW_EVENT.ANUB_AQ20_ENRAGE and arg2 == AQW_EVENT.ANUB_AQ20) then
            AQWarner_Message(AQW_MSG.ANUB_ENRAGE, AQW_OPTIONS.ANUB_AQ20_ENRAGE);
            AQWarner_PlaySound(3, AQW_OPTIONS.ANUB_AQ20_ENRAGE);
            
-- ANUBISATH GUARDIAN - DEATH
        elseif (event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" and string.find(arg1, AQW_EVENT.ANUB_AQ20)) then
            AQWarner_AnubDeath();

-- BURU THE GORGER - WATCHING
--        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and arg2 == AQW_EVENT.BURU) then
        elseif (event == "CHAT_MSG_MONSTER_EMOTE") then
            local _, _, playerWatched = string.find(arg1, AQW_EVENT.BURU_EYES);
            
            if (playerWatched) then
                local playerSelf = UnitName("player");
                
                AQWarner_Message(string.format(AQW_MSG.BURU_EYES, playerWatched), AQW_OPTIONS.BURU_EYES);
                AQWarner_PlaySound(2, AQW_OPTIONS.BURU_EYES);
                
                if (playerWatched ~= playerSelf and AQW_OPTIONS.SEND_TELLS) then
                    SendChatMessage(AQW_MSG.BURU_EYES_YOU, "WHISPER", nil, playerWatched);
                elseif (playerWatched == playerSelf and AQW_OPTIONS.SELF_MESSAGE) then
                    AQWarner_SelfAfflictedMessage(AQW_MSG.BURU_EYES_YOU, AQW_MSG.BURU_EYES);
                end
                
            end
            
-- GENERAL RAJAXX - WAVES
        elseif (event == "CHAT_MSG_MONSTER_YELL" and (arg2 == AQW_EVENT.RAJAXX or arg2 == AQW_EVENT.RAJAXX_LIEUTENANT)) then
            
            if (arg1 == AQW_EVENT.RAJAXX_WAVE1) then
                AQWarner_Message(string.format(AQW_MSG.RAJAXX_WAVE, 1), AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(1, AQW_OPTIONS.RAJAXX_WAVES);
            elseif (arg1 == AQW_EVENT.RAJAXX_WAVE3) then
                AQWarner_Message(string.format(AQW_MSG.RAJAXX_WAVE, 3), AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(1, AQW_OPTIONS.RAJAXX_WAVES);
            elseif (arg1 == AQW_EVENT.RAJAXX_WAVE4) then
                AQWarner_Message(string.format(AQW_MSG.RAJAXX_WAVE, 4), AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(1, AQW_OPTIONS.RAJAXX_WAVES);
            elseif (arg1 == AQW_EVENT.RAJAXX_WAVE5) then
                AQWarner_Message(string.format(AQW_MSG.RAJAXX_WAVE, 5), AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(1, AQW_OPTIONS.RAJAXX_WAVES);
            elseif (arg1 == AQW_EVENT.RAJAXX_WAVE6) then
                AQWarner_Message(string.format(AQW_MSG.RAJAXX_WAVE, 6), AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(1, AQW_OPTIONS.RAJAXX_WAVES);
            elseif (arg1 == AQW_EVENT.RAJAXX_WAVE7) then
                AQWarner_Message(string.format(AQW_MSG.RAJAXX_WAVE, 7), AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(1, AQW_OPTIONS.RAJAXX_WAVES);
            elseif (arg1 == AQW_EVENT.RAJAXX_WAVE8) then
                AQWarner_Message(AQW_MSG.RAJAXX_INC, AQW_OPTIONS.RAJAXX_WAVES);
                AQWarner_PlaySound(3, AQW_OPTIONS.RAJAXX_WAVES);
            end

-- MOAM - ENGAGE
        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and arg1 == AQW_EVENT.MOAM_FEAR) then
            AQWarner_UnscheduleMoam();
            AQWarner_Message(AQW_OPTIONS.MOAM_ENGAGE, AQW_OPTIONS.MOAM_ADDS);
            AQWarner_PlaySound(1, AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_ADDS_IN_30", 60, AQWarner_Message, string.format(AQW_MSG.MOAM_ADDSINC, 30), AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_ADDS_IN_30_SOUND", 60, AQWarner_PlaySound, 1, AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_ADDS_IN_15", 75, AQWarner_Message, string.format(AQW_MSG.MOAM_ADDSINC, 15), AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_ADDS_IN_15_SOUND", 75, AQWarner_PlaySound, 2, AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_ADDS_IN_5", 85, AQWarner_Message, string.format(AQW_MSG.MOAM_ADDSINC, 5), AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_ADDS_IN_5_SOUND", 85, AQWarner_PlaySound, 3, AQW_OPTIONS.MOAM_ADDS);
            
-- MOAM - ADDS
        elseif (event == "CHAT_MSG_MONSTER_EMOTE" and arg1 == AQW_EVENT.MOAM_STONE) then
            AQWarner_UnscheduleMoam();
            AQWarner_Message(AQW_OPTIONS.MOAM_ADDS, AQW_OPTIONS.MOAM_ADDS);
            AQWarner_PlaySound(2, AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_AWAKE_IN_15", 75, AQWarner_Message, string.format(AQW_MSG.MOAM_RETURNINC, 15), AQW_OPTIONS.MOAM_ADDS);
            Chronos.scheduleByName("MOAM_AWAKE_IN_15_SOUND", 75, AQWarner_PlaySound, 2, AQW_OPTIONS.MOAM_ADDS);
            
-- MOAM - UN-PARALYZE
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and string.find(arg1, AQW_EVENT.MOAM_RETURN)) then
            AQWarner_UnscheduleMoam();
            AQWarner_Message(AQW_MSG.MOAM_RETURN, AQW_OPTIONS.MOAM_ADDS);
            AQWarner_PlaySound(3, AQW_OPTIONS.MOAM_ADDS);
            
-- OSSIRIAN THE UNSCARRED - SUPREME
        elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS" and string.find(arg1, AQW_EVENT.OSSIRIAN)) then
        
            if (arg1 == AQW_EVENT.OSSIRIAN_SUPREME) then
                AQWarner_Message(AQW_MSG.OSSIRIAN_SUPREME, AQW_OPTIONS.OSSIRIAN_SUPREME);
                AQWarner_PlaySound(3, AQW_OPTIONS.OSSIRIAN_SUPREME);
            else
                local _, _, whatDebuff = string.find(arg1, AQW_EVENT.OSSIRIAN_WEAKNESS);
                
                if (whatDebuff) then
                    AQWarner_Message(string.format(AQW_MSG.OSSIRIAN_WEAKNESS, whatDebuff), AQW_OPTIONS.OSSIRIAN_WEAKNESS);
                    AQWarner_PlaySound(1, AQW_OPTIONS.OSSIRIAN_WEAKNESS);
                    AQWarner_UnscheduleOssirian();
                    Chronos.scheduleByName("DEBUFF_FADE_IN_15", 40, AQWarner_Message, string.format(AQW_MSG.OSSIRIAN_SUPREME_IMMINENT, 15), AQW_OPTIONS.OSSIRIAN_SUPREME_IMMINENT);
                    Chronos.scheduleByName("DEBUFF_FADE_IN_15", 40, AQWarner_PlaySound, 2, AQW_OPTIONS.OSSIRIAN_SUPREME_IMMINENT);
                    Chronos.scheduleByName("DEBUFF_FADE_IN_5", 30, AQWarner_Message, string.format(AQW_MSG.OSSIRIAN_SUPREME_IMMINENT, 5), AQW_OPTIONS.OSSIRIAN_SUPREME_IMMINENT);
                    Chronos.scheduleByName("DEBUFF_FADE_IN_5_SOUND", 30, AQWarner_PlaySound, 3, AQW_OPTIONS.OSSIRIAN_SUPREME_IMMINENT);
                end
                
            end

-- OSSIRIAN THE UNSCARRED - DEATH
        elseif (event == "CHAT_MSG_MONSTER_YELL" and arg2 == AQW_EVENT.OSSIRIAN) then
            AQWarner_UnscheduleOssirian();
        end
            
    end
    
end

--**********************************
--*                                *
--*       Display Settings         *
--*                                *
--**********************************
function AQWarner_DisplayStatus()
    AQWarner_AddMessage(AQW_COLORS.YELLOW.."\nAQWarner Status:\n================");
    
    if (AQW_OPTIONS.ENABLED) then
        AQWarner_AddMessage(AQW_MSG.ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.DISABLED);
        return;
    end
    
    if (AQW_OPTIONS.RAID) then
        AQWarner_AddMessage(AQW_MSG.RAID_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.RAID_DISABLED);
    end

    if (AQW_OPTIONS.STARS) then
        AQWarner_AddMessage(AQW_MSG.STARS_ENABLED);   
    else
        AQWarner_AddMessage(AQW_MSG.STARS_DISABLED);
    end
    
    if (AQW_OPTIONS.SOUND) then
        AQWarner_AddMessage(AQW_MSG.SOUND_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.SOUND_DISABLED);
    end
    
    AQWarner_AddMessage("\n"..AQW_MSG.SKERAM_HEADER);
    
    if (AQW_OPTIONS.SKERAM_AE) then 
        AQWarner_AddMessage(AQW_MSG.SKERAM_AE_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.SKERAM_AE_DISABLED);
    end

    if (AQW_OPTIONS.SKERAM_MC) then 
        AQWarner_AddMessage(AQW_MSG.SKERAM_MC_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.SKERAM_MC_DISABLED);
    end

    if (AQW_OPTIONS.SKERAM_SPLIT) then 
        AQWarner_AddMessage(AQW_MSG.SKERAM_SPLIT_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.SKERAM_SPLIT_DISABLED);
    end
    
    AQWarner_AddMessage("\n"..AQW_MSG.TRIO_HEADER);

    if (AQW_OPTIONS.TRIO_YAUJ_HEAL) then 
        AQWarner_AddMessage(AQW_MSG.TRIO_YAUJ_HEAL_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.TRIO_YAUJ_HEAL_DISABLED);
    end

    AQWarner_AddMessage("\n"..AQW_MSG.SARTURA_HEADER);

    if (AQW_OPTIONS.SARTURA_WHIRL) then 
        AQWarner_AddMessage(AQW_MSG.SARTURA_WHIRL_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.SARTURA_WHIRL_DISABLED);
    end

    if (AQW_OPTIONS.SARTURA_ENRAGE) then 
        AQWarner_AddMessage(AQW_MSG.SARTURA_ENRAGE_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.SARTURA_ENRAGE_DISABLED);
    end
    
    AQWarner_AddMessage("\n"..AQW_MSG.FANKRISS_HEADER);

    if (AQW_OPTIONS.FANKRISS_SUMMON) then 
        AQWarner_AddMessage(AQW_MSG.FANKRISS_SUMMON_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.FANKRISS_SUMMON_DISABLED);
    end
    
    AQWarner_AddMessage("\n"..AQW_MSG.HUHURAN_HEADER);

    if (AQW_OPTIONS.HUHURAN_FRENZY) then 
        AQWarner_AddMessage(AQW_MSG.HUHURAN_FRENZY_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.HUHURAN_FRENZY_DISABLED);
    end

    if (AQW_OPTIONS.HUHURAN_BERSERK_IMMINENT) then 
        AQWarner_AddMessage(AQW_MSG.HUHURAN_BERSERK_IMMINENT_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.HUHURAN_BERSERK_IMMINENT_DISABLED);
    end
    
    if (AQW_OPTIONS.HUHURAN_BERSERK) then 
        AQWarner_AddMessage(AQW_MSG.HUHURAN_BERSERK_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.HUHURAN_BERSERK_DISABLED);
    end
    
    if (AQW_OPTIONS.HUHURAN_STING) then 
        AQWarner_AddMessage(AQW_MSG.HUHURAN_STING_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.HUHURAN_STING_DISABLED);
    end
    
    AQWarner_AddMessage("\n"..AQW_MSG.ANUB_HEADER);
    
    if (AQW_OPTIONS.ANUB_SUMMON) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_SUMMON_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_SUMMON_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_PLAGUE) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_PLAGUE_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_PLAGUE_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_METEOR) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_METEOR_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_METEOR_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_THUNDERCLAP) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_THUNDERCLAP_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_THUNDERCLAP_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_STORM) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_STORM_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_STORM_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_EXPLODE) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_EXPLODE_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_EXPLODE_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_ENRAGE) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_ENRAGE_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_ENRAGE_DISABLED);
    end

    if (AQW_OPTIONS.ANUB_AQ20) then 
        AQWarner_AddMessage(AQW_MSG.ANUB_AQ20_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.ANUB_AQ20_DISABLED);
    end

    AQWarner_AddMessage("\n"..AQW_MSG.TWINS_HEADER);
    
    if (AQW_OPTIONS.TWINS_PORT) then 
        AQWarner_AddMessage(AQW_MSG.TWINS_PORT_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.TWINS_PORT_DISABLED);
    end

    if (AQW_OPTIONS.TWINS_HEAL) then 
        AQWarner_AddMessage(AQW_MSG.TWINS_HEAL_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.TWINS_HEAL_DISABLED);
    end

    if (AQW_OPTIONS.TWINS_BUG_EXPLODE) then 
        AQWarner_AddMessage(AQW_MSG.TWINS_BUG_EXPLODE_ENABLED);
    else
        AQWarner_AddMessage(AQW_MSG.TWINS_BUG_EXPLODE_DISABLED);
    end
    
end

--**********************************
--*                                *
--*        Register Events         *
--*                                *
--**********************************
function AQWarner_Register()
    for index, value in AQW_EVENTS do
        this:RegisterEvent(value);
    end
end

--**********************************
--*                                *
--*      Unregister Events         *
--*                                *
--**********************************
function AQWarner_Unregister()
    for index, value in AQW_EVENTS do
        this:UnregisterEvent(value);
    end
end

--**********************************
--*                                *
--*        Frame Message           *
--*                                *
--**********************************
function AQWarner_AddMessage(msg)
    DEFAULT_CHAT_FRAME:AddMessage(msg);
end

--**********************************
--*                                *
--*        Display Message         *
--*        in /ra and /rs          *
--*                                *
--**********************************
function AQWarner_Message(msg, isVisible)

    if (msg == AQW_MSG.HUHURAN_STING_IMMINENT) then
        AQW_EVENT.HUHURAN_STING_ANNOUNCED = false;
    elseif (msg == AQW_MSG.HUHURAN_STING and not AQW_EVENT.HUHURAN_STING_ANNOUNCED) then
        AQW_EVENT.HUHURAN_STING_ANNOUNCED = true;
    elseif (msg == AQW_MSG.HUHURAN_STING and AQW_EVENT.HUHURAN_STING_ANNOUNCED) then
        return;
    end
    
    if (AQW_OPTIONS.STARS) then
        msg = "*** "..msg.." ***";
    end
    
    if (AQW_OPTIONS.RAID and GetNumRaidMembers() > 0) and (isVisible) then
        local ctra_msg = "MS "..msg;
        SendChatMessage(msg, "RAID");
        CT_RA_AddMessage(ctra_msg);
    end

    if (isVisible) then   
        AQWarnerFrame:AddMessage(msg, 1, 1, 1, 1, 3);
    end
    
end

--**********************************
--*                                *
--*         Small Message          *
--*                                *
--**********************************
function AQWarner_SmallMessage(msg, isVisible)
    
    if (isVisible) then
        AQWarnerFrame:AddMessage(msg, 1, 1, 1, 1, 3);
    end
    
end

--**********************************
--*                                *
--*         Play Sound             *
--*                                *
--**********************************
function AQWarner_PlaySound(id, doSound)

    if (doSound and AQW_OPTIONS.SOUND) then
        PlaySoundFile(AQW_SND[id]);
    end
    
end

--**********************************
--*                                *
--*   Display LARGE Self-Warning   *
--*                                *
--**********************************
function AQWarner_SelfAfflictedMessage(msg, isVisible)
    
    if (AQW_OPTIONS.STARS) then
        msg = "*** "..msg.." ***";
    end
    
    if (AQW_OPTIONS.SELF_MESSAGE and isVisible) then
        AQWarnerSelfWarningFrame:AddMessage(msg, 1, 1, 1, 1, 3);
    end;
  
end

--**********************************
--*                                *
--*      Warn for port 25sec       *
--*          after port            *
--*                                *
--**********************************
function AQWarner_TraceTwinsPort()
    local prewarnTime = 30 - AQW_OPTIONS.TWINS_PREWARN_INTERVAL;
    AQWarner_Message(AQW_MSG.TWINS_PORT, AQW_OPTIONS.TWINS_PORT);
    AQWarner_PlaySound(2, AQW_OPTIONS.TWINS_PORT);        
    Chronos.scheduleByName("PORT_IMMINENT", prewarnTime, AQWarner_Message, string.format(AQW_MSG.TWINS_PORT_IMMINENT, AQW_OPTIONS.TWINS_PREWARN_INTERVAL), AQW_OPTIONS.TWINS_PORT);
    Chronos.scheduleByName("PORT_IMMINENT_SOUND", prewarnTime, AQWarner_PlaySound, 3, AQW_OPTIONS.TWINS_PORT);
    
    if (not AQW_TWINS_SUPREME_RUNNING) then
        AQWarner_UnscheduleTwinsSupreme();
        AQWarner_Message(string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 15, AQW_MSG.MINUTES), AQW_MSG.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_10MINS", 270, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 10, AQW_MSG.MINUTES), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_10MINS_SOUND", 270, AQWarner_PlaySound, 1, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5MINS", 570, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 5, AQW_MSG.MINUTES), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5MINS_SOUND", 570, AQWarner_PlaySound, 1, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_1MIN", 810, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 1, AQW_MSG.MINUTES), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_1MIN_SOUND", 810, AQWarner_PlaySound, 2, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_30SECS", 840, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 30, AQW_MSG.SECONDS), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_30SECS_SOUND", 840, AQWarner_PlaySound, 2, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_15SECS", 855, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 15, AQW_MSG.SECONDS), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_15SECS_SOUND", 855, AQWarner_PlaySound, 3, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5SECS", 865, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 5, AQW_MSG.SECONDS), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5SECS_SOUND", 865, AQWarner_PlaySound, 3, AQW_OPTIONS.TWINS_SUPREME);
        AQW_TWINS_SUPREME_RUNNING = true;
    end
    
end

--**********************************
--*                                *
--*   Unschedule Twins Supreme     *
--*                                *
--**********************************
function AQWarner_UnscheduleTwinsSupreme()

    if (Chronos.isScheduledByName("TWINS_SUPREME_5MINS")) then
        Chronos.unscheduleByName("TWINS_SUPREME_5MINS");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_1MIN")) then
        Chronos.unscheduleByName("TWINS_SUPREME_1MIN");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_30SECS")) then
        Chronos.unscheduleByName("TWINS_SUPREME_30SECS");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_15SECS")) then
        Chronos.unscheduleByName("TWINS_SUPREME_15SECS");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_5SECS")) then
        Chronos.unscheduleByName("TWINS_SUPREME_5SECS");
    end

    if (Chronos.isScheduledByName("TWINS_SUPREME_5MINS_SOUND")) then
        Chronos.unscheduleByName("TWINS_SUPREME_5MINS_SOUND");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_1MIN_SOUND")) then
        Chronos.unscheduleByName("TWINS_SUPREME_1MIN_SOUND");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_30SECS_SOUND")) then
        Chronos.unscheduleByName("TWINS_SUPREME_30SECS_SOUND");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_15SECS_SOUND")) then
        Chronos.unscheduleByName("TWINS_SUPREME_15SECS_SOUND");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_5SECS_SOUND")) then
        Chronos.unscheduleByName("TWINS_SUPREME_5SECS_SOUND");
    end

    if (Chronos.isScheduledByName("TWINS_SUPREME_10MINS")) then
        Chronos.unscheduleByName("TWINS_SUPREME_10MINS");
    end
    
    if (Chronos.isScheduledByName("TWINS_SUPREME_10MINS_SOUND")) then
        Chronos.unscheduleByName("TWINS_SUPREME_10MINS_SOUND");
    end

    AQW_TWINS_SUPREME_RUNNING = false;
end

--**********************************
--*                                *
--*   Unschedule Twins Warnings    *
--*                                *
--**********************************
function AQWarner_UnscheduleTwins()

    if (Chronos.isScheduledByName("PORT_IMMINENT")) then
        Chronos.unscheduleByName("PORT_IMMINENT");
    end
    
    if (Chronos.isScheduledByName("PORT_IMMINENT_SOUND")) then
        Chronos.unscheduleByName("PORT_IMMINENT_SOUND");
    end
    
    if (Chronos.isScheduledByName("TRACE_PORT")) then
        Chronos.unscheduleByName("TRACE_PORT");
    end
    
end

--**********************************
--*                                *
--*     Start Teleport Announce    *
--*           Manually             *
--*                                *
--**********************************
function AQWarner_CmdPortAnnounce()
    local prewarnTime = 30 - AQW_OPTIONS.TWINS_PREWARN_INTERVAL;
    AQWarner_UnscheduleTwins();
    AQWarner_Message(AQW_MSG.TWINS_PORT, AQW_OPTIONS.TWINS_PORT);
    AQWarner_PlaySound(2, AQW_OPTIONS.TWINS_PORT);        
    Chronos.scheduleByName("PORT_IMMINENT", prewarnTime, AQWarner_Message, string.format(AQW_MSG.TWINS_PORT_IMMINENT, AQW_OPTIONS.TWINS_PREWARN_INTERVAL), AQW_OPTIONS.TWINS_PORT);
    Chronos.scheduleByName("PORT_IMMINENT_SOUND", prewarnTime, AQWarner_PlaySound, 3, AQW_OPTIONS.TWINS_PORT);
    
    if (not AQW_TWINS_SUPREME_RUNNING) then
        AQWarner_UnscheduleTwinsSupreme();
        AQWarner_Message(string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 15, AQW_MSG.MINUTES), AQW_MSG.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_10MINS", 300, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 10, AQW_MSG.MINUTES), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_10MINS_SOUND", 300, AQWarner_PlaySound, 1, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5MINS", 600, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 5, AQW_MSG.MINUTES), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5MINS_SOUND", 600, AQWarner_PlaySound, 1, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_1MIN", 840, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 1, AQW_MSG.MINUTES), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_1MIN_SOUND", 840, AQWarner_PlaySound, 2, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_30SECS", 870, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 30, AQW_MSG.SECONDS), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_30SECS_SOUND", 870, AQWarner_PlaySound, 2, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_15SECS", 885, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 15, AQW_MSG.SECONDS), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_15SECS_SOUND", 885, AQWarner_PlaySound, 3, AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5SECS", 895, AQWarner_Message, string.format(AQW_MSG.TWINS_SUPREME_INC_MIN, 5, AQW_MSG.SECONDS), AQW_OPTIONS.TWINS_SUPREME);
        Chronos.scheduleByName("TWINS_SUPREME_5SECS_SOUND", 895, AQWarner_PlaySound, 3, AQW_OPTIONS.TWINS_SUPREME);
        AQW_TWINS_SUPREME_RUNNING = true;
    end
    
end

--**********************************
--*                                *
--*  Reset Heal Announce for Twins *
--*                                *
--**********************************
function AQWarner_ResetHealAnnounced()
    AQW_EVENT.TWINS_HEAL_ANNOUNCED = false;
end

--**********************************
--*                                *
--*    Anubisath Warnings Reset    *
--*                                *
--**********************************
function AQWarner_AnubDeath()
    
    if (AQW_THUNDERCLAP_ANNOUNCED) then
        AQW_ANUB_THUNDERCLAP_ANNOUNCED = false;
    end
    
    if (AQW_ANUB_SUMMON_ANNOUNCED) then
        AQW_ANUB_SUMMON_ANNOUNCED = false;
    end
    
    if (AQW_ANUB_STORM_ANNOUNCED) then
        AQW_ANUB_STORM_ANNOUNCED = false;
    end
    
    if (AQW_ANUB_METEOR_ANNOUNCED) then
        AQW_ANUB_METEOR_ANNOUNCED = false;
    end
    
end

--**********************************
--*                                *
--*  Unschedule Ossirian Warnings  *
--*                                *
--**********************************
function AQWarner_UnscheduleOssirian()

    if (Chronos.isScheduledByName("DEBUFF_FADE_IN_15")) then
        Chronos.unscheduleByName("DEBUFF_FADE_IN_15");
    end
    
    if (Chronos.isScheduledByName("DEBUFF_FADE_IN_15")) then
        Chronos.unscheduleByName("DEBUFF_FADE_IN_15");
    end
    
    if (Chronos.isScheduledByName("DEBUFF_FADE_IN_5")) then
        Chronos.unscheduleByName("DEBUFF_FADE_IN_5");
    end
    
    if (Chronos.isScheduledByName("DEBUFF_FADE_IN_5_SOUND")) then
        Chronos.unscheduleByName("DEBUFF_FADE_IN_5_SOUND");
    end

end

--**********************************
--*                                *
--*  Unschedule Sartura Warnings   *
--*                                *
--**********************************
function AQWarner_UnscheduleSartura()

    if (Chronos.isScheduledByName("SARTURA_ENRAGE_5MINS")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_5MINS");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_5MINS_SOUND")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_5MINS_SOUND");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_1MIN")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_1MIN");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_1MIN_SOUND")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_1MIN_SOUND");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_30SECS")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_30SECS");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_30SECS_SOUND")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_30SECS_SOUND");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_15SECS")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_15SECS");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_15SECS_SOUND")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_15SECS_SOUND");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_5SECS")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_5SECS");
    end
    
    if (Chronos.isScheduledByName("SARTURA_ENRAGE_5SECS_SOUND")) then
        Chronos.unscheduleByName("SARTURA_ENRAGE_5SECS_SOUND");
    end

end

--**********************************
--*                                *
--*    Unschedule Moam Warnings    *
--*                                *
--**********************************
function AQWarner_UnscheduleMoam()

    if (Chronos.isScheduledByName("MOAM_ADDS_IN_30")) then
        Chronos.unscheduleByName("MOAM_ADDS_IN_30");
    end
    
    if (Chronos.isScheduledByName("MOAM_ADDS_IN_30_SOUND")) then
        Chronos.unscheduleByName("MOAM_ADDS_IN_30_SOUND");
    end
    
    if (Chronos.isScheduledByName("MOAM_ADDS_IN_15")) then
        Chronos.unscheduleByName("MOAM_ADDS_IN_15");
    end
    
    if (Chronos.isScheduledByName("MOAM_ADDS_IN_15_SOUND")) then
        Chronos.unscheduleByName("MOAM_ADDS_IN_15_SOUND");
    end
    
    if (Chronos.isScheduledByName("MOAM_ADDS_IN_5")) then
        Chronos.unscheduleByName("MOAM_ADDS_IN_5");
    end
    
    if (Chronos.isScheduledByName("MOAM_ADDS_IN_5_SOUND")) then
        Chronos.unscheduleByName("MOAM_ADDS_IN_5_SOUND");
    end
        
    if (Chronos.isScheduledByName("MOAM_AWAKE_IN_15")) then
        Chronos.unscheduleByName("MOAM_AWAKE_IN_15");
    end
        
    if (Chronos.isScheduledByName("MOAM_AWAKE_IN_15_SOUND")) then
        Chronos.unscheduleByName("MOAM_AWAKE_IN_15_SOUND");
    end
        
end

--**********************************
--*                                *
--*  Unschedule C'Thun Warnings    *
--*                                *
--**********************************
function AQWarner_UnscheduleCThun()
		AQWarner_UnscheduleGlare();
		AQWarner_UnscheduleEyeTent();
		AQWarner_UnscheduleClawTent();
end