Advertisement
RetroZelda

modified CLCRet\retmodule\rotation.lua

Apr 10th, 2015
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.78 KB | None | 0 0
  1. -- modified by RetroZelda;
  2. --      updated default rotation
  3. --      added a few spell actions
  4.  
  5. -- thank cremor for all the work done on updating the rotation for wod changes
  6.  
  7. -- don't load if class is wrong
  8. local _, class = UnitClass("player")
  9. if class ~= "PALADIN" then return end
  10.  
  11. local _, xmod = ...
  12.  
  13. xmod.retmodule = {}
  14. xmod = xmod.retmodule
  15.  
  16. local qTaint = true -- will force queue check
  17.  
  18. -- thanks cremor
  19. local GetTime, GetSpellCooldown, UnitBuff, UnitAura, UnitPower, UnitSpellHaste, UnitHealth, UnitHealthMax, GetActiveSpecGroup, GetTalentInfoByID, GetGlyphSocketInfo, IsUsableSpell, GetShapeshiftForm, max, min, SPELL_POWER_HOLY_POWER  =
  20.       GetTime, GetSpellCooldown, UnitBuff, UnitAura, UnitPower, UnitSpellHaste, UnitHealth, UnitHealthMax, GetActiveSpecGroup, GetTalentInfoByID, GetGlyphSocketInfo, IsUsableSpell, GetShapeshiftForm, max, min, SPELL_POWER_HOLY_POWER
  21. local db
  22.  
  23. -- debug if clcInfo detected
  24. local debug
  25. if clcInfo then debug = clcInfo.debug end
  26.  
  27. xmod.version = 6000005
  28. xmod.defaults = {
  29.     version = xmod.version,
  30.    
  31.     prio = "es eds5_fv eds_fv tv_dp_4s eds_4s ds_fv tv5 exo_bc how eds_fv_aw_exec ds_fv_aw_exec tv_aw_exec ds_fv_dp tv_dp cs j eds_fv tv4 exo tv3",
  32.     rangePerSkill = false,
  33.  
  34.     howclash = 0,   -- priority time for hammer of wrath
  35.     csclash = 0,        -- priority time for cs
  36.     exoclash = 0,   -- priority time for exorcism
  37.     ssduration = 0, -- minimum duration on ss buff before suggesting refresh
  38. }
  39.  
  40. -- @defines
  41. --------------------------------------------------------------------------------
  42. local gcdId                 = 85256     -- tv for gcd
  43. -- list of spellId
  44. local tvId                  = 85256     -- templar's verdict
  45. local fvId                  = 157048    -- Final Verdict
  46. local exoId                 = 879       -- exorcism
  47. local mexoId                = 122032    -- mass exorcism
  48. local howId                 = 24275     -- hammer of wrath
  49. local empHowId              = 158392    -- Hammer of Wrath with Empowered Hammer of Wrath perk
  50. local csId                  = 35395     -- crusader strike
  51. local dsId                  = 53385     -- divine storm
  52. local jId                   = 20271     -- judgement
  53. local esId                  = 114157    -- execution sentence
  54. local hprId                 = 114165    -- holy prism
  55. local lhId                  = 114158    -- light's hammer
  56. local ssId                  = 20925     -- sacred shield
  57. -- buffs
  58. local buffDP        = GetSpellInfo(90174)       -- divine purpose
  59. local buffHA        = GetSpellInfo(105809)      -- holy avenger
  60. local buffAW        = GetSpellInfo(31884)       -- avenging wrath
  61. local buffDC        = GetSpellInfo(144595)      -- Divine Crusader
  62. local buffFV        = GetSpellInfo(157048)      -- Final Verdict
  63. local buffBC        = GetSpellInfo(166831)      -- Blazing Contempt (T17 4piece bonus)
  64.  
  65. -- seal swap of suckage
  66. -- I wanna see a dev perform this shit without addons in a raid setting (GREAT IDEA WITH PRETTY GRAPHICS UNDER FEET)
  67. local sorId                 = 20154     -- seal of righteousness
  68. local sotId                 = 31801     -- seal of truth
  69. local buffMT        = GetSpellInfo(156990)      -- Maraad's Truth
  70. local buffLR        = GetSpellInfo(156989)      -- Liadrin's Righteousness
  71.  
  72. -- ss checked in a function since there are 2 buffs with same name
  73. local buffSS = 20925
  74.  
  75. local t17_items = { 115565, 115566, 115567, 115568, 115569 }
  76.  
  77. -- status vars
  78. local s1, s2
  79. local s_ctime, s_otime, s_gcd, s_hp, s_dp, s_ha, s_aw, s_ss, s_dc, s_fv, s_bc, s_haste, s_in_execute_range
  80. local s_fv_talent, s_4t17_equipped, s_execute_range_start
  81. local s_emp_talent, s_mt, s_lr, s_emp_active
  82. local s_exoId = exoId
  83.  
  84. -- the queue
  85. local qn = {}   -- normal queue
  86. local q         -- working queue
  87.  
  88. local function GetCooldown(id)
  89.     local start, duration = GetSpellCooldown(id)
  90.     if start == nil then return 100 end
  91.     local cd = start + duration - s_ctime - s_gcd
  92.     if cd < 0 then return 0 end
  93.     return cd
  94. end
  95.  
  96. -- TODO DP tests
  97. -- actions ---------------------------------------------------------------------
  98. local actions = {  
  99.     tv5 = {
  100.         id = tvId,
  101.         GetCD = function()
  102.             if (s_hp >= 5) or (s_hp >= 3 and s_ha > 0) then return 0 end
  103.             return 100
  104.         end,
  105.         UpdateStatus = function()
  106.             s_ctime = s_ctime + s_gcd + 1.5
  107.             if s_dp > 0 then
  108.                 s_dp = 0
  109.             else
  110.                 s_hp = max(0, s_hp - 3)
  111.             end
  112.             if s_fv_talent then
  113.                 s_fv = 30
  114.             end
  115.         end,
  116.         info = "Templar's Verdict or Final Verdict with HP >= 5",
  117.     },
  118.     tv4 = {
  119.         id = tvId,
  120.         GetCD = function()
  121.             if (s_hp >= 4) or (s_hp >= 3 and s_ha > 0) then return 0 end
  122.             return 100
  123.         end,
  124.         UpdateStatus = function()
  125.             s_ctime = s_ctime + s_gcd + 1.5
  126.             if s_dp > 0 then
  127.                 s_dp = 0
  128.             else
  129.                 s_hp = max(0, s_hp - 3)
  130.             end
  131.             if s_fv_talent then
  132.                 s_fv = 30
  133.             end
  134.         end,
  135.         info = "Templar's Verdict or Final Verdict with HP >= 4",
  136.     },
  137.     tv4_aw = {
  138.         id = tvId,
  139.         GetCD = function()
  140.             if ( ((s_hp >= 4) or (s_hp >= 3 and s_ha > 0)) and (s_aw > 0) ) then return 0 end
  141.             return 100
  142.         end,
  143.         UpdateStatus = function()
  144.             s_ctime = s_ctime + s_gcd + 1.5
  145.             if s_dp > 0 then
  146.                 s_dp = 0
  147.             else
  148.                 s_hp = max(0, s_hp - 3)
  149.             end
  150.             if s_fv_talent then
  151.                 s_fv = 30
  152.             end
  153.         end,
  154.         info = "Templar's Verdict or Final Verdict with HP >= 4 and Avenging Wrath up",
  155.     },
  156.     tv3 = {
  157.         id = tvId,
  158.         GetCD = function()
  159.             if s_hp >= 3 then return 0 end
  160.             return 100
  161.         end,
  162.         UpdateStatus = function()
  163.             s_ctime = s_ctime + s_gcd + 1.5
  164.             if s_dp > 0 then
  165.                 s_dp = 0
  166.             else
  167.                 s_hp = max(0, s_hp - 3)
  168.             end
  169.             if s_fv_talent then
  170.                 s_fv = 30
  171.             end
  172.         end,
  173.         info = "Templar's Verdict or Final Verdict with HP >= 3",
  174.     },
  175.     tv_dp = {
  176.         id = tvId,
  177.         GetCD = function()
  178.             if s_dp > 0.1 then return 0 end
  179.             return 100
  180.         end,
  181.         UpdateStatus = function()
  182.             s_ctime = s_ctime + s_gcd + 1.5
  183.             s_dp = 0
  184.             if s_fv_talent then
  185.                 s_fv = 30
  186.             end
  187.         end,
  188.         info = "Templar's Verdict or Final Verdict when Divine Purpose procs"
  189.     },
  190.     tv_dp_4s = {
  191.         id = tvId,
  192.         GetCD = function()
  193.             if (s_dp > 0.1) and (s_dp < 4) then return 0 end
  194.             return 100
  195.         end,
  196.         UpdateStatus = function()
  197.             s_ctime = s_ctime + s_gcd + 1.5
  198.             s_dp = 0
  199.             if s_fv_talent then
  200.                 s_fv = 30
  201.             end
  202.         end,
  203.         info = "Templar's Verdict or Final Verdict with Divine Purpose < 4s remaining"
  204.     },
  205.     tv_aw = {
  206.         id = tvId,
  207.         GetCD = function()
  208.             if ((s_hp >= 3) or (s_dp > 0.1)) and (s_aw > 0) then return 0 end
  209.             return 100
  210.         end,
  211.         UpdateStatus = function()
  212.             s_ctime = s_ctime + s_gcd + 1.5
  213.             if s_dp > 0 then
  214.                 s_dp = 0
  215.             else
  216.                 s_hp = max(0, s_hp - 3)
  217.             end
  218.             if s_fv_talent then
  219.                 s_fv = 30
  220.             end
  221.         end,
  222.         info = "Templar's Verdict or Final Verdict with HP >= 3 or Divine Purpose during Avenging Wrath",
  223.     },
  224.     tv_aw_exec = {
  225.         id = tvId,
  226.         GetCD = function()
  227.             if ((s_hp >= 3) or (s_dp > 0.1)) and (s_aw > 0 or s_in_execute_range) then return 0 end
  228.             return 100
  229.         end,
  230.         UpdateStatus = function()
  231.             s_ctime = s_ctime + s_gcd + 1.5
  232.             if s_dp > 0 then
  233.                 s_dp = 0
  234.             else
  235.                 s_hp = max(0, s_hp - 3)
  236.             end
  237.             if s_fv_talent then
  238.                 s_fv = 30
  239.             end
  240.         end,
  241.         info = "Templar's Verdict or Final Verdict with HP >= 3 or Divine Purpose during Avenging Wrath or execute range",
  242.     },
  243.     fv = {
  244.         id = fvId,
  245.         GetCD = function()
  246.             if s_hp >= 3 then return 0 end
  247.             return 100
  248.         end,
  249.         UpdateStatus = function()
  250.             s_ctime = s_ctime + s_gcd + 1.5
  251.             if s_dp > 0 then
  252.                 s_dp = 0
  253.             else
  254.                 s_hp = max(0, s_hp - 3)
  255.             end
  256.             s_fv = 30
  257.         end,
  258.         info = "Final Verdict with HP >= 3",
  259.         reqTalent = 21672,
  260.     },
  261.     fv_dp = {
  262.         id = fvId,
  263.         GetCD = function()
  264.             if s_dp > 0.1 then return 0 end
  265.             return 100
  266.         end,
  267.         UpdateStatus = function()
  268.             s_ctime = s_ctime + s_gcd + 1.5
  269.             s_dp = 0
  270.             s_fv = 30
  271.         end,
  272.         info = "Final Verdict when Divine Purpose procs",
  273.         reqTalent = 21672,
  274.     },
  275.     eds = {
  276.         id = dsId,
  277.         GetCD = function()
  278.             if ( s_dc > 0.1 ) then return 0 end
  279.             return 100
  280.         end,
  281.         UpdateStatus = function()
  282.             s_ctime = s_ctime + s_gcd + 1.5
  283.             s_dc = 0
  284.             s_fv = 0
  285.             -- Using EDS should not consume DP
  286.         end,
  287.         info = "Empowered Divine Storm",
  288.     },
  289.     ds5 = {
  290.         id = dsId,
  291.         GetCD = function()
  292.             if s_hp >= 5 then return 0 end
  293.             return 100
  294.         end,
  295.         UpdateStatus = function()
  296.             s_ctime = s_ctime + s_gcd + 1.5
  297.             s_dc = 0
  298.             s_fv = 0
  299.             s_hp = s_hp - 3
  300.         end,
  301.         info = "Divine Storm with 5HP and no buff/proc",
  302.     },
  303.     eds5 = {
  304.         id = dsId,
  305.         GetCD = function()
  306.             if ( (s_dc > 0.1) and (s_hp >= 5) ) then return 0 end
  307.             return 100
  308.         end,
  309.         UpdateStatus = function()
  310.             s_ctime = s_ctime + s_gcd + 1.5
  311.             s_dc = 0
  312.             s_fv = 0
  313.             -- Using EDS should not consume DP
  314.         end,
  315.         info = "Empowered Divine Storm with 5HP",
  316.     },
  317.     eds_aw = {
  318.         id = dsId,
  319.         GetCD = function()
  320.             if ( (s_dc > 0.1) and (s_aw > 0) ) then return 0 end
  321.             return 100
  322.         end,
  323.         UpdateStatus = function()
  324.             s_ctime = s_ctime + s_gcd + 1.5
  325.             s_dc = 0
  326.             s_fv = 0
  327.             -- Using EDS should not consume DP
  328.         end,
  329.         info = "Empowered Divine Storm during Avenging Wrath",
  330.     },
  331.     eds_aw_exec = {
  332.         id = dsId,
  333.         GetCD = function()
  334.             if ( (s_dc > 0.1) and (s_aw > 0 or s_in_execute_range) ) then return 0 end
  335.             return 100
  336.         end,
  337.         UpdateStatus = function()
  338.             s_ctime = s_ctime + s_gcd + 1.5
  339.             s_dc = 0
  340.             s_fv = 0
  341.             -- Using EDS should not consume DP
  342.         end,
  343.         info = "Empowered Divine Storm during Avenging Wrath or execute range",
  344.     },
  345.     eds_4s = {
  346.         id = dsId,
  347.         GetCD = function()
  348.             if ((s_dc > 0.1) and (s_dc < 4) ) then return 0 end
  349.             return 100
  350.         end,
  351.         UpdateStatus = function()
  352.             s_ctime = s_ctime + s_gcd + 1.5
  353.             s_dc = 0
  354.             s_fv = 0
  355.             -- Using EDS should not consume DP
  356.         end,
  357.         info = "Empowered Divine Storm < 4s remaining",
  358.     },
  359.     eds_fv = {
  360.         id = dsId,
  361.         GetCD = function()
  362.             if (( s_dc > 0.1 ) and (s_fv > 0.1) ) then return 0 end
  363.             return 100
  364.         end,
  365.         UpdateStatus = function()
  366.             s_ctime = s_ctime + s_gcd + 1.5
  367.             s_dc = 0
  368.             s_fv = 0
  369.             -- Using EDS should not consume DP
  370.         end,
  371.         info = "Empowered Divine Storm with Final Verdict buff",
  372.         reqTalent = 21672,
  373.     },
  374.     ds_fv = {
  375.         id = dsId,
  376.         GetCD = function()
  377.             if ( (s_hp >= 3) and (s_fv > 0.1) ) then return 0 end
  378.             return 100
  379.         end,
  380.         UpdateStatus = function()
  381.             s_ctime = s_ctime + s_gcd + 1.5
  382.             s_fv = 0
  383.             -- Using DS should not consume DP
  384.         end,
  385.         info = "Divine Storm with Final Verdict buff",
  386.         reqTalent = 21672,
  387.     },
  388.     ds_fv_dp = {
  389.         id = dsId,
  390.         GetCD = function()
  391.             if ((s_dp > 0.1) and (s_fv > 0.1) ) then return 0 end
  392.             return 100
  393.         end,
  394.         UpdateStatus = function()
  395.             s_ctime = s_ctime + s_gcd + 1.5
  396.             s_fv = 0
  397.             -- Using DS should not consume DP
  398.         end,
  399.         info = "Divine Storm with Final Verdict buff",
  400.         reqTalent = 21672,
  401.     },
  402.     eds5_fv = {
  403.         id = dsId,
  404.         GetCD = function()
  405.             if ( (s_dc > 0.1) and (s_fv > 0.1) and (s_hp >= 5) ) then return 0 end
  406.             return 100
  407.         end,
  408.         UpdateStatus = function()
  409.             s_ctime = s_ctime + s_gcd + 1.5
  410.             s_dc = 0
  411.             s_fv = 0
  412.             -- Using EDS should not consume DP
  413.         end,
  414.         info = "Empowered Divine Storm with Final Verdict buff and 5HP",
  415.         reqTalent = 21672,
  416.     },
  417.     eds_fv_aw = {
  418.         id = dsId,
  419.         GetCD = function()
  420.             if ( (s_dc > 0.1) and (s_fv > 0.1) and (s_aw > 0) ) then return 0 end
  421.             return 100
  422.         end,
  423.         UpdateStatus = function()
  424.             s_ctime = s_ctime + s_gcd + 1.5
  425.             s_dc = 0
  426.             s_fv = 0
  427.             -- Using EDS should not consume DP
  428.         end,
  429.         info = "Empowered Divine Storm with Final Verdict buff during Avenging Wrath",
  430.         reqTalent = 21672,
  431.     },
  432.     eds_fv_aw_exec = {
  433.         id = dsId,
  434.         GetCD = function()
  435.             if ( (s_dc > 0.1) and (s_fv > 0.1) and (s_aw > 0 or s_in_execute_range) ) then return 0 end
  436.             return 100
  437.         end,
  438.         UpdateStatus = function()
  439.             s_ctime = s_ctime + s_gcd + 1.5
  440.             s_dc = 0
  441.             s_fv = 0
  442.             -- Using EDS should not consume DP
  443.         end,
  444.         info = "Empowered Divine Storm with Final Verdict buff during Avenging Wrath or execute range",
  445.         reqTalent = 21672,
  446.     },
  447.     ds_fv_aw_exec = {
  448.         id = dsId,
  449.         GetCD = function()
  450.             if ( (s_hp >= 3) and (s_fv > 0.1) and (s_aw > 0 or s_in_execute_range) ) then return 0 end
  451.             return 100
  452.         end,
  453.         UpdateStatus = function()
  454.             s_ctime = s_ctime + s_gcd + 1.5
  455.             s_dc = 0
  456.             s_fv = 0
  457.             -- Using EDS should not consume DP
  458.         end,
  459.         info = "Empowered Divine Storm with Final Verdict buff during Avenging Wrath or execute range",
  460.         reqTalent = 21672,
  461.     },
  462.     exo = {
  463.         id = s_exoId,
  464.         GetCD = function()
  465.             if s1 == s_exoId then
  466.                 return 100 -- lazy stuff
  467.             else
  468.                 return max(0, GetCooldown(s_exoId) - db.exoclash)
  469.             end
  470.         end,
  471.         UpdateStatus = function()
  472.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  473.             if (s_ha > 0) or (s_bc > 0) then
  474.                 s_hp = min(5, s_hp + 3)
  475.             else
  476.                 s_hp = min(5, s_hp + 1)
  477.             end
  478.             s_bc = 0
  479.         end,
  480.         info = "Exorcism",
  481.     },
  482.     exo_aw = {
  483.         id = s_exoId,
  484.         GetCD = function()
  485.             if (s1 ~= s_exoId) and (s_aw > 0) then
  486.                 return max(0, GetCooldown(s_exoId) - db.exoclash)
  487.             end
  488.             return 100 -- lazy stuff
  489.         end,
  490.         UpdateStatus = function()
  491.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  492.             if (s_ha > 0) or (s_bc > 0) then
  493.                 s_hp = min(5, s_hp + 3)
  494.             else
  495.                 s_hp = min(5, s_hp + 1)
  496.             end
  497.             s_bc = 0
  498.         end,
  499.         info = "Exorcism during Avenging Wrath",
  500.     },
  501.     exo_bc = {
  502.         id = s_exoId,
  503.         GetCD = function()
  504.             if (s1 ~= s_exoId) and (s_hp <= 2) and (s_bc > 0.1) then
  505.                 return max(0, GetCooldown(s_exoId) - db.exoclash)
  506.             end
  507.             return 100
  508.         end,
  509.         UpdateStatus = function()
  510.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  511.             s_hp = min(5, s_hp + 3)
  512.             s_bc = 0
  513.         end,
  514.         info = "Exorcism with Blazing Contempt (T17 4piece bonus) buff",
  515.     },
  516.     how = {
  517.         id = howId,
  518.         GetCD = function()
  519.             if (s1 ~= howId) and IsUsableSpell(howId) then
  520.                 return max(0, GetCooldown(howId) - db.howclash)
  521.             end
  522.             return 100 -- lazy stuff
  523.         end,
  524.         UpdateStatus = function()
  525.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  526.             if s_ha > 0 then
  527.                 s_hp = min(5, s_hp + 3)
  528.             else
  529.                 s_hp = min(5, s_hp + 1)
  530.             end
  531.             if s_4t17_equipped then
  532.                 s_bc = 20
  533.             end
  534.         end,
  535.         info = "Hammer of Wrath",
  536.     },
  537.     cs = {
  538.         id = csId,
  539.         GetCD = function()
  540.             if s1 == csId then
  541.                 return max(0, (4.5 / s_haste - 1.5 - db.csclash))
  542.             else
  543.                 return max(0, GetCooldown(csId) - db.csclash)
  544.             end
  545.         end,
  546.         UpdateStatus = function()
  547.             s_ctime = s_ctime + s_gcd + 1.5
  548.             if s_ha > 0 then
  549.                 s_hp = min(5, s_hp + 3)
  550.             else
  551.                 s_hp = min(5, s_hp + 1)
  552.             end
  553.         end,
  554.         info = "Crusader Strike",
  555.     },
  556.     j = {
  557.         id = jId,
  558.         GetCD = function()
  559.             if s1 ~= jId then
  560.                 return GetCooldown(jId)
  561.             end
  562.             return 100 -- lazy stuff
  563.         end,
  564.         UpdateStatus = function()
  565.             s_ctime = s_ctime + s_gcd + 1.5
  566.             if s_ha > 0 then
  567.                 s_hp = min(5, s_hp + 3)
  568.             else
  569.                 s_hp = min(5, s_hp + 1)
  570.             end
  571.  
  572.             if (s_emp_talent) then
  573.                 local sform = s_emp_active
  574.                 if sform == 1 then
  575.                     s_mt = 20
  576.                 elseif sform == 2 then
  577.                     s_lr = 20
  578.                 end
  579.             end
  580.         end,
  581.         info = "Judgement",
  582.     },
  583.     j_aw = {
  584.         id = jId,
  585.         GetCD = function()
  586.             if ( (s1 ~= jId) and (s_aw > 0) ) then
  587.                 return GetCooldown(jId)
  588.             end
  589.             return 100 -- lazy stuff
  590.         end,
  591.         UpdateStatus = function()
  592.             s_ctime = s_ctime + s_gcd + 1.5
  593.             if s_ha > 0 then
  594.                 s_hp = min(5, s_hp + 3)
  595.             else
  596.                 s_hp = min(5, s_hp + 1)
  597.             end
  598.  
  599.             if (s_emp_talent) then
  600.                 local sform = s_emp_active
  601.                 if sform == 1 then
  602.                     s_mt = 20
  603.                 elseif sform == 2 then
  604.                     s_lr = 20
  605.                 end
  606.             end
  607.         end,
  608.         info = "Judgement during Avenging Wrath",
  609.     },
  610.     es = {
  611.         id = esId,
  612.         GetCD = function()
  613.             if s1 ~= esId then
  614.                 return GetCooldown(esId)
  615.             end
  616.             return 100 -- lazy stuff
  617.         end,
  618.         UpdateStatus = function()
  619.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  620.         end,
  621.         info = "Execution Sentence",
  622.         reqTalent = 17609,
  623.     },
  624.     hpr = {
  625.         id = hprId,
  626.         GetCD = function()
  627.             if s1 ~= hprId then
  628.                 return GetCooldown(hprId)
  629.             end
  630.             return 100 -- lazy stuff
  631.         end,
  632.         UpdateStatus = function()
  633.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  634.         end,
  635.         info = "Holy Prism",
  636.         reqTalent = 17605,
  637.     },
  638.     lh = {
  639.         id = lhId,
  640.         GetCD = function()
  641.             if s1 ~= lhId then
  642.                 return GetCooldown(lhId)
  643.             end
  644.             return 100 -- lazy stuff
  645.         end,
  646.         UpdateStatus = function()
  647.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  648.         end,
  649.         info = "Light's Hammer",
  650.         reqTalent = 17607,
  651.     },
  652.     ss = {
  653.         id = ssId,
  654.         GetCD = function()
  655.             if s1 ~= ssId and s_ss <= db.ssduration then
  656.                 return 1.5 / s_haste    -- always return the time it would need to cast the skill so it doesn't overlap any dmg ability
  657.             end
  658.             return 100 -- lazy stuff
  659.         end,
  660.         UpdateStatus = function()
  661.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste + 0.1 -- a bit of extra time to reduce flashing
  662.             s_ss = 30
  663.         end,
  664.         info = "Sacred Shield",
  665.         reqTalent = 21098,
  666.     },
  667.  
  668.     -- seal swaps
  669.     emp_sot_exp = {
  670.         id = sotId,
  671.         GetCD = function()
  672.             if s_emp_active ~= 1 and s_mt < 5 then
  673.                 return 0
  674.             end
  675.             return 100
  676.         end,
  677.         UpdateStatus = function()
  678.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  679.             s_emp_active = 1
  680.         end,
  681.         info = "Empowered Seals go to Truth when buff has less than 5s left",
  682.         reqTalent = 21201,
  683.     },
  684.     emp_sor_exp = {
  685.         id = sorId,
  686.         GetCD = function()
  687.             if s_emp_active ~= 2 and s_lr < 5 then
  688.                 return 0
  689.             end
  690.             return 100
  691.         end,
  692.         UpdateStatus = function()
  693.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  694.             s_emp_active = 2
  695.         end,
  696.         info = "Empowered Seals go to Righteousness when buff has less than 5s left",
  697.         reqTalent = 21201,
  698.     },
  699.     emp_sot_return = {
  700.         id = sotId,
  701.         GetCD = function()
  702.             if s_emp_active ~= 1 and s_lr > 10 then
  703.                 return 0
  704.             end
  705.             return 100
  706.         end,
  707.         UpdateStatus = function()
  708.             s_ctime = s_ctime + s_gcd + 1.5 / s_haste
  709.             s_emp_active = 1
  710.         end,
  711.         info = "Empowered Seals go back to Truth after casting Righteousness",
  712.         reqTalent = 21201,
  713.     },
  714.  
  715. }
  716. --------------------------------------------------------------------------------
  717.  
  718. local function UpdateQueue()
  719.     -- normal queue
  720.     qn = {}
  721.     for v in string.gmatch(db.prio, "[^ ]+") do
  722.         if actions[v] then
  723.             table.insert(qn, v)
  724.         else
  725.             print("clcretmodule - invalid action:", v)
  726.         end
  727.     end
  728.     db.prio = table.concat(qn, " ")
  729.  
  730.     -- force reconstruction for q
  731.     qTaint = true
  732. end
  733.  
  734. local function GetBuff(buff)
  735.     local left = 0
  736.     local _, expires
  737.     _, _, _, _, _, _, expires = UnitBuff("player", buff, nil, "PLAYER")
  738.     if expires then
  739.         left = max(0, expires - s_ctime - s_gcd)
  740.     end
  741.     return left
  742. end
  743.  
  744. -- special case for SS
  745. local function GetBuffSS()
  746.     -- parse all buffs and look for id
  747.     local i = 1
  748.     local name, _, _, _, _, _, expires, _, _, _, spellId = UnitAura("player", i, "HELPFUL")
  749.     while name do
  750.         if spellId == buffSS then break end
  751.         i = i + 1
  752.         name, _, _, _, _, _, expires, _, _, _, spellId = UnitAura("player", i, "HELPFUL")
  753.     end
  754.    
  755.     local left = 0
  756.     if name and expires then
  757.         left = max(0, expires - s_ctime - s_gcd)
  758.     end
  759.     s_ss = left
  760. end
  761.  
  762. -- reads all the interesting data
  763. local function GetStatus()
  764.     -- current time
  765.     s_ctime = GetTime()
  766.    
  767.     -- gcd value
  768.     local start, duration = GetSpellCooldown(gcdId)
  769.     s_gcd = start + duration - s_ctime
  770.     if s_gcd < 0 then s_gcd = 0 end
  771.    
  772.     -- the buffs
  773.     s_dp    = GetBuff(buffDP)
  774.     s_ha    = GetBuff(buffHA)
  775.     s_aw    = GetBuff(buffAW)
  776.     s_dc    = GetBuff(buffDC)
  777.     s_bc    = GetBuff(buffBC)
  778.  
  779.     if s_fv_talent then
  780.         s_fv = GetBuff(buffFV)
  781.     elseif s_emp_talent then
  782.         s_mt = GetBuff(buffMT)
  783.         s_lr = GetBuff(buffLR)
  784.         s_emp_active = GetShapeshiftForm()
  785.     end
  786.  
  787.     -- special for ss
  788.     GetBuffSS()
  789.  
  790.     -- client hp and haste
  791.     s_hp = UnitPower("player", SPELL_POWER_HOLY_POWER)
  792.     s_haste = 1 + UnitSpellHaste("player") / 100
  793.  
  794.     -- execute range: custom health check instead of checking HoW to ensure that 2T17 doesn't cause problems
  795.     s_in_execute_range = (UnitHealth("target") / UnitHealthMax("target")) <= s_execute_range_start
  796. end
  797.  
  798. -- remove all talents not available and present in rotation
  799. -- adjust for modified skills present in rotation
  800. local function GetWorkingQueue()
  801.     q = {}
  802.     local name, selected, available
  803.     for k, v in pairs(qn) do
  804.         -- see if it has a talent requirement
  805.         if actions[v].reqTalent then
  806.             -- see if the talent is activated
  807.             _, name, _, selected, available = GetTalentInfoByID(actions[v].reqTalent, GetActiveSpecGroup())
  808.             if name and selected and available then
  809.                 table.insert(q, v)
  810.             end
  811.         else
  812.             table.insert(q, v)
  813.         end
  814.     end
  815. end
  816.  
  817. local function GetNextAction()
  818.     -- check if working queue needs updated due to glyph talent changes
  819.     if qTaint then
  820.         GetWorkingQueue()
  821.         qTaint = false
  822.     end
  823.  
  824.     local n = #q
  825.    
  826.     -- parse once, get cooldowns, return first 0
  827.     for i = 1, n do
  828.         local action = actions[q[i]]
  829.         local cd = action.GetCD()
  830.         if debug and debug.enabled then
  831.             debug:AddBoth(q[i], cd)
  832.         end
  833.         if cd == 0 then
  834.             return action.id, q[i]
  835.         end
  836.         action.cd = cd
  837.     end
  838.    
  839.     -- parse again, return min cooldown
  840.     local minQ = 1
  841.     local minCd = actions[q[1]].cd
  842.     for i = 2, n do
  843.         local action = actions[q[i]]
  844.         if minCd > action.cd then
  845.             minCd = action.cd
  846.             minQ = i
  847.         end
  848.     end
  849.     return actions[q[minQ]].id, q[minQ]
  850. end
  851.  
  852. -- exposed functions
  853.  
  854. -- this function should be called from addons
  855. function xmod.Init()
  856.     db = xmod.db
  857.     UpdateQueue()
  858. end
  859.  
  860. function xmod.GetActions()
  861.     return actions
  862. end
  863.  
  864. function xmod.Update()
  865.     UpdateQueue()
  866. end
  867.  
  868. function xmod.Rotation()
  869.     s1 = nil
  870.     GetStatus()
  871.     if debug and debug.enabled then
  872.         debug:Clear()
  873.         debug:AddBoth("ctime", s_ctime)
  874.         debug:AddBoth("gcd", s_gcd)
  875.         debug:AddBoth("hp", s_hp)
  876.         debug:AddBoth("haste", s_haste)
  877.         debug:AddBoth("s_mt", s_mt)
  878.         debug:AddBoth("s_lr", s_lr)
  879.     end
  880.     local action
  881.     s1, action = GetNextAction()
  882.     if debug and debug.enabled then
  883.         debug:AddBoth("s1", action)
  884.         debug:AddBoth("s1Id", s1)
  885.     end
  886.     --
  887.     s_otime = s_ctime -- save it so we adjust buffs for next
  888.     actions[action].UpdateStatus()
  889.    
  890.     -- adjust buffs
  891.     s_otime = s_ctime - s_otime
  892.     s_dp = max(0, s_dp - s_otime)
  893.     s_ha = max(0, s_ha - s_otime)
  894.     s_ss = max(0, s_ss - s_otime)
  895.     s_aw = max(0, s_aw - s_otime)
  896.     s_dc = max(0, s_dc - s_otime)
  897.     s_bc = max(0, s_bc - s_otime)
  898.  
  899.     if s_fv_talent then
  900.         s_fv = max(0, s_fv - s_otime)
  901.     elseif s_emp_talent then
  902.         s_mt = max(0, s_mt - s_otime)
  903.         s_lr = max(0, s_lr - s_otime)
  904.     end
  905.  
  906.    
  907.     if debug and debug.enabled then
  908.         debug:AddBoth("ctime", s_ctime)
  909.         debug:AddBoth("otime", s_otime)
  910.         debug:AddBoth("gcd", s_gcd)
  911.         debug:AddBoth("hp", s_hp)
  912.         debug:AddBoth("haste", s_haste)
  913.         debug:AddBoth("s_mt", s_mt)
  914.         debug:AddBoth("s_lr", s_lr)
  915.     end
  916.     s2, action = GetNextAction()
  917.     if debug and debug.enabled then
  918.         debug:AddBoth("s2", action)
  919.     end
  920.  
  921.     return s1, s2
  922. end
  923.  
  924. -- event frame
  925. local ef = CreateFrame("Frame", "clcRetModuleEventFrame") -- event frame
  926. ef:Hide()
  927. local function OnEvent()
  928.     qTaint = true
  929.    
  930.     local count = 0
  931.     for i, v in ipairs(t17_items) do
  932.         if IsEquippedItem(v) then
  933.             count = count + 1
  934.         end
  935.     end
  936.     s_4t17_equipped = count >= 4
  937.  
  938.     -- check for how perk
  939.     if IsPlayerSpell(157496) then
  940.         s_execute_range_start = 0.35
  941.         howId = empHowId
  942.         actions['how'].id = howId
  943.     else
  944.         s_execute_range_start = 0.20
  945.     end
  946.     -- fv talent
  947.     local _, name, _, selected, available = GetTalentInfoByID(21672, GetActiveSpecGroup())
  948.     if name and selected and available then
  949.         s_fv_talent = selected
  950.     end
  951.     _, name, _, selected, available = GetTalentInfoByID(21201, GetActiveSpecGroup())
  952.     if name and selected and available then
  953.         s_emp_talent = selected
  954.     end
  955.  
  956.     -- adjust exo depending on glyph
  957.     local glyphSpellId
  958.     local mexo = false
  959.     for i = 1, 3 do
  960.         -- major glyphs are 2, 4, 6
  961.         _, _, _, glyphSpellId = GetGlyphSocketInfo(i*2)
  962.         if glyphSpellId == 122028 then
  963.             mexo = true
  964.             break
  965.         end
  966.     end
  967.  
  968.     if mexo then
  969.         -- mass exorcism glyph detected
  970.         -- switch spellid for actions
  971.         actions["exo"].id = mexoId
  972.         actions["exo_aw"].id = mexoId
  973.         actions["exo_bc"].id = mexoId
  974.         s_exoId = mexoId
  975.     else
  976.         actions["exo"].id = exoId
  977.         actions["exo_aw"].id = exoId
  978.         actions["exo_bc"].id = exoId
  979.         s_exoId = exoId
  980.     end
  981. end
  982.  
  983. ef:SetScript("OnEvent", OnEvent)
  984. ef:RegisterEvent("PLAYER_ENTERING_WORLD")
  985. ef:RegisterEvent("PLAYER_TALENT_UPDATE")
  986. ef:RegisterEvent("PLAYER_LEVEL_UP")
  987. ef:RegisterEvent("GLYPH_ADDED")
  988. ef:RegisterEvent("GLYPH_UPDATED")
  989. ef:RegisterEvent("GLYPH_REMOVED")
  990. ef:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement