Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. function(event,time,type,_,sourceGUID,sourcename,_,_,destGUID,destname,_,_,spellid,spellname,_,_,_,_,_,_,_,spellcritical,_,_,_,spellmultistrike)
  2. local CurrentTime = GetTime();
  3.  
  4. WA_SA_NUM_UNITS = WA_SA_NUM_UNITS or 0;
  5. WA_SA_TOTAL = WA_SA_TOTAL or 0;
  6.  
  7. -- Stats buffer
  8. WA_SA_STATS = WA_SA_STATS or {};
  9.  
  10. WA_SA_DEAD = WA_SA_DEAD or {};
  11.  
  12. WA_LAST_CONTINUITY_CHECK = WA_LAST_CONTINUITY_CHECK or GetTime();
  13.  
  14. WA_SA_Cleanup = WA_SA_Cleanup or function(guid)
  15. if WA_SA_STATS[guid] then
  16. WA_SA_TOTAL = WA_SA_TOTAL - WA_SA_STATS[guid].Count;
  17.  
  18. if WA_SA_TOTAL < 0 then
  19. WA_SA_TOTAL = 0;
  20. end
  21.  
  22. WA_SA_STATS[guid].Count = nil;
  23. WA_SA_STATS[guid].LastUpdate = nil;
  24. WA_SA_STATS[guid] = nil;
  25.  
  26. WA_SA_NUM_UNITS = WA_SA_NUM_UNITS - 1;
  27.  
  28. if WA_SA_NUM_UNITS < 0 then
  29. WA_SA_NUM_UNITS = 0;
  30. end
  31. end
  32. end
  33.  
  34. if event == "COMBAT_LOG_EVENT_UNFILTERED" and sourceGUID == UnitGUID("player") then
  35. if spellid == 147193 and type == "SPELL_CAST_SUCCESS" then -- Shadowy Apparition Spawned
  36. if not WA_SA_STATS[destGUID] or WA_SA_STATS[destGUID] == nil then
  37. WA_SA_STATS[destGUID] = {};
  38. WA_SA_STATS[destGUID].Count = 0;
  39. WA_SA_NUM_UNITS = WA_SA_NUM_UNITS + 1;
  40. end
  41.  
  42. WA_SA_TOTAL = WA_SA_TOTAL + 1;
  43. WA_SA_STATS[destGUID].Count = WA_SA_STATS[destGUID].Count + 1;
  44. WA_SA_STATS[destGUID].LastUpdate = CurrentTime;
  45. elseif spellid == 148859 and type == "SPELL_DAMAGE" then --Auspicious Spirit Hit
  46. WA_SA_TOTAL = WA_SA_TOTAL - 1;
  47. if WA_SA_STATS[destGUID] and WA_SA_STATS[destGUID].Count > 0 then
  48. WA_SA_STATS[destGUID].Count = WA_SA_STATS[destGUID].Count - 1;
  49. WA_SA_STATS[destGUID].LastUpdate = CurrentTime;
  50.  
  51. if WA_SA_STATS[destGUID].Count <= 0 then
  52. WA_SA_Cleanup(destGUID);
  53. end
  54. end
  55. end
  56. end
  57.  
  58. if WA_SA_TOTAL < 0 then
  59. WA_SA_TOTAL = 0;
  60. end
  61.  
  62. for guid,count in pairs(WA_SA_STATS) do
  63. if (CurrentTime - WA_SA_STATS[guid].LastUpdate) > 10 then
  64. --If we haven't had a new SA spawn in 10sec, that means all SAs that are out have hit the target (usually), or, the target disappeared.
  65. WA_SA_Cleanup(guid);
  66. end
  67. end
  68.  
  69.  
  70. if event == "COMBAT_LOG_EVENT_UNFILTERED" and (type == "UNIT_DIED" or type == "UNIT_DESTROYED" or type == "SPELL_INSTAKILL") then -- Unit Died, remove them from the target list.
  71. WA_SA_Cleanup(destGUID);
  72. end
  73.  
  74. if UnitIsDeadOrGhost("player") or not UnitAffectingCombat("player") or event == "PLAYER_REGEN_ENABLED" then -- We died, or, exited combat, go ahead and purge the list
  75. for guid,count in pairs(WA_SA_STATS) do
  76. WA_SA_Cleanup(guid);
  77. end
  78.  
  79. WA_SA_STATS = {};
  80. WA_SA_NUM_UNITS = 0;
  81. WA_SA_TOTAL = 0;
  82. end
  83.  
  84. if CurrentTime - WA_LAST_CONTINUITY_CHECK > 10 then --Force check of unit count every 10sec
  85. local newUnits = 0;
  86. for guid,count in pairs(WA_SA_STATS) do
  87. newUnits = newUnits + 1;
  88. end
  89. WA_SA_NUM_UNITS = newUnits;
  90. WA_LAST_CONTINUITY_CHECK = CurrentTime;
  91. end
  92.  
  93. if WA_SA_NUM_UNITS > 0 then
  94. local totalSAs = 0;
  95.  
  96. for guid,count in pairs(WA_SA_STATS) do
  97. if WA_SA_STATS[guid].Count <= 0 or (UnitIsDeadOrGhost(guid)) then
  98. WA_SA_DEAD[guid] = true;
  99. else
  100. totalSAs = totalSAs + WA_SA_STATS[guid].Count;
  101. end
  102. end
  103.  
  104. if totalSAs > 0 and WA_SA_TOTAL > 0 then
  105. return true;
  106. end
  107. end
  108.  
  109. return false;
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement