Guest User

Untitled

a guest
Oct 19th, 2022
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.08 KB | None | 0 0
  1. function PQR_Debug(strText)
  2. if PQR_DebugEnabled == true then
  3. PQR_WriteToChat("[DEBUG] " .. strText);
  4. end
  5. end
  6. function PQR_SetDebug(enabled)
  7. if enabled == true then
  8. PQR_DebugEnabled = true
  9. else
  10. PQR_DebugEnabled = false
  11. end
  12. end
  13. function PQR_WriteToChat(strText)
  14. if PQR_ShowChat == true then
  15. DEFAULT_CHAT_FRAME:AddMessage(strText)
  16. end
  17. end
  18. function PQR_EventFrame_OnUpdate(self)
  19. local elapsed = 0;
  20. if PQR_LastGetTime ~= 0 then
  21. elapsed = GetTime() - PQR_LastGetTime;
  22. PQR_LastGetTime = GetTime()
  23. else
  24. PQR_LastGetTime = GetTime()
  25. end
  26. PQR_totalElapsed = PQR_totalElapsed + elapsed;
  27. PQR_totalElapsed2 = PQR_totalElapsed2 + elapsed;
  28. if PQR_totalElapsed > (PQR_UpdateInterval2 + 0.1) then
  29. PQR_totalElapsed = 0
  30. end
  31. if PQR_totalElapsed2 > (PQR_UpdateInterval2 + 0.1) then
  32. PQR_totalElapsed2 = 0
  33. end
  34. while (PQR_totalElapsed2 > PQR_UpdateInterval2) do
  35. -- PQR_RegisterMovement(PQR_totalElapsed2)
  36. PQR_SetRecastDelay()
  37. PQR_ExecuteInterrupt()
  38. PQR_totalElapsed2 = PQR_totalElapsed2 - PQR_UpdateInterval2
  39. end
  40. if PQR_ChangeIntervalFlag == 1 then
  41. PQR_UpdateInterval = PQR_NewInterval
  42. PQR_ChangeIntervalFlag = 0
  43. PQR_totalElapsed = 0
  44. else
  45. while (PQR_totalElapsed > PQR_UpdateInterval) do
  46. -- PQR_RegisterMovement(PQR_totalElapsed)
  47. PQR_SetRecastDelay()
  48. PQR_ExecuteBot()
  49. PQR_totalElapsed = PQR_totalElapsed - PQR_UpdateInterval
  50. end
  51. end
  52. end
  53. function PQR_EventFrame_OnEvent(self, event, argVar1, argVar2, argVar3, argVar4, argVar5)
  54. if event == "PLAYER_ENTERING_WORLD" then
  55. PQR_EventFrame:Show()
  56. SetMapToCurrentZone()
  57. PQR_Debug("Setting Map to Current Zone.")
  58. elseif event == "PLAYER_REGEN_DISABLED" then
  59. SetMapToCurrentZone()
  60. PQR_Debug("Setting Map to Current Zone.")
  61. elseif event == "PLAYER_LOGOUT" then
  62. PQR_EnableInterrupt(false)
  63. PQR_EnableBot("")
  64. elseif event == "UNIT_SPELLCAST_FAILED" then
  65. local source, spellName = argVar1, argVar2
  66. PQR_DropThreat("FAILED", source, spellName)
  67. elseif event == "UNIT_SPELLCAST_FAILED_QUIET" then
  68. local source, spellName = argVar1, argVar2
  69. PQR_DropThreat("FAILED", source, spellName)
  70. elseif event == "UI_ERROR_MESSAGE" then
  71. local errorMessage = argVar1
  72. if errorMessage == SPELL_FAILED_NOT_BEHIND then
  73. PQR_BehindTime = GetTime()
  74. elseif errorMessage == SPELL_FAILED_LINE_OF_SIGHT then
  75. if PQR_LastTarget ~= nil then
  76. if PQR_LastTarget ~= "none" and PQR_LastTime > GetTime() - 1 then -- LOS message in the last 1 second. Register it.
  77. for i = 1, 10000 do
  78. if PQR.losTable.name[i] == nil or PQR.losTable.name[i] == PQR_LastTarget then -- we got to an empty slot in the table
  79. PQR.losTable.name[i] = PQR_LastTarget
  80. PQR.losTable.time[i] = PQR_LastTime
  81. PQR_Debug("Added LOS for unit " .. PQR_LastTarget .. " at index " .. i)
  82. break
  83. end
  84. end
  85. PQR_LastTarget = "none"
  86. PQR_LastTime = 0
  87. end
  88. end
  89. end
  90. elseif event == "UNIT_SPELLCAST_SUCCEEDED" then
  91. local unitCaster, unitSpell, _, _, unitSpellID = argVar1, argVar2, argVar3, argVar4, argVar5
  92. if unitCaster == "player" then
  93. PQR_SetRecastDelay(unitSpell)
  94. end
  95. if unitCaster ~= "player" then
  96. return
  97. end
  98. if unitSpellID ~= 75 then -- Auto Shot
  99. if unitSpellID == 56641 or unitSpellID == 77767 then -- Steady or Cobra
  100. PQR_SteadyCount = PQR_SteadyCount + 1
  101. PQR_LastCasted = unitSpellID
  102. else
  103. PQR_SteadyCount = 0
  104. PQR_LastCasted = unitSpellID
  105. end
  106. end
  107. elseif event == "UNIT_SPELLCAST_SENT" then
  108. local unitCaster, unitSpell = argVar1, argVar2
  109. local vanishName = GetSpellInfoMod(1856)
  110. local mdName = GetSpellInfoMod(34477)
  111. local feignName = GetSpellInfoMod(5384)
  112. if unitSpell == vanishName then
  113. PQR_DropDelay = GetTime() + 0.5
  114. end
  115. if unitSpell == feignName then
  116. PQR_DropDelay = GetTime() + 1
  117. end
  118. if unitSpell == mdName then
  119. PQR_DropDelay = GetTime() + 2.0
  120. end
  121. end
  122. end
  123. function PQR_ExecuteBot() -- this is the main bot execution function.
  124. if UnitAffectingCombat ~= nil then -- make sure we arent at a loading screen, DCd, etc.
  125. PQR_Combat = UnitAffectingCombat("player")
  126. if PQR_Combat == nil then
  127. PQR_Combat = UnitAffectingCombat("pet")
  128. end
  129. if PQR_RequireCombat == false and PQR_RotationDesignation == false then
  130. PQR_Combat = 1
  131. end
  132. if PQR ~= nil then
  133. if PQR_RotationDesignation == true and PQR[0].priorityTable.requireCombat == false then
  134. PQR_Combat = 1
  135. end
  136. end
  137. local PQR_ExecuteNext = GetCVar("violenceLevel")
  138. if tonumber(PQR_ExecuteNext) ~= nil then
  139. PQR_ExecuteNext = PQR_ExecuteNext - 5
  140. SetCVar("violenceLevel", 2)
  141. else
  142. PQR_ExecuteNext = 0
  143. end
  144. if PQR_ExecuteNext > 0 then -- cast the next ability in X queue.
  145. PQR_Interrupt()
  146. PQR_CastNext(PQR_ExecuteNext)
  147. else
  148. if PQR_ManualMode == false and PQR_BotEnabled == true and PQR_Combat ~= nil then -- auto rotation mode is running... execute next.
  149. PQR_CastNext(0)
  150. end
  151. end
  152. end
  153. end
  154. function PQR_CastNext(rotation)
  155. if PQR[rotation] == nil then
  156. return
  157. end
  158. local nextAbility = PQR_NextAbility(rotation)
  159. if nextAbility ~= -1 then -- Run luaBefore
  160. PQR[rotation].priorityTable.luaBefore[nextAbility]() -- split actions and send RunMacroText
  161. if PQR[rotation].priorityTable.actn[nextAbility] ~= "" and PQR[rotation].priorityTable.actn[nextAbility] ~= nil then
  162. local tbl = {strsplit("|", PQR[rotation].priorityTable.actn[nextAbility])}
  163. for i = 1, 100 do
  164. if tbl[i] == nil then
  165. break
  166. end
  167. if tbl[i] ~= "" then
  168. PQR_Debug("Running Action: " .. tbl[i])
  169. RunMacroText(tbl[i])
  170. end
  171. end
  172. end -- send spell ID
  173. local castingID = PQR[rotation].priorityTable.spid[nextAbility]
  174. if castingID ~= 0 then
  175. local castingName = GetSpellInfoMod(PQR[rotation].priorityTable.spid[nextAbility])
  176. PQR_LastTime = GetTime()
  177. if PQR[rotation].priorityTable.targetCast[nextAbility] == "player" then
  178. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on PLAYER")
  179. PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
  180. CastSpellByID(castingID, "player")
  181. elseif PQR[rotation].priorityTable.targetCast[nextAbility] == "focus" then
  182. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on FOCUS")
  183. PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
  184. CastSpellByID(castingID, "focus")
  185. elseif PQR[rotation].priorityTable.targetCast[nextAbility] == "pet" then
  186. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on PET")
  187. PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
  188. CastSpellByID(castingID, "pet")
  189. elseif PQR[rotation].priorityTable.targetCast[nextAbility] == "mouseover" then
  190. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on MOUSEOVER")
  191. PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
  192. CastSpellByID(castingID, "mouseover")
  193. elseif PQR[rotation].priorityTable.targetCast[nextAbility] == "click" then
  194. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on MOUSE LOCATION")
  195. PQR_LastTarget = "none"
  196. CastSpellByID(castingID)
  197. local PQR_TargetName = UnitName("target")
  198. CameraOrSelectOrMoveStart()
  199. CameraOrSelectOrMoveStop()
  200. local PQR_TargetNameNew = UnitName("target")
  201. if PQR_TargetName ~= nil then
  202. if PQR_TargetName ~= PQR_TargetNameNew then
  203. TargetLastTarget()
  204. end
  205. end
  206. elseif PQR[rotation].priorityTable.targetCast[nextAbility] == "custom" then
  207. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on CUSTOM TARGET " ..
  208. PQR_CustomTarget)
  209. if UnitExists(PQR_CustomTarget) then
  210. PQR_LastTarget = UnitName(PQR_CustomTarget)
  211. CastSpellByID(castingID, PQR_CustomTarget)
  212. else
  213. PQR_Debug("Custom Target does not exist!")
  214. end
  215. PQR_CustomTarget = ""
  216. else
  217. PQR_Debug("Casting Spell " .. castingName .. " (" .. castingID .. ") on TARGET")
  218. PQR_LastTarget = UnitName(PQR[rotation].priorityTable.targetCast[nextAbility])
  219. CastSpellByID(castingID, "target")
  220. end
  221. end -- Run luaAfter
  222. PQR[rotation].priorityTable.luaAfter[nextAbility]()
  223. end
  224. end
  225. function PQR_NextAbility(rotation)
  226. if PQR[rotation] ~= nil then
  227. local _, _, _, _, _, playerChanneling = UnitChannelInfo("player")
  228. if playerChanneling ~= nil then
  229. local currentTime = GetTime() * 1000
  230. if (playerChanneling - currentTime) > 100 then
  231. PQR_IsChanneling = true
  232. else
  233. PQR_IsChanneling = false
  234. end
  235. else
  236. PQR_IsChanneling = false
  237. end
  238. for i = 0, 1023 do
  239. if PQR[rotation].priorityTable.index[i] ~= nil then
  240. if PQR_DropDelay <= GetTime() then
  241. if PQR[rotation].priorityTable.spid[i] ~= 0 then
  242. if PQR_SpellAvailable(PQR[rotation].priorityTable.spid[i]) == true and
  243. PQR[rotation].priorityTable.delay[i] <= (GetTime() * 1000) then
  244. local PQR_Result = PQR[rotation].priorityTable.test[i]()
  245. if PQR_Result == true then
  246. if PQR_IsChanneling == true then
  247. if PQR[rotation].priorityTable.cancelChannel[i] == true then
  248. return i
  249. end
  250. else
  251. return i
  252. end
  253. end
  254. end
  255. else
  256. local PQR_Result = PQR[rotation].priorityTable.test[i]()
  257. if PQR_Result == true then
  258. if PQR_IsChanneling == true then
  259. if PQR[rotation].priorityTable.cancelChannel[i] == true then
  260. return i
  261. end
  262. else
  263. return i
  264. end
  265. end
  266. end
  267. end
  268. end
  269. end
  270. end
  271. return -1
  272. end
  273. function PQR_ExecuteInterrupt()
  274. if UnitAffectingCombat ~= nil then
  275. PQR_Interrupt()
  276. end
  277. end
  278. function PQR_Interrupt()
  279. if PQR_InterruptEnabled == false or PQR_InterruptEnabled == nil then
  280. return
  281. end
  282. if PQR == nil then
  283. return
  284. end
  285. if PQR.interruptTable == nil then
  286. return
  287. end
  288. if PQR_InterruptTest() == true then
  289. PQR_Debug("Casting Interrupt...")
  290. CastSpellByID(PQR_MyInterruptSpell())
  291. end
  292. end
  293. function PQR_InterruptTest()
  294. local pq_castingName, _, _, _, pq_castingStartTime, _, _, _, pq_castingInterrupt = UnitCastingInfo("target")
  295. if pq_castingInterrupt ~= nil then
  296. if pq_castingInterrupt == true then
  297. pq_castingInterrupt = false
  298. else
  299. pq_castingInterrupt = true
  300. end
  301. end
  302. local pq_channelName, _, _, _, pq_channelStartTime, _, _, pq_channelInterrupt = UnitChannelInfo("target")
  303. if pq_channelInterrupt ~= nil then
  304. pq_castingName = pq_channelName
  305. pq_castingStartTime = pq_channelStartTime
  306. if pq_channelInterrupt == true then
  307. pq_castingInterrupt = false
  308. else
  309. pq_castingInterrupt = true
  310. end
  311. end
  312. if pq_castingName == nil then
  313. pq_castingName = ""
  314. end
  315. if pq_castingInterrupt == nil then
  316. pq_castingInterrupt = false
  317. else
  318. local PQR_msCastingSpell = GetTime() * 1000 - pq_castingStartTime
  319. if PQR_msCastingSpell < PQR_InterruptDelay then
  320. pq_castingInterrupt = false
  321. end
  322. end
  323. if UnitCanAttack("player", "target") == nil then -- we cannot attack/interrupt the target.
  324. pq_castingInterrupt = false
  325. end
  326. local PQR_CastInterrupt = false
  327. if pq_castingInterrupt == true then
  328. local _, InterruptCD, _ = GetSpellCooldownMod(PQR_MyInterruptSpell())
  329. if InterruptCD == 0 then
  330. if PQR_InterruptAllSpells == true then
  331. PQR_CastInterrupt = true
  332. end
  333. for i = 0, 1023 do -- check to see if any abilities need to be cast.
  334. if PQR.interruptTable.spell[i] ~= nil then
  335. if strupper(PQR.interruptTable.spell[i]) == strupper(pq_castingName) then
  336. PQR_CastInterrupt = true
  337. break
  338. end
  339. else
  340. break
  341. end
  342. end
  343. end
  344. end
  345. if PQR_CastInterrupt == true then
  346. return true
  347. else
  348. return false
  349. end
  350. end
  351. function PQR_MyInterruptSpell()
  352. if UnitClass ~= nil then
  353. local _, PQR_UnitClass = UnitClass("player")
  354. if PQR_UnitClass == "DEATHKNIGHT" then
  355. return 47528
  356. elseif PQR_UnitClass == "DRUID" then
  357. local catForm = UnitBuffID("player", 768)
  358. if catForm ~= nil then
  359. return 80965
  360. else
  361. return 80964
  362. end
  363. elseif PQR_UnitClass == "HUNTER" then
  364. return 34490
  365. elseif PQR_UnitClass == "MAGE" then
  366. return 2139
  367. elseif PQR_UnitClass == "PALADIN" then
  368. return 96231
  369. elseif PQR_UnitClass == "PRIEST" then
  370. return 15487
  371. elseif PQR_UnitClass == "ROGUE" then
  372. return 1766
  373. elseif PQR_UnitClass == "SHAMAN" then
  374. return 57994
  375. elseif PQR_UnitClass == "WARLOCK" then
  376. return 19647
  377. elseif PQR_UnitClass == "WARRIOR" then
  378. return 6552
  379. else
  380. return 0
  381. end
  382. else
  383. return 0
  384. end
  385. end
  386. function PQR_SetRecastDelay(manualSpellName)
  387. local PQR_CurrentSpellName = UnitCastingInfo("player")
  388. if PQR_CurrentSpellName == nil then
  389. PQR_CurrentSpellName = UnitCastingInfo("player")
  390. end
  391. if manualSpellName ~= nil then
  392. PQR_CurrentSpellName = manualSpellName
  393. end
  394. if PQR_CurrentSpellName == nil then
  395. return
  396. end
  397. PQR_Debug("SetRecastDelay called for spell: " .. PQR_CurrentSpellName)
  398. if PQR_ManualMode == false and PQR_BotEnabled == true then -- PQR[0]
  399. for i = 0, 1023 do
  400. if PQR[0].priorityTable.index[i] == nil then
  401. break
  402. else
  403. if PQR[0].priorityTable.spid[i] ~= 0 then
  404. local PQR_LookupSpell = GetSpellInfoMod(PQR[0].priorityTable.spid[i])
  405. if PQR_LookupSpell == PQR_CurrentSpellName then
  406. PQR[0].priorityTable.delay[i] = (GetTime() * 1000) + PQR[0].priorityTable.recast[i]
  407. end
  408. end
  409. end
  410. end
  411. else -- PQR[1]
  412. for i = 0, 1023 do
  413. if PQR[1].priorityTable.index[i] == nil then
  414. break
  415. else
  416. if PQR[1].priorityTable.spid[i] ~= 1 then
  417. local PQR_LookupSpell = GetSpellInfoMod(PQR[1].priorityTable.spid[i])
  418. if PQR_LookupSpell == PQR_CurrentSpellName then
  419. PQR[1].priorityTable.delay[i] = (GetTime() * 1000) + PQR[1].priorityTable.recast[i]
  420. end
  421. end
  422. end
  423. end -- PQR[2]
  424. for i = 0, 1023 do
  425. if PQR[2].priorityTable.index[i] == nil then
  426. break
  427. else
  428. if PQR[2].priorityTable.spid[i] ~= 2 then
  429. local PQR_LookupSpell = GetSpellInfoMod(PQR[2].priorityTable.spid[i])
  430. if PQR_LookupSpell == PQR_CurrentSpellName then
  431. PQR[2].priorityTable.delay[i] = (GetTime() * 1000) + PQR[2].priorityTable.recast[i]
  432. end
  433. end
  434. end
  435. end -- PQR[3]
  436. for i = 0, 1023 do
  437. if PQR[3].priorityTable.index[i] == nil then
  438. break
  439. else
  440. if PQR[3].priorityTable.spid[i] ~= 3 then
  441. local PQR_LookupSpell = GetSpellInfoMod(PQR[3].priorityTable.spid[i])
  442. if PQR_LookupSpell == PQR_CurrentSpellName then
  443. PQR[3].priorityTable.delay[i] = (GetTime() * 1000) + PQR[3].priorityTable.recast[i]
  444. end
  445. end
  446. end
  447. end -- PQR[4]
  448. for i = 0, 1023 do
  449. if PQR[4].priorityTable.index[i] == nil then
  450. break
  451. else
  452. if PQR[4].priorityTable.spid[i] ~= 4 then
  453. local PQR_LookupSpell = GetSpellInfoMod(PQR[4].priorityTable.spid[i])
  454. if PQR_LookupSpell == PQR_CurrentSpellName then
  455. PQR[4].priorityTable.delay[i] = (GetTime() * 1000) + PQR[4].priorityTable.recast[i]
  456. end
  457. end
  458. end
  459. end
  460. end
  461. end
  462. if PQR_EventFrame == nil then
  463. PQR = {}
  464. PQR.interruptTable = {}
  465. PQR.interruptTable.spell = {}
  466. for i = 0, 4 do
  467. PQR[i] = {}
  468. end
  469. PQR_RotationDesignation = true
  470. PQR_ManualMode = false
  471. PQR_totalElapsed = 0.0
  472. PQR_totalElapsed2 = 0.0
  473. PQR_SteadyCount = 0
  474. PQR_LastCasted = 0
  475. PQR_DropDelay = 0
  476. PQR_ChangeIntervalFlag = 0
  477. PQR_NewInterval = 0.1
  478. PQR_UpdateInterval = 0.1
  479. PQR_UpdateInterval2 = 0.1
  480. PQR_BehindTime = 0
  481. PQR_CurrentX = 0
  482. PQR_CurrentY = 0
  483. PQR_StationaryX = 0
  484. PQR_StationaryY = 0
  485. PQR_StationaryTime = 0
  486. PQR_CurrentMovingTime = 0
  487. PQR_CurrentStationaryTime = 1
  488. PQR_ResetMovementTime = 1
  489. PQR_LastMovementTime = 0
  490. PQR_RequireCombat = true
  491. PQR_InterruptDelay = 0
  492. PQR_IsChanneling = false
  493. PQR_LastTarget = "none"
  494. PQR_LastTime = 0
  495. PQR_LastGetTime = 0
  496. PQR_CustomTarget = ""
  497. PQR_EventFrame = CreateFrame("Frame")
  498. PQR_EventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") -- Added in 2.4.0 TBC
  499. PQR_EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  500. PQR_EventFrame:RegisterEvent("UNIT_SPELLCAST_SENT") -- Added in Patch 2.0
  501. PQR_EventFrame:RegisterEvent("PLAYER_LOGOUT")
  502. PQR_EventFrame:RegisterEvent("UNIT_SPELLCAST_FAILED") -- Added in Patch 2.0
  503. PQR_EventFrame:RegisterEvent("UNIT_SPELLCSAT_FAILED_QUIET")
  504. PQR_EventFrame:RegisterEvent("UI_ERROR_MESSAGE")
  505. PQR_EventFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") -- Added in Patch 2.0
  506. PQR_EventFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
  507. PQR_EventFrame:SetScript("OnUpdate", PQR_EventFrame_OnUpdate)
  508. PQR_EventFrame:SetScript("OnEvent", PQR_EventFrame_OnEvent)
  509. PQR_EventFrame:Show()
  510. end
  511. function PQR_EnableInterrupt(disable)
  512. if PQR_InterruptEnabled == true then
  513. PlaySound(PQR_StopInterruptSound, "Master")
  514. PQR_WriteToChat("Interrupt Disabled")
  515. PQR_InterruptEnabled = false
  516. else
  517. if disable == nil then
  518. PlaySound(PQR_StartInterruptSound, "Master")
  519. PQR_WriteToChat("Interrupt Enabled")
  520. PQR_InterruptEnabled = true
  521. else
  522. if disable == true and PQR_InterruptEnabled == true then
  523. PlaySound(PQR_StopInterruptSound, "Master")
  524. PQR_WriteToChat("Interrupt Disabled")
  525. end
  526. PQR_InterruptEnabled = false
  527. end
  528. end
  529. end
  530. function PQR_EnableBot(mode) -- This function will display the proper chat message regarding if the bot is switching modes or is enabling/disabling.
  531. PQR_ResetMovementTime = 1.0
  532. if (mode ~= PQR_BotRotation) then
  533. if mode == "" then
  534. PlaySound(PQR_StopRotationSound, "Master")
  535. PQR_WriteToChat("Disabled")
  536. PQR_BotRotation = ""
  537. PQR_BotEnabled = false
  538. else
  539. if PQR_BotRotation == "" or PQR_BotRotation == nil then
  540. PlaySound(PQR_StartRotationSound, "Master")
  541. else
  542. PlaySound(PQR_ChangeRotationSound, "Master")
  543. end
  544. local PQR_CorrectMode = strsplit("^&*", mode)
  545. PQR_WriteToChat(" " .. PQR_CorrectMode .. " ")
  546. SetMapToCurrentZone()
  547. PQR_BotRotation = mode
  548. PQR_BotEnabled = true
  549. end
  550. else
  551. if (mode == "* Manual") then
  552. PQR_WriteToChat(" " .. mode .. " ")
  553. PQR_BotRotation = mode
  554. PQR_BotEnabled = true
  555. else
  556. PlaySound(PQR_StopRotationSound, "Master")
  557. PQR_WriteToChat("Disabled")
  558. PQR_BotRotation = ""
  559. PQR_BotEnabled = false
  560. end
  561. end
  562. end
  563. function PQR_ChangeInterval(newInterval)
  564. PQR_Debug("Changing Interval to: '" .. newInterval .. "'")
  565. if newInterval >= 20 and newInterval <= 1000 then
  566. PQR_NewInterval = (newInterval / 1000)
  567. else
  568. PQR_NewInterval = 0.1
  569. end
  570. PQR_ChangeIntervalFlag = 1
  571. end
  572. function PQR_DropThreat(successType, spellCaster, spellName)
  573. if spellCaster == "player" and PQR_isThreatDrop(spellName) == true then
  574. if successType == "SUCCESS" then
  575. PQR_DropDelay = 0
  576. elseif successType == "FAILED" then -- player is attempting to drop threat but failing due to being on GCD. Delay any future updates for .5 seconds so player can drop threat.
  577. local start, duration, enabled = GetSpellCooldownMod(spellName);
  578. local dropthreatCD = (start + duration - GetTime())
  579. if dropthreatCD <= 5 then
  580. PQR_DropDelay = GetTime() + 0.5
  581. end
  582. end
  583. end
  584. end
  585. function PQR_isThreatDrop(spellName)
  586. if PQTD == nil then
  587. PQTD = {}
  588. end
  589. PQTD[1] = GetSpellInfoMod(5384) -- Feign Death
  590. PQTD[2] = GetSpellInfoMod(642) -- Divine Shield
  591. PQTD[3] = GetSpellInfoMod(12042) -- Arcane Power
  592. PQTD[4] = GetSpellInfoMod(66) -- Invisibility
  593. for i = 1, 3 do
  594. if PQTD[i] == spellName then
  595. return true
  596. end
  597. end
  598. return false
  599. end
  600. function PQR_GCDSpell()
  601. if UnitClass ~= nil then
  602. local _, PQR_UnitClass = UnitClass("player")
  603. local _, build = GetBuildInfo()
  604. if tonumber(build) <= 2973 then
  605. if PQR_UnitClass == "DEATHKNIGHT" then
  606. return 52375
  607. elseif PQR_UnitClass == "DRUID" then
  608. return 774
  609. elseif PQR_UnitClass == "HUNTER" then
  610. return 56641
  611. elseif PQR_UnitClass == "MAGE" then
  612. return 1459
  613. elseif PQR_UnitClass == "PALADIN" then
  614. return 85256
  615. elseif PQR_UnitClass == "PRIEST" then
  616. return 2050
  617. elseif PQR_UnitClass == "ROGUE" then
  618. return 1752
  619. elseif PQR_UnitClass == "SHAMAN" then
  620. return 45284
  621. elseif PQR_UnitClass == "WARLOCK" then
  622. return 980
  623. elseif PQR_UnitClass == "WARRIOR" then
  624. return 1715
  625. else
  626. return 0
  627. end
  628. else
  629. if PQR_UnitClass == "DEATHKNIGHT" then
  630. return 52375
  631. elseif PQR_UnitClass == "DRUID" then
  632. return 774
  633. elseif PQR_UnitClass == "HUNTER" then
  634. return 56641
  635. elseif PQR_UnitClass == "MAGE" then
  636. return 1459
  637. elseif PQR_UnitClass == "PALADIN" then
  638. return 85256
  639. elseif PQR_UnitClass == "PRIEST" then
  640. return 2050
  641. elseif PQR_UnitClass == "ROGUE" then
  642. return 1752
  643. elseif PQR_UnitClass == "SHAMAN" then
  644. return 45284
  645. elseif PQR_UnitClass == "WARLOCK" then
  646. return 980
  647. elseif PQR_UnitClass == "WARRIOR" then
  648. return 1715
  649. else
  650. return 0
  651. end
  652. end
  653. else
  654. return 0
  655. end
  656. end
  657. function PQR_SpellAvailable(SpellID)
  658. local GCDSpell = PQR_GCDSpell()
  659. if GetSpellCooldown ~= nil then
  660. local GCDstartTime, GCDduration = GetSpellCooldownMod(GCDSpell)
  661. local startTime, duration, enabled = GetSpellCooldownMod(SpellID)
  662. local usableName, _, _, spellCost = GetSpellInfoMod(SpellID)
  663. local spellUsable = nil
  664. local _, build = GetBuildInfo()
  665. if tonumber(build) <= 12340 then
  666. if GetSpellCooldownMod(usableName) == 0 then spellUsable = true else spellUsable = nil end
  667. else
  668. if GetSpellCooldownMod(SpellID) == 0 then spellUsable = true else spellUsable = nil end
  669. end
  670. pq_SpellAvailable = "false"
  671. if startTime ~= nil and GCDstartTime ~= nil then
  672. local timeLeft = startTime + duration - GetTime()
  673. local GCDtimeLeft = GCDstartTime + GCDduration - GetTime()
  674. if GCDtimeLeft <= 0 then
  675. if timeLeft <= 0.25 then
  676. if spellUsable ~= nil then
  677. pq_SpellAvailable = "true"
  678. end
  679. end
  680. else
  681. if timeLeft <= GCDtimeLeft + 0.25 then
  682. if spellUsable ~= nil then
  683. pq_SpellAvailable = "true"
  684. end
  685. end
  686. end
  687. else
  688. pq_SpellAvailable = "false"
  689. end
  690. else
  691. pq_SpellAvailable = "false"
  692. end
  693. if pq_SpellAvailable == nil or pq_SpellAvailable == "false" then
  694. return false
  695. else
  696. return true
  697. end
  698. end
  699. function PQR_IsCastingSpell(spellID)
  700. local spellName = GetSpellInfoMod(spellID)
  701. local spellCasting = UnitCastingInfo("player")
  702. if spellCasting == nil then
  703. spellCasting = UnitChannelInfo("player")
  704. end
  705. if spellCasting == spellName then
  706. return true
  707. else
  708. return false
  709. end
  710. end
  711. function PQR_NotBehindTarget()
  712. if PQR_BehindTime + 3 > GetTime() then
  713. return true
  714. else
  715. return false
  716. end
  717. end
  718. function PQR_IsMoving(seconds)
  719. local PQR_MoltenFeathers = UnitBuffID("player", 98767)
  720. if PQR_CurrentMovingTime >= seconds and PQR_MoltenFeathers == nil then
  721. return true
  722. else
  723. return false
  724. end
  725. end
  726. function PQR_IsOutOfSight(unit, seconds)
  727. local secondsCheck = seconds
  728. if secondsCheck == nil then
  729. secondsCheck = 3
  730. end
  731. local unitCheck = unit
  732. if unitCheck == nil then
  733. unitCheck = "target"
  734. end
  735. local PQR_TargetName = UnitName(unitCheck)
  736. if PQR_TargetName ~= nil then
  737. for i = 1, 10000 do
  738. if PQR.losTable.name[i] == nil then
  739. return false
  740. end
  741. if PQR.losTable.name[i] == PQR_TargetName then
  742. if PQR.losTable.time[i] > GetTime() - secondsCheck then
  743. return true
  744. else
  745. return false
  746. end
  747. end
  748. end
  749. end
  750. return false
  751. end
  752. function UnitBuffID(unit, spellID, filter)
  753. local spellName = GetSpellInfoMod(spellID)
  754. if filter == nil then
  755. return Buffed(unit, spellName)
  756. else
  757. return Buffed(unit, spellName, nil, filter)
  758. end
  759. end
  760. function UnitDebuffID(unit, spellID, filter)
  761. local spellName = GetSpellInfoMod(spellID)
  762. if filter == nil then
  763. return Buffed(unit, spellName)
  764. else
  765. return Buffed(unit, spellName, nil, filter)
  766. end
  767. end
  768.  
  769. function CastSpellByID(spellID, unit)
  770. if unit == "player" then
  771. print(GetSpellNameFromID(spellID) .." On " ..unit)
  772. CastSpellByName(GetSpellNameFromID(spellID), 1)
  773. elseif unit == "target" then
  774. CastSpellByName(GetSpellNameFromID(spellID))
  775. elseif unit == "focus" then
  776. print("Focus Cast WIP...")
  777. elseif unit == "pet" then
  778. print("Pet Cast WIP...")
  779. elseif unit == "mouseover" then
  780. print("Mouseover Cast WIP...")
  781. else
  782. print("Cast On : " ..unit .."WIP...")
  783. end
  784. end
Advertisement
Add Comment
Please, Sign In to add comment