📄 countdoomspelltimer.lua
字号:
-- CountDoomSpellTimer stuff
-- Author: Scrum
CDTimerSpell_numSpells = 0;
CDTimerSpell_spellID = 0;
CDTimerSpells = {};
-- timerIndex = timerIndex;
-- warningHit = false;
-- spellAbbreviation = spellAbbreviation;
-- announceWarning = false;
-- warningSound = false;
-- announceEnd = false;
-- endSound = false;
-- targetName = nil;
-- targetLevel = nil;
-- type = nil;
-- ID = 0;
local function CDTimerSpell_Dump( spellIndex )
CountDoom.DebugPrint( "Spell#: " .. spellIndex );
CountDoom.DebugPrint( " timerIndex: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].timerIndex ) );
CountDoom.DebugPrint( " spellID: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].spellID ) );
CountDoom.DebugPrint( " warningHit: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].warningHit ) );
CountDoom.DebugPrint( " spellAbbreviation: " .. CDTimerSpells[ spellIndex ].spellAbbreviation );
CountDoom.DebugPrint( " announceWarning: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].announceWarning ) );
CountDoom.DebugPrint( " warningSound: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].warningSound ) );
CountDoom.DebugPrint( " announceEnd: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].announceEnd ) );
CountDoom.DebugPrint( " endSound: " .. CountDoom.ToString( CDTimerSpells[ spellIndex ].endSound ) );
end
local function CDTimerSpell_DumpAll()
if CountDoom.debugVerbose then
local spellIndex;
for spellIndex = 0, CDTimerSpell_numSpells - 1 do
CDTimerSpell_Dump( spellIndex );
end
end
end
local function CDTimerSpell_AnnounceMessage( msg )
if CountDoom.config.announceSpells == nil or CountDoom.config.announceSpells == "never" then
return;
end
local announceRaid = CountDoom.config.announceSpells == "all" or CountDoom.config.announceSpells == "raid";
local announceParty = CountDoom.config.announceSpells == "all" or CountDoom.config.announceSpells == "party";
local isRaid = GetNumRaidMembers() > 0;
local isParty = GetNumPartyMembers() > 0;
if( CountDoom.debugVerbose ) then
isRaid = false;
isParty = false;
end
if( announceRaid and isRaid ) then
SendChatMessage( msg, "RAID" )
elseif( announceParty and isParty ) then
SendChatMessage( msg, "PARTY" );
elseif ( CountDoom.config.announceSpells == "channel" )and
( CountDoom.config.announceChannel ~= nil ) then
local channelID = GetChannelName( CountDoom.config.announceChannel );
if channelID ~= nil then
SendChatMessage( msg, "CHANNEL", nil, channelID);
else
CountDoom.ChatPrint( msg, 1, 1, 1);
end
else
CountDoom.ChatPrint( msg, 1, 1, 1);
end
end
function CDTimerSpell_OnTimerWarning( timerIndex, timeUsed )
local spellIndex = CDTimer_GetUserHandle( timerIndex );
if spellIndex == nil then
return;
elseif CDTimerSpells[ spellIndex ].warningHit ~= true then
if CountDoom.config.flashSpells ~= nil and
CountDoom.config.flashSpells == true then
CDTimer_EnableFlash( timerIndex, 2.0 );
end
CDTimerSpells[ spellIndex ].warningHit = true;
local spellAbbreviation = CDTimerSpells[ spellIndex ].spellAbbreviation;
local spellText = CountDoomSpell[ spellAbbreviation ].text;
--
-- Announce a warning message
--
if CDTimerSpells[ spellIndex ].announceWarning then
local timeRemaining = CountDoomSpell[ spellAbbreviation ].warningTime;
CDTimerSpell_AnnounceMessage( string.format( "%s has %d seconds remaining.", spellText, timeRemaining ) );
end
--
-- Play a warning sound
--
if CDTimerSpells[ spellIndex ].warningSound and CountDoom.config.playSounds then
local soundFile = CountDoom.soundPath .. CDTimerSpells[ spellIndex ].warningSound .. ".wav";
CountDoom.DebugPrint("Playing " .. soundFile);
PlaySoundFile(soundFile);
end
end
end
function CDTimerSpell_OnTimerEnd( timerIndex, arg1 )
local spellIndex = CDTimer_GetUserHandle( timerIndex );
if spellIndex ~= nil then
local spellAbbreviation = CDTimerSpells[ spellIndex ].spellAbbreviation;
local spellText = CountDoomSpell[ spellAbbreviation ].text;
--
-- Announce a completion message
--
if CDTimerSpells[ spellIndex ].announceEnd then
CDTimerSpell_AnnounceMessage( string.format( "%s has finished.", spellText ) );
CDTimerSpells[ spellIndex ].announceEnd = false;
end
--
-- Play a completion sound
--
if CDTimerSpells[ spellIndex ].endSound and CountDoom.config.playSounds then
local soundFile = CountDoom.soundPath .. CDTimerSpells[ spellIndex ].endSound .. ".wav";
CountDoom.DebugPrint("Playing " .. soundFile);
PlaySoundFile(soundFile);
CDTimerSpells[ spellIndex ].endSound = false;
end
local remainingTime = CDTimer_GetRemainingTime( timerIndex );
if (remainingTime + CountDoom.config.postExpireDelay) < 0 then
CDTimerSpell_DeleteIndex( spellIndex );
end
end
end
function CDTimerSpell_OnTimerMove( newTimerIndex, oldTimerIndex )
local spellIndex = CDTimer_GetUserHandle( newTimerIndex );
if spellIndex ~= nil then
if CDTimerSpells[ spellIndex ] ~= nil then
CDTimerSpells[ spellIndex ].timerIndex = newTimerIndex;
else
CountDoom.DebugPrint( "Unexpected nil CDTimerSpells[ spellIndex ] in CDTimerSpell_OnTimerMove" );
end
else
CountDoom.DebugPrint( "Unexpected nil spellIndex in CDTimerSpell_OnTimerMove" );
end
end
function CDTimerSpell_TargetUnit( spellIndex )
if spellIndex == nil then
return false
end
local changedTarget = false;
if CDTimerSpells[ spellIndex ].targetID == CountDoom.targetID then
if (UnitName( "target" ) == nil and CDTimerSpells[ spellIndex ].targetName ~= nil) then
TargetByName( CDTimerSpells[ spellIndex ].targetName );
changedTarget = true;
end
elseif UnitName( "target" ) == CDTimerSpells[ spellIndex ].targetName and
UnitLevel( "target" ) == CDTimerSpells[ spellIndex ].targetLevel then
-- Nothing to do here as this matches our target
elseif( CDTimerSpells[ spellIndex ].targetName ~= nil ) then
ClearTarget();
TargetByName( CDTimerSpells[ spellIndex ].targetName );
changedTarget = true;
end
return changedTarget;
end
function CDTimerSpell_RecastSpell( spellIndex )
if spellIndex == nil or spellIndex == -1 then
return
end
local spellAbbreviation = CDTimerSpells[ spellIndex ].spellAbbreviation;
if spellAbbreviation ~= nil then
local spellName = CountDoomSpell[ spellAbbreviation ].text;
-- recast spell
if spellName ~= nil and spellName ~= COUNTDOOMSPELL_SEDUCE then
-- re-target this mob
local changedTarget = CDTimerSpell_TargetUnit( spellIndex );
-- cast the spell
if CountDoom.spellTable and CountDoom.spellTable[spellName] then
local maxRank = CountDoom.spellTable[spellName].maxRank;
if maxRank then
local tab = CountDoom.spellTable[spellName][maxRank].tab;
local spellID = CountDoom.spellTable[spellName][maxRank].spell;
if spellID and tab then
CountDoom.DebugPrint( "recasting " .. spellName .. " ID " .. spellID .. " tab " .. tab + 1 );
CastSpell( spellID, tab + 1 );
end
end
end
-- revert to previous target
if changedTarget then
TargetLastTarget();
end
end
end
end
function CDTimerSpell_OnTimerClick( timerIndex, arg1 )
local spellIndex = CDTimer_GetUserHandle( timerIndex );
CountDoom.DebugPrint( "CDTimerSpell_OnTimerClick(spellIndex = " .. spellIndex .. " arg1 = " .. arg1 .. ")" );
if arg1 == "LeftButton" then
if IsShiftKeyDown() then
if IsAltKeyDown() then
-- Do nothing. Too complex of a key combination
else
-- Delete this timer
CDTimerSpell_DeleteIndex( spellIndex );
end
elseif IsAltKeyDown() then
else
-- re-target this mob
CDTimerSpell_TargetUnit( spellIndex );
end
elseif arg1 == "RightButton" then
if IsShiftKeyDown() then
-- Cast secondary spell (conflagrate if immolated)
elseif IsAltKeyDown() then
else
-- recast the spell
CDTimerSpell_RecastSpell( spellIndex );
end
end
end
function CDTimerSpell_OnEnter( timerIndex )
local spellIndex = CDTimer_GetUserHandle( timerIndex );
if spellIndex ~= nil then
local msg = "Target: ";
if( CDTimerSpells[ spellIndex ].targetName ~= nil ) then
msg = msg .. CDTimerSpells[ spellIndex ].targetName .. "(";
msg = msg .. CDTimerSpells[ spellIndex ].targetLevel .. ")";
end
GameTooltip:AddLine( msg, 1.00, 1.00, 1.00 );
end
GameTooltip:AddLine("Left-click to target", 1.00, 1.00, 1.00);
--GameTooltip:AddLine("Right-click to re-cast", 1.00, 1.00, 1.00);
GameTooltip:AddLine("Shift+Left-click to delete", 1.00, 1.00, 1.00);
end
function CDTimerSpell_CreateTimerString(spellIndex)
local timerIndex = CDTimerSpells[ spellIndex ].timerIndex;
local targetName = CDTimerSpells[ spellIndex ].targetName;
local targetLevel = CDTimerSpells[ spellIndex ].targetLevel;
local spellAbbreviation = CDTimerSpells[ spellIndex ].spellAbbreviation;
if targetName == nil then
targetName = "Unknown";
end;
if targetLevel == nil then
targetLevel = "??";
end;
local timerString = " - " .. string.upper(spellAbbreviation) .. " - ";
timerString = timerString .. CountDoom.ToString(targetName) .. "(" .. CountDoom.ToString(targetLevel) .. ")";
return timerString;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -