Whenever I turn off the rotation or when combat ends, my game freezes for like 5 seconds. if I was in combat for a longer period of time, it freezes for longer.
Code:
HunterRotation = LibStub("AceAddon-3.0"):NewAddon("HunterRotation", "AceConsole-3.0", "AceEvent-3.0")
local doRotation = false;
local blackArrowID = 3674;
local killCommandID = 34026;
local chimShotID = 53209;
local explShotID = 60053;
local multiShotID = 49048;
local killShotID = 61006;
local rapidFireID = 3045;
local readinessID = 23989;
local bestWrathID = 19574;
local blackArrowName = "Black Arrow";
local killCommandName = "Kill Command";
local chimShotName = "Chimera Shot";
local explShotName = "Explosive Shot";
local multiShotName = "Multi-Shot";
local steadyShotName = "Steady Shot";
local serpStingName = "Serpent Sting";
local huntMarkName = "Hunter's Mark";
local killShotName = "Kill Shot";
local rapidFireName = "Rapid Fire";
local readinessName = "Readiness";
local bestWrathName = "Bestial Wrath";
local bloodFuryName = "Blood Fury";
function HunterRotation:OnInitialize()
self:RegisterEvent("COMBAT_LOG_EVENT");
HunterRotation:RegisterChatCommand("on", "On");
HunterRotation:RegisterChatCommand("off", "Off");
end
function HunterRotation:On(input)
print("On");
doRotation = true;
-- Process the slash command ('input' contains whatever follows the slash command)
end
function HunterRotation:Off(input)
print("Off");
doRotation = false;
-- Process the slash command ('input' contains whatever follows the slash command)
end
function IsOnCD(spellID)
local a, cd = GetSpellCooldown(spellID);
if (cd > 1.5) then
return true;
end
return false;
end
function TargetDebuff(spellName, onlyMe)
local name;
if onlyMe then
name = UnitDebuff("target", spellName,nil,'PLAYER');
else
name = UnitDebuff("target", spellName);
end
if (name == nil) then
return false;
end
return true;
end
function HunterRotation:COMBAT_LOG_EVENT()
if UnitAffectingCombat("player") and UnitExists("target") then
--if doRotation and (UnitHealthMax("target") - UnitHealth("target") > 0) then
if doRotation then
if not TargetDebuff(huntMarkName, false) then
CastSpellByName("!Auto Shot");
CastSpellByName(huntMarkName);
return;
elseif IsShiftKeyDown() and not IsOnCD(rapidFireID) and UnitBuff("player","Rapid Fire") == nil then
CastSpellByName("!Auto Shot");
CastSpell(5, "pet");
CastSpellByName(bloodFuryName);
CastSpellByName(rapidFireName);
return;
elseif IsShiftKeyDown() and not IsOnCD(readinessID) and IsOnCD(rapidFireID) and IsOnCD(multiShotID)and IsOnCD(explShotID) and IsOnCD(chimShotID) and IsOnCD(killCommandID) and IsOnCD(bestWrathID) then
CastSpellByName("!Auto Shot");
CastSpellByName(readinessName);
return;
elseif not TargetDebuff(serpStingName, true) then
CastSpellByName("!Auto Shot");
CastSpellByName(serpStingName);
return;
elseif not IsOnCD(blackArrowID) then
CastSpellByName("!Auto Shot");
CastSpellByName(blackArrowName);
return;
elseif UnitExists("pet") and IsShiftKeyDown() and not IsOnCD(bestWrathID) and not IsOnCD(killCommandID) then
CastSpellByName("!Auto Shot");
CastSpell(5, "pet");
CastSpellByName(bloodFuryName);
CastSpellByName(bestWrathName);
return;
elseif UnitExists("pet") and not IsOnCD(killCommandID) then
CastSpellByName("!Auto Shot");
CastSpell(5, "pet");
CastSpellByName(killCommandName);
return;
elseif not IsOnCD(chimShotID) then
CastSpellByName("!Auto Shot");
CastSpellByName(chimShotName);
return;
elseif not IsOnCD(killShotID) and UnitHealth("target")/UnitHealthMax("target") <= .20 then
CastSpellByName("!Auto Shot");
CastSpellByName(killShotName);
return;
elseif not IsOnCD(explShotID) and not TargetDebuff(explShotName, true) then
CastSpellByName("!Auto Shot");
CastSpellByName(explShotName);
return;
elseif not IsOnCD(multiShotID) then
CastSpellByName("!Auto Shot");
CastSpellByName(multiShotName);
return;
else
CastSpellByName("!Auto Shot");
CastSpellByName(steadyShotName);
end
end
end
end
Any ideas how to fix?