PHP Code:
if AlphaInterrupt_stop()
or not AlphaInterrupt_AlphaBattleGroundInterrupt_enable
or UnitIsDeadOrGhost("player")
or ((GetBattlefieldInstanceRunTime()/1000) < 120)
or not PQR_SpellAvailable(PQR_InterruptSpell())
or IsActiveBattlefieldArena() == 1
then return false end
local name, realm = UnitName("target")
if realm == nil then
if name == nil then
lasttargetname = nil
else lasttargetname = name end
else
lasttargetname = name.."-"..realm
end
if AlphaInterrupt_targetProtect == nil then AlphaInterrupt_targetProtect = 0 end
if AlphaInterrupt_targetProtect < GetTime() then
AlphaInterrupt_targetProtect = GetTime() + 1
RequestBattlefieldScoreData()
if BGnum == nil then BGnum = 0 end
if BGnum >= GetNumBattlefieldScores() then BGnum = 0 end
BGnum = BGnum + 1
local BG_PlayerInfo, _, _, _, _, BG_PlayerFaction = GetBattlefieldScore(BGnum)
local BG_PlayerName, BG_PlayerServer = strsplit("-", BG_PlayerInfo)
if UnitFactionGroup("player") == "Horde" then CheckMyFaction = 0
elseif UnitFactionGroup("player") == "Horde Horde" then CheckMyFaction = 0
elseif UnitFactionGroup("player") == "Alliance" then CheckMyFaction = 1
elseif UnitFactionGroup("player") == "Alliance Alliance" then CheckMyFaction = 1 end
if CheckMyFaction == BG_PlayerFaction then
--They are on my team dont need to focus
AlphaInterrupt_targetProtect = GetTime() - 0.2
return false
end
if UnitName("target") == BG_PlayerInfo then
AlphaInterrupt_targetProtect = GetTime() - 0.2
return false
end
if BG_PlayerInfo ~= nil then
RunMacroText("/targetexact "..BG_PlayerInfo)
RunMacroText("/focus [@target, exists]")
if lasttargetname == nil then
ClearTarget()
else
RunMacroText("/targetexact "..lasttargetname)
end
end
if UnitFactionGroup("player") == UnitFactionGroup("focus") then
--They are on my team need to re focus (should not happen)
AlphaInterrupt_targetProtect = GetTime() - 2
return false
end
if IsSpellInRange(GetSpellInfo(PQR_InterruptSpell()), "focus") ~= 1 then
AlphaInterrupt_targetProtect = GetTime() - 2
return false
end
if UnitName("target") == UnitName("focus") then
AlphaInterrupt_targetProtect = GetTime() - 2
return false
end
end
local customTarget = "focus"
local castName, _, _, _, castStartTime, castEndTime, _, _, castInterruptable = UnitCastingInfo(customTarget)
local channelName, _, _, _, channelStartTime, channelEndTime, _, channelInterruptable = UnitChannelInfo(customTarget)
local divineshield = UnitBuffID(customTarget,642)
local Inner_Focus = UnitBuffID(customTarget,89485)
if channelName ~= nil then
--target is channeling a spell that is interruptable
--load the channel variables into the cast variables to make logic a little easier.
castName = channelName
castStartTime = channelStartTime
castEndTime = channelEndTime
castInterruptable = channelInterruptable
end
--This is actually "Not Interruptable"... so lets swap it around to use in the positive.
if castInterruptable == false then
castInterruptable = true
else
castInterruptable = false
end
--we can't attack the target.
if UnitCanAttack("player", customTarget) == nil then
return false
end
--we can't Interrupt when target has immunity.
if divineshield or Inner_Focus then
AlphaInterrupt_targetProtect = GetTime() + 0.2
return false
end
if castInterruptable then
--target is casting something that is interruptable.
--the following 2 variables are named logically... value is in seconds.
local timeSinceStart = (GetTime() * 1000 - castStartTime) / 1000
local timeLeft = ((GetTime() * 1000 - castEndTime) * -1) / 1000
local castTime = castEndTime - castStartTime
local currentPercent = timeSinceStart / castTime * 100000
AlphaInterrupt_targetProtect = GetTime() + 0.5
--make sure the interrupt spell is available
local interruptSpell = PQR_InterruptSpell()
if interruptSpell ~= 0 then
local interruptName = GetSpellInfo(interruptSpell)
if not PQR_SpellAvailable(interruptSpell) or IsSpellInRange(interruptName, customTarget) ~= 1 or SpellIsTargeting() then
return false
end
else
return false
end
--Ignore spells on Ignore list
if AlphaInterrupt_Ignorelist_enable then
Alpha_Deserialize(AlphaInterrupt_Ignorelist, "Ignore")
local unitname = GetUnitName(customTarget)
local Interruptspellname = GetSpellInfo(PQR_InterruptSpell())
for i = 1, #toIgnore do
if type(toIgnore[i]) == "string" then
if toIgnore[i] == castName then
PQR_Event("PQR_Text", "Ignoring - "..unitname..": "..castName, 20, "DC143C")
return false
end
elseif type(toIgnore[i]) == "number" then
if (GetSpellInfo(toIgnore[i])) == castName then
PQR_Event("PQR_Text", "Ignoring - "..unitname..": "..castName, 20, "DC143C")
return false
end
end
end
end
--should we use InstantInterrupt delays or normal?
if AlphaInterrupt_InstantInterruptlist_enable then
Alpha_Deserialize(AlphaInterrupt_Instantlist, "Instant Interrupt")
local OnInstantlist = false
for i = 1, #toInstantInterrupt do
if type(toInstantInterrupt[i]) == "string" then
if toInstantInterrupt[i] == castName then OnInstantlist = true end
elseif type(toInstantInterrupt[i]) == "number" then
if (GetSpellInfo(toInstantInterrupt[i]))== castName then OnInstantlist = true end
end end
if OnInstantlist then
if timeSinceStart - AlphaInterrupt_Instant_InterruptDelay < 0 then return false end
if currentPercent < AlphaInterrupt_Instant_InterruptPercent then return false end
else
--interrupt percentage check
if AlphaInterrupt_Protect1 == nil then AlphaInterrupt_Protect1 = 0 end
if AlphaInterrupt_Protect1 < GetTime() then
AlphaInterrupt_Protect1 = GetTime() + 1.5
PQR_InterruptPercent = randompercentage()
end
if currentPercent < PQR_InterruptPercent then
return false
end
--minimum interrupt time
if AlphaInterrupt_Protect2 == nil then AlphaInterrupt_Protect2 = 0 end
if AlphaInterrupt_Protect2 < GetTime() then
AlphaInterrupt_Protect2 = GetTime() + 1.5
PQR_InterruptDelay = randomdelay()
end
if timeSinceStart - PQR_InterruptDelay < 0 then
return false
end
end
else
--interrupt percentage check
if AlphaInterrupt_Protect1 == nil then AlphaInterrupt_Protect1 = 0 end
if AlphaInterrupt_Protect1 < GetTime() then
AlphaInterrupt_Protect1 = GetTime() + 1.5
PQR_InterruptPercent = randompercentage()
end
if currentPercent < PQR_InterruptPercent then
return false
end
--minimum interrupt time
if AlphaInterrupt_Protect2 == nil then AlphaInterrupt_Protect2 = 0 end
if AlphaInterrupt_Protect2 < GetTime() then
AlphaInterrupt_Protect2 = GetTime() + 1.5
PQR_InterruptDelay = randomdelay()
end
if timeSinceStart - PQR_InterruptDelay < 0 then
return false
end
end
--Finally, make sure the spell they are casting is on the interrupt list or interrupt all is checked
if PQR_IsOnInterruptList(castName) or PQR_IsInterruptAll() then
--Nerder's DK priority
if UnitClass("player") == "DEATHKNIGHT" then
local name, _, _, count = UnitBuffID("player",114851)
if PQR_InterruptSpell() ~= 47528 then
for i = 1, 2 do
local RuneCDstart, RuneCDduration = GetRuneCooldown(i)
if GetRuneType(i) == 1
and ( RuneCDstart + RuneCDduration - GetTime() > 0 ) then
if (name ~= nil and count >= 5) then
local unitname = GetUnitName(customTarget)
local Interruptspellname = GetSpellInfo(PQR_InterruptSpell())
PQR_Event("PQR_Text", "Interrupted - "..unitname..": "..castName.." - With: "..Interruptspellname.." - Used: "..GetSpellInfo(45529), 20, "DC143C")
CastSpellByName(GetSpellInfo(45529), "player")
CastSpellByID(interruptSpell, customTarget)
return true
end
else
return false
end
end
elseif PQR_InterruptSpell() == 47528 then
local unitname = GetUnitName(customTarget)
local Interruptspellname = GetSpellInfo(PQR_InterruptSpell())
PQR_Event("PQR_Text", "Interrupted - "..unitname..": "..castName.." - With: "..Interruptspellname, 20, "DC143C")
CastSpellID(interruptSpell, customTarget)
return true
end
else
local unitname = GetUnitName(customTarget)
local Interruptspellname = GetSpellInfo(PQR_InterruptSpell())
PQR_Event("PQR_Text", "Interrupted - "..unitname..": "..castName.." - With: "..Interruptspellname, 20, "DC143C")
PQR_Debug("Casting interrupt on "..customTarget)
CastSpellByID(interruptSpell, customTarget)
return true
end
end
end