Advertisement
alexdubovyck

Исходник pqr

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