WoWInterface SVN NeedToKnow-Updated

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /branches
    from Rev 83 to Rev 84
    Reverse comparison

Rev 83 → Rev 84

Kitjan/NeedToKnow/NeedToKnow.lua
721,9 → 721,11
 
-- Split the spell names
bar.spells = {}
bar.functions = {}
for barSpell in bar.auraName:gmatch("([^,]+)") do
barSpell = strtrim(barSpell)
table.insert(bar.spells, barSpell)
table.insert(bar.functions, NeedToKnow.GetSpellCooldown)
end
 
-- split the user name overrides
742,6 → 744,13
barSpell == "75" )
then
barSettings.bAutoShot = true
bar.functions[idx] = NeedToKnow.GetAutoShotCooldown
elseif (barSpell:match("%d+") ~= barSpell) then
local item_id = NeedToKnow.GetItemIDString(barSpell)
if item_id then
bar.spells[idx] = item_id
bar.functions[idx] = NeedToKnow.GetItemCooldown
end
end
end
end
1004,7 → 1013,7
if ( self.settings.bAutoShot and caster == "player" and spell == NEEDTOKNOW.AUTO_SHOT ) then
local interval = UnitRangedDamage("player")
self.tAutoShotCD = interval
self.tAutoShotExpires = GetTime() + interval
self.tAutoShotStart = GetTime()
NeedToKnow.Bar_AuraCheck(self)
end
end
1314,6 → 1323,77
end
 
 
function NeedToKnow.GetItemIDString(id_or_name)
local _, link = GetItemInfo(id_or_name)
if link then
local idstring = link:match("item:(%d+):")
if idstring then
return idstring
end
end
end
 
 
function NeedToKnow.GetAutoShotCooldown(bar)
local tNow = GetTime()
if ( bar.tAutoShotStart and bar.tAutoShotStart + bar.tAutoShotCD > tNow ) then
local n, icon = GetSpellInfo(75)
return bar.tAutoShotStart, bar.tAutoShotCD, 1, NEEDTOKNOW.AUTO_SHOT, icon
else
bar.tAutoShotStart = nil
end
end
 
 
-- Wrapper around GetSpellCooldown with extra sauce
-- Expected to return start, cd_len, enable, buffName, iconpath
function NeedToKnow.GetSpellCooldown(bar, barSpell)
local start, cd_len, enable = GetSpellCooldown(barSpell)
if start and start > 0 then
local spellName, spellRank, spellIconPath, _, _, spellPower = GetSpellInfo(barSpell)
if 0 == enable then
-- Filter out conditions like Stealth while stealthed
start = nil
elseif spellPower == 5 then -- Rune
-- Filter out rune cooldown artificially extending the cd
if cd_len <= 10 then
if bar.expirationTime and tNow < bar.expirationTime then
-- We've already seen the correct CD for this; keep using it
start = bar.expirationTime - bar.duration
cd_len = bar.duration
elseif NeedToKnow.last_sent and NeedToKnow.last_sent[barSpell] and NeedToKnow.last_sent[barSpell] > (tNow - 1.5) then
-- We think the spell was just cast, and a CD just started but it's short.
-- Look at the tooltip to tell what the correct CD should be. If it's supposed
-- to be short (Ghoul Frenzy, Howling Blast), then start a CD bar
cd_len = NeedToKnow.DetermineShortCooldownFromTooltip(barSpell)
if cd_len == 0 or cd_len > 10 then
start = nil
end
else
start = nil
end
end
end
 
if start then
return start, cd_len, enable, spellName, spellIconPath
end
end
end
 
 
 
-- Wrapper around GetItemCooldown
-- Expected to return start, cd_len, enable, buffName, iconpath
function NeedToKnow.GetItemCooldown(bar, item_id)
local start, cd_len, enable = GetItemCooldown(item_id)
if start then
local name, _, _, _, _, _, _, _, icon = GetItemInfo(item_id)
return start, cd_len, enable, name, icon
end
end
 
 
-- Called whenever the state of auras on the bar's unit may have changed
function NeedToKnow.Bar_AuraCheck(bar)
local buffName, count, duration, expirationTime, caster, iconPath
1408,87 → 1488,33
caster = "player"
end
elseif settings.BuffOrDebuff == "CASTCD" then
local spellName=barSpell, spellRank, spellIconPath
local spellPower=0
if isSpellID or NeedToKnow.is_DK then
spellName, spellRank, spellIconPath, _, _, spellPower = GetSpellInfo(barSpell)
local start, cd_len, should_cooldown
local func = bar.functions[idxName]
start, cd_len, should_cooldown, buffName, iconPath = func(bar, barSpell)
 
-- filter out the GCD, we only care about actual spell CDs
if start and cd_len <= 1.5 and func ~= NeedToKnow.GetAutoShotCooldown then
if bar.expirationTime then
start = bar.expirationTime - bar.duration
cd_len = bar.duration
else
start = nil
end
end
if ( settings.bAutoShot and (barSpell == "Auto Shot" or barSpell == NEEDTOKNOW.AUTO_SHOT or barSpell == "75") ) then
 
if start and cd_len then
local tNow = GetTime()
if ( bar.tAutoShotExpires and bar.tAutoShotExpires > tNow ) then
buffName = NEEDTOKNOW.AUTO_SHOT
local tEnd = start + cd_len
if ( tEnd > tNow + 0.1 ) then
count = 1
duration = bar.tAutoShotCD
expirationTime = bar.tAutoShotExpires
caster = "player"
duration = cd_len
expirationTime = tEnd
cast = "player"
end
else
local tNow = GetTime()
local start, cd_len, should_cooldown = GetSpellCooldown(barSpell)
local is_spell = true
if not start then
start, cd_len = GetItemCooldown(barSpell)
is_spell = false
end
 
if is_spell and start and start > 0 then
if 0 == should_cooldown then
-- Filter out conditions like Stealth while stealthed
start = nil
elseif spellPower == 5 then -- Rune
-- Filter out rune cooldown artificially extending the cd
if cd_len <= 10 then
if bar.expirationTime and tNow < bar.expirationTime then
-- We've already seen the correct CD for this; keep using it
start = bar.expirationTime - bar.duration
cd_len = bar.duration
elseif NeedToKnow.last_sent and NeedToKnow.last_sent[barSpell] and NeedToKnow.last_sent[barSpell] > (tNow - 1.5) then
-- We think the spell was just cast, and a CD just started but it's short.
-- Look at the tooltip to tell what the correct CD should be. If it's supposed
-- to be short (Ghoul Frenzy, Howling Blast), then start a CD bar
cd_len = NeedToKnow.DetermineShortCooldownFromTooltip(barSpell)
if cd_len == 0 or cd_len > 10 then
start = nil
end
else
start = nil
end
end
end
end
 
-- filter out the GCD, we only care about actual spell CDs
if cd_len <= 1.5 then
if not bar.expirationTime or bar.expirationTime < tNow then
start = nil
else
start = bar.expirationTime - bar.duration
cd_len = bar.duration
end
end
 
if start and cd_len then
local tEnd = start + cd_len
if ( tEnd > tNow + 0.1 ) then
if is_spell then
buffName, _, iconPath = GetSpellInfo(barSpell)
else
buffName, _, _, _, _, _, _, _, _, iconPath = GetItemInfo(barSpell)
end
if not buffName then buffName = barSpell end
 
count = 1
duration = cd_len
expirationTime = tEnd
cast = "player"
end
end
end
elseif settings.BuffOrDebuff == "USABLE" then
local _, nDigits = barSpell:find("^%d+")
local isSpellID = ( nDigits == barSpell:len() )
local key = barSpell
if ( isSpellID ) then key = tonumber(barSpell) end
local key
if ( isSpellID ) then key = tonumber(barSpell) else key = barSpell end
if ( not key ) then key = "" end
local spellName
spellName, _, iconPath = GetSpellInfo(key)