📄 countdoom.lua
字号:
local spellNameLast = CDTimerSpell_GetSpellName( CountDoom.lastSpellID );
if spellNameLast == spellName then
CDTimerSpell_DeleteID( CountDoom.lastSpellID );
end
CountDoom.lastSpellID = -1;
return;
end
-- Determine if the target was immune
local found,_,spellName,mobName,index3,index4,index5 = string.find(arg1, CD_SPELLIMMUNESELFOTHER);
if found then
CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( mobName ) .. " was immune to " .. CountDoom.ToString( spellName ) );
-- Destroy the last active spell
CountDoom.activeSpell = nil;
if (CountDoom.lastSpellID == nil or CountDoom.lastSpellID == -1 or
CountDoom.replacedASpell) then
return;
end
local spellNameLast = CDTimerSpell_GetSpellName( CountDoom.lastSpellID );
if spellNameLast == spellName then
CDTimerSpell_DeleteID( CountDoom.lastSpellID );
end
CountDoom.lastSpellID = -1;
return;
end
-- Determine if the target was evaded
local found,_,spellName,mobName,index3,index4,index5 = string.find(arg1, CD_SPELLEVADEDSELFOTHER);
if found then
CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( mobName ) .. " evaded your " .. CountDoom.ToString( spellName ) );
-- Destroy the last active spell
CountDoom.activeSpell = nil;
if (CountDoom.lastSpellID == nil or CountDoom.lastSpellID == -1 or
CountDoom.replacedASpell) then
return;
end
local spellNameLast = CDTimerSpell_GetSpellName( CountDoom.lastSpellID );
if spellNameLast == spellName then
CDTimerSpell_DeleteID( CountDoom.lastSpellID );
end
CountDoom.lastSpellID = -1;
return;
end
-- Creature received damage. See if Succubus seduced a mob.
elseif(event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE") then
arg1 = string.gsub(arg1," %(.+%)","") -- strip trailing ()'s we don't use
arg1 = string.gsub(arg1,"%.$","") -- strip trailing .'s
local found,_,mobName,spellName,index3,index4,index5 = string.find(arg1, CD_AURAADDEDOTHERHARMFUL);
if found and spellName ~= nil then
CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( mobName ) .. " is afflicted by " .. CountDoom.ToString( spellName ) );
if (spellName == COUNTDOOMSPELL_SEDUCE and CountDoom.petActiveSpell == COUNTDOOMSPELL_SEDUCE) or
(spellName == COUNTDOOMSPELL_SPELL_LOCK) then
local targetInfo = {};
targetInfo.targetName = CountDoom.petTargetName;
targetInfo.targetLevel = CountDoom.petTargeLevel;
targetInfo.id = -1;
-- Currently we assume pet casts max rank spell.
local petRank = nil;
CountDoom.lastSpellID, CountDoom.replacedASpell = CDTimerSpell_CreateBySpellName( spellName, targetInfo, petRank );
CountDoom.petTargetName = nil;
CountDoom.petTargeLevel = 0;
CountDoom.petActiveSpell = nil;
end
return;
end
-- Created lost a debuff. See if Succubus' seduction had faded.
elseif(event == "CHAT_MSG_SPELL_AURA_GONE_OTHER") then
arg1 = string.gsub(arg1," %(.+%)","") -- strip trailing ()'s we don't use
arg1 = string.gsub(arg1,"%.$","") -- strip trailing .'s
local found,_,spellName,mobName,index3,index4,index5 = string.find(arg1, CD_AURAREMOVEDOTHER);
if found then
CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( spellName ) .. " fades from " .. CountDoom.ToString( mobName ) );
if spellName == COUNTDOOMSPELL_SEDUCE or spellName == COUNTDOOMSPELL_SPELL_LOCK then
CDTimerSpell_DestroyBySpellName( spellName );
CountDoom.event.removedSpellName = spellName;
CountDoom.event.removedLastReason = CHAT_MSG_SPELL_AURA_GONE_OTHER;
CountDoom.event.removedTarget = mobName;
end
return;
end
elseif(event == "CHAT_MSG_COMBAT_HOSTILE_DEATH") then
arg1 = string.gsub(arg1," %(.+%)","") -- strip trailing ()'s we don't use
arg1 = string.gsub(arg1,"%.$","") -- strip trailing .'s
local found,_,mobName,index3,index4,index5 = string.find(arg1, CD_UNITDIESOTHER);
if found then
CountDoom.DebugPrint( "CD: " .. CountDoom.ToString( mobName ) .. " dies." );
if UnitIsDead( "target" ) then
local deletedOne;
repeat
deletedOne = CDTimerSpell_DeleteTarget( CountDoom.targetID );
until deletedOne == false;
end;
return;
end
-- Determine if the player has changed targets (FUTURE USE)
elseif(event == "PLAYER_TARGET_CHANGED") then
-- Keep track of the current targetID
CountDoom.targetID = CountDoom.targetID + 1;
if CountDoom.targetID > 10000 then
CountDoom.targetID = 0;
end
end
end
CountDoom.GetSpellBookInfo = function()
CountDoom.DebugPrint( "CountDoom.GetSpellBookInfo" );
local i;
for i = 1, GetNumSpellTabs(), 1 do
local name, texture, offset, numSpells = GetSpellTabInfo(i);
local y;
for y = 1, numSpells, 1 do
local spellName, rankName = GetSpellName(offset+y, BOOKTYPE_SPELL);
local _, _, rankStr = string.find(rankName, "(%d+)");
local rank = tonumber(rankStr);
if rank then
if not CountDoom.spellTable then
CountDoom.spellTable = {};
end;
if not CountDoom.spellTable[spellName] then
CountDoom.spellTable[spellName] = {};
end
if not CountDoom.spellTable[spellName].maxRank or
rank > CountDoom.spellTable[spellName].maxRank then
CountDoom.spellTable[spellName].maxRank = rank;
end
CountDoom.DebugPrint( "Adding spell (" .. y+offset .. ") " .. spellName .. " rank " .. rank .. " to spellTable" );
CountDoom.spellTable[spellName][rank] = { ["tab"] = i, ["spell"] = y+offset };
end
end
end
end;
-- SPELLCAST_START event only sets the spell name for spells that are
-- not insta-cast. To detect insta-cast spells, we need to hook into
-- the CastSpell function. Once hooked, each spell is placed into a hidden
-- tooltip and the name is extracted. Courtesy of CT_RaidAssist.
CountDoom.oldCastSpell = CastSpell;
CountDoom.OnCastSpell = function (spellId,spellbookTabNum)
local spellName, spellRank = GetSpellName(spellId, spellbookTabNum);
CountDoom.DebugPrint( CountDoom.ToString( spellName ) .. " " .. CountDoom.ToString( spellRank ) );
if spellRank ~= nil then
local _, _, spellRankString = string.find(spellRank, "(%d+)");
--local _, _, spellRankString = string.find( spellRank, "[^%d]*(%d+)");
rank = tonumber(spellRankString);
CountDoom.DebugPrint( "Rank: " .. CountDoom.ToString( rank ) );
end;
CountDoom.spellRank = rank;
if SpellIsTargeting() then
CountDoom.activeSpellWaitingForTarget = spellName;
else
CountDoom.activeSpell = spellName;
CountDoom.targetName = UnitName( "target" );
CountDoom.targetLevel = UnitLevel( "target" );
CountDoom.lastSpellID = -1;
CountDoom.replacedASpell = false;
CountDoom.event.castSpellName = spellName;
CountDoom.event.castMode = "CastSpell";
CountDoom.event.castTarget = CountDoom.targetName;
end
CountDoom.DebugPrint( "Starting cast of: " .. CountDoom.ToString( spellName ) .. " " .. spellId .. " " .. spellbookTabNum );
CountDoom.oldCastSpell( spellId, spellbookTabNum );
end;
CastSpell = CountDoom.OnCastSpell;
CountDoom.oldSpellTargetUnit = SpellTargetUnit;
CountDoom.OnSpellTargetUnit = function (unit)
if CountDoom.activeSpellWaitingForTarget then
CountDoom.activeSpell = CountDoom.activeSpellWaitingForTarget;
CountDoom.targetName = UnitName( unit );
CountDoom.targetLevel = UnitLevel( unit );
CountDoom.activeSpellWaitingForTarget = nil;
CountDoom.lastSpellID = -1;
end
CountDoom.oldSpellTargetUnit(unit);
end;
SpellTargetUnit = CountDoom.OnSpellTargetUnit;
CountDoom.oldTargetUnit = TargetUnit;
CountDoom.OnTargetUnit = function (unit)
if CountDoom.activeSpellWaitingForTarget then
CountDoom.activeSpell = CountDoom.activeSpellWaitingForTarget;
CountDoom.targetName = UnitName( unit );
CountDoom.targetLevel = UnitLevel( unit );
CountDoom.activeSpellWaitingForTarget = nil;
CountDoom.lastSpellID = -1;
end
CountDoom.oldTargetUnit(unit);
end;
TargetUnit = CountDoom.OnTargetUnit;
CountDoom.oldSpellStopTargetting = SpellStopTargetting;
CountDoom.OnSpellStopTargetting = function()
if CountDoom.activeSpellWaitingForTarget then
CountDoom.activeSpell = nil;
CountDoom.targetName = nil;
CountDoom.targetLevel = 0;
CountDoom.activeSpellWaitingForTarget = nil;
end
CountDoom.oldSpellStopTargetting();
end;
SpellStopTargetting = CountDoom.OnSpellStopTargetting;
CountDoom.oldUseAction = UseAction;
CountDoom.OnUseAction = function (a1, a2, a3)
-- Only process if it isn't a macro
if GetActionText(a1) == nil then
CD_SpellDetector:Hide();
CD_SpellDetector:SetOwner(CountDoomFrame,"ANCHOR_NONE");
CD_SpellDetector:SetAction(a1);
local spellName = nil;
if CD_SpellDetectorTextLeft1 ~= nil then
spellName = CD_SpellDetectorTextLeft1:GetText();
end;
local spellRank = nil;
if CD_SpellDetectorTextRight1 ~= nil then
spellRank = CD_SpellDetectorTextRight1:GetText();
end;
local rank = nil;
if spellRank ~= nil then
local _, _, spellRankString = string.find( spellRank, "[^%d]*(%d+)");
rank = tonumber(spellRankString);
end;
CountDoom.spellRank = rank;
if SpellIsTargeting() then
CountDoom.activeSpellWaitingForTarget = spellName;
else
CountDoom.activeSpell = spellName;
CountDoom.targetName = UnitName( "target" );
CountDoom.targetLevel = UnitLevel( "target" );
CountDoom.lastSpellID = -1;
CountDoom.event.castSpellName = spellName;
CountDoom.event.castMode = "UseAction";
CountDoom.event.castTarget = CountDoom.targetName;
end
if ( a3 and a3 == 1 ) then
CountDoom.activeSpell = nil;
end
if CountDoom.debugEvents then
local msg = "UseAction: " .. CountDoom.ToString( a1 ) .. " " .. CountDoom.ToString( a2 ) .. " " .. CountDoom.ToString( a3 );
msg = msg .. " " .. CountDoom.ToString( spellName );
CountDoom.CombatPrint(msg);
end
CountDoom.DebugPrint( "UseAction cast of: " .. CountDoom.ToString( spellName ) .. " Rank: " .. CountDoom.ToString( rank ) );
end
CountDoom.oldUseAction(a1, a2, a3);
end;
UseAction = CountDoom.OnUseAction;
CountDoom.oldCastSpellByName = CastSpellByName;
CountDoom.OnCastSpellByName = function(spellString)
local startIndex, endIndex, spellName = string.find( spellString, "(.+)%(" );
local _, _, spellRankStr = string.find( spellString, "([%d]+)");
local rank = nil;
CountDoom.DebugPrint( spellString );
if spellName == nil then
startIndex, endIndex, spellName = string.find( spellString, "(.+)" );
end
if spellName == nil then
CountDoom.ChatPrint( "CountDoom: Error: Unable to determine spell information from: '" .. spellString .. "'");
CountDoom.ChatPrint( "CountDoom: contact mod owner with string for help." );
end
if spellRankStr ~= nil then
CountDoom.DebugPrint( spellRankStr );
rank = tonumber( spellRankStr );
end;
CountDoom.spellRank = rank;
if SpellIsTargeting() then
CountDoom.activeSpellWaitingForTarget = spellName;
else
CountDoom.activeSpell = spellName;
CountDoom.targetName = UnitName( "target" );
CountDoom.targetLevel = UnitLevel( "target" );
CountDoom.lastSpellID = -1;
CountDoom.replacedASpell = false;
CountDoom.event.castSpellName = spellName;
CountDoom.event.castMode = "CastSpellByName";
CountDoom.event.castTarget = CountDoom.targetName;
end
CountDoom.DebugPrint( "CastSpellByName cast of: " .. CountDoom.ToString( spellName ) .. " Rank: " .. CountDoom.ToString( rank ) );
CountDoom.oldCastSpellByName(spellString);
end;
CastSpellByName = CountDoom.OnCastSpellByName;
--[[ Can't hook this in 1.10
CountDoom.oldCameraOrSelectOrMoveStart = CameraOrSelectOrMoveStart;
function CountDoom.OnCameraOrSelectOrMoveStart()
-- If we're waiting to target
local targetName = nil;
local targetLevel = 0;
if CountDoom.activeSpellWaitingForTarget and UnitName("mouseover") then
targetName = UnitName("mouseover");
targetLevel = UnitLevel("mouseover");
end
CountDoom.oldCameraOrSelectOrMoveStart();
if CountDoom.activeSpellWaitingForTarget then
CountDoom.activeSpell = CountDoom.activeSpellWaitingForTarget;
CountDoom.targetName = targetName;
CountDoom.targetLevel = targetLevel;
CountDoom.activeSpellWaitingForTarget = nil;
CountDoom.lastSpellID = -1;
CountDoom.replacedASpell = false;
end
end;
CameraOrSelectOrMoveStart = CountDoom.OnCameraOrSelectOrMoveStart;
--]]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -