annotate Turok/Turok.lua @ 6:a9b8b0866ece

clear out log jam
author Nenue
date Sun, 21 Feb 2016 08:32:53 -0500
parents
children 9400a0ff8540
rev   line source
Nenue@6 1 --- Turok
Nenue@6 2 -- @file-author@
Nenue@6 3 -- @project-revision@ @project-hash@
Nenue@6 4 -- @file-revision@ @file-hash@
Nenue@6 5 --- Defines the mechanisms for the storage and dispatch of events data.
Nenue@6 6 --@debug@
Nenue@6 7 --@end-debug@
Nenue@6 8 -- GLOBALS: LibStub, Turok, TurokData, ReloadUI
Nenue@6 9 local ADDON, Tk = ...
Nenue@6 10 local db, L
Nenue@6 11 local MAJOR, MINOR = "Turok", "@project-revision@"
Nenue@6 12 local T, LGIST, _G = Tk.Addon, Tk.LGIST, _G
Nenue@6 13
Nenue@6 14
Nenue@6 15 local pcall, type, ipairs, pairs, format, tinsert, match, strpad, error = pcall, type, ipairs, pairs, string.format, table.insert, string.match, string.rep, error
Nenue@6 16 local PlaySoundFile, LoadAddOn, IsAddOnLoaded, UnitName, UnitGUID, UnitPowerMax = PlaySoundFile, LoadAddOn, IsAddOnLoaded, UnitName, UnitGUID, UnitPowerMax
Nenue@6 17 local GetSpecializationInfo, GetSpecialization, UnitSpellHaste, GetActiveSpecGroup = GetSpecializationInfo, GetSpecialization, UnitSpellHaste, GetActiveSpecGroup
Nenue@6 18 local UnitInfo, UnitCastingInfo, UnitChannelInfo = UnitInfo, UnitCastingInfo, UnitChannelInfo
Nenue@6 19 local rawset, unpack, tostring, setmetatable, xpcall, unpack = rawset, unpack, tostring, setmetatable, xpcall, unpack
Nenue@6 20
Nenue@6 21 --@debug@
Nenue@6 22 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool
Nenue@6 23 local print = function(...)
Nenue@6 24 if _G.Devian and _G.DevianDB.workspace ~= 1 then
Nenue@6 25 _G.print('Turok', ...)
Nenue@6 26 end
Nenue@6 27 end
Nenue@6 28 local GetPrint = function(trace)
Nenue@6 29 return trace and print or function() end
Nenue@6 30 end
Nenue@6 31 --@end-debug@
Nenue@6 32
Nenue@6 33
Nenue@6 34
Nenue@6 35 --- Pull saved variables and make them sane
Nenue@6 36 function T.OnInitialize(T)
Nenue@6 37
Nenue@6 38 --@debug@
Nenue@6 39 local tmpidx
Nenue@6 40 if TurokData and TurokData.spirit and TurokData.spirit.timerindex then
Nenue@6 41 tmpidx = TurokData.spirit.timerindex
Nenue@6 42 end
Nenue@6 43 TurokData = Turok.defaults
Nenue@6 44 if tmpidx then
Nenue@6 45 TurokData.spirit.timerindex = tmpidx
Nenue@6 46 end
Nenue@6 47 --@end-debug@
Nenue@6 48 T.db = _G.TurokData
Nenue@6 49 LibStub("LibFog-1.0"):Embed(T)
Nenue@6 50 if T.db.queue_for_wipe then
Nenue@6 51 T:Print("db reset flag received")
Nenue@6 52 local index = _G.TurokData.spirit.timerindex
Nenue@6 53 _G.TurokData = T.defaults
Nenue@6 54 T.db = _G.TurokData
Nenue@6 55 T.db.spirit.timerindex = index
Nenue@6 56 end
Nenue@6 57
Nenue@6 58 T:RegisterChatCommand("tkr", function()
Nenue@6 59 T.db.queue_for_wipe = true
Nenue@6 60 ReloadUI()
Nenue@6 61 end)
Nenue@6 62
Nenue@6 63 -- db hierarchy
Nenue@6 64 for k, v in pairs(T.db) do
Nenue@6 65 if type(v) == 'table' then
Nenue@6 66 --@debug@
Nenue@6 67 --print('|cFF44FF88loading stored db|r: db.|cFF44AAFF'.. k ..'|r')--@end-debug@
Nenue@6 68 T.LinkTable(T.db, v, 'db', k)
Nenue@6 69 end
Nenue@6 70 end
Nenue@6 71 setmetatable(T.db,
Nenue@6 72 {__newindex = function (t, k, v)
Nenue@6 73 rawset(t,k,v)
Nenue@6 74 if type(v) == 'table' then
Nenue@6 75 --@debug@
Nenue@6 76 --print('|cFF44FF88creating new db|r: db.|cFF44AAFF'.. k ..'|r')--@end-debug@
Nenue@6 77 T.LinkTable(T.db, v, 'db', k)
Nenue@6 78 end
Nenue@6 79 end})
Nenue@6 80 T.L = setmetatable({}, {__call = function(t, s) return t[s] or s end})
Nenue@6 81 end
Nenue@6 82
Nenue@6 83 --- Get everything rolling
Nenue@6 84 function T:OnEnable()
Nenue@6 85 db = TurokData
Nenue@6 86 L = T.L
Nenue@6 87
Nenue@6 88 self.dispatchQueue = {}
Nenue@6 89 self.sharedTables = {}
Nenue@6 90 local skip = {modules = true, db = true, defaultModuleLibraries = true, orderedModules = true, prototype = true, events = true} -- local data that exists before init
Nenue@6 91 for id, mod in pairs(self.orderedModules) do
Nenue@6 92 mod.ID = id
Nenue@6 93 mod.RegisterCallback = self.RegisterCallback
Nenue@6 94 print('load', mod:GetName())
Nenue@6 95 for k, v in pairs(mod) do
Nenue@6 96 if not skip[k] then
Nenue@6 97 if match(k, '^[%u_]+$') then
Nenue@6 98 if not self.dispatchQueue[k] then
Nenue@6 99 self.dispatchQueue[k] = {}
Nenue@6 100 end
Nenue@6 101 self:RegisterEvent(k, 'Dispatch')
Nenue@6 102 self.dispatchQueue[k][id] = mod:GetName()
Nenue@6 103 end
Nenue@6 104 end
Nenue@6 105 end
Nenue@6 106 end
Nenue@6 107
Nenue@6 108 print('events')
Nenue@6 109 for k, v in pairs(self.dispatchQueue) do
Nenue@6 110 print(' ',k,'->', unpack(v))
Nenue@6 111 end
Nenue@6 112
Nenue@6 113 print('shared')
Nenue@6 114 for k, v in pairs(self.sharedTables) do
Nenue@6 115 print(' ',k)
Nenue@6 116 end
Nenue@6 117 --@debug@
Nenue@6 118 self:Print(MAJOR, MINOR, 'enabled.')--@end-debug@
Nenue@6 119 self:RegisterChatCommand("tkl", function()
Nenue@6 120 PlaySoundFile([[Interface\Addons\Turok\Media\sound\wilhelm.ogg]])
Nenue@6 121 if not IsAddOnLoaded("Turok_Config") then
Nenue@6 122 local loaded, message = LoadAddOn("Turok_Config")
Nenue@6 123 if not loaded then
Nenue@6 124 return T:Print("|cFFFF0000Load-on-Demand failed!|r Reason: " .. message)
Nenue@6 125 end
Nenue@6 126 --self.config = LibStub('AceConfigDialog-3.0'):AddToBlizOptions(MAJOR)
Nenue@6 127 end
Nenue@6 128 InterfaceOptionsFrame_OpenToCategory(MAJOR)
Nenue@6 129 InterfaceOptionsFrame_OpenToCategory(MAJOR)
Nenue@6 130 end)
Nenue@6 131
Nenue@6 132 self:RegisterChatCommand("unlock", function()
Nenue@6 133 T.unlocked = (not T.unlocked) and true or nil
Nenue@6 134 if T.unlocked then
Nenue@6 135 self:Print('frames unlocked')
Nenue@6 136 else
Nenue@6 137 self:Print('frames locked')
Nenue@6 138 end
Nenue@6 139 for k, v in pairs(self.orderedModules) do
Nenue@6 140 if v.UpdateLocked then
Nenue@6 141 v:UpdateLocked()
Nenue@6 142 end
Nenue@6 143 end
Nenue@6 144 end)
Nenue@6 145
Nenue@6 146 self:RegisterChatCommand("lsm", function(input)
Nenue@6 147 local a1, n = self:GetArgs(input, 1,0)
Nenue@6 148 local a2 = self:GetArgs(input, 1, n)
Nenue@6 149 self:Print(self.LSM:Fetch(a1, a2))
Nenue@6 150 end)
Nenue@6 151
Nenue@6 152 local name, realm = UnitFullName('player')
Nenue@6 153 LGIST.RegisterCallback(self, "GroupInSpecT_InspectReady", 'GIST_InspectReady')
Nenue@6 154 LGIST.RegisterCallback(self, "GroupInSpecT_Update", 'GIST_Update')
Nenue@6 155 self:RegisterCharacterInfo(name, realm)
Nenue@6 156
Nenue@6 157 if InCombatLockdown() then
Nenue@6 158 T.inCombat = true
Nenue@6 159 end
Nenue@6 160
Nenue@6 161 T:PLAYER_SPECIALIZATION_CHANGED('PLAYER_SPECIALIZATION_CHANGED','player')
Nenue@6 162 for order, event in ipairs(self.events) do
Nenue@6 163 self:RegisterEvent(event, 'Dispatch')
Nenue@6 164 end
Nenue@6 165 end
Nenue@6 166
Nenue@6 167 do
Nenue@6 168 local bucket_events = {['PLAYER_SPECIALIZATION_CHANGED'] = {}, ['PLAYER_TALENT_UPDATE'] = {}}
Nenue@6 169 local bucket_start = {}
Nenue@6 170 local event_queue = {}
Nenue@6 171 local wipe, debugstack = table.wipe, debugstack
Nenue@6 172
Nenue@6 173 --- Passes event data to the appropriate handlers, and runs any callback returned
Nenue@6 174 -- @param e event name
Nenue@6 175 -- @param ... event arguments as given by WoW Lua
Nenue@6 176 -- @return callback1 runs after its corresponding method has been dispatched to
Nenue@6 177 -- @return callback2 runs after all dispatching has completed, in the order that dispatches occurred
Nenue@6 178 function T:Dispatch(event, ...)
Nenue@6 179 if not (self[event] or self.dispatchQueue[event]) then
Nenue@6 180 return
Nenue@6 181 end
Nenue@6 182
Nenue@6 183
Nenue@6 184 if bucket_events[event] then
Nenue@6 185 local unit = ...
Nenue@6 186 if unit and unit ~= 'player' then
Nenue@6 187 return
Nenue@6 188 end
Nenue@6 189
Nenue@6 190 print(cText('*** Bucket Event:'), cWord(event))
Nenue@6 191 if not bucket_start[event] then
Nenue@6 192 self['TKBATCH_'..event] = {}
Nenue@6 193 bucket_start[event] = GetTime()
Nenue@6 194 T:ScheduleTimer( function()
Nenue@6 195 print('*** Firing bucketed event ('..#bucket_events[event]..'):', event, unpack(bucket_events[event][#bucket_events[event]]))
Nenue@6 196 T:Dispatch('TKBATCH_'..event, unpack(bucket_events[event][#bucket_events[event]]))
Nenue@6 197 bucket_start[event] = nil
Nenue@6 198
Nenue@6 199 self['TKBATCH_'..event] = nil
Nenue@6 200 end,0.1)
Nenue@6 201 end
Nenue@6 202 tinsert(bucket_events[event], {...})
Nenue@6 203 return
Nenue@6 204 else
Nenue@6 205 event = event:gsub('^TKBATCH_', '')
Nenue@6 206 end
Nenue@6 207
Nenue@6 208
Nenue@6 209 if event ~= 'COMBAT_LOG_EVENT_UNFILTERED' then print('|cFFFF0088received|r', event, ...) end
Nenue@6 210 local args = {event, ...}
Nenue@6 211
Nenue@6 212 -- if addon is listening directly
Nenue@6 213 if self[event] then
Nenue@6 214 print(cWord(event))
Nenue@6 215 local reg = function() print(unpack(args)) self[event](self, unpack(args)) end
Nenue@6 216 tinsert(event_queue, {self, event, reg})
Nenue@6 217
Nenue@6 218
Nenue@6 219 -- if modules want this event directly
Nenue@6 220 end
Nenue@6 221 if self.dispatchQueue[event] then
Nenue@6 222 for id, name in pairs(self.dispatchQueue[event]) do
Nenue@6 223 local mod = self.orderedModules[id]
Nenue@6 224 local reg = function() print(unpack(args)) mod[event](mod, unpack(args)) end
Nenue@6 225 tinsert(event_queue, {mod, event, reg})
Nenue@6 226 end
Nenue@6 227 else
Nenue@6 228 print("Received", event, "but nothing is listening to it.")
Nenue@6 229 end
Nenue@6 230
Nenue@6 231 for i, entry in ipairs(event_queue) do
Nenue@6 232 local handler, event, func = unpack(entry)
Nenue@6 233 print('->', cWord(handler:GetName()), cBool(result), cText(message))
Nenue@6 234 local result, message = xpcall(func, function(m) print(m, debugstack()) return debugstack() end)
Nenue@6 235
Nenue@6 236 if bucket_events[event] then
Nenue@6 237 wipe(bucket_events[event])
Nenue@6 238 bucket_events[event].history = {}
Nenue@6 239 end
Nenue@6 240 end
Nenue@6 241 wipe(event_queue)
Nenue@6 242 end
Nenue@6 243 end
Nenue@6 244 --- Store character data to speed up spec-specific load time
Nenue@6 245 function T:RegisterCharacterInfo(name,realm)
Nenue@6 246 local classLocalized, classEnglish, classID = UnitClass('player')
Nenue@6 247
Nenue@6 248 -- set savedvars
Nenue@6 249 self.playerName = name
Nenue@6 250 self.playerRealm = realm
Nenue@6 251 self.playerClass = classEnglish
Nenue@6 252 self.playerClassLocalized = classLocalized
Nenue@6 253 self.playerClassID = classID
Nenue@6 254 self.GUID = UnitGUID('player')
Nenue@6 255 local namerealm = name..'-'..realm
Nenue@6 256 if not db.char[namerealm] then
Nenue@6 257 db.char[namerealm] = {
Nenue@6 258 spellBook = {}
Nenue@6 259 }
Nenue@6 260 end
Nenue@6 261 T.spellBook = db.char[namerealm].spellBook
Nenue@6 262
Nenue@6 263 -- push combat ratings calc
Nenue@6 264 self:COMBAT_RATING_UPDATE()
Nenue@6 265 end
Nenue@6 266
Nenue@6 267 --- Polls for specialization info until it's available
Nenue@6 268 function T:RegisterSpecEvents()
Nenue@6 269 local specPage = GetSpecialization()
Nenue@6 270 if specPage then
Nenue@6 271
Nenue@6 272 local specID, specName, specDesc, specTexture = GetSpecializationInfo(specPage)
Nenue@6 273 local specGroup = GetActiveSpecGroup()
Nenue@6 274 print('Turok', cText('* Spec Info:'), GetSpecializationInfo(GetSpecialization()))
Nenue@6 275 if T.specID and specID ~= T.specID then
Nenue@6 276 print('pushing out old spec data')
Nenue@6 277 T.previousSpec = {
Nenue@6 278 specPage = T.specPage,
Nenue@6 279 specGroup = T.specGroup,
Nenue@6 280 specID = T.specID,
Nenue@6 281 specName = T.specName,
Nenue@6 282 specTexture = T.specTexture
Nenue@6 283 }
Nenue@6 284 elseif not T.previousSpec then
Nenue@6 285 print('first run probably')
Nenue@6 286 T.previousSpec = {}
Nenue@6 287 end
Nenue@6 288
Nenue@6 289
Nenue@6 290 T.specUpdate = (specID ~= T.specID)
Nenue@6 291 T.talentsChanged = (T.specGroup ~= specGroup)
Nenue@6 292 T.specPage = specPage
Nenue@6 293 T.specGroup = specGroup
Nenue@6 294 T.specID = specID
Nenue@6 295 T.specName = specName
Nenue@6 296 T.specTexture = specTexture
Nenue@6 297 else
Nenue@6 298 print('Turok', cText('* No Spec Info yet, start polling'))
Nenue@6 299 -- repeat until we get something to update with
Nenue@6 300 T:ScheduleTimer('RegisterSpecEvents', 1)
Nenue@6 301 end
Nenue@6 302
Nenue@6 303 if T.specID and not T.__specevents then
Nenue@6 304 T.__specevents = true
Nenue@6 305 T:PLAYER_SPECIALIZATION_CHANGED('PLAYER_SPECIALIZATION_CHANGED','player')
Nenue@6 306 T:RegisterEvent('PLAYER_TALENT_UPDATE', 'Dispatch')
Nenue@6 307 T:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', 'Dispatch')
Nenue@6 308 T:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED', 'Dispatch')
Nenue@6 309 T:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', 'Dispatch')
Nenue@6 310 end
Nenue@6 311 end
Nenue@6 312
Nenue@6 313 --- Event handler wrapper for the Specialization getter used at load time
Nenue@6 314 local GetSpecializationSpells, GetSpellInfo = GetSpecializationSpells, GetSpellInfo
Nenue@6 315 function T:PLAYER_SPECIALIZATION_CHANGED(event, unit)
Nenue@6 316 -- make sure this was fired for player
Nenue@6 317 if (unit ~= 'player') then
Nenue@6 318 return
Nenue@6 319 end
Nenue@6 320
Nenue@6 321
Nenue@6 322 print('Turok', '|cFF00FF00'.. event)
Nenue@6 323 -- Set current spec values and fill out previousSpec table
Nenue@6 324 T:RegisterSpecEvents()
Nenue@6 325 local ot = T.previousSpec
Nenue@6 326
Nenue@6 327 -- Is the new spec different?
Nenue@6 328 if T.specUpdate then
Nenue@6 329 print(cText('Spec changed from'), cWord(ot.specName), cText('to'), cKey(T.specName))
Nenue@6 330
Nenue@6 331 if ot.specPage and not T.spellBook[ot.specPage] then
Nenue@6 332 T.spellBook[ot.specPage] = {}
Nenue@6 333 end
Nenue@6 334
Nenue@6 335 local spellBook = {GetSpecializationSpells(T.specPage)}
Nenue@6 336 if not T.spellBook[T.specPage] then
Nenue@6 337 T.spellBook[T.specPage] = {}
Nenue@6 338 for i = 1, #spellBook, 2 do
Nenue@6 339 T.spellBook[T.specPage][spellBook[i]] = GetSpellInfo(spellBook[i])
Nenue@6 340 if (not ot.specPage) or (T.spellBook[ot.specPage] and not T.spellBook[ot.specPage][spellBook[i]]) then
Nenue@6 341 print(cText('activating for spell'), T.spellBook[T.specPage][spellBook[i]])
Nenue@6 342 end
Nenue@6 343 end
Nenue@6 344 end
Nenue@6 345
Nenue@6 346
Nenue@6 347
Nenue@6 348 -- list changed spells for use by spell posession checks
Nenue@6 349 local diff = {
Nenue@6 350 gained = {},
Nenue@6 351 lost = {}
Nenue@6 352 }
Nenue@6 353
Nenue@6 354 --- Check against current for removed spells
Nenue@6 355 if T.spellBook[ot.specPage] then
Nenue@6 356 for id, spellInfo in pairs(T.spellBook[ot.specPage]) do
Nenue@6 357 if not T.spellBook[ot.specPage] then
Nenue@6 358 tinsert(diff.lost, spellInfo)
Nenue@6 359 print('lost', spellInfo.spellName)
Nenue@6 360 else
Nenue@6 361 print('keep', spellInfo.spellName)
Nenue@6 362 end
Nenue@6 363 end
Nenue@6 364 end
Nenue@6 365
Nenue@6 366 T.spellBook.change = diff
Nenue@6 367 end
Nenue@6 368 end
Nenue@6 369
Nenue@6 370 local GetInventoryItemID, GetItemSpell, GetSpellInfo, GetItemInfo = GetInventoryItemID, GetItemSpell, GetSpellInfo, GetItemInfo
Nenue@6 371 function T:PLAYER_EQUIPMENT_CHANGED(event, slot, hasItem)
Nenue@6 372 print('Equip slot #', slot, ' has?', hasItem)
Nenue@6 373 if hasItem then
Nenue@6 374 local itemID = GetInventoryItemID('player', slot)
Nenue@6 375 print('itemID?', itemID)
Nenue@6 376 local spellName = GetItemSpell(itemID)
Nenue@6 377 print('spell?', spellName)
Nenue@6 378 local _, spellID
Nenue@6 379 if spellName then
Nenue@6 380 _, _, _, _, _, _, spellID = GetSpellInfo(spellName)
Nenue@6 381 end
Nenue@6 382
Nenue@6 383 local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID)
Nenue@6 384 T.equipped[slot] = {
Nenue@6 385 itemID = itemID,
Nenue@6 386 spellName = spellName,
Nenue@6 387 spellID = spellID,
Nenue@6 388 name = name,
Nenue@6 389 link = link,
Nenue@6 390 equipSlot = equipSlot,
Nenue@6 391 texture = texture,
Nenue@6 392 }
Nenue@6 393 print('equipped', name)
Nenue@6 394
Nenue@6 395 else
Nenue@6 396 self.equipped[slot] = nil
Nenue@6 397 end
Nenue@6 398 end
Nenue@6 399
Nenue@6 400 local GetPowerRegen, UnitPowerType = GetPowerRegen, UnitPowerType
Nenue@6 401 function T:COMBAT_RATING_UPDATE(t,e)
Nenue@6 402 --@debug@
Nenue@6 403 print('|cFF00FFFFCOMBAT_RATING_UPDATE')--@end-debug@
Nenue@6 404 self.haste = UnitSpellHaste('player')
Nenue@6 405 self.powerRegen = GetPowerRegen()
Nenue@6 406 self.powerType = UnitPowerType('player')
Nenue@6 407 self.castTimeMod = 1+ self.haste/100
Nenue@6 408 self.GCD = 1.5 * self.castTimeMod
Nenue@6 409
Nenue@6 410 L.haste = format('%.2f', self.haste)
Nenue@6 411 L.focusregen = format('%.2f', self.powerRegen)
Nenue@6 412 L.castingmod = format('%.2f', self.castTimeMod)
Nenue@6 413 end
Nenue@6 414
Nenue@6 415 function T:UNIT_SPELLCAST_INTERRUPTED(e, unit, spellName, rank, target, castID)
Nenue@6 416 if not T.isEventUnit[unit] then
Nenue@6 417 return
Nenue@6 418 end
Nenue@6 419 T.spellevent[unit] = {unit, spellName, rank, target, castID, nil }
Nenue@6 420 end
Nenue@6 421
Nenue@6 422 function T:UNIT_SPELLCAST_SENT(e,unit, spellName, rank, target, castID)
Nenue@6 423 if not T.isEventUnit[unit] then
Nenue@6 424 return
Nenue@6 425 end
Nenue@6 426 T.unit[unit].spellEventString = e
Nenue@6 427 T.unit[unit].spellevent = {unit, spellName, rank, target, castID}
Nenue@6 428 end
Nenue@6 429
Nenue@6 430 function T:UNIT_SPELLCAST (e, unit, spellName, rank, castID, spellID)
Nenue@6 431 if not T.isEventUnit[unit] then
Nenue@6 432 return
Nenue@6 433 end
Nenue@6 434 --name, subText, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible
Nenue@6 435 local q = {UnitCastingInfo(unit)}
Nenue@6 436 T.unit[unit].casting = q[1] and q or false
Nenue@6 437 T.unit[unit].spellEventString = e
Nenue@6 438 T.unit[unit].spellevent = {unit, spellName, rank, nil,castID, spellID }
Nenue@6 439 print(e, unit)
Nenue@6 440 end
Nenue@6 441
Nenue@6 442 function T:UNIT_CHANNEL(e, unit, spellName, rank, castID, spellID)
Nenue@6 443 if not T.isEventUnit[unit] then
Nenue@6 444 return
Nenue@6 445 end
Nenue@6 446 --name, subText, text, texture, startTime, endTime, isTradeSkill, notInterruptible
Nenue@6 447 local q = {UnitChannelInfo(unit) }
Nenue@6 448 T.unit[unit].channeling = q[1] and q or false
Nenue@6 449 T.unit[unit].spellEventString = e
Nenue@6 450 T.unit[unit].spellevent = {unit, spellName, rank, nil, castID, spellID }
Nenue@6 451 print(e, unit)
Nenue@6 452 end
Nenue@6 453
Nenue@6 454 T.UNIT_SPELLCAST_START = T.UNIT_SPELLCAST
Nenue@6 455 T.UNIT_SPELLCAST_STOP = T.UNIT_SPELLCAST
Nenue@6 456 T.UNIT_SPELLCAST_DELAYED = T.UNIT_SPELLCAST
Nenue@6 457 T.UNIT_SPELLCAST_INTERRUPTED = T.UNIT_SPELLCAST
Nenue@6 458 T.UNIT_SPELLCAST_FAILED = T.UNIT_SPELLCAST
Nenue@6 459 T.UNIT_SPELLCAST_SUCCEEDED = T.UNIT_SPELLCAST
Nenue@6 460 T.UNIT_SPELLCAST_CHANNEL_START = T.UNIT_CHANNEL
Nenue@6 461 T.UNIT_SPELLCAST_CHANNEL_UPDATE= T.UNIT_CHANNEL
Nenue@6 462 T.UNIT_SPELLCAST_CHANNEL_STOP= T.UNIT_CHANNEL
Nenue@6 463
Nenue@6 464 local UnitExists, GetRealmName, UnitClassification, UnitClass, UnitIsFriend, UnitIsEnemy, UnitIsFeignDeath
Nenue@6 465 = UnitExists, GetRealmName, UnitClassification, UnitClass, UnitIsFriend, UnitIsEnemy, UnitIsFeignDeath
Nenue@6 466 function T:UnitChanged(e, unit)
Nenue@6 467 local u = T.unit[unit]
Nenue@6 468 local exists = UnitExists(unit)
Nenue@6 469 local realm
Nenue@6 470 _G.print('Update', cText(' '..unit..' change:'), cText(unit), cText(exists and UnitName(unit)))
Nenue@6 471
Nenue@6 472 u.exists = exists
Nenue@6 473 u.name, realm = UnitName(unit)
Nenue@6 474 u.realm = realm or GetRealmName()
Nenue@6 475 u.classification = UnitClassification(unit)
Nenue@6 476 u.class = UnitClass(unit)
Nenue@6 477 u.isFriendly = UnitIsFriend('player', unit)
Nenue@6 478 u.isEnemy = UnitIsEnemy('player', unit)
Nenue@6 479 u.isFeign = UnitIsFeignDeath(unit)
Nenue@6 480 u.isNeutral = not(u.isHostile or u.isFriendly)
Nenue@6 481
Nenue@6 482 local castinfo, channelinfo = {UnitCastingInfo(unit)}, {UnitChannelInfo(unit)}
Nenue@6 483 u.casting = (u.exists and castinfo[1]) and castinfo or false
Nenue@6 484 u.channeling = (u.exists and channelinfo[1]) and channelinfo or false
Nenue@6 485 u.isCasting = (u.casting or u.channeling) and true or false
Nenue@6 486
Nenue@6 487
Nenue@6 488 for k,v in pairs(T.unit[unit]) do
Nenue@6 489 _G.print('Update', cText(' -'), cText(k),'->', cText(v))
Nenue@6 490 end
Nenue@6 491 end
Nenue@6 492 function T:PLAYER_TARGET_CHANGED(e)
Nenue@6 493 T:UnitChanged(e, 'target')
Nenue@6 494 end
Nenue@6 495 function T:PLAYER_FOCUS_CHANGED(e)
Nenue@6 496 T:UnitChanged(e, 'focus')
Nenue@6 497 end
Nenue@6 498 function T:UNIT_PET(e, unit,...)
Nenue@6 499 if unit == 'player' then
Nenue@6 500 print(e, unit, ...)
Nenue@6 501 T:UnitChanged(e, 'pet')
Nenue@6 502 end
Nenue@6 503 end
Nenue@6 504
Nenue@6 505 local Turok_OnCombat = function(inCombat)
Nenue@6 506 print(cText('* CombatToggle:'), cBool(inCombat))
Nenue@6 507 PlaySoundFile(db['battle_noise'.. (inCombat and '_start' or '_end')])
Nenue@6 508
Nenue@6 509 for _, region in pairs(Tk.LibFog.animate_regions) do
Nenue@6 510 if region.combatFade then
Nenue@6 511 print(' |cFFFFFF00+|r', region:GetName())
Nenue@6 512 region:UpdateAlpha(inCombat)
Nenue@6 513 else
Nenue@6 514 print(' |cFFFF4400-|r', region:GetName())
Nenue@6 515 end
Nenue@6 516 end
Nenue@6 517 end
Nenue@6 518
Nenue@6 519 --- InCombatLockdown() isn't updated immediately, so we have to assume
Nenue@6 520 function T:PLAYER_REGEN_DISABLED(e,...)
Nenue@6 521 T.inCombat = true
Nenue@6 522 Turok_OnCombat(true)
Nenue@6 523 end
Nenue@6 524 function T:PLAYER_REGEN_ENABLED(e,...)
Nenue@6 525 T.inCombat = nil
Nenue@6 526 Turok_OnCombat(false)
Nenue@6 527 end
Nenue@6 528
Nenue@6 529 -- GIST datas
Nenue@6 530 function T:GIST_InspectReady (event, guid, unit)
Nenue@6 531 print('GIST barf', guid, unit)
Nenue@6 532 end
Nenue@6 533
Nenue@6 534 function T:GIST_Update(event, guid, unit, info)
Nenue@6 535
Nenue@6 536 if info.class_id and info.global_spec_id and info.guid and info.lku then
Nenue@6 537 --_G.print('GIST', 'Update', unit)
Nenue@6 538 --_G.print('GIST',' class:', info.class_id, 'specid:', info.global_spec_id, 'guid:', info.guid)
Nenue@6 539
Nenue@6 540 self.units[info.guid] = info
Nenue@6 541 self.unitsBySlot[info.lku] = info
Nenue@6 542 end
Nenue@6 543 end
Nenue@6 544
Nenue@6 545 -- todo: re-locate these
Nenue@6 546
Nenue@6 547 T.PLAY_MOVIE = function (e, id)
Nenue@6 548 MovieFrame:Hide()
Nenue@6 549 T:Print('skipped a shitty movie', e, id)
Nenue@6 550 end
Nenue@6 551 T.CINEMATIC_START = function(...)
Nenue@6 552 CinematicFrame_CancelCinematic()
Nenue@6 553 T:Print('skipped a shitty cinematic', ...)
Nenue@6 554 end