Mercurial > wow > turok
comparison Turok/Modules/Timer/Cooldown.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 |
comparison
equal
deleted
inserted
replaced
| 8:7790dff0fe13 | 9:9400a0ff8540 |
|---|---|
| 28 local T = Turok | 28 local T = Turok |
| 29 local db | 29 local db |
| 30 local FADE_TIME = 0.2 | 30 local FADE_TIME = 0.2 |
| 31 --@debug@ | 31 --@debug@ |
| 32 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool | 32 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool |
| 33 local print = function(...) print('Cooldown', ...) end | 33 |
| 34 local print = function(...) | |
| 35 if _G.Devian and _G.DevianDB.workspace ~= 1 then | |
| 36 _G.print('Cooldown', ...) | |
| 37 end | |
| 38 end | |
| 34 local function GetPrint (trace) | 39 local function GetPrint (trace) |
| 35 return trace and print or function() end | 40 return trace and print or function() end |
| 36 end | 41 end |
| 37 | 42 |
| 38 | 43 |
| 48 inverse = false, | 53 inverse = false, |
| 49 persist = false, | 54 persist = false, |
| 50 desaturated = false, | 55 desaturated = false, |
| 51 fill_inverse = true, | 56 fill_inverse = true, |
| 52 size = 24, | 57 size = 24, |
| 53 counterText = "%p", | 58 counterText = "%i", |
| 54 subCounterText = "%.p", | 59 subCounterText = "%.p", |
| 55 chargesText = "%s", | 60 chargesText = "%s", |
| 56 justifyH = 'CENTER', | 61 justifyH = 'CENTER', |
| 57 justifyV = 'TOP', | 62 justifyV = 'TOP', |
| 58 | 63 |
| 61 rightText = "%n / %d", | 66 rightText = "%n / %d", |
| 62 passive = { | 67 passive = { |
| 63 icon = { | 68 icon = { |
| 64 desaturated = false, | 69 desaturated = false, |
| 65 color = {1, 1, 1, 1}, | 70 color = {1, 1, 1, 1}, |
| 66 blend = 'BLEND' | |
| 67 } | 71 } |
| 68 }, | 72 }, |
| 69 active = { | 73 active = { |
| 70 icon = { | 74 icon = { |
| 71 desaturated = false, | 75 desaturated = true, |
| 72 color = {1, 1, 1, .6}, | 76 color = {1, 1, 1, .6}, |
| 73 blend = 'ADD' | |
| 74 } | 77 } |
| 75 }, | 78 }, |
| 76 | 79 |
| 77 --- control displays of aura information in cooldown displays | 80 --- control displays of aura information in cooldown displays |
| 78 showAura = false, | 81 overrideAura = false, |
| 79 cooldownAura = { | 82 overrideDuration = false, |
| 83 override = { | |
| 80 icon = { | 84 icon = { |
| 81 desaturated = true, | 85 desaturated = true, |
| 82 color = {0,1,0,1}, | 86 color = {0,1,0,1}, |
| 83 } | 87 } |
| 84 } | 88 } |
| 97 self.spellID = spellID and spellID or self.spellID | 101 self.spellID = spellID and spellID or self.spellID |
| 98 self.unit = caster and caster or self.unit | 102 self.unit = caster and caster or self.unit |
| 99 self.persist = tristate and tristate or self.persist | 103 self.persist = tristate and tristate or self.persist |
| 100 self.minValue = minValue and minValue or tonumber(self.minValue) | 104 self.minValue = minValue and minValue or tonumber(self.minValue) |
| 101 self.maxValue = maxValue and maxValue or tonumber(self.maxValue) | 105 self.maxValue = maxValue and maxValue or tonumber(self.maxValue) |
| 106 | |
| 107 self.start = 0 | |
| 108 self.duration = 0 | |
| 109 self.expires = 0 | |
| 110 self.charges = nil | |
| 111 self.charges_max = 0 | |
| 112 self.charge_start = 0 | |
| 113 self.charge_duration = 0 | |
| 114 self.charge_expires = 0 | |
| 115 self.override = false | |
| 116 self.override_start = 0 | |
| 117 self.override_duration = 0 | |
| 118 self.override_expires = 0 | |
| 102 | 119 |
| 103 --- current and last state values need to be flipped for inverted conditional | 120 --- current and last state values need to be flipped for inverted conditional |
| 104 --- last state is defined in case it needs to be overridden to ensure proper frame update | 121 --- last state is defined in case it needs to be overridden to ensure proper frame update |
| 105 print(cWord('Load:'),cNum(self.spellID or self.inventoryID or self.itemID), cText(self.spellName or GetItemSpell('player', self.inventoryID or self.itemID)) ) | 122 print(cWord('Load:'),cNum(self.spellID or self.inventoryID or self.itemID), cText(self.spellName or GetItemSpell('player', self.inventoryID or self.itemID)) ) |
| 106 print(cWord(' inverse=')..cBool(self.cvars.inverse)) | 123 print(cWord(' inverse=')..cBool(self.cvars.inverse)) |
| 130 | 147 |
| 131 local GetItemCooldown, GetItemInfo = GetItemCooldown, GetItemInfo | 148 local GetItemCooldown, GetItemInfo = GetItemCooldown, GetItemInfo |
| 132 p.Query = function(self) | 149 p.Query = function(self) |
| 133 local print = GetPrint(self.trace) | 150 local print = GetPrint(self.trace) |
| 134 local id = self.inventoryID or self.itemID or self.spellID | 151 local id = self.inventoryID or self.itemID or self.spellID |
| 135 local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count | 152 local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration = nil, false, 0, 0, nil, nil, nil, 0, 0 |
| 153 local override, overrideStart, overrideDuration = false, 0, 0 | |
| 136 | 154 |
| 137 --- checked in order of precedence | 155 --- checked in order of precedence |
| 138 if self.inventoryID then | 156 if self.inventoryID then |
| 139 print(cText(' type'), cWord('inventory slot'), cNum(id)) | 157 print(cText(' type'), cWord('inventory slot'), cNum(id)) |
| 140 self.cooldownType = CD_SLOT | 158 self.cooldownType = CD_SLOT |
| 141 start, duration, enabled = GetInventoryItemCooldown('player', id) | 159 start, duration, enabled = GetInventoryItemCooldown('player', id) |
| 142 charges, maxCharges, chargeStart, chargeDuration = nil, nil, nil, nil | 160 charges, maxCharges, chargeStart, chargeDuration = nil, nil, nil, nil |
| 143 count = GetInventoryItemCount('player', id) | |
| 144 usable = name and true or false | 161 usable = name and true or false |
| 145 elseif self.itemID then | 162 elseif self.itemID then |
| 146 self.cooldownType = CD_ITEM | 163 self.cooldownType = CD_ITEM |
| 147 | 164 |
| 148 start, duration, enabled = GetItemCooldown(self.itemID) | 165 start, duration, enabled = GetItemCooldown(self.itemID) |
| 152 elseif self.spellID then | 169 elseif self.spellID then |
| 153 self.cooldownType = CD_SPELL | 170 self.cooldownType = CD_SPELL |
| 154 name = GetSpellInfo(self.spellID) | 171 name = GetSpellInfo(self.spellID) |
| 155 start, duration, enabled = GetSpellCooldown(self.spellID) | 172 start, duration, enabled = GetSpellCooldown(self.spellID) |
| 156 charges, maxCharges, chargeStart, chargeDuration = GetSpellCharges(self.spellID) | 173 charges, maxCharges, chargeStart, chargeDuration = GetSpellCharges(self.spellID) |
| 157 count = GetSpellCount(self.spellID) | |
| 158 usable = true -- they still exist even when dead | 174 usable = true -- they still exist even when dead |
| 159 else | 175 else |
| 160 self.unit = 'notaunit' | 176 self.unit = 'notaunit' |
| 161 T:Print('Timer \''..tostring(self.timerName)..'\' doesn\'t have a valid status ID.') | 177 T:Print('Timer \''..tostring(self.timerName)..'\' doesn\'t have a valid status ID.') |
| 162 end | 178 end |
| 164 -- may not have been stored for some reason | 180 -- may not have been stored for some reason |
| 165 if charges and not self.maxCharges then | 181 if charges and not self.maxCharges then |
| 166 self.maxCharges = maxCharges | 182 self.maxCharges = maxCharges |
| 167 end | 183 end |
| 168 | 184 |
| 169 print('cooldown.Query(',id,')', name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration) | 185 if self.spellName and self.cvars.overrideAura then |
| 170 return name, usable, start, duration, enabled, charges, chargeStart, chargeDuration, count | 186 local name, _, _, _, _, d, e = UnitAura(self.unit , self.spellName, nil, 'HELPFUL') |
| 187 if name then | |
| 188 override = true | |
| 189 overrideDuration = d | |
| 190 overrideStart = e - d | |
| 191 end | |
| 192 end | |
| 193 | |
| 194 if self.overrideDuration and start > 0 then | |
| 195 override = true | |
| 196 overrideDuration = self.overrideDuration | |
| 197 overrideStart = start | |
| 198 end | |
| 199 | |
| 200 print('cooldown.Query(',id,')', 'name:'..cText(name), 'usable:'..cBool(usable), 'start:'..cNum(start), 'duration:'..cNum(duration), 'enabled:'..cWord(enabled), | |
| 201 'charges:'.. cNum(charges), 'charge_start:'.. cNum(chargeStart), 'charge_duration:'.. cNum(chargeDuration), | |
| 202 'override:' .. cBool(override), 'override_start'..cNum(overrideStart), 'override_duration:'.. cNum(overrideDuration)) | |
| 203 return name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, override, overrideStart, overrideDuration | |
| 171 end | 204 end |
| 172 | 205 |
| 173 p.Set = function(self, ...) | 206 p.Set = function(self, ...) |
| 174 local print = GetPrint(self.trace) | 207 local print = GetPrint(self.trace) |
| 175 | 208 |
| 176 --name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count | 209 --name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count |
| 177 local name | 210 local name |
| 178 name, self.usable, self.start, self.duration, self.enabled, self.charges, self.chargeStart, self.chargeDuration, self.count = ... | 211 name, self.usable, self.start, self.duration, self.enabled, self.charges, self.charges_max, self.charge_start, self.charge_duration, self.override, self.override_start, self.override_duration = ... |
| 179 if name then | 212 if name then |
| 180 self.spellName = name | 213 self.spellName = name |
| 181 end | 214 end |
| 182 | 215 |
| 183 if self.duration and self.start then | 216 if self.duration and self.start then |
| 184 self.expires = self.start + self.duration | 217 self.expires = self.start + self.duration |
| 185 else | 218 else |
| 186 self.expires = 0 | 219 self.expires = 0 |
| 187 end | 220 end |
| 221 | |
| 222 if self.charges then | |
| 223 self.charge_expires = self.charge_start + self.charge_duration | |
| 224 end | |
| 225 if self.override then | |
| 226 self.override_expires = self.override_start + self.override_duration | |
| 227 end | |
| 228 | |
| 188 end | 229 end |
| 189 | 230 |
| 190 p.Value = function(self) | 231 p.Value = function(self) |
| 191 return (self.charges and self.charges < self.maxCharges) and ((GetTime() - self.chargeStart) / self.chargeDuration) or ((GetTime() - self.start) / self.duration) | 232 return (self.charges and self.charges < self.maxCharges) and ((GetTime() - self.chargeStart) / self.chargeDuration) or ((GetTime() - self.start) / self.duration) |
| 192 end | 233 end |
| 206 if not event then | 247 if not event then |
| 207 print(' *', cWord('Poke')) | 248 print(' *', cWord('Poke')) |
| 208 end | 249 end |
| 209 local diff = 'start='..cText(self.start)..' duration='..cText(self.duration)..' charges='.. | 250 local diff = 'start='..cText(self.start)..' duration='..cText(self.duration)..' charges='.. |
| 210 cText(self.charges).. ' chargeStart='..cText(self.chargeStart).. ' chargeDuration='..cText(self.chargeDuration) | 251 cText(self.charges).. ' chargeStart='..cText(self.chargeStart).. ' chargeDuration='..cText(self.chargeDuration) |
| 211 local name, usable, start, duration, enabled, charges, chargeStart, chargeDuration, count = self:Query() | 252 local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, override, overrideStart, overrideDuration = self:Query() |
| 212 | |
| 213 -- If we want and can, pull aura data and use that in place of cooldown information | |
| 214 local expires, hasAura, _ | |
| 215 if self.cvars.showAura then | |
| 216 print(cText('UnitAura'), self.unit, self.spellName, nil, 'HELPFUL') | |
| 217 local name, _, _, count, _, auraDuration, auraExpires = UnitAura(self.unit , self.spellName, nil, 'HELPFUL') | |
| 218 if name and (auraDuration ~= self.auraDuration or auraExpires ~= self.auraExpires) then | |
| 219 | |
| 220 print(cText('aura check ='), cBool(name), 's='..cNum(count), 'd='..cNum(auraDuration), 'e='..cNum(auraExpires)) | |
| 221 start = auraExpires - auraDuration | |
| 222 duration = auraDuration | |
| 223 expires = auraExpires | |
| 224 end | |
| 225 end | |
| 226 | 253 |
| 227 -- print(name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count) | 254 -- print(name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count) |
| 228 if duration ~= self.duration or | 255 if duration ~= self.duration or |
| 229 start ~= self.start or | 256 start ~= self.start or |
| 230 chargeStart ~= self.chargeStart | 257 chargeStart ~= self.charge_start or |
| 231 or charges ~= self.charges then | 258 charges ~= self.charges or |
| 259 override ~= self.override | |
| 260 then | |
| 232 print('a variable has changed') | 261 print('a variable has changed') |
| 233 local state | 262 local state |
| 234 | 263 |
| 235 | 264 |
| 236 if duration == 0 and charges == self.maxCharges then | 265 if duration == 0 and charges == self.maxCharges then |
| 259 end | 288 end |
| 260 | 289 |
| 261 self:Stats(state) | 290 self:Stats(state) |
| 262 end | 291 end |
| 263 | 292 |
| 264 | |
| 265 -- form ID, id type, displayState, prevState | |
| 266 --T:Dispatch('TK_COOLDOWN_UPDATE', self.spellID, self.cooldownType, state, self.displayState) | |
| 267 if state then | 293 if state then |
| 268 self:Set(name, usable, start, duration, enabled, charges, chargeStart, chargeDuration, count) | 294 self:Set(name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, override, overrideStart, overrideDuration) |
| 269 self.expires = charges and (self.chargeStart + self.chargeDuration) or (self.start + self.duration) | 295 self.expires = charges and (self.chargeStart + self.chargeDuration) or (self.start + self.duration) |
| 270 self:SetState(state) | 296 self:SetState(state) |
| 271 --print(' ', cText('SetState'), cNum(self.displayState), 'from', cNum(self.prevState), cWord(self.timerName)) | |
| 272 print(' ',diff) | 297 print(' ',diff) |
| 273 print(' start='..cText(self.start)..' duration='..cText(self.duration)..' charges='.. | 298 print(' start='..cText(self.start)..' duration='..cText(self.duration)..' charges='.. |
| 274 cText(self.charges).. ' chargeStart='..cText(self.chargeStart).. ' chargeDuration='..cText(self.chargeDuration)) | 299 cText(self.charges).. ' chargeStart='..cText(self.chargeStart).. ' chargeDuration='..cText(self.chargeDuration)) |
| 275 end | 300 end |
| 276 elseif self.cooldownType == CD_SPELL then | 301 else |
| 277 if duration == 0 and charges == self.maxCharges and self.displayState == HIDDEN then | 302 if self.cooldownType == CD_SPELL then |
| 278 print(cKey(self.timerName), cText('post-framescript clean-up')) | 303 if duration == 0 and charges == self.maxCharges and self.displayState == HIDDEN then |
| 279 self.triggerState = nil | 304 print(cKey(self.timerName), cText('post-framescript clean-up')) |
| 305 self.triggerState = nil | |
| 306 end | |
| 280 end | 307 end |
| 281 end | 308 end |
| 282 end | 309 end |
| 283 --self:DumpMessages() | |
| 284 | |
| 285 end | 310 end |
| 286 | 311 |
| 287 p.Stats = function(self, state) | 312 p.Stats = function(self, state) |
| 288 print(self.unit, self.spellName) | 313 print(self.unit, self.spellName) |
| 289 local auraName, _, _, auraCharges, _, auraDuration, auraExpires = UnitAura(self.unit, self.spellName, nil, 'HELPFUL') | 314 if self.spellName then |
| 315 local auraName, _, _, auraCharges, _, auraDuration, auraExpires = UnitAura(self.unit, self.spellName, nil, 'HELPFUL') | |
| 316 print(' # Aura', auraName and 'yes' or 'no', auraName and ('d='..cNum(auraDuration)) or '', auraName and ('e='..auraExpires)) | |
| 317 end | |
| 318 | |
| 290 local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count = self:Query() | 319 local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count = self:Query() |
| 291 print('# GCD =', T.GCD) | 320 print(' # GCD =', T.GCD) |
| 292 print('# SpellCooldown', 's =', start, 'd =', duration, 's =', charges and (charges..'/'..maxCharges) or 'NA') | 321 print(' # SpellCooldown', 's =', start, 'd =', duration, 's =', charges and (charges..'/'..maxCharges) or 'NA') |
| 293 print('# Aura', auraName and 'yes' or 'no', auraName and ('d='..cNum(auraDuration)) or '', auraName and ('e='..auraExpires)) | 322 print(' # Frame', 'state1 =', self.displayState, 'state2 =', self.previousState, state and ('change to '..cWord(state)) or '') |
| 294 print('# Frame', 'state1 =', self.displayState, 'state2 =', self.previousState, state and ('change to '..cWord(state)) or '') | |
| 295 | 323 |
| 296 | 324 |
| 297 end | 325 end |
| 298 | 326 |
| 299 --- Event pointers | 327 --- Event pointers |
