⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countdoom.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
    elseif CountDoom.config.announceSpells == "local" then
        CountDoom.config.announceSpells = "party";
    elseif CountDoom.config.announceSpells == "party" then
        CountDoom.config.announceSpells = "raid";
    elseif CountDoom.config.announceSpells == "raid" then
        CountDoom.config.announceSpells = "channel";
    elseif CountDoom.config.announceSpells == "channel" then
        CountDoom.config.announceSpells = "all";
    else
        CountDoom.config.announceSpells = "never";
    end

    CountDoom.ChatPrint( "Spells will be announced: " .. CountDoom.config.announceSpells );
end;


CountDoom.SetEnable = function( enable )
    CountDoom.config.enable = enable;
    if( CountDoom.config.enable == true ) then
        CountDoom.ChatPrint( COUNTDOOM_ENABLEDMSG );
    else
        CountDoom.ChatPrint( COUNTDOOM_DISABLEDMSG );
    end
end;


CountDoom.SetLocked = function( locked )
    CountDoom.config.isLocked = locked;
    if( CountDoom.config.isLocked == true ) then
        CountDoom.ChatPrint( COUNTDOOM_LOCKED );
    else
        CountDoom.ChatPrint( COUNTDOOM_UNLOCKED );
    end
    
    CountDoom.UpdateDragButtons();
end;


CountDoom.ToggleFlashingSpells = function ()
    if( CountDoom.config.flashSpells == true ) then
        CountDoom.config.flashSpells = false;
        CountDoom.ChatPrint( COUNTDOOM_NOFLASHMSG );
    else
        CountDoom.config.flashSpells = true;
        CountDoom.ChatPrint( COUNTDOOM_YESFLASHMSG );
    end
end;


CountDoom.TogglePlayingSounds = function ()
    if( CountDoom.config.playSounds == true ) then
        CountDoom.config.playSounds = false;
        CountDoom.ChatPrint( COUNTDOOM_NOSOUNDSMSG );
    else
        CountDoom.config.playSounds = true;
        CountDoom.ChatPrint( COUNTDOOM_YESSOUNDSMSG );
    end
end;


CountDoom.ToggleHseconds = function ()
    if( CountDoom.config.hseconds == true ) then
        CountDoom.config.hseconds = false;
        CountDoom.ChatPrint( COUNTDOOM_HSECONDS_OFF );
    else
        CountDoom.config.hseconds = true;
        CountDoom.ChatPrint( COUNTDOOM_HSECONDS_ON );
    end
end;


CountDoom.SetOOCTime = function ( delayString )
    if delayString ~= nil then
        local oocTime = tonumber( delayString );
        if oocTime ~= nil then
            CountDoom.config.outofcombatDelay = oocTime;
        end 
    end
    
    CountDoom.ChatPrint( "Out of combat delay is: " .. CountDoom.ToString( CountDoom.config.outofcombatDelay ) );
end;


CountDoom.SetPostExpireDelay = function ( delayString )
    if delayString ~= nil then
        local expireDelayTime = tonumber( delayString );
        if expireDelayTime ~= nil then
            CountDoom.config.postExpireDelay = expireDelayTime;
        end 
    end
    
    CountDoom.ChatPrint( "Delay before removing expired timers: " .. CountDoom.ToString( CountDoom.config.postExpireDelay ) );
end;


CountDoom.SetAnnounceChannel = function( channelName )
    if channelName ~= nil then
        CountDoom.config.announceChannel = channelName;
    end
    CountDoom.ChatPrint( "Announce channel: " .. CountDoom.ToString( CountDoom.config.announceChannel ) );
end;


CountDoom.DumpEvents = function ()
    CountDoom.ChatPrint( "Last spell cast: " .. CountDoom.ToString( CountDoom.event.castSpellName ) );
    CountDoom.ChatPrint( "Mode: " .. CountDoom.ToString( CountDoom.event.castMode ) );
    CountDoom.ChatPrint( "Target: " .. CountDoom.ToString( CountDoom.event.castTarget ) );
    CountDoom.ChatPrint( "Last spell removed: " .. CountDoom.ToString( CountDoom.event.removedSpellName ) );
    CountDoom.ChatPrint( "Removal reason: " .. CountDoom.ToString( CountDoom.event.removedLastReason ) );
    CountDoom.ChatPrint( "Target: " .. CountDoom.ToString( CountDoom.event.removedTarget ) );
end;


function CountDoomSlash(msg)

    msg = string.lower(msg);
    local a, b, c, n = string.find (msg, "(%w+) ([_%w]+)");
    
    if( c == nil and n == nil ) then
        a, b, c = string.find (msg, "(%w+)");
    end
    
    if (c ~= nil) then
        CountDoom.DebugPrint("c:"..c);
    else
        CountDoom.DebugPrint("c: nil");
    end
    
    if (n ~= nil) then
        CountDoom.DebugPrint("n:"..n);
    else
        CountDoom.DebugPrint("n: nil");
    end

    if (c == nil) then
        CountDoom.DisplayCommands();
        CountDoom.DisplaySettings();
        return;
    end
    
    if( CountDoomSpell[ c ] ~= nil ) then
        if( n == "start" ) then
        
            local targetInfo = {};
            targetInfo.targetName = UnitName( "target" );
            targetInfo.targetLevel = UnitLevel( "target" );
            targetInfo.id = CountDoom.targetID;
            
            CountDoom.lastSpellID, CountDoom.replacedASpell = CDTimerSpell_CreateBySpellAbbreviation( c, targetInfo, nil );
            
        elseif( n == "end" ) then
            CDTimerSpell_DestroyBySpellAbbreviation( c );

            CountDoom.event.removedSpellName = c;
            CountDoom.event.removedLastReason = "/cd " .. c .. " end";
            CountDoom.event.removedTarget = nil;
        elseif( n == "toggle" ) then
            CountDoomSpell.ToggleEnabled( c );
        elseif( n == "play" ) then
            CountDoomSpell.ToggleSound( c );
        elseif( n == "announce" ) then
            CountDoomSpell.ToggleAnnounce( c );
        elseif( n == nil ) then
            CountDoomSpell.Dump( c );
        end
    elseif( c == "announce" ) then
        CountDoom.ToggleAnnouncingSpells();        
    elseif( c == "play" ) then
        CountDoom.TogglePlayingSounds();
    elseif( c == "flash" ) then
        CountDoom.ToggleFlashingSpells();
    elseif( c == "debug" ) then
        if( n == "verbose" ) then
            if( CountDoom.debugVerbose == true ) then
                CountDoom.debugVerbose = false;
                CountDoom.DebugPrint( "debugVerbose is off" );
            else
                CountDoom.debugVerbose = true;
                CountDoom.DebugPrint( "debugVerbose is on" );
            end
        elseif( n == "events" ) then
            if( CountDoom.debugEvents == true ) then
                CountDoom.debugEvents = false;
                CountDoom.ChatPrint( "debugEvents is off" );
            else
                CountDoom.debugEvents = true;
                CountDoom.ChatPrint( "debugEvents is on" );
            end
        elseif( n == "dump" ) then
            CountDoom.DumpEvents();
        end
    elseif( c == "enable" ) then
        CountDoom.SetEnable( true );
    elseif( c == "disable" ) then
        CountDoom.SetEnable( false );
    elseif( c == "layout" ) then
        CountDoom.RotateLayout( "CountDoomFrame" );
    elseif( c == "unlock" ) then
        CountDoom.SetLocked( false );
    elseif( c == "lock" ) then
        CountDoom.SetLocked( true );
    elseif( c == "scale" ) then
        CountDoom.CycleScale();
    elseif( c == "hseconds" ) then
        CountDoom.ToggleHseconds();
    elseif( c == "ooc" and n ~= nil ) then
        CountDoom.SetOOCTime( n );
    elseif( c == "expire" and n ~= nil ) then
        CountDoom.SetPostExpireDelay( n );
    elseif( c == "channel" ) then
        CountDoom.SetAnnounceChannel( n );
    end
end


function CDFrame_OnUpdate(elapsed)
    CountDoom.totalTime = CountDoom.totalTime + elapsed;

    if CountDoom.timeRemoveAllTimers ~= nil then

        -- Dont' remove timers if we have a pending spell to cast
        if CountDoom.activeSpell ~= nil then
            CountDoom.timeRemoveAllTimers = nil;
            return;
        end

        if GetTime() >= CountDoom.timeRemoveAllTimers then
            CountDoom.event.removedSpellName = "All timers";
            CountDoom.event.removedLastReason = event;
            CountDoom.event.removedTarget = nil;

            CDTimerSpell_RemoveCombatSpellTimers();
            CountDoom.timeRemoveAllTimers = nil;
        end
    end
end


function CDFrame_OnLoad()
    -- Used for initialization of the mod
    this:RegisterEvent("VARIABLES_LOADED");
end


function CDFrame_OnEvent(event)

    -- Keep track of the events
    if CountDoom.debugVerbose or CountDoom.debugEvents then
        local msg = "Event: " .. event .. ": " .. CountDoom.ToString( arg1 ) .. " " .. CountDoom.ToString( arg2 );
        
        if CountDoom.debugEvents then
            CountDoom.CombatPrint(msg);
        end

        CountDoom.DebugPrint(msg);
    end        
    
    -- Initialize as soon as the player logs in
    if (event == "VARIABLES_LOADED") then
        CountDoom.Initialize();
        return;
    end
    
    if CountDoom.initialized ~= true then
        return;
    end 
    
    if CountDoom.config.enable ~= true then 
        return;
    end 

    if UnitClass("player") ~= COUNTDOOM_WARLOCK then
        return;
    end
    
    -- Pet status changed
    if (event == "UNIT_PET" and arg1 == "player") or 
       (event == "LOCALPLAYER_PET_CHANGED") then
        
        if (UnitIsFriend("player", "pet")) then
            local iIterator = 1
            while (UnitDebuff("pet", iIterator)) do
                local debuffString = UnitDebuff("pet", iIterator);
                CountDoom.DebugPrint( "Debuff[" .. iIterator .. "] " .. debuffString);
                if (string.find(debuffString, COUNTDOOMDEBUFF_ENSLAVEDEMON)) then
                
                    local targetInfo = {};
                    targetInfo.targetName = UnitName( "target" );
                    targetInfo.targetLevel = UnitLevel( "target" );
                    targetInfo.id = CountDoom.targetID;
                    
                    CountDoom.lastSpellID, CountDoom.replacedASpell = CDTimerSpell_CreateBySpellAbbreviation( "enslave", targetInfo, nil );
                end                       
                iIterator = iIterator + 1
            end 
        else
            CDTimerSpell_DestroyBySpellAbbreviation( "enslave" );

            CountDoom.event.removedSpellName = "enslave";
            CountDoom.event.removedLastReason = event;
            CountDoom.event.removedTarget = nil;
        end

    -- Started casting a spell (DEBUG)
    elseif event == "SPELLCAST_START" then
    
        --We used to track the activeSpell name by monitoring this event but
        --unfortunately it doesn't track insta-cast spells
        
    -- Spell casting was interrupted
    elseif event == "SPELLCAST_INTERRUPTED" or event == "SPELLCAST_FAILED" then

        CountDoom.activeSpell = nil;
        CountDoom.targetName = nil;
        CountDoom.targetLevel = 0;
        CountDoom.activeSpellWaitingForTarget = nil;

        if CountDoom.lastSpellID ~= -1 and CountDoom.replacedASpell == false then
            CDTimerSpell_DeleteID( CountDoom.lastSpellID );	

            CountDoom.event.removedSpellName = "spellID: " .. CountDoom.lastSpellID;
            CountDoom.event.removedLastReason = event;
            if CDTimerSpells[ CountDoom.lastSpellID ] ~= nil then
                CountDoom.event.removedTarget = CDTimerSpells[ CountDoom.lastSpellID ].targetName;
            else
                CountDoom.event.removedTarget = nil;
            end
        end
        
        CountDoom.lastSpellID = -1;
        CountDoom.replacedASpell = false;

    -- User stopped casting a spell
    elseif event == "SPELLCAST_STOP" then

        if CountDoom.activeSpell ~= nil then
            local targetInfo = {};
            targetInfo.targetName = CountDoom.targetName;
            targetInfo.targetLevel = CountDoom.targetLevel;
            targetInfo.id = CountDoom.targetID;

            -- We are likely to enter combat.  Don't delete timers immediately.
            CountDoom.timeRemoveAllTimers = nil;
        
            CountDoom.lastSpellID, CountDoom.replacedASpell = CDTimerSpell_CreateBySpellName(
                CountDoom.activeSpell, targetInfo, CountDoom.spellRank );
            CountDoom.activeSpell = nil;
        end
    
    -- Player has left combat or changed zones
    elseif event == "PLAYER_REGEN_ENABLED" or event == "PLAYER_ENTERING_WORLD" then
        
        CountDoom.timeRemoveAllTimers = GetTime() + CountDoom.config.outofcombatDelay;

    -- Player has entered combat
    elseif event == "PLAYER_REGEN_DISABLED" then

        CountDoom.timeRemoveAllTimers = nil;

    -- Pet has cast a spell (DEBUG)
    elseif(event == "CHAT_MSG_SPELL_PET_DAMAGE") then
		arg1 = string.gsub(arg1," %(.+%)","") -- strip trailing ()'s we don't use
		arg1 = string.gsub(arg1,"%.$","") -- strip trailing .'s
		
        local found,_,casterName,spellName,index3,index4,index5 = string.find(arg1, CD_SPELLCASTOTHERSTART);
        if found then
            CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( casterName ) .. " begins to cast " .. CountDoom.ToString( spellName ) );
            
            CountDoom.petTargetName = UnitName( "pettarget" );
            CountDoom.petTargeLevel = UnitLevel( "pettarget" );
            CountDoom.petActiveSpell = spellName;
        end

    elseif(event == "CHAT_MSG_SPELL_SELF_DAMAGE") then
		arg1 = string.gsub(arg1," %(.+%)","") -- strip trailing ()'s we don't use
		arg1 = string.gsub(arg1,"%.$","") -- strip trailing .'s

        -- Determine if the target resisted
        local found,_,spellName,mobName,index3,index4,index5 = string.find(arg1, CD_SPELLRESISTSELFOTHER);
        if found then
            CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( spellName ) .. " was resisted by " .. CountDoom.ToString( mobName ) );

            -- Destroy the last active spell
            CountDoom.activeSpell = nil;
    
        	if (CountDoom.lastSpellID == nil or CountDoom.lastSpellID == -1 or
                CountDoom.replacedASpell) then
                return;
            end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -