annotate Turok/Modules/Timer/Aura.lua @ 9:9400a0ff8540

Ugh Timer: - container update directionality - talent update iterates over a non-volatile table to carry out updates - index management steps organized - talentRow status implemented, returns the spell associated with the talent chosen from that row CombatLog: - sort out font controls and unbork arguments
author Nenue
date Sun, 21 Feb 2016 13:08:30 -0500
parents a9b8b0866ece
children 0b1a2f3dbfc4
rev   line source
Nenue@6 1 --- Turok - Aura.lua
Nenue@6 2 -- @file-author@
Nenue@6 3 -- @project-revision@ @project-hash@
Nenue@6 4 -- @file-revision@ @file-hash@
Nenue@6 5 -- Created: 12/25/2015 5:58 AM
Nenue@6 6 -- Aura data collection
Nenue@6 7 local GetTime, UnitAura, GetSpellDescription, GetSpellInfo = GetTime, UnitAura, GetSpellDescription, GetSpellInfo
Nenue@6 8 local T, _G, tinsert = Turok, _G, tinsert
Nenue@6 9 local mod = T:GetModule("TimerControl")
Nenue@6 10
Nenue@6 11 --@debug@
Nenue@6 12 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool
Nenue@6 13 local print = function(...)
Nenue@6 14 if _G.Devian and _G.DevianDB.workspace ~= 1 then
Nenue@6 15 _G.print('Aura', ...)
Nenue@6 16 end
Nenue@6 17 end
Nenue@6 18 --@end-debug@
Nenue@6 19
Nenue@6 20 T.defaults.spirit.aura = {
Nenue@6 21 counterText = "%p",
Nenue@6 22 subCounterText = "%.p",
Nenue@6 23 chargesText = "%s",
Nenue@6 24 justifyH = 'CENTER',
Nenue@6 25 justifyV = 'TOP',
Nenue@6 26 leftText = "%p",
Nenue@6 27 rightText = "%n",
Nenue@6 28
Nenue@6 29 passive = {
Nenue@6 30 icon = {
Nenue@6 31 desaturated = false,
Nenue@6 32 color = {1, 1, 1, 1},
Nenue@6 33 blend = 'BLEND'
Nenue@6 34 }
Nenue@6 35 },
Nenue@6 36 active = {
Nenue@6 37 icon = {
Nenue@6 38 desaturated = false,
Nenue@6 39 color = {1, 1, 1, 1},
Nenue@6 40 blend = 'BLEND'
Nenue@6 41 }
Nenue@6 42 },
Nenue@6 43 }
Nenue@6 44
Nenue@6 45 local p = mod.prototype.trigger.aura
Nenue@6 46 p.class = 'trigger' -- identifier values that are visible from function scope
Nenue@6 47 p.type = 'aura'
Nenue@6 48 p.cvars = { -- only define things that could break the frame here
Nenue@6 49 }
Nenue@6 50 p.events = {
Nenue@6 51 ['UNIT_AURA'] = true,
Nenue@6 52 }
Nenue@6 53
Nenue@6 54 --- takes user supplied values or fills itself with the cvar values provided
Nenue@6 55 p.Init = function(self, auraName, auraFilters, auraUnit)
Nenue@6 56
Nenue@9 57 print('Aura.Init')
Nenue@6 58 self.unit = auraUnit and auraUnit or self.dvars.unit
Nenue@6 59 self.spellName = auraName and auraName or self.spellName
Nenue@6 60 self.filters = auraFilters and auraFilters or self.dvars.filters
Nenue@6 61 -- set inversion states, states 0 and 1 are only processed when prevState differs
Nenue@6 62 if self.cvars.inverse then
Nenue@6 63 self.flags = {
Nenue@6 64 active = 0,
Nenue@6 65 active_prev = 2,
Nenue@6 66 passive = 0,
Nenue@6 67 passive_prev = 1,
Nenue@6 68 hidden = 1,
Nenue@6 69 hidden_prev = 0,
Nenue@6 70 }
Nenue@6 71 self.duration = 1
Nenue@6 72 self.expires = 1
Nenue@6 73 else
Nenue@6 74 self.flags = {
Nenue@6 75 active = 2,
Nenue@6 76 active_prev = 0,
Nenue@6 77 passive = 1,
Nenue@6 78 passive_prev = 0,
Nenue@6 79 hidden = 0,
Nenue@6 80 hidden_prev = 1}
Nenue@6 81 end
Nenue@6 82 print(cWord('Load:'),cNum(self.spellID or self.inventoryID or self.itemID), cText(self.spellName))
Nenue@6 83 end
Nenue@6 84
Nenue@6 85 p.Unload = function(self)
Nenue@6 86 print('unloading events')
Nenue@6 87 for k,v in pairs(p.events) do
Nenue@6 88 self:UnregisterEvent(k)
Nenue@6 89 end
Nenue@6 90 end
Nenue@6 91
Nenue@6 92 --- Return current status data
Nenue@6 93 p.Query = function(self)
Nenue@6 94 print( ' Q:', self.unit , self.spellName, nil, self.filters)
Nenue@6 95 return UnitAura(self.unit , self.spellName, nil, self.filters)
Nenue@6 96 end
Nenue@6 97
Nenue@6 98 p.SetText = mod.SetText
Nenue@6 99
Nenue@6 100 --- Set supplied status data, using the list returned by p.Query()
Nenue@6 101 p.Set = function(self, ...)
Nenue@6 102 self.active, self.rank, _, self.count, self.dispelType, self.duration, self.expires, self.caster,
Nenue@6 103 self.isStealable, self.shouldConsolidate, self.spellID, self.canApplyAura, self.isBossDebuff = ...
Nenue@6 104 if self.active then
Nenue@6 105 if self.cvars.duration then
Nenue@6 106 self.duration = self.cvars.duration
Nenue@6 107 print(cKey('force duration ='), cNum(self.cvars.duration))
Nenue@6 108 end
Nenue@6 109 self.start = self.expires - self.duration
Nenue@6 110 end
Nenue@6 111 end
Nenue@6 112
Nenue@6 113 --- Handle in the frame itself to limit collateral from bugs
Nenue@6 114 function p.Event(self, event, unit)
Nenue@6 115 self.event = event
Nenue@6 116 if not event then
Nenue@6 117 print(' DRY FIRE')
Nenue@6 118 elseif unit ~= self.unit then
Nenue@6 119 return
Nenue@6 120 end
Nenue@6 121
Nenue@6 122 --- 3 states: nil, 0, >0
Nenue@6 123
Nenue@6 124 local active, rank, _, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff = self:Query()
Nenue@6 125 local state
Nenue@6 126 if self.cvars.duration and active ~= self.active then
Nenue@6 127 print('passive aura with forced duration')
Nenue@6 128 state = self.flags.active
Nenue@6 129 duration = self.cvars.duration
Nenue@6 130 expires = GetTime() + self.cvars.duration
Nenue@6 131 elseif (not self.cvars.duration and (duration ~= self.duration or expires ~= self.expires)) or active ~= self.active then
Nenue@6 132 if not active then
Nenue@6 133 if (not self.untriggerFunc) or self:untriggerFunc() then
Nenue@6 134 state = self.flags.hidden
Nenue@6 135 end
Nenue@6 136 else
Nenue@6 137 if (not self.triggerFunc) or self:triggerFunc() then
Nenue@6 138 if duration == 0 then
Nenue@6 139 print('passive aura')
Nenue@6 140 state = self.flags.passive
Nenue@6 141 else
Nenue@6 142 print('updating an active aura')
Nenue@6 143 state = self.flags.active
Nenue@6 144 end
Nenue@6 145 self.start = expires - duration
Nenue@6 146 end
Nenue@6 147 end
Nenue@6 148 end
Nenue@6 149
Nenue@6 150 if state then
Nenue@6 151 T:Dispatch('TK_AURA_UPDATE', self.spellID, self.filters, state, self.displayState)
Nenue@6 152 self:Set(active, rank, _, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
Nenue@6 153 self:SetState(state)
Nenue@6 154 print(cText('push state'), cNum(self.displayState).. ' (prev: '.. cNum(self.prevState)..')', self.timerName, cText(active), cKey(duration), cNum(expires), cBool(self.cvars.inverse))
Nenue@6 155 else
Nenue@6 156 print(cText('no changes'), cNum(self.displayState).. ' (prev: '.. cNum(self.prevState)..')', cText(self.timerName))
Nenue@6 157 end
Nenue@6 158 end
Nenue@6 159
Nenue@6 160 p.Value = function(self)
Nenue@6 161 return (self.charges and self.charges < self.maxCharges) and ((GetTime() - self.chargeStart) / self.chargeDuration) or ((GetTime() - self.start) / self.duration)
Nenue@6 162 end