Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Beginning of first load
- function PQR_Debug(strText)
- if PQR_DebugEnabled == true then
- PQR_WriteToChat(\"[DEBUG] \"..strText);
- end
- end
- function PQR_SetDebug(enabled)
- if enabled == true then
- PQR_DebugEnabled = true
- else
- PQR_DebugEnabled = false
- end
- end
- function PQR_WriteToChat(strText)
- if PQR_ShowChat == true then
- print(\"|cffff7d0a<|r|cffffd200PQR|r|cffff7d0a>|r \"..strText)
- end
- end
- function PQR_EventFrame_OnUpdate(self, elapsed)
- PQR_totalElapsed = PQR_totalElapsed + elapsed;
- PQR_totalElapsed2 = PQR_totalElapsed2 + elapsed;
- while (PQR_totalElapsed2 > PQR_UpdateInterval2) do
- PQR_RegisterMovement(PQR_totalElapsed2)
- PQR_SetRecastDelay()
- PQR_ExecuteInterrupt()
- PQR_totalElapsed2 = PQR_totalElapsed2 - PQR_UpdateInterval2
- end
- if PQR_ChangeIntervalFlag == 1 then
- PQR_UpdateInterval = PQR_NewInterval
- PQR_ChangeIntervalFlag = 0
- PQR_totalElapsed = 0
- else
- while (PQR_totalElapsed > PQR_UpdateInterval) do
- PQR_RegisterMovement(PQR_totalElapsed)
- PQR_SetRecastDelay()
- PQR_ExecuteBot()
- PQR_totalElapsed = PQR_totalElapsed - PQR_UpdateInterval
- end
- end
- end
- function PQR_EventFrame_OnEvent(self,event,...)
- if event == \"PLAYER_ENTERING_WORLD\" then
- PQR_EventFrame:Show()
- SetMapToCurrentZone()
- PQR_Debug(\"Setting Map to Current Zone.\")
- elseif event ==\"PLAYER_REGEN_DISABLED\" then
- SetMapToCurrentZone()
- PQR_Debug(\"Setting Map to Current Zone.\")
- elseif event == \"PLAYER_LOGOUT\" then
- PQR_EnableInterrupt(false)
- PQR_EnableBot(\"\")
- elseif event == \"UNIT_SPELLCAST_FAILED\" then
- local source, spellName = ...
- PQR_DropThreat(\"FAILED\", source, spellName)
- elseif event == \"UNIT_SPELLCAST_FAILED_QUIET\" then
- local source, spellName = ...
- PQR_DropThreat(\"FAILED\", source, spellName)
- elseif event == \"UI_ERROR_MESSAGE\" then
- local errorMessage = ...
- if errorMessage == SPELL_FAILED_NOT_BEHIND then
- PQR_BehindTime = GetTime()
- elseif errorMessage == SPELL_FAILED_LINE_OF_SIGHT then
- if PQR_LastTarget ~= nil then
- if PQR_LastTarget ~= \"none\" and PQR_LastTime > GetTime() - 1 then
- --LOS message in the last 1 second. Register it.
- for i=1,10000 do
- if PQR.losTable.name[i] == nil or PQR.losTable.name[i] == PQR_LastTarget then
- --we got to an empty slot in the table
- PQR.losTable.name[i] = PQR_LastTarget
- PQR.losTable.time[i] = PQR_LastTime
- PQR_Debug(\"Added LOS for unit \"..PQR_LastTarget..\" at index \"..i)
- break
- end
- end
- PQR_LastTarget = \"none\"
- PQR_LastTime = 0
- end
- end
- end
- elseif event == \"UNIT_SPELLCAST_SUCCEEDED\" then
- local unitCaster, unitSpell, _, _, unitSpellID = ...
- if unitCaster == \"player\" then
- PQR_SetRecastDelay(unitSpell)
- end
- if unitCaster ~= \"player\" then
- return
- end
- if unitSpellID ~= 75 then --Auto Shot
- if unitSpellID == 56641 or unitSpellID == 77767 then --Steady or Cobra
- PQR_SteadyCount = PQR_SteadyCount + 1
- PQR_LastCasted = unitSpellID
- else
- PQR_SteadyCount = 0
- PQR_LastCasted = unitSpellID
- end
- end
- elseif event == \"UNIT_SPELLCAST_SENT\" then
- local unitCaster, unitSpell = ...
- local vanishName = GetSpellInfo(1856)
- local mdName = GetSpellInfo(34477)
- local feignName = GetSpellInfo(5384)
- if unitSpell == vanishName then
- PQR_DropDelay = GetTime() + 0.5
- end
- if unitSpell == feignName then
- PQR_DropDelay = GetTime() + 1
- end
- if unitSpell == mdName then
- PQR_DropDelay = GetTime() + 2.0
- end
- end
- end
- function PQR_ExecuteBot()
- --this is the main bot execution function.
- if UnitAffectingCombat ~= nil then
- --make sure we arent at a loading screen, DCd, etc.
- PQR_Combat = UnitAffectingCombat(\"player\")
- if PQR_Combat == nil then
- PQR_Combat = UnitAffectingCombat(\"pet\")
- end
- if PQR_RequireCombat == false and PQR_RotationDesignation == false then
- PQR_Combat = 1
- end
- if PQR ~= nil then
- if PQR_RotationDesignation == true and PQR[0].priorityTable.requireCombat == false then
- PQR_Combat = 1
- end
- end
- local PQR_ExecuteNext = GetCVar(\"violenceLevel\")
- if tonumber(PQR_ExecuteNext) ~= nil then
- PQR_ExecuteNext = PQR_ExecuteNext - 5
- SetCVar(\"violenceLevel\", 2)
- else
- PQR_ExecuteNext = 0
- end
- if PQR_ExecuteNext > 0 then
- --cast the next ability in X queue.
- PQR_Interrupt()
- PQR_CastNext(PQR_ExecuteNext)
- else
- if PQR_ManualMode == false and PQR_BotEnabled == true and PQR_Combat ~= nil then
- --auto rotation mode is running... execute next.
- PQR_CastNext(0)
- end
- end
- end
- end
- function PQR_CastNext(rotation)
- if PQR[rotation] == nil then
- return
- end
- local nextAbility = PQR_NextAbility(rotation)
- if nextAbility ~= -1 then
- --Run luaBefore
- PQR[rotation].priorityTable.luaBefore[nextAbility]()
- --split actions and send RunMacroText
- if PQR[rotation].priorityTable.actn[nextAbility] ~= \"\" and PQR[rotation].priorityTable.actn[nextAbility] ~= nil then
- local tbl = { strsplit(\"|\", PQR[rotation].priorityTable.actn[nextAbility]) }
- for i=1,100 do
- if tbl[i] == nil then
- break
- end
- if tbl[i] ~= \"\" then
- PQR_Debug(\"Running Action: \"..tbl[i])
- RunMacroText(tbl[i])
- end
- end
- end
- --send spell ID
- local castingID = PQR[rotation].priorityTable.spid[nextAbility]
- if castingID ~= 0 then
- local castingName = GetSpellInfo(PQR[rotation].priorityTable.spid[nextAbility])
- PQR_LastTime = GetTime()
- if PQR[rotation].priorityTable.targetCast[nextAbility] == \"player\" then
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on PLAYER\")
- PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
- CastSpellByID(castingID, \"player\")
- elseif PQR[rotation].priorityTable.targetCast[nextAbility] == \"focus\" then
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on FOCUS\")
- PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
- CastSpellByID(castingID, \"focus\")
- elseif PQR[rotation].priorityTable.targetCast[nextAbility] == \"pet\" then
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on PET\")
- PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
- CastSpellByID(castingID, \"pet\")
- elseif PQR[rotation].priorityTable.targetCast[nextAbility] == \"mouseover\" then
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on MOUSEOVER\")
- PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
- CastSpellByID(castingID, \"mouseover\")
- elseif PQR[rotation].priorityTable.targetCast[nextAbility] == \"click\" then
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on MOUSE LOCATION\")
- PQR_LastTarget = \"none\"
- CastSpellByID(castingID)
- local PQR_TargetName = UnitName(\"target\")
- CameraOrSelectOrMoveStart()
- CameraOrSelectOrMoveStop()
- local PQR_TargetNameNew = UnitName(\"target\")
- if PQR_TargetName ~= nil then
- if PQR_TargetName ~= PQR_TargetNameNew then
- TargetLastTarget()
- end
- end
- elseif PQR[rotation].priorityTable.targetCast[nextAbility] == \"custom\" then
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on CUSTOM TARGET \"..PQR_CustomTarget)
- if UnitExists(PQR_CustomTarget) then
- PQR_LastTarget = UnitName(PQR_CustomTarget)
- CastSpellByID(castingID, PQR_CustomTarget)
- else
- PQR_Debug(\"Custom Target does not exist!\")
- end
- PQR_CustomTarget = \"\"
- else
- PQR_Debug(\"Casting Spell \"..castingName..\" (\"..castingID..\") on TARGET\")
- PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
- CastSpellByID(castingID, \"target\")
- end
- end
- --Run luaAfter
- PQR[rotation].priorityTable.luaAfter[nextAbility]()
- end
- end
- function PQR_NextAbility(rotation)
- if PQR[rotation] ~= nil then
- local _, _, _, _, _, playerChanneling = UnitChannelInfo(\"player\")
- if playerChanneling ~= nil then
- local currentTime = GetTime() * 1000
- if (playerChanneling - currentTime) > 100 then
- PQR_IsChanneling = true
- else
- PQR_IsChanneling = false
- end
- else
- PQR_IsChanneling = false
- end
- for i=0,1023 do
- if PQR[rotation].priorityTable.index[i] ~= nil then
- if PQR_DropDelay <= GetTime() then
- if PQR[rotation].priorityTable.spid[i] ~= 0 then
- if PQR_SpellAvailable(PQR[rotation].priorityTable.spid[i]) == true and PQR[rotation].priorityTable.delay[i] <= (GetTime() * 1000) then
- local PQR_Result = PQR[rotation].priorityTable.test[i]()
- if PQR_Result == true then
- if PQR_IsChanneling == true then
- if PQR[rotation].priorityTable.cancelChannel[i] == true then
- return i
- end
- else
- return i
- end
- end
- end
- else
- local PQR_Result = PQR[rotation].priorityTable.test[i]()
- if PQR_Result == true then
- if PQR_IsChanneling == true then
- if PQR[rotation].priorityTable.cancelChannel[i] == true then
- return i
- end
- else
- return i
- end
- end
- end
- end
- end
- end
- end
- return -1
- end
- function PQR_ExecuteInterrupt()
- if UnitAffectingCombat ~= nil then
- PQR_Interrupt()
- end
- end
- function PQR_Interrupt()
- if PQR_InterruptEnabled == false or PQR_InterruptEnabled == nil then
- return
- end
- if PQR == nil then
- return
- end
- if PQR.interruptTable == nil then
- return
- end
- if PQR_InterruptTest() == true then
- PQR_Debug(\"Casting Interrupt...\")
- CastSpellByID(PQR_MyInterruptSpell())
- end
- end
- function PQR_InterruptTest()
- local pq_castingName, _, _, _, pq_castingStartTime, _, _, _, pq_castingInterrupt = UnitCastingInfo(\"target\")
- if pq_castingInterrupt ~= nil then
- if pq_castingInterrupt == true then
- pq_castingInterrupt = false
- else
- pq_castingInterrupt = true
- end
- end
- local pq_channelName, _, _, _, pq_channelStartTime, _, _, pq_channelInterrupt = UnitChannelInfo(\"target\")
- if pq_channelInterrupt ~= nil then
- pq_castingName = pq_channelName
- pq_castingStartTime = pq_channelStartTime
- if pq_channelInterrupt == true then
- pq_castingInterrupt = false
- else
- pq_castingInterrupt = true
- end
- end
- if pq_castingName == nil then
- pq_castingName = \"\"
- end
- if pq_castingInterrupt == nil then
- pq_castingInterrupt = false
- else
- local PQR_msCastingSpell = GetTime() * 1000 - pq_castingStartTime
- if PQR_msCastingSpell < PQR_InterruptDelay then
- pq_castingInterrupt = false
- end
- end
- if UnitCanAttack(\"player\", \"target\") == nil then
- --we cannot attack/interrupt the target.
- pq_castingInterrupt = false
- end
- local PQR_CastInterrupt = false
- if pq_castingInterrupt == true then
- local _, InterruptCD, _ = GetSpellCooldown(PQR_MyInterruptSpell())
- if InterruptCD == 0 then
- if PQR_InterruptAllSpells == true then
- PQR_CastInterrupt = true
- end
- for i=0,1023 do
- --check to see if any abilities need to be cast.
- if PQR.interruptTable.spell[i] ~= nil then
- if strupper(PQR.interruptTable.spell[i]) == strupper(pq_castingName) then
- PQR_CastInterrupt = true
- break
- end
- else
- break
- end
- end
- end
- end
- if PQR_CastInterrupt == true then
- return true
- else
- return false
- end
- end
- function PQR_MyInterruptSpell()
- if UnitClass ~= nil then
- local _, PQR_UnitClass = UnitClass(\"player\")
- if PQR_UnitClass == \"DEATHKNIGHT\" then
- return 47528
- elseif PQR_UnitClass == \"DRUID\" then
- local catForm = UnitBuffID(\"player\", 768)
- if catForm ~= nil then
- return 80965
- else
- return 80964
- end
- elseif PQR_UnitClass == \"HUNTER\" then
- return 34490
- elseif PQR_UnitClass == \"MAGE\" then
- return 2139
- elseif PQR_UnitClass == \"PALADIN\" then
- return 96231
- elseif PQR_UnitClass == \"PRIEST\" then
- return 15487
- elseif PQR_UnitClass == \"ROGUE\" then
- return 1766
- elseif PQR_UnitClass == \"SHAMAN\" then
- return 57994
- elseif PQR_UnitClass == \"WARLOCK\" then
- return 19647
- elseif PQR_UnitClass == \"WARRIOR\" then
- return 6552
- else
- return 0
- end
- else
- return 0
- end
- end
- function PQR_SetRecastDelay(manualSpellName)
- local PQR_CurrentSpellName = UnitCastingInfo(\"player\")
- if PQR_CurrentSpellName == nil then
- PQR_CurrentSpellName = UnitCastingInfo(\"player\")
- end
- if manualSpellName ~= nil then
- PQR_CurrentSpellName = manualSpellName
- end
- if PQR_CurrentSpellName == nil then
- return
- end
- PQR_Debug(\"SetRecastDelay called for spell: \"..PQR_CurrentSpellName)
- if PQR_ManualMode == false and PQR_BotEnabled == true then
- --PQR[0]
- for i=0,1023 do
- if PQR[0].priorityTable.index[i] == nil then
- break
- else
- if PQR[0].priorityTable.spid[i] ~= 0 then
- local PQR_LookupSpell = GetSpellInfo(PQR[0].priorityTable.spid[i])
- if PQR_LookupSpell == PQR_CurrentSpellName then
- PQR[0].priorityTable.delay[i] = (GetTime() * 1000) + PQR[0].priorityTable.recast[i]
- end
- end
- end
- end
- else
- --PQR[1]
- for i=0,1023 do
- if PQR[1].priorityTable.index[i] == nil then
- break
- else
- if PQR[1].priorityTable.spid[i] ~= 1 then
- local PQR_LookupSpell = GetSpellInfo(PQR[1].priorityTable.spid[i])
- if PQR_LookupSpell == PQR_CurrentSpellName then
- PQR[1].priorityTable.delay[i] = (GetTime() * 1000) + PQR[1].priorityTable.recast[i]
- end
- end
- end
- end
- --PQR[2]
- for i=0,1023 do
- if PQR[2].priorityTable.index[[...string is too long...]
- --In the assembly this string is actually cut short here for that function
- --Scripting Functions
- function PQR_IsCastingSpell(spellID)
- local spellName = GetSpellInfo(spellID)
- local spellCasting = UnitCastingInfo(\"player\")
- if spellCasting == nil then
- spellCasting = UnitChannelInfo(\"player\")
- end
- if spellCasting == spellName then
- return true
- else
- return false
- end
- end
- function PQR_NotBehindTarget()
- if PQR_BehindTime + 3 > GetTime() then
- return true
- else
- return false
- end
- end
- function PQR_IsMoving(seconds)
- local PQR_MoltenFeathers = UnitBuffID(\"player\", 98767)
- if PQR_CurrentMovingTime >= seconds and PQR_MoltenFeathers == nil then
- return true
- else
- return false
- end
- end
- function PQR_IsOutOfSight(unit, seconds)
- local secondsCheck = seconds
- if secondsCheck == nil then
- secondsCheck = 3
- end
- local unitCheck = unit
- if unitCheck == nil then
- unitCheck = \"target\"
- end
- local PQR_TargetName = UnitName(unitCheck)
- if PQR_TargetName ~= nil then
- for i=1,10000 do
- if PQR.losTable.name[i] == nil then
- return false
- end
- if PQR.losTable.name[i] == PQR_TargetName then
- if PQR.losTable.time[i] > GetTime() - secondsCheck then
- return true
- else
- return false
- end
- end
- end
- end
- return false
- end
- function UnitBuffID(unit, spellID, filter)
- local spellName = GetSpellInfo(spellID)
- if filter == nil then
- return UnitBuff(unit, spellName)
- else
- return UnitBuff(unit, spellName, nil, filter)
- end
- end
- function UnitDebuffID(unit, spellID, filter)
- local spellName = GetSpellInfo(spellID)
- if filter == nil then
- return UnitDebuff(unit, spellName)
- else
- return UnitDebuff(unit, spellName, nil, filter)
- end
- end
- --Table Setup
- function PQR_SetupTables()
- PQR = {}
- for i=0,4 do
- PQR[i] = {}
- PQR[i].priorityTable = {}
- PQR[i].priorityTable.index = {}
- PQR[i].priorityTable.spid = {}
- PQR[i].priorityTable.actn = {}
- PQR[i].priorityTable.test = {}
- PQR[i].priorityTable.recast = {}
- PQR[i].priorityTable.targetCast = {}
- PQR[i].priorityTable.delay = {}
- PQR[i].priorityTable.cancelChannel = {}
- PQR[i].priorityTable.requireCombat = true
- PQR[i].priorityTable.luaBefore = {}
- PQR[i].priorityTable.luaAfter = {}
- PQR.interruptTable = {}
- PQR.interruptTable.spell = {}
- PQR.losTable = {}
- PQR.losTable.name = {}
- PQR.losTable.time = {}
- end
- end
- function PQR_AddAbility(rotationNumber, index, spid, actn, testCode, recastDelay, targetCast, cancelChannel, luaBefore, luaAfter)
- PQR[rotationNumber].priorityTable.index[index] = index
- PQR[rotationNumber].priorityTable.spid[index] = spid
- PQR[rotationNumber].priorityTable.actn[index] = actn
- PQR[rotationNumber].priorityTable.test[index] = testCode
- PQR[rotationNumber].priorityTable.recast[index] = recastDelay
- PQR[rotationNumber].priorityTable.targetCast[index] = targetCast
- PQR[rotationNumber].priorityTable.delay[index] = rotationNumber
- PQR[rotationNumber].priorityTable.cancelChannel[index] = cancelChannel
- PQR[rotationNumber].priorityTable.luaBefore[index] = luaBefore
- PQR[rotationNumber].priorityTable.luaAfter[index] = luaAfter
- end
- function PQR_AddInterrupt(spellName)
- for i=0,1023 do
- if PQR.interruptTable.spell[i] == nil then
- PQR.interruptTable.spell[i] = spellName
- return
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment