Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function(...)
- -- START EDIT
- local CUSTOM_ID = 'DIAMOND'
- local DEBUG_MODE = true
- local OUTPUT_MODE = 'total' -- Options: full, total
- -- END EDIT
- local SetValue = function(value, ...)
- if not WeakAuras.CustomValues then WeakAuras.CustomValues = {} end
- if not ... then return end
- local count, data = #{...}
- for i,v in pairs({...}) do
- if i==1 then if count and count == 1 then WeakAuras.CustomValues[v] = value else
- WeakAuras.CustomValues[v] = WeakAuras.CustomValues[v] or {}
- data = WeakAuras.CustomValues[v] end
- else if i ~= count then if not data[v] then data[v] = {} end data = data[v] else data[v] = value end end
- end
- end
- local GetValue = function(...)
- if not WeakAuras.CustomValues then WeakAuras.CustomValues = {} end
- if not ... then return end
- local count, data = #{...}
- if count and (count > 1) then
- for i,v in pairs({...}) do
- if i==1 then WeakAuras.CustomValues[v] = WeakAuras.CustomValues[v] or {} data = WeakAuras.CustomValues[v]
- else if i ~= count then if not data[v] then data[v] = {} else data = data[v] end else data = data[v] end end
- end
- else data = WeakAuras.CustomValues[select(1, ...)] end
- return data
- end
- local IsDestination = function(value, ...)
- if not select(1, ...) or select(1, ...) ~= 'COMBAT_LOG_EVENT_UNFILTERED' or not value then return end
- local comparison
- if type(value) == 'string' then comparison = select(10, ...)
- for i,v in pairs({'player', 'target', 'focus', 'raid'}) do
- if string.find(value, v) then value = UnitExists(value) and UnitName(value) end
- end
- elseif type(value) == 'number' then
- local GUID = select(9, ...)
- if GUID then comparison = tonumber(GUID:sub(6,10), 16) end
- else return end
- if not comparison then return end
- return (value == comparison)
- end
- local IsSource = function(value, ...)
- if not select(1, ...) or select(1, ...) ~= 'COMBAT_LOG_EVENT_UNFILTERED' or not value then return end
- local comparison
- if type(value) == 'string' then comparison = select(6, ...)
- for i,v in pairs({'player', 'target', 'focus', 'raid'}) do
- if string.find(value, v) then value = UnitExists(value) and UnitName(value) end
- end
- elseif type(value) == 'number' then
- local GUID = select(5, ...)
- if GUID then comparison = tonumber(GUID:sub(6,10), 16) end
- else return end
- if not comparison then return end
- return (value == comparison)
- end
- local IsEventType = function(value, ...)
- if not select(1, ...) or select(1, ...) ~= 'COMBAT_LOG_EVENT_UNFILTERED' or not value or type(value) ~= 'string' then return end
- local event = select(3, ...)
- if not event then return end
- if event == value then return true end
- end
- local GetUnitAuraValue = function(aura, valueType, unit, sourceUnit)
- if not aura then return end valueType, unit = valueType or 'name', unit or 'player' if not UnitExists(unit) then return end local v, value = {}
- local GetAuraValues = function(unit, aura, filter)
- local v, filter = {}, filter or 'HELPFUL'
- v.name, v.rank, v.icon, v.count, v.auraType, v.duration, v.expirationTime, v.unitCaster, v.isStealable, v.shouldConsolidate, v.spellId, v.canApplyAura, v.isBossDebuff, v.value1, v.value2, v.value3 = UnitAura(unit, aura, type(aura)=='number' and filter or nil, filter)
- return v
- end
- local GetAuraValue = function(v, t, s) if v[t] then if s then if v.unitCaster and UnitExists(s) and v.unitCaster == s then return v[t] end else return v[t] end end end
- if type(aura) == 'string' then
- v = GetAuraValues(unit, aura)
- if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end
- v = GetAuraValues(unit, aura, 'HARMFUL')
- if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end
- elseif type(aura) == 'number' then
- for i=1,40 do v = GetAuraValues(unit, i)
- if v.spellId and v.spellId == aura then if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end end
- v = GetAuraValues(unit, i, 'HARMFUL')
- if v.spellId and v.spellId == aura then if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end end
- end
- end
- end
- local DATA = {
- DRUID = {
- clearcasting = 137247,
- },
- MONK = {
- clearcasting = 137331,
- spells = {
- {
- id = 108557, -- Jab
- cost = 24000,
- },
- {
- id = 115072, -- Expel Harm
- cost = 7500,
- },
- {
- id = 101546, -- Spinning Crane Kick
- cost = 21450,
- },
- {
- id = 115460, -- Healing Sphere
- cost = 6000,
- },
- {
- id = 117952, -- Cracking Jade Lightning
- cost = 4710,
- eventType = 'SPELL_PERIODIC_DAMAGE',
- },
- {
- id = 115450, -- Detox
- cost = 7800,
- },
- {
- id = 116095, -- Disable
- cost = 2100,
- },
- {
- id = 115078, -- Paralysis
- cost = 9000,
- },
- {
- id = 115921, -- Legacy of the Emperor
- cost = 18000,
- },
- {
- id = 119996, -- Transendence: Transfer
- cost = 1500,
- },
- {
- id = 115175, -- Soothing Mist
- cost = 3000,
- eventType = 'SPELL_PERIODIC_HEAL',
- },
- {
- id = 116694, -- Surging Mist
- cost = 26400,
- },
- {
- id = 115151, -- Renewing Mist
- cost = 17550,
- },
- {
- id = 116849, -- Life Cocoon
- cost = 14850,
- },
- {
- id = 115310, -- Revival
- cost = 23100,
- },
- },
- },
- PALADIN = {
- clearcasting = 137288,
- },
- }
- -- RESET
- if (IsEventType('UNIT_DIED', ...) and IsDestination('player', ...)) or -- Reset: Death
- (select(1, ...) == 'ZONE_CHANGED' or select(1, ...) == 'ZONE_CHANGED_NEW_AREA') or -- Reset: Zone
- (select(1, ...) == 'PLAYER_REGEN_ENABLED') then -- Reset: Combat
- -- Output report
- if OUTPUT_MODE == 'full' or OUTPUT_MODE == 'total' then
- local startTime, endTime, spells = GetValue(CUSTOM_ID, 'start'), GetTime(), GetValue(CUSTOM_ID, 'spells')
- local totalManaSavings, totalCasts = 0, 0
- if GetValue(CUSTOM_ID) and spells then
- for i,v in pairs(spells) do
- totalManaSavings = totalManaSavings + v.mana;
- totalCasts = totalCasts + v.casts;
- end
- for i,v in pairs(spells) do
- if OUTPUT_MODE == 'full' then print(('%s [%s casts] %s mana, %s of Total:'):format(i, v.casts, v.mana, ('%.2f%%'):format(v.mana/totalManaSavings*100))) end
- end
- if GetValue(CUSTOM_ID) then
- if OUTPUT_MODE == 'full' or OUTPUT_MODE == 'total' then print(('CASTS: %s, MANA SAVED: %s, DURATION: %s, MPSec: %d, MP5: %d, SPIRIT VALUE: %d'):format(totalCasts, totalManaSavings, (endTime - startTime), (totalManaSavings/(endTime - startTime)), (totalManaSavings/(endTime - startTime))*5, (totalManaSavings/(endTime - startTime))*5/(1.1287*.5))) end
- end
- end
- end
- SetValue(nil, CUSTOM_ID)
- end
- if IsSource('player', ...) then
- local spellId, playerClass = select(13, ...), select(2, UnitClass('player'))
- local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spellId)
- if IsEventType('SPELL_CAST_SUCCESS', ...) then
- if name and powerType == 0 and cost and (cost > 0) then
- if DEBUG_MODE then print('PRE-AURA', select(3, ...), name, cost) end
- if GetUnitAuraValue(137288, 'name', 'player') then
- local totalMana = GetValue(CUSTOM_ID, 'spells', name, 'mana')
- local totalCasts = GetValue(CUSTOM_ID, 'spells', name, 'casts')
- SetValue(totalMana and totalMana+cost or cost, CUSTOM_ID, 'spells', name, 'mana')
- SetValue(totalCasts and totalCasts+1 or 1, CUSTOM_ID, 'spells', name, 'casts')
- -- Start
- if not GetValue(CUSTOM_ID, 'start') then SetValue(GetTime(), CUSTOM_ID, 'start') end
- if DEBUG_MODE then print('POST-AURA', select(3, ...), name, cost) end
- end
- end
- end
- if DATA[playerClass] and DATA[playerClass].spells then
- for i,v in pairs(DATA[playerClass].spells) do
- if (v.eventType and v.eventType == select(3, ...)) or (not v.eventType and IsEventType('SPELL_CAST_SUCCESS', ...)) then
- if v.id == spellId then
- if DEBUG_MODE then print('PRE-AURA', select(3, ...), name, v.cost) end
- if GetUnitAuraValue(DATA[playerClass].clearcasting, 'name', 'player') then
- local totalMana = GetValue(CUSTOM_ID, 'spells', name, 'mana')
- local totalCasts = GetValue(CUSTOM_ID, 'spells', name, 'casts')
- SetValue(totalMana and totalMana+v.cost or v.cost, CUSTOM_ID, 'spells', name, 'mana')
- SetValue(totalCasts and totalCasts+1 or 1, CUSTOM_ID, 'spells', name, 'casts')
- -- Start
- if not GetValue(CUSTOM_ID, 'start') then SetValue(GetTime(), CUSTOM_ID, 'start') end
- if DEBUG_MODE then print('POST-AURA', select(3, ...), name, v.cost) end
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment