daily pastebin goal
32%
SHARE
TWEET

WoW - WeakAuras, Hematology (Code w/ Documentation)

Collie Feb 8th, 2013 886 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[ SNAPSHOT LOGIC ]]--
  2. --[[ This is the module that sniffs the combat log for specific events. Whenever it sees that we have successfully cast either Rip (1079) or Rake (1822) onto our target,
  3.          it records what our stats were at that instant so we can calculate the difference of a future Rip or Rake. This accounts for Attack Power, Combo Points, Mastery,
  4.          and damage multiplier buffs like Dream of Cenarius and Tiger's Fury. This module runs all the time. ]]--
  5. function (event, ...)
  6.         if (event == "COMBAT_LOG_EVENT_UNFILTERED") then        --Scan all combat log events
  7.                 local _, param, _, source, _, _, _, destination, _, _, _, spell, _, _, _, _, _, _, _, _, _ = ...        --Filter log events based on specific criteria
  8.                 if (source == UnitGUID("player") and destination == UnitGUID("target") and param == "SPELL_CAST_SUCCESS") then    --Check to see if an entry matches what we want
  9.                         if (spell == 1079) then   --If we apply Rip to our target successfully...
  10.                                 local Rip_sAP, Rip_sMastery, Rip_sMult = AP, Mastery, DamageMultiplier    --Create snapshots of our current Attack Power, Mastery, and any multipliers
  11.                                 Rip_sDamage = (((113 * Rip_sMastery) + 320 * 5 * Rip_sMastery + 0.0484 * 5 * Rip_sAP * Rip_sMastery) * Rip_sMult)        --Calculates exactly how hard Rip ticks with those snapshots
  12.                         elseif(spell == 1822) then        --If we apply Rake to our target successfully...
  13.                                 local Rake_sAP, Rake_sMastery, Rake_sMult = AP, Mastery, DamageMultiplier        --Create snapshots of our current Attack Power, Mastery, and any multipliers
  14.                                 Rake_sDamage = (((99 + (Rake_sAP * 0.3)) * Rake_sMastery) * Rake_sMult)    --Calculates exactly how hard Rake ticks with those snapshots
  15.                         end
  16.                 end
  17.         end
  18. end
  19.  
  20. --[[ STAT LOGIC ]]--
  21. --[[ To compare how much of a difference a new Rip or Rake could have on our target, we need to monitor our buffs and stats in real time. All other modules depend on
  22.          the variables created here to form their snapshots or calculate damage deltas, hence the global declarations for Attack Power, CPs, and so on. Runs all the time. ]]--
  23. function()
  24.         local APBase, APPos, APNeg = UnitAttackPower("player")    --Attack Power is an aggregate value, so we have to combine base AP, AP bonuses, and AP decrements together
  25.         local DoCSID = select(11, UnitAura("player", "Dream of Cenarius"))    --Attempts to see if the player has the Dream of Cenarius buff, and if so, grabs its Spell ID
  26.         AP, ComboPoints, DamageMultiplier, Mastery = (APBase + APPos + APNeg), GetComboPoints("player", "target"), select(7, UnitDamage("player")), (1 + (GetMasteryEffect() / 100))    --Global vars
  27.        
  28.         --[[ Due to the fact that Dream of Cenarius only increases the damage of two abilities when they are used, compared to abilities like Tiger's Fury which buff ALL
  29.                  damage over a period of time, the +25% damage multiplier isn't rolled into the API function we used to get our DamageMultiplier value above. Instead, we have
  30.                  to track the exact Spell ID and modify the DamageMultiplier value manually. ]]--
  31.         if (DoCSID == 108381) then    --If it turns out the Dream of Cenarius buff (the one that buffs damage) exists on the player...
  32.                 DamageMultiplier = DamageMultiplier * 1.25    --Increase DamageMultiplier by 25%
  33.         end
  34.        
  35.         return ''    --Returns an empty string. This is a remnant from my own version which I used to return my amount of DoC stacks, in addition to what it already does here
  36. end
  37.  
  38.  
  39. --[[ RAKE RATIO ]]--
  40. --[[ Displays the percent ratio of your next Rake, based on values fed to it by the Snapshot/Stat Logic modules. Color-coded to highlight specific thresholds for easier
  41.          reaction in-game. Increases to Rake's duration by tier bonuses and the like are handled accurately, and although flat damage increases from tier bonuses aren't directly
  42.          accounted for in the raw damage calculations, they are unneccary for comparative reasons since both our snapshot Rake and potential Rake will be affected by them.
  43.          Only runs while in combat. ]]--
  44. function()
  45.         if (displayRakeRatio == true) then    --Global variable handled by WA's trigger detection. Only while Rake exists on a target will this script run
  46.                 local Rake_pDamage = (((99 + (AP * 0.3)) * Mastery) * DamageMultiplier)    --Rake damage formula
  47.                 local Rake_Ratio = (Rake_pDamage / Rake_sDamage)    --Decimal ratio of our potential Rake (pDamage) and snapshot Rake (sDamage.) Used for DPE calculation below
  48.                 local Rake_RatioPercent = (Rake_Ratio * 100)    --Percent ratio. What ends up being shown on the text readout
  49.                
  50.                 if (Rake_RatioPercent >= 101) then    --DPE calculation. Since we can't possibly have a new Rake with higher DPE that's weaker, only run when >101%
  51.                         local _, _, _, _, _, Rake_tDuration, Rake_tExpiry = UnitDebuff("target", "Rake", nil, "PLAYER")    --Grabs full duration of Rake and the timestamp it was applied
  52.                         local Rake_tClipPerSec = ((Rake_Ratio * Rake_tDuration) - Rake_tDuration)    --Finds where the per-second damage advantage is
  53.                         local Rake_tClipInterval = (Rake_tClipPerSec - (Rake_tClipPerSec % 3))    --Updates damage advantage point to account for the fact that Rake ticks every 3 seconds
  54.                         local Rake_tRemaining = (Rake_tExpiry - GetTime())    --Calculate how much time is left on our Rake (since the WoW API does not do this for us)
  55.                        
  56.                         if (Rake_tRemaining <= Rake_tClipInterval) then    --If we are at the point where we can clip Rake with a DPE gain...
  57.                                 return format("|cFFFF6900%d|r", Rake_RatioPercent)    --Return the damage ratio in ORANGE
  58.                         else    --If not, we're still returning a ratio above 101%, so...
  59.                                 return format("|cFF00FF00%d|r", Rake_RatioPercent)    --Return the damage ratio in GREEN
  60.                         end
  61.                 else    --If our damage ratio is <=100%...
  62.                         return format("|cFF777777%d|r", Rake_RatioPercent)    --Return the damage ratio in GRAY
  63.                 end
  64.         else    --If Rake is not on our target at all...
  65.                 return ''    --Return an empty string so nothing shows up
  66.         end
  67. end
  68.  
  69. --[[ RIP RATIO ]]--
  70. --[[ Displays the percent ratio of your next Rip, based on values fed to it by the Snapshot/Stat Logic modules. Color-coded to highlight specific thresholds for easier
  71.          reaction in-game. Increases to Rip's duration by tier bonuses and Shred are handled accurately, and although flat damage increases from tier bonuses aren't directly
  72.          accounted for in the raw damage calculations, they are unneccary for comparative reasons since both our snapshot Rip and potential Rip will be affected by them.
  73.          Only runs while in combat. ]]--
  74. function()
  75.         if (displayRipRatio == true) then    --Global variable handled by WA's trigger detection. Only while Rip exists on a target will this script run
  76.                 local Rip_pDamage = (((113 * Mastery) + 320 * ComboPoints * Mastery + 0.0484 * ComboPoints * AP * Mastery) * DamageMultiplier)    --Rip damage formula
  77.                 local Rip_Ratio = (Rip_pDamage / Rip_sDamage)    --Decimal ratio of our potential Rip (pDamage) and snapshot Rip (sDamage.) Used for DPE calculation below
  78.                 local Rip_RatioPercent = (Rip_Ratio * 100)    --Percent ratio. What ends up being shown on the text readout
  79.                
  80.                 if (Rip_RatioPercent >= 101) then    --DPE calculation. Since we can't possibly have a new Rip with higher DPE that's weaker, only run when >101%
  81.                         local _, _, _, _, _, Rip_tDuration, Rip_tExpiry = UnitDebuff("target", "Rip", nil, "PLAYER")    --Grabs full duration of Rip and the timestamp it was applied
  82.                         local Rip_tClipPerSec = ((Rip_Ratio * Rip_tDuration) - Rip_tDuration)    --Finds where the per-second damage advantage is
  83.                         local Rip_tClipInterval = (Rip_tClipPerSec - (Rip_tClipPerSec % 2))    --Updates damage advantage point to account for the fact that Rip ticks every 2 seconds
  84.                         local Rip_tRemaining = (Rip_tExpiry - GetTime())    --Calculate how much time is left on our Rip (since the WoW API does not do this for us.) Does update with Shred
  85.                        
  86.                         if (Rip_tRemaining <= Rip_tClipInterval) then    --If we are at the point where we can clip Rip with a DPE gain...
  87.                                 return format("|cFFFF6900%d|r", Rip_RatioPercent)    --Return the damage ratio in ORANGE
  88.                         else    --If not, we're still returning a ratio above 101%, so...
  89.                                 return format("|cFF00FF00%d|r", Rip_RatioPercent)    --Return the damage ratio in GREEN
  90.                         end
  91.                 else    --If our damage ratio is <=100%...
  92.                         return format("|cFF777777%d|r", Rip_RatioPercent)    --Return the damage ratio in GRAY
  93.                 end
  94.         else    --If Rip is not on our target at all...
  95.                 return ''    --Return an empty string so nothing shows up
  96.         end
  97. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top