/
{ Setting = "TOTEM", MenuText = NEEDTOKNOW.BARMENU_TOTEM }, |
{ Setting = "CASTCD", MenuText = NEEDTOKNOW.BARMENU_CASTCD }, |
{ Setting = "BUFFCD", MenuText = NEEDTOKNOW.BARMENU_BUFFCD }, |
{ Setting = "USABLE", MenuText = NEEDTOKNOW.BARMENU_USABLE }, |
-- Now that Victory Rush adds a buff when you can use it, this confusing option is being removed. |
-- The code that drives it remains so that any existing users' bars won't break. |
-- { Setting = "USABLE", MenuText = NEEDTOKNOW.BARMENU_USABLE }, |
{ Setting = "EQUIPSLOT", MenuText = NEEDTOKNOW.BARMENU_EQUIPSLOT }, |
}, |
TimeFormat = { |
{ Setting = "vehicle", MenuText = NEEDTOKNOW.BARMENU_VEHICLE }, |
{ Setting = "mhand", MenuText = NEEDTOKNOW.BARMENU_MAIN_HAND }, |
{ Setting = "ohand", MenuText = NEEDTOKNOW.BARMENU_OFF_HAND }, |
{ Setting = "lastraid", MenuText = NEEDTOKNOW.BARMENU_LAST_RAID }, |
}, |
DebuffUnit = { |
{ Setting = "player", MenuText = NEEDTOKNOW.BARMENU_PLAYER }, |
}, |
total = 0 |
} |
NeedToKnow.scratch.bar_entry = |
{ |
idxName = 0, |
barSpell = "", |
isSpellID = false, |
} |
-- NEEDTOKNOW = {} is defined in the localization file, which must be loaded before this file |
NEEDTOKNOW.VERSION = "4.0.02" |
NEEDTOKNOW.VERSION = "4.0.03" |
NEEDTOKNOW.UPDATE_INTERVAL = 0.05 |
NEEDTOKNOW.MAXBARS = 20 |
end |
end |
function NeedToKnow.ExecutiveFrame_UNIT_SPELLCAST_SENT(unit, spell, tgt, serialno) |
function NeedToKnow.ExecutiveFrame_UNIT_SPELLCAST_SENT(unit, spell, rank_str, tgt, serialno) |
if unit == "player" then |
-- TODO: I hate to pay this memory cost for every "spell" ever cast. |
-- Would be nice to at least garbage collect this data at some point, but that |
if ( NeedToKnow.last_guid[spell] or NeedToKnow.BarsForPSS ) then |
local r = NeedToKnow.last_cast[NeedToKnow.last_cast_tail] |
if not r then |
r = { spell=spell, target=target, serial=serialno } |
r = { spell=spell, target=tgt, serial=serialno } |
NeedToKnow.last_cast[NeedToKnow.last_cast_tail] = r |
else |
r.spell = spell |
r.target = target |
r.target = tgt |
r.serial = serialno |
end |
NeedToKnow.last_cast_tail = NeedToKnow.last_cast_tail + 1 |
if ( NeedToKnow.last_cast_tail == 1 ) then |
NeedToKnow.last_cast_head = 0 |
if ( NeedToKnow.last_cast_tail == 2 ) then |
NeedToKnow.last_cast_head = 1 |
if ( NeedToKnow.last_guid[spell] ) then |
NeedToKnow_ExecutiveFrame:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
NeedToKnow_ExecutiveFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
end |
function NeedToKnow.ExecutiveFrame_UNIT_SPELLCAST_SUCCEEDED(unit, spell, serialno, spellid) |
function NeedToKnow.ExecutiveFrame_UNIT_SPELLCAST_SUCCEEDED(unit, spell, rank_str, serialno, spellid) |
if unit == "player" then |
local found |
local t = NeedToKnow.last_cast |
break |
end |
end |
if found then |
if ( NeedToKnow.BarsForPSS ) then |
local bar,one |
for bar,one in pairs(NeedToKnow.BarsForPSS) do |
NeedToKnow.Bar_OnEvent(bar, "PLAYER_SPELLCAST_SUCCEEDED", spell, spellid, t[i].target); |
local unitTarget = NeedToKnow.raid_members[t[found].target or ""] |
NeedToKnow.Bar_OnEvent(bar, "PLAYER_SPELLCAST_SUCCEEDED", "player", spell, spellid, unitTarget); |
end |
end |
if ( found == last ) then |
NeedToKnow.last_cast_tail = 0 |
NeedToKnow.last_cast_head = 0 |
NeedToKnow.last_cast_tail = 1 |
NeedToKnow.last_cast_head = 1 |
NeedToKnow_ExecutiveFrame:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
else |
NeedToKnow.last_cast_head = found+1 |
if ( NeedToKnow.BarsForPSS ) then |
local bar,one |
for bar,one in pairs(NeedToKnow.BarsForPSS) do |
NeedToKnow.Bar_OnEvent(bar, "PLAYER_SPELLCAST_SUCCEEDED", spell, spellid, t[i].target); |
local unitTarget = NeedToKnow.raid_members[t[found].target or ""] |
NeedToKnow.Bar_OnEvent(bar, "PLAYER_SPELLCAST_SUCCEEDED", "player", spell, spellid, unitTarget); |
end |
end |
end |
if ( found == last ) then |
NeedToKnow.last_cast_tail = 0 |
NeedToKnow.last_cast_head = 0 |
NeedToKnow.last_cast_tail = 1 |
NeedToKnow.last_cast_head = 1 |
NeedToKnow_ExecutiveFrame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
else |
NeedToKnow.last_cast_head = found+1 |
end |
NeedToKnow.last_cast = {} -- [n] = { spell, target, serial } |
NeedToKnow.last_cast_head = 0 |
NeedToKnow.last_cast_tail = 0 |
NeedToKnow.last_cast_head = 1 |
NeedToKnow.last_cast_tail = 1 |
NeedToKnow.last_guid = {} -- [spell][guidTarget] = { time, dur, expiry } |
NeedToKnow.totem_drops = {} -- array 1-4 of precise times the totems appeared |
NeedToKnow.weapon_enchants = { mhand = {}, ohand = {} } |
NeedToKnow_ExecutiveFrame:RegisterEvent("UNIT_TARGET") |
NeedToKnow_ExecutiveFrame:RegisterEvent("PLAYER_REGEN_DISABLED") |
NeedToKnow_ExecutiveFrame:RegisterEvent("PLAYER_REGEN_ENABLED") |
NeedToKnow_ExecutiveFrame:RegisterEvent("PARTY_MEMBERS_CHANGED") |
if ( NeedToKnow.is_DK ) then |
NeedToKnow.RegisterSpellcastSent(); |
end |
NeedToKnow.ExecutiveFrame_PLAYER_LOGIN = nil |
NeedToKnowLoader = nil |
NeedToKnow.RefreshRaidMemberNames() |
NeedToKnow.UpdateWeaponEnchants() |
end |
end |
function NeedToKnow.RefreshRaidMemberNames() |
NeedToKnow.raid_members = {} |
if GetNumRaidMembers() > 0 then |
for i = 1, 40 do |
local unit = "raid"..i |
local name = UnitName(unit) |
if ( name ) then NeedToKnow.raid_members[name] = unit end |
end |
elseif GetNumPartyMembers() > 0 then |
for i = 1, 5 do |
local unit = "party"..i |
local name = UnitName(unit) |
if ( name ) then NeedToKnow.raid_members[name] = unit end |
end |
end |
local unit = "player" |
local name = UnitName(unit) |
NeedToKnow.raid_members[name] = unit |
unit = "pet" |
name = UnitName(unit) |
if ( name ) then |
NeedToKnow.raid_members[name] = unit |
end |
end |
function NeedToKnow.ExecutiveFrame_PARTY_MEMBERS_CHANGED() |
NeedToKnow.RefreshRaidMemberNames(); |
end |
function NeedToKnow.ExecutiveFrame_PLAYER_REGEN_DISABLED(unitTargeting) |
NeedToKnow.bInCombat = true |
NeedToKnow.bCombatWithBoss = false |
bar.cd_functions[idx] = NeedToKnow.GetSpellCooldown |
elseif not GetSpellCooldown(name) then |
bar.cd_functions[idx] = NeedToKnow.GetUnresolvedCooldown |
else |
bar.cd_functions[idx] = NeedToKnow.GetSpellCooldown |
end |
end |
end |
bar.cd_functions = {} |
local iSpell = 0 |
for barSpell in bar.auraName:gmatch("([^,]+)") do |
iSpell = iSpell+1 |
barSpell = strtrim(barSpell) |
local _, nDigits = barSpell:find("^%d+") |
if ( nDigits == barSpell:len() ) then |
else |
table.insert(bar.spells, { idxName=iSpell, name=barSpell } ) |
end |
iSpell = iSpell+1 |
end |
-- split the user name overrides |
bar.reset_start = {} |
iSpell = 0 |
for resetSpell in barSettings.buffcd_reset_spells:gmatch("([^,]+)") do |
iSpell = iSpell+1 |
resetSpell = strtrim(resetSpell) |
local _, nDigits = resetSpell:find("^%d+") |
if ( nDigits == resetSpell:len() ) then |
bar:RegisterEvent("SPELL_UPDATE_USABLE") |
elseif ( "mhand" == bar.settings.Unit or "ohand" == bar.settings.Unit ) then |
bar:RegisterEvent("UNIT_INVENTORY_CHANGED") |
elseif ( bar.unit == "targettarget" ) then |
elseif ( bar.settings.Unit == "targettarget" ) then |
-- WORKAROUND: PLAYER_TARGET_CHANGED happens immediately, UNIT_TARGET every couple seconds |
bar:RegisterEvent("PLAYER_TARGET_CHANGED") |
bar:RegisterEvent("UNIT_TARGET") |
bar:RegisterEvent("PLAYER_TARGET_CHANGED") |
elseif ( bar.unit == "pet" ) then |
bar:RegisterEvent("UNIT_PET") |
elseif ( "lastraid" == bar.settings.Unit ) then |
if ( not NeedToKnow.BarsForPSS ) then |
NeedToKnow.BarsForPSS = {} |
end |
NeedToKnow.BarsForPSS[bar] = true |
NeedToKnow.RegisterSpellcastSent() |
end |
end |
elseif ( event == "UNIT_PET" and unit == "player" ) then |
NeedToKnow.Bar_AuraCheck(self) |
elseif ( event == "PLAYER_SPELLCAST_SUCCEEDED" ) then |
--if ( self.settings.Unit == "lastcast" ) then |
--end |
local spellName, spellID, tgt = select(1,...) |
local i,entry |
for i,entry in ipairs(self.spells) do |
if entry.id == spellID or entry.name == spellName then |
self.unit = tgt or "unknown" |
--trace("Updating",self:GetName(),"since it was recast on",self.unit) |
NeedToKnow.Bar_AuraCheck(self) |
break; |
end |
end |
elseif ( event == "START_AUTOREPEAT_SPELL" ) then |
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
elseif ( event == "STOP_AUTOREPEAT_SPELL" ) then |
function NeedToKnow.PrettyName(barSettings) |
if ( barSettings.BuffOrDebuff == "EQUIPSLOT" ) then |
return NEEDTOKNOW.ITEM_NAMES[tonumber(barSettings.AuraName)] |
local idx = tonumber(barSettings.AuraName) |
if idx then return NEEDTOKNOW.ITEM_NAMES[idx] end |
return "" |
else |
return barSettings.AuraName |
end |
local idxName = bar_entry.idxName |
local func = bar.cd_functions[idxName] |
if ( not func ) then |
trace("ERROR setting up index",idxName,"on bar",bar:GetName(),bar.settings.AuraName); |
print("NTK ERROR setting up index",idxName,"on bar",bar:GetName(),bar.settings.AuraName); |
return; |
end |
local start, cd_len, should_cooldown, buffName, iconPath = func(bar, bar_entry) |
else |
local buffName, _ , iconPath, count, _, duration, expirationTime, caster |
= UnitAura(bar.unit, bar_entry.name, nil, filter) |
AddInstanceToStacks( all_stacks, bar_entry, |
duration, -- duration |
buffName, -- name |
bUnitExists = true |
elseif "player" == settings.Unit then |
bUnitExists = true |
elseif "lastraid" == settings.Unit then |
bUnitExists = bar.unit and UnitExists(bar.unit) |
else |
bUnitExists = UnitExists(settings.Unit) |
end |
local r = NeedToKnow.last_guid[buffName] |
if ( not r[guidTarget] ) then -- Should only happen from /reload or /ntk while the aura is active |
trace("WARNING! allocating guid slot for ", buffName, "on", guidTarget, "due to UNIT_AURA"); |
-- This went off for me, but I don't know a repro yet. I suspect it has to do with bear/cat switching |
--trace("WARNING! allocating guid slot for ", buffName, "on", guidTarget, "due to UNIT_AURA"); |
r[guidTarget] = { time=curStart, dur=duration, expiry=expirationTime } |
else |
r = r[guidTarget] |
local oldExpiry = r.expiry |
if ( oldExpiry > 0 and oldExpiry < curStart ) then |
trace("WARNING! stale entry for ",buffName,"on",guidTarget,curStart-r.time,curStart-oldExpiry) |
end |
-- This went off for me, but I don't know a repro yet. I suspect it has to do with bear/cat switching |
--if ( oldExpiry > 0 and oldExpiry < curStart ) then |
--trace("WARNING! stale entry for ",buffName,"on",guidTarget,curStart-r.time,curStart-oldExpiry) |
--end |
if ( oldExpiry < curStart ) then |
r.time = curStart |
NEEDTOKNOW.BARMENU_VEHICLE = "Vehicle"; |
NEEDTOKNOW.BARMENU_TARGETTARGET = "Target of Target"; |
NEEDTOKNOW.BARMENU_BUFFORDEBUFF = "Bar Type"; |
NEEDTOKNOW.BARMENU_LAST_RAID = "Last Raid Recipient"; |
NEEDTOKNOW.BARMENU_SPELLID = "Use SpellID"; |
NEEDTOKNOW.BARMENU_HELPFUL = "Buff"; |
NEEDTOKNOW.BARMENU_HARMFUL = "Debuff"; |