Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- don't load if class is wrong
- local _, class = UnitClass("player")
- if class ~= "MONK" then return end
- local GetTime = GetTime
- local debug = clcInfo.debug
- local version = 5000002
- local modName = "__ww"
- local mod = clcInfo:RegisterClassModule(modName)
- local emod = clcInfo.env
- local ef = CreateFrame("Frame")
- ef:Hide()
- local defaults = {
- version = version,
- rangePerSkill = true,
- }
- -- @defines
- --------------------------------------------------------------------------------
- local gcdId = 115693 -- jab for gcd
- -- list of spellId
- local tpId = 100787 -- tiger palm
- local bokId = 100784 -- blackout kick
- local rskId = 107428 -- rising sun kick
- local fofId = 113656 -- fists of fury
- local jabId = 115693 -- jab
- local todId = 115080 -- touch of death
- local ebrewId = 115288 -- energizing brew
- local ehId = 115072 -- expel harm
- local fbId = 115203 -- fortifying brew
- -- status
- local s_ctime, s_otime, s_gcd, chi, energy
- -- buffs & procs
- local cmbBok = "Combo Breaker: Blackout Kick" -- ComboBreaker BOK
- local cmbTP = "Combo Breaker: Tiger Palm" -- ComboBreaker TP
- local buffTP = "Tiger Power" -- Tiger Power
- local buffToD = "Death Note" -- Death Note (Touch of Death ok)
- local cmbBokDur
- local cmbTpDur
- local todOK = false
- local useFB = false
- -- debuffs
- local debuffRsk = "Rising Sun Kick" -- RSK debuff
- -- status vars
- local s1, s2
- local s_ctime, s_otime, s_gcd, s_chi, s_tp, s_rsk, s_energy, s_tsStack
- local s_chi_previous = 0
- local s_effectife_chi = 0
- local s_health_per
- local PSTimer
- local PS_talented = false
- local expelHarmOK = true
- -- the queue
- local qn = {} -- normal queue
- -- local qz = {} -- zeal queue
- local q -- working var
- local prio = "fb tod rsk tp fof cbbok cbtp bok ebrew eh jab"
- local tpRefresh = 4.0
- local rskRefresh = 4.0
- local function GetCooldown(id)
- local start, duration = GetSpellCooldown(id)
- local cd = start + duration - s_ctime - s_gcd
- if cd < 0 then return 0 end
- return cd
- end
- -- actions ---------------------------------------------------------------------
- local actions = {
- fb = {
- id = fbId,
- GetCD = function()
- if useFB and GetCooldown(fbId) == 0.0 then
- if s_chi >= 3 and GetCooldown(todId) <= 1 then
- return 0
- end
- end
- return 100 -- lazy stuff
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + 1
- end,
- info = "Fortifying Brew"
- },
- tod = {
- id = todId,
- GetCD = function()
- if s_chi >= 3 and GetCooldown(todId) <= 1 then
- if todOK then
- return 0
- else
- return 100
- end
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- s_chi = max(0, s_chi - 3)
- end,
- info = "Touch of Death"
- },
- rsk = {
- id = rskId,
- GetCD = function()
- if s_chi >= 2 and GetCooldown(rskId) <= 1 and s_rsk < 100 then
- if todOK and GetCooldown(todId) <= 1 then
- return 100
- end
- if s_tp == 0.0 or s_tp >= tpRefresh then
- return 0
- else
- return 100
- end
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- s_rsk = 100 -- make sure it's not shown as next skill
- s_chi = max(0, s_chi - 2)
- end,
- info = "apply RSK"
- },
- tp = {
- id = tpId,
- GetCD = function()
- if s_chi >= 1 and (s_tp <= tpRefresh or s_tpStack < 3) then
- if todOK and GetCooldown(todId) <= 1 then
- return 100
- end
- if s_tp == 0.0 and GetCooldown(rskId) <= 1 then
- return 100
- else
- return 0
- end
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- s_chi = max(0, s_chi - 1)
- s_tpStack = min(3, s_tpStack + 1)
- s_tp = 20
- end,
- info = "Tiger Palm"
- },
- fof = {
- id = fofId,
- GetCD = function()
- if s_chi >= 3 and GetCooldown(fofId) <= 1 then
- if todOK and GetCooldown(todId) <= 1 then
- return 100
- end
- if s_tp >= (tpRefresh + 3) then -- +3 seconds to prevent TP from falling off
- return 0
- else
- return 100
- end
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 3
- s_chi = max(0, s_chi - 3)
- end,
- info = "Fists of Fury"
- },
- cbbok = {
- id = bokId,
- GetCD = function()
- if todOK and GetCooldown(todId) <= 1 then
- return 100
- end
- if cmbBokDur >= 1 then
- return 0
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- cmbBokDur = 0.0
- end,
- info = "Combo Breaker Blackout Kick"
- },
- cbtp = {
- id = tpId,
- GetCD = function()
- if todOK and GetCooldown(todId) <= 1 then
- return 100
- end
- if cmbTpDur >= 1 then
- return 0
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- cmbTpDur = 0.0
- end,
- info = "Combo Breaker Tiger Palm"
- },
- bok = {
- id = bokId,
- GetCD = function()
- if todOK and GetCooldown(todId) <= 1 then
- return 100
- end
- if s_chi >= 2 and GetCooldown(fofId) >= 3 then
- return 0
- end
- return 100
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- s_chi = max(0, s_chi - 2)
- end,
- info = "Blackout Kick"
- },
- ebrew = {
- id = ebrewId,
- GetCD = function()
- if s_energy < 30 and GetCooldown(ebrewId) == 0.0 then
- return 0
- end
- return 100 -- lazy stuff
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + 1
- s_energy = 30
- end,
- info = "Energizing Brew",
- },
- eh = {
- id = ehId,
- GetCD = function()
- if s_health_per < 30 and GetCooldown(ehId) == 0.0 then
- return 0
- end
- return 100 -- lazy stuff
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- s_chi = min(4, s_chi + 2)
- s_health_per = 30
- end,
- info = "Expel Harm",
- },
- jab = {
- id = jabId,
- GetCD = function()
- if s_chi < 4 then
- return 0
- end
- return 100 -- lazy stuff
- end,
- UpdateStatus = function()
- s_ctime = s_ctime + s_gcd + 1
- if PS_talented then
- if PSTimer == 0 or PSTimer == nil then
- s_chi = min(4, s_chi + 3)
- else
- s_chi = min(4, s_chi + 2)
- end
- else
- s_chi = min(4, s_chi + 2)
- end
- end,
- info = "Jab",
- },
- }
- mod.actions = actions
- --------------------------------------------------------------------------------
- local function UpdateTimers()
- local cTime = GetTime()
- local t
- -- Power Strikes
- if PSTimer then
- t = PSTimer - cTime
- debug:AddBoth("timer", t)
- if (t <= 0) then
- PSTimer = nil
- end
- end
- end
- local function getPlayerHealthPer()
- player_health = UnitHealth("player")
- player_health_max = UnitHealthMax("player")
- return (player_health / player_health_max) * 100
- end
- -- reads all the interesting data
- local function GetStatus()
- -- current time
- s_ctime = GetTime()
- debug:Clear()
- s_health_per = getPlayerHealthPer()
- debug:AddBoth("s_health_per", s_health_per)
- -- gcd value
- local start, duration = GetSpellCooldown(gcdId)
- s_gcd = start + duration - s_ctime
- if s_gcd < 0 then s_gcd = 0 end
- debug:AddBoth("s_chi_previous", s_chi_previous)
- debug:AddBoth("s_effectife_chi", s_effectife_chi)
- -- client chi and energy
- s_energy = UnitPower("player")
- if PS_talented then
- UpdateTimers()
- if s_effectife_chi ~= nil then
- s_chi_previous = s_effectife_chi
- end
- s_chi = UnitPower("player", 12)
- s_effectife_chi = UnitPower("player", 12)
- if s_effectife_chi == s_chi_previous + 3 then
- PSTimer = (s_ctime + 20)
- debug:AddBoth("PSTimer", PSTimer)
- end
- else
- s_chi = UnitPower("player", 12)
- end
- qn = {}
- for v in string.gmatch(prio, "[^ ]+") do
- if actions[v] then
- table.insert(qn, v)
- else
- print("clcInfo", modName, "invalid action:", v)
- end
- end
- end
- local function GetNextAction()
- q = qn
- local n = #q
- --debug:AddBoth("n", n)
- -- parse once, get cooldowns, return first 0
- for i = 1, n do
- local action = actions[q[i]]
- local cd = action.GetCD()
- if debug.enabled then
- --debug:AddBoth(q[i], cd)
- end
- if cd == 0 then
- return action.id, q[i]
- end
- action.cd = cd
- end
- -- parse again, return min cooldown
- local minQ = 1
- local minCd = actions[q[1]].cd
- for i = 2, n do
- local action = actions[q[i]]
- if minCd > action.cd then
- minCd = action.cd
- minQ = i
- end
- end
- return actions[q[minQ]].id, q[minQ]
- end
- local function WWRotation()
- s1 = nil
- _, talent = GetTalentRowSelectionInfo(3)
- if talent == 7 then
- PS_talented = true
- end
- GetStatus()
- if debug.enabled then
- --debug:AddBoth("ctime", s_ctime)
- --debug:AddBoth("gcd", s_gcd)
- debug:AddBoth("chi variable", s_chi)
- --debug:AddBoth("tp", s_tp)
- --debug:AddBoth("rsk debuff ", s_rsk)
- --debug:AddBoth("energy", s_energy)
- --debug:AddBoth("prio", prio)
- debug:AddBoth("talent", talent)
- end
- -- the buffs
- -- get tiger power duration & stack
- local _, _, _, cntTP, _, _, expTP = UnitBuff("player", buffTP)
- if expTP ~= nil then
- s_tp = expTP - s_ctime
- s_tpStack = cntTP
- else
- s_tp = 0.0
- s_tpStack = 0
- end
- -- is Touch of Death usable ?
- pH = UnitHealth("player")
- tH = UnitHealth("target")
- if pH * 1.2 > tH and pH < tH then
- useFB = true
- toD = true
- else
- local name = UnitBuff("player", buffToD)
- if name ~= nil then
- todOK = true
- else
- todOK = false
- end
- end
- -- get RSK debuff on target's duration
- local _, _, _, _, _, _, expRSK = UnitDebuff("target", "Rising Sun Kick")
- if expRSK ~= nil then
- s_rsk = expRSK - s_ctime
- else
- s_rsk = 0.0
- end
- -- get mastery procs' duration : BoK
- local _, _, _, _, _, _, expCBBoK = UnitBuff("player", cmbBok)
- if expCBBoK ~= nil then
- cmbBokDur = expCBBoK - s_ctime
- else
- cmbBokDur = 0.0
- end
- -- get mastery procs' duration : TP
- local _, _, _, _, _, _, expCBTP = UnitBuff("player", cmbTP)
- if expCBTP ~= nil then
- cmbTpDur = expCBTP - s_ctime
- else
- cmbTpDur = 0.0
- end
- local action
- s1, action = GetNextAction()
- if debug.enabled then
- debug:AddBoth("s1", action)
- end
- --
- s_otime = s_ctime -- save it so we adjust buffs for next
- actions[action].UpdateStatus()
- debug:AddBoth("chi variable a la fin", s_chi)
- debug:AddBoth("chi effectif a la fin", s_effectife_chi)
- s2, action = GetNextAction()
- if debug.enabled then
- debug:AddBoth("s2", action)
- end
- end
- -- plug in
- --------------------------------------------------------------------------------
- local secondarySkill
- function emod.IconWW1(...)
- WWRotation(...)
- if secondarySkill then secondarySkill:DoUpdate() end
- return emod.IconSpell(s1, rangePerSkill)
- end
- local function SecondaryExec()
- return emod.IconSpell(s2, rangePerSkill)
- end
- local function ExecCleanup2()
- secondarySkill = nil
- end
- function emod.IconWW2(...)
- secondarySkill = emod.___e
- secondarySkill:SetScript("OnUpdate", nil)
- secondarySkill.exec = SecondaryExec
- secondarySkill.ExecCleanup = ExecCleanup2
- end
Add Comment
Please, Sign In to add comment