gabestah

Untitled

May 6th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.87 KB | None | 0 0
  1. function(...)
  2.     -- START EDIT
  3.     local CUSTOM_ID = 'DIAMOND'
  4.     local DEBUG_MODE = true
  5.     local OUTPUT_MODE = 'total' -- Options: full, total
  6.     -- END EDIT
  7.     local SetValue = function(value, ...)
  8.         if not WeakAuras.CustomValues then WeakAuras.CustomValues = {} end
  9.         if not ... then return end
  10.         local count, data = #{...}
  11.         for i,v in pairs({...}) do
  12.             if i==1 then if count and count == 1 then WeakAuras.CustomValues[v] = value else
  13.                 WeakAuras.CustomValues[v] = WeakAuras.CustomValues[v] or {}
  14.                 data = WeakAuras.CustomValues[v] end
  15.             else if i ~= count then if not data[v] then data[v] = {} end data = data[v] else data[v] = value end end
  16.         end
  17.     end
  18.     local GetValue = function(...)
  19.         if not WeakAuras.CustomValues then WeakAuras.CustomValues = {} end
  20.         if not ... then return end
  21.         local count, data = #{...}
  22.         if count and (count > 1) then
  23.             for i,v in pairs({...}) do
  24.                 if i==1 then WeakAuras.CustomValues[v] = WeakAuras.CustomValues[v] or {} data = WeakAuras.CustomValues[v]
  25.                 else if i ~= count then if not data[v] then data[v] = {} else data = data[v] end else data = data[v] end end
  26.             end
  27.         else data = WeakAuras.CustomValues[select(1, ...)] end
  28.         return data
  29.     end
  30.     local IsDestination = function(value, ...)
  31.         if not select(1, ...) or select(1, ...) ~= 'COMBAT_LOG_EVENT_UNFILTERED' or not value then return end
  32.         local comparison
  33.         if type(value) == 'string' then comparison = select(10, ...)
  34.             for i,v in pairs({'player', 'target', 'focus', 'raid'}) do
  35.                 if string.find(value, v) then value = UnitExists(value) and UnitName(value) end
  36.             end
  37.         elseif type(value) == 'number' then
  38.             local GUID = select(9, ...)
  39.             if GUID then comparison = tonumber(GUID:sub(6,10), 16) end
  40.         else return end
  41.         if not comparison then return end
  42.         return (value == comparison)
  43.     end
  44.     local IsSource = function(value, ...)
  45.        if not select(1, ...) or select(1, ...) ~= 'COMBAT_LOG_EVENT_UNFILTERED' or not value then return end
  46.        local comparison
  47.        if type(value) == 'string' then comparison = select(6, ...)
  48.           for i,v in pairs({'player', 'target', 'focus', 'raid'}) do
  49.              if string.find(value, v) then value = UnitExists(value) and UnitName(value) end
  50.           end
  51.        elseif type(value) == 'number' then
  52.           local GUID = select(5, ...)
  53.           if GUID then comparison = tonumber(GUID:sub(6,10), 16) end
  54.        else return end
  55.        if not comparison then return end
  56.        return (value == comparison)
  57.     end
  58.     local IsEventType = function(value, ...)
  59.         if not select(1, ...) or select(1, ...) ~= 'COMBAT_LOG_EVENT_UNFILTERED' or not value or type(value) ~= 'string' then return end
  60.         local event = select(3, ...)
  61.         if not event then return end
  62.         if event == value then return true end
  63.     end
  64.     local GetUnitAuraValue = function(aura, valueType, unit, sourceUnit)
  65.        if not aura then return end valueType, unit = valueType or 'name', unit or 'player' if not UnitExists(unit) then return end local v, value = {}
  66.        local GetAuraValues = function(unit, aura, filter)
  67.           local v, filter = {}, filter or 'HELPFUL'
  68.           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)
  69.           return v
  70.        end
  71.        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
  72.        if type(aura) == 'string' then
  73.           v = GetAuraValues(unit, aura)
  74.           if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end
  75.           v = GetAuraValues(unit, aura, 'HARMFUL')
  76.           if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end
  77.        elseif type(aura) == 'number' then
  78.           for i=1,40 do v = GetAuraValues(unit, i)
  79.              if v.spellId and v.spellId == aura then if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end end
  80.              v = GetAuraValues(unit, i, 'HARMFUL')
  81.              if v.spellId and v.spellId == aura then if GetAuraValue(v,valueType,sourceUnit) then return GetAuraValue(v,valueType,sourceUnit) end end
  82.           end    
  83.        end
  84.     end
  85.     local DATA = {
  86.         DRUID = {
  87.             clearcasting = 137247,
  88.         },
  89.         MONK = {
  90.             clearcasting = 137331,
  91.             spells = {
  92.                 {
  93.                     id = 108557, -- Jab
  94.                     cost = 24000,
  95.                 },
  96.                 {
  97.                     id = 115072, -- Expel Harm
  98.                     cost = 7500,
  99.                 },
  100.                 {
  101.                     id = 101546, -- Spinning Crane Kick
  102.                     cost = 21450,
  103.                 },
  104.                 {
  105.                     id = 115460, -- Healing Sphere
  106.                     cost = 6000,
  107.                 },
  108.                 {
  109.                     id = 117952, -- Cracking Jade Lightning
  110.                     cost = 4710,
  111.                     eventType = 'SPELL_PERIODIC_DAMAGE',
  112.                 },
  113.                 {
  114.                     id = 115450, -- Detox
  115.                     cost = 7800,
  116.                 },
  117.                 {
  118.                     id = 116095, -- Disable
  119.                     cost = 2100,
  120.                 },        
  121.                 {
  122.                     id = 115078, -- Paralysis
  123.                     cost = 9000,
  124.                 },
  125.                 {
  126.                     id = 115921, -- Legacy of the Emperor
  127.                     cost = 18000,
  128.                 },        
  129.                 {
  130.                     id = 119996, -- Transendence: Transfer
  131.                     cost = 1500,
  132.                 },
  133.                 {
  134.                     id = 115175, -- Soothing Mist
  135.                     cost = 3000,
  136.                     eventType = 'SPELL_PERIODIC_HEAL',
  137.                 },
  138.                 {
  139.                     id = 116694, -- Surging Mist
  140.                     cost = 26400,
  141.                 },
  142.                 {
  143.                     id = 115151, -- Renewing Mist
  144.                     cost = 17550,
  145.                 },
  146.                 {
  147.                     id = 116849, -- Life Cocoon
  148.                     cost = 14850,
  149.                 },
  150.                 {
  151.                     id = 115310, -- Revival
  152.                     cost = 23100,
  153.                 },
  154.             },
  155.         },
  156.         PALADIN = {
  157.             clearcasting = 137288,
  158.         },
  159.     }
  160.    
  161.     -- RESET
  162.     if  (IsEventType('UNIT_DIED', ...) and IsDestination('player', ...)) or -- Reset: Death
  163.         (select(1, ...) == 'ZONE_CHANGED' or select(1, ...) == 'ZONE_CHANGED_NEW_AREA') or -- Reset: Zone
  164.         (select(1, ...) == 'PLAYER_REGEN_ENABLED') then -- Reset: Combat
  165.         -- Output report
  166.         if OUTPUT_MODE == 'full' or OUTPUT_MODE == 'total' then
  167.             local startTime, endTime, spells = GetValue(CUSTOM_ID, 'start'), GetTime(), GetValue(CUSTOM_ID, 'spells')
  168.             local totalManaSavings, totalCasts = 0, 0
  169.             if GetValue(CUSTOM_ID) and spells then
  170.                 for i,v in pairs(spells) do
  171.                     totalManaSavings = totalManaSavings + v.mana;
  172.                     totalCasts = totalCasts + v.casts;
  173.                 end
  174.                 for i,v in pairs(spells) do
  175.                     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
  176.                 end
  177.                 if GetValue(CUSTOM_ID) then
  178.                     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
  179.                 end
  180.             end
  181.         end
  182.         SetValue(nil, CUSTOM_ID)
  183.     end
  184.    
  185.     if IsSource('player', ...) then
  186.         local spellId, playerClass = select(13, ...), select(2, UnitClass('player'))
  187.         local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spellId)    
  188.         if IsEventType('SPELL_CAST_SUCCESS', ...) then
  189.             if name and powerType == 0 and cost and (cost > 0) then
  190.                 if DEBUG_MODE then print('PRE-AURA', select(3, ...), name, cost) end
  191.                 if GetUnitAuraValue(137288, 'name', 'player') then
  192.                     local totalMana = GetValue(CUSTOM_ID, 'spells', name, 'mana')
  193.                     local totalCasts = GetValue(CUSTOM_ID, 'spells', name, 'casts')                
  194.                     SetValue(totalMana and totalMana+cost or cost, CUSTOM_ID, 'spells', name, 'mana')
  195.                     SetValue(totalCasts and totalCasts+1 or 1, CUSTOM_ID, 'spells', name, 'casts')
  196.                     -- Start
  197.                     if not GetValue(CUSTOM_ID, 'start') then SetValue(GetTime(), CUSTOM_ID, 'start') end
  198.                     if DEBUG_MODE then print('POST-AURA', select(3, ...), name, cost) end
  199.                 end
  200.             end            
  201.         end
  202.         if DATA[playerClass] and DATA[playerClass].spells then
  203.             for i,v in pairs(DATA[playerClass].spells) do
  204.                 if (v.eventType and v.eventType == select(3, ...)) or (not v.eventType and IsEventType('SPELL_CAST_SUCCESS', ...)) then
  205.                     if v.id == spellId then
  206.                         if DEBUG_MODE then print('PRE-AURA', select(3, ...), name, v.cost) end
  207.                         if GetUnitAuraValue(DATA[playerClass].clearcasting, 'name', 'player') then
  208.                             local totalMana = GetValue(CUSTOM_ID, 'spells', name, 'mana')
  209.                             local totalCasts = GetValue(CUSTOM_ID, 'spells', name, 'casts')                
  210.                             SetValue(totalMana and totalMana+v.cost or v.cost, CUSTOM_ID, 'spells', name, 'mana')
  211.                             SetValue(totalCasts and totalCasts+1 or 1, CUSTOM_ID, 'spells', name, 'casts') 
  212.                             -- Start
  213.                             if not GetValue(CUSTOM_ID, 'start') then SetValue(GetTime(), CUSTOM_ID, 'start') end                       
  214.                             if DEBUG_MODE then print('POST-AURA', select(3, ...), name, v.cost) end
  215.                         end
  216.                     end                
  217.                 end
  218.             end
  219.         end
  220.     end
  221. end
Advertisement
Add Comment
Please, Sign In to add comment