aggixx

Untitled

Jul 24th, 2016
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.97 KB | None | 0 0
  1. function(event)
  2. if not WA_SnapshotLocale then
  3. setglobal("WA_SnapshotLocale", {});
  4.  
  5. local t = WA_SnapshotLocale;
  6.  
  7. t["Rip"] = GetSpellInfo(1079) or "Rip";
  8. t["Rake"] = GetSpellInfo(1822) or "Rake";
  9. t["Thrash"] = GetSpellInfo(106830) or "Thrash";
  10. t["Tiger's Fury"] = GetSpellInfo(5217) or "Tiger's Fury";
  11. t["Savage Roar"] = GetSpellInfo(52610) or "Savage Roar";
  12. t["Bloodtalons"] = GetSpellInfo(155672) or "Bloodtalons";
  13. t["Moonfire"] = GetSpellInfo(8921) or "Moonfire";
  14. t["Incarnation"] = GetSpellInfo(102543) or "Incarnation: King of the Jungle";
  15. end
  16.  
  17. if not WA_DoTInfo then
  18. setglobal("WA_DoTInfo", {
  19. ["Rake"] = {
  20. ["dur"] = 15,
  21. ["tick"] = 3,
  22. },
  23. ["Rip"] = {
  24. ["dur"] = 24,
  25. ["tick"] = 2,
  26. },
  27. })
  28. end
  29.  
  30. if event == "PLAYER_TALENT_UPDATE" or not WA_hasFoN then
  31. setglobal("WA_hasFoN", select(4, GetTalentInfo(4, 3, GetActiveSpecGroup())));
  32. end
  33.  
  34. if event == "PLAYER_TALENT_UPDATE" or event == "LEARNED_SPELL_IN_TAB" or not WA_GetSnapshotState then
  35.  
  36. local hasBT = select(4, GetTalentInfo(7, 2, GetActiveSpecGroup()));
  37.  
  38. local l = WA_SnapshotLocale;
  39.  
  40. setglobal("WA_GetSnapshotState", function(isRake)
  41. local s = {};
  42. if UnitBuff("player", l["Tiger's Fury"]) then
  43. s.TF = true;
  44. end
  45.  
  46. if UnitBuff("player", l["Savage Roar"]) then
  47. s.SR = true;
  48. else
  49. -- Explicitly set a value so we know the state will never be empty.
  50. s.SR = false;
  51. end
  52.  
  53. if hasBT and (UnitBuff("player", l["Bloodtalons"]) or (WA_SnapshotBloodtalonsFades and GetTime()-WA_SnapshotBloodtalonsFades < 0.250)) then
  54. s.BT = true;
  55. end
  56.  
  57. if isRake then
  58. if (WA_SnapshotStealthRake and GetTime() - WA_SnapshotStealthRake < 0.25) or UnitBuff("player", l["Incarnation"]) then
  59. WA_SnapshotStealthRake = nil;
  60. s.ImpRake = true;
  61. end
  62. end
  63.  
  64. return s;
  65. end)
  66. end
  67.  
  68. if not WA_SnapshotInit then
  69. setglobal("WA_SnapshotInit", function(dest)
  70. setglobal("WA_SnapshotData", WA_SnapshotData or {
  71. ["Thrash"] = {
  72. ["cache"] = {},
  73. },
  74. });
  75.  
  76. if dest then
  77. WA_SnapshotData[dest] = WA_SnapshotData[dest] or {
  78. ["Rip"] = {
  79. ["state"] = {},
  80. ["cache"] = {},
  81. },
  82. ["Rake"] = {
  83. ["state"] = {},
  84. ["cache"] = {},
  85. },
  86. ["Thrash"] = {
  87. ["state"] = {},
  88. },
  89. };
  90. end
  91. end)
  92. end
  93.  
  94. if not WA_CacheSnapshot then
  95. setglobal("WA_CacheSnapshot", function(dest, key)
  96. if not key or (not dest and key ~= "Thrash") then
  97. return
  98. end
  99.  
  100. WA_SnapshotInit(dest);
  101.  
  102. if key == "Thrash" then
  103. WA_SnapshotData[key].cache = WA_GetSnapshotState();
  104. else
  105. WA_SnapshotData[dest][key].cache = WA_GetSnapshotState(key == "Rake");
  106. end
  107. end)
  108. end
  109.  
  110. if not WA_SaveSnapshot then
  111. setglobal("WA_SaveSnapshot", function(dest, key, isRefresh)
  112. if not (dest and key) then
  113. return
  114. end
  115.  
  116. WA_SnapshotInit(dest);
  117.  
  118. -- track partial
  119. if WA_ShowPartialTicks and key ~= "Thrash" then
  120. if isRefresh and WA_DoTInfo[key] then
  121. -- Calculate the time left on the bleed when it is refreshed
  122. local remaining = WA_SnapshotData[dest][key].exp - GetTime();
  123. -- Calculate what the new duration will be post refresh
  124. local newDuration = WA_DoTInfo[key].dur + min(WA_DoTInfo[key].dur*0.3, remaining);
  125. -- Store the new expiration time in the DoT state
  126. WA_SnapshotData[dest][key].exp = GetTime() + newDuration;
  127.  
  128. if WA_SnapshotData[dest][key].partial and remaining < WA_SnapshotData[dest][key].partial then
  129. -- If we successfully landed a refresh in the partial window, then reset the partial to nil.
  130. WA_SnapshotData[dest][key].partial = nil;
  131. elseif remaining > WA_DoTInfo[key].dur*0.3 then
  132. -- Otherwise, if the refresh happened before pandemic zone we need to adjust the partial length.
  133. local timeToNextTick = ( remaining - ( WA_SnapshotData[dest][key].partial or 0 ) ) % WA_DoTInfo[key].tick;
  134. WA_SnapshotData[dest][key].partial = ( newDuration - timeToNextTick ) % WA_DoTInfo[key].tick;
  135. end
  136. else
  137. -- Its not a refresh, so just set the expiration time.
  138. WA_SnapshotData[dest][key].exp = GetTime() + WA_DoTInfo[key].dur;
  139. end
  140. end
  141.  
  142. if key == "Thrash" then
  143. if not WA_SnapshotData[key].cache then
  144. return
  145. end
  146.  
  147. WA_SnapshotData[dest][key].state =
  148. WA_shallowCopy(WA_SnapshotData[key].cache);
  149. else
  150. if not WA_SnapshotData[dest][key].cache then
  151. return
  152. end
  153.  
  154. WA_SnapshotData[dest][key].state = WA_shallowCopy(WA_SnapshotData[dest][key].cache);
  155. WA_SnapshotData[dest][key].cache = {};
  156. end
  157.  
  158. if WA_SnapshotCurrentTarget and WA_SnapshotCurrentTarget == dest then
  159. WeakAuras.ScanEvents("WA_"..string.upper(key).."_APPLIED");
  160. end
  161. end)
  162. end
  163.  
  164. if not WA_ClearSnapshot then
  165. setglobal("WA_ClearSnapshot", function(dest, key)
  166. if not (WA_SnapshotData and dest and key and WA_SnapshotData[dest] and WA_SnapshotData[dest][key]) then
  167. return
  168. end
  169.  
  170. WA_SnapshotData[dest][key].state = {};
  171. WA_SnapshotData[dest][key].partial = nil;
  172. WA_SnapshotData[dest][key].exp = nil;
  173.  
  174. if WA_SnapshotCurrentTarget and WA_SnapshotCurrentTarget == dest then
  175. WeakAuras.ScanEvents("WA_"..string.upper(key).."_REMOVED");
  176. end
  177. end)
  178. end
  179.  
  180. if not WA_shallowCopy then
  181. setglobal("WA_shallowCopy", function(orig)
  182. local orig_type = type(orig)
  183. local copy
  184. if orig_type == 'table' then
  185. copy = {}
  186. for orig_key, orig_value in pairs(orig) do
  187. copy[orig_key] = orig_value
  188. end
  189. else -- number, string, boolean, etc
  190. copy = orig
  191. end
  192. return copy
  193. end)
  194. end
  195. end
Advertisement
Add Comment
Please, Sign In to add comment