Advertisement
Guest User

chuj

a guest
Apr 22nd, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.34 KB | None | 0 0
  1. local major = "DRData-1.0"
  2. local minor = 1003
  3. assert(LibStub, string.format("%s requires LibStub.", major))
  4.  
  5. local Data = LibStub:NewLibrary(major, minor)
  6. if( not Data ) then return end
  7.  
  8. local L = {
  9. ["Banish"] = "Banish",
  10. ["Charge"] = "Charge",
  11. ["Cheap Shot"] = "Cheap Shot",
  12. ["Controlled stuns"] = "Controlled stuns",
  13. ["Cyclone"] = "Cyclone",
  14. ["Disarms"] = "Disarms",
  15. ["Disorients"] = "Disorients",
  16. ["Entrapment"] = "Entrapment",
  17. ["Fears"] = "Fears",
  18. ["Horrors"] = "Horrors",
  19. ["Mind Control"] = "Mind Control",
  20. ["Random roots"] = "Random roots",
  21. ["Random stuns"] = "Random stuns",
  22. ["Controlled roots"] = "Controlled roots",
  23. ["Scatter Shot"] = "Scatter Shot",
  24. ["Silences"] = "Silences",
  25. ["Hibernate"] = "Hibernate",
  26. ["Taunts"] = "Taunts",
  27. }
  28.  
  29. if GetLocale() == "frFR" then
  30. L["Banish"] = "Bannissement"
  31. L["Charge"] = "Charge"
  32. L["Cheap Shot"] = "Coup bas"
  33. L["Controlled stuns"] = "Etourdissements contrôlés"
  34. L["Cyclone"] = "Cyclone"
  35. L["Disarms"] = "Désarmements"
  36. L["Disorients"] = "Désorientations"
  37. L["Entrapment"] = "Piège"
  38. L["Fears"] = "Peurs"
  39. L["Horrors"] = "Horreurs"
  40. L["Mind Control"] = "Contrôle mental"
  41. L["Random roots"] = "Immobilisations aléatoires"
  42. L["Random stuns"] = "Etourdissemensts aléatoires"
  43. L["Controlled roots"] = "Immobilisations contrôlées"
  44. L["Scatter Shot"] = "Flèche de dispersion"
  45. L["Silences"] = "Silences"
  46. L["Hibernate"] = "Hibernation"
  47. L["Taunts"] = "Provocations"
  48. end
  49.  
  50. -- How long before DR resets
  51. -- While everyone will tell you it's 15 seconds, it's actually 16 - 20 seconds with 18 being a decent enough average
  52. Data.RESET_TIME = 15
  53.  
  54. -- List of spellID -> DR category
  55. Data.spells = {
  56. --[[ TAUNT ]]--
  57. -- Taunt (Warrior)
  58. [355] = "taunt",
  59. -- Taunt (Pet)
  60. [53477] = "taunt",
  61. -- Mocking Blow
  62. [694] = "taunt",
  63. -- Growl (Druid)
  64. [6795] = "taunt",
  65. -- Dark Command
  66. [56222] = "taunt",
  67. -- Hand of Reckoning
  68. [62124] = "taunt",
  69. -- Righteous Defense
  70. [31790] = "taunt",
  71. -- Distracting Shot
  72. [20736] = "taunt",
  73. -- Challenging Shout
  74. [1161] = "taunt",
  75. -- Challenging Roar
  76. [5209] = "taunt",
  77. -- Death Grip
  78. [49560] = "taunt",
  79. -- Challenging Howl
  80. [59671] = "taunt",
  81. -- Angered Earth
  82. [36213] = "taunt",
  83.  
  84. --[[ DISORIENTS ]]--
  85. -- Dragon's Breath
  86. [31661] = "disorient",
  87. [33041] = "disorient",
  88. [33042] = "disorient",
  89. [33043] = "disorient",
  90. [42949] = "disorient",
  91. [42950] = "disorient",
  92.  
  93. -- Hungering Cold
  94. [49203] = "disorient",
  95.  
  96. -- Sap
  97. [6770] = "disorient",
  98. [2070] = "disorient",
  99. [11297] = "disorient",
  100. [51724] = "disorient",
  101.  
  102. -- Gouge
  103. [1776] = "disorient",
  104.  
  105. -- Hex (Guessing)
  106. [51514] = "disorient",
  107.  
  108. -- Shackle
  109. [9484] = "disorient",
  110. [9485] = "disorient",
  111. [10955] = "disorient",
  112.  
  113. -- Polymorph
  114. [118] = "disorient",
  115. [12824] = "disorient",
  116. [12825] = "disorient",
  117. [28272] = "disorient",
  118. [28271] = "disorient",
  119. [12826] = "disorient",
  120. [61305] = "disorient",
  121. [61025] = "disorient",
  122. [61721] = "disorient",
  123. [61780] = "disorient",
  124.  
  125. -- Freezing Trap
  126. [3355] = "disorient",
  127. [14308] = "disorient",
  128. [14309] = "disorient",
  129.  
  130. -- Freezing Arrow
  131. [60210] = "disorient",
  132.  
  133. -- Wyvern Sting
  134. [19386] = "disorient",
  135. [24132] = "disorient",
  136. [24133] = "disorient",
  137. [27068] = "disorient",
  138. [49011] = "disorient",
  139. [49012] = "disorient",
  140.  
  141. -- Repentance
  142. [20066] = "disorient",
  143.  
  144. --[[ SILENCES ]]--
  145. -- Nether Shock
  146. [53588] = "silence",
  147. [53589] = "silence",
  148.  
  149. -- Garrote
  150. [1330] = "silence",
  151.  
  152. -- Arcane Torrent (Energy version)
  153. [25046] = "silence",
  154.  
  155. -- Arcane Torrent (Mana version)
  156. [28730] = "silence",
  157.  
  158. -- Arcane Torrent (Runic power version)
  159. [50613] = "silence",
  160.  
  161. -- Silence
  162. [15487] = "silence",
  163.  
  164. -- Silencing Shot
  165. [34490] = "silence",
  166.  
  167. -- Improved Kick
  168. [18425] = "silence",
  169.  
  170. -- Improved Counterspell
  171. [18469] = "silence",
  172.  
  173. -- Spell Lock
  174. [19244] = "silence",
  175. [19647] = "silence",
  176.  
  177. -- Shield of the Templar
  178. [63529] = "silence",
  179.  
  180. -- Strangulate
  181. [47476] = "silence",
  182. [49913] = "silence",
  183. [49914] = "silence",
  184. [49915] = "silence",
  185. [49916] = "silence",
  186.  
  187. -- Gag Order (Warrior talent)
  188. [18498] = "silence",
  189.  
  190. --[[ DISARMS ]]--
  191. -- Snatch
  192. [53542] = "disarm",
  193. [53543] = "disarm",
  194.  
  195. -- Dismantle
  196. [51722] = "disarm",
  197.  
  198. -- Disarm
  199. [676] = "disarm",
  200.  
  201. -- Chimera Shot - Scorpid
  202. [53359] = "disarm",
  203.  
  204. -- Psychic Horror (Disarm effect)
  205. [64058] = "disarm",
  206.  
  207. --[[ FEARS ]]--
  208. -- Blind
  209. [2094] = "fear",
  210.  
  211. -- Fear (Warlock)
  212. [5782] = "fear",
  213. [6213] = "fear",
  214. [6215] = "fear",
  215.  
  216. -- Seduction (Pet)
  217. [6358] = "fear",
  218.  
  219. -- Howl of Terror
  220. [5484] = "fear",
  221. [17928] = "fear",
  222.  
  223. -- Psychic scream
  224. [8122] = "fear",
  225. [8124] = "fear",
  226. [10888] = "fear",
  227. [10890] = "fear",
  228.  
  229. -- Scare Beast
  230. [1513] = "fear",
  231. [14326] = "fear",
  232. [14327] = "fear",
  233.  
  234. -- Turn Evil
  235. [10326] = "fear",
  236.  
  237. -- Intimidating Shout
  238. [5246] = "fear",
  239.  
  240.  
  241. --[[ CONTROL STUNS ]]--
  242. -- Intercept (Felguard)
  243. [30153] = "ctrlstun",
  244. [30195] = "ctrlstun",
  245. [30197] = "ctrlstun",
  246. [47995] = "ctrlstun",
  247.  
  248. -- Ravage
  249. [50518] = "ctrlstun",
  250. [53558] = "ctrlstun",
  251. [53559] = "ctrlstun",
  252. [53560] = "ctrlstun",
  253. [53561] = "ctrlstun",
  254. [53562] = "ctrlstun",
  255.  
  256. -- Sonic Blast
  257. [50519] = "ctrlstun",
  258. [53564] = "ctrlstun",
  259. [53565] = "ctrlstun",
  260. [53566] = "ctrlstun",
  261. [53567] = "ctrlstun",
  262. [53568] = "ctrlstun",
  263.  
  264. -- Concussion Blow
  265. [12809] = "ctrlstun",
  266.  
  267. -- Shockwave
  268. [46968] = "ctrlstun",
  269.  
  270. -- Hammer of Justice
  271. [853] = "ctrlstun",
  272. [5588] = "ctrlstun",
  273. [5589] = "ctrlstun",
  274. [10308] = "ctrlstun",
  275.  
  276. -- Bash
  277. [5211] = "ctrlstun",
  278. [6798] = "ctrlstun",
  279. [8983] = "ctrlstun",
  280.  
  281. -- Intimidation
  282. [19577] = "ctrlstun",
  283.  
  284. -- Maim
  285. [22570] = "ctrlstun",
  286. [49802] = "ctrlstun",
  287.  
  288. -- Kidney Shot
  289. [408] = "ctrlstun",
  290. [8643] = "ctrlstun",
  291.  
  292. -- War Stomp
  293. [20549] = "ctrlstun",
  294.  
  295. -- Intercept
  296. [20252] = "ctrlstun",
  297.  
  298. -- Deep Freeze
  299. [44572] = "ctrlstun",
  300.  
  301. -- Shadowfury
  302. [30283] = "ctrlstun",
  303. [30413] = "ctrlstun",
  304. [30414] = "ctrlstun",
  305.  
  306. -- Holy Wrath
  307. [2812] = "ctrlstun",
  308.  
  309. -- Inferno Effect
  310. [22703] = "ctrlstun",
  311.  
  312. -- Demon Charge
  313. [60995] = "ctrlstun",
  314.  
  315. -- Gnaw (Ghoul)
  316. [47481] = "ctrlstun",
  317.  
  318. --[[ RANDOM STUNS ]]--
  319. -- Impact
  320. [12355] = "rndstun",
  321.  
  322. -- Stoneclaw Stun
  323. [39796] = "rndstun",
  324.  
  325. -- Seal of Justice
  326. [20170] = "rndstun",
  327.  
  328. -- Revenge Stun
  329. [12798] = "rndstun",
  330.  
  331. --[[ CYCLONE ]]--
  332. -- Cyclone
  333. [33786] = "cyclone",
  334.  
  335. --[[ ROOTS ]]--
  336. -- Freeze (Water Elemental)
  337. [33395] = "ctrlroot",
  338.  
  339. -- Pin (Crab)
  340. [50245] = "ctrlroot",
  341. [53544] = "ctrlroot",
  342. [53545] = "ctrlroot",
  343. [53546] = "ctrlroot",
  344. [53547] = "ctrlroot",
  345. [53548] = "ctrlroot",
  346.  
  347. -- Frost Nova
  348. [122] = "ctrlroot",
  349. [865] = "ctrlroot",
  350. [6131] = "ctrlroot",
  351. [10230] = "ctrlroot",
  352. [27088] = "ctrlroot",
  353. [42917] = "ctrlroot",
  354.  
  355. -- Entangling Roots
  356. [339] = "ctrlroot",
  357. [1062] = "ctrlroot",
  358. [5195] = "ctrlroot",
  359. [5196] = "ctrlroot",
  360. [9852] = "ctrlroot",
  361. [9853] = "ctrlroot",
  362. [26989] = "ctrlroot",
  363. [53308] = "ctrlroot",
  364.  
  365. -- Nature's Grasp (Uses different spellIDs than Entangling Roots for the same spell)
  366. [19970] = "ctrlroot",
  367. [19971] = "ctrlroot",
  368. [19972] = "ctrlroot",
  369. [19973] = "ctrlroot",
  370. [19974] = "ctrlroot",
  371. [19975] = "ctrlroot",
  372. [27010] = "ctrlroot",
  373. [53313] = "ctrlroot",
  374.  
  375. -- Earthgrab (Storm, Earth and Fire talent)
  376. [8377] = "ctrlroot",
  377. [31983] = "ctrlroot",
  378.  
  379. -- Web (Spider)
  380. [4167] = "ctrlroot",
  381.  
  382. -- Venom Web Spray (Silithid)
  383. [54706] = "ctrlroot",
  384. [55505] = "ctrlroot",
  385. [55506] = "ctrlroot",
  386. [55507] = "ctrlroot",
  387. [55508] = "ctrlroot",
  388. [55509] = "ctrlroot",
  389.  
  390.  
  391. --[[ RANDOM ROOTS ]]--
  392. -- Improved Hamstring
  393. [23694] = "rndroot",
  394.  
  395. -- Frostbite
  396. [12494] = "rndroot",
  397.  
  398. -- Shattered Barrier
  399. [55080] = "rndroot",
  400.  
  401. --[[ SLEEPS ]]--
  402. -- Hibernate
  403. [2637] = "sleep",
  404. [18657] = "sleep",
  405. [18658] = "sleep",
  406.  
  407. --[[ HORROR ]]--
  408. -- Death Coil
  409. [6789] = "horror",
  410. [17925] = "horror",
  411. [17926] = "horror",
  412. [27223] = "horror",
  413. [47859] = "horror",
  414. [47860] = "horror",
  415.  
  416. -- Psychic Horror
  417. [64044] = "horror",
  418.  
  419. --[[ MISC ]]--
  420. -- Scatter Shot
  421. [19503] = "scatters",
  422.  
  423. -- Cheap Shot
  424. [1833] = "cheapshot",
  425.  
  426. -- Pounce
  427. [9005] = "cheapshot",
  428. [9823] = "cheapshot",
  429. [9827] = "cheapshot",
  430. [27006] = "cheapshot",
  431. [49803] = "cheapshot",
  432.  
  433. -- Charge
  434. [7922] = "charge",
  435.  
  436. -- Mind Control
  437. [605] = "mc",
  438.  
  439. -- Banish
  440. [710] = "banish",
  441. [18647] = "banish",
  442.  
  443. -- Entrapment
  444. [64804] = "entrapment",
  445. [64804] = "entrapment",
  446. [19185] = "entrapment",
  447. }
  448.  
  449. -- DR Category names
  450. Data.categoryNames = {
  451. ["banish"] = L["Banish"],
  452. ["charge"] = L["Charge"],
  453. ["cheapshot"] = L["Cheap Shot"],
  454. ["ctrlstun"] = L["Controlled stuns"],
  455. ["cyclone"] = L["Cyclone"],
  456. ["disarm"] = L["Disarms"],
  457. ["disorient"] = L["Disorients"],
  458. ["entrapment"] = L["Entrapment"],
  459. ["fear"] = L["Fears"],
  460. ["horror"] = L["Horrors"],
  461. ["mc"] = L["Mind Control"],
  462. ["rndroot"] = L["Random roots"],
  463. ["rndstun"] = L["Random stuns"],
  464. ["ctrlroot"] = L["Controlled roots"],
  465. ["scatters"] = L["Scatter Shot"],
  466. ["silence"] = L["Silences"],
  467. ["sleep"] = L["Hibernate"],
  468. ["taunt"] = L["Taunts"],
  469. }
  470.  
  471. -- Categories that have DR in PvE as well as PvP
  472. Data.pveDR = {
  473. ["ctrlstun"] = true,
  474. ["rndstun"] = true,
  475. ["taunt"] = true,
  476. ["cyclone"] = true,
  477. }
  478.  
  479. -- Public APIs
  480. -- Category name in something usable
  481. function Data:GetCategoryName(cat)
  482. return cat and Data.categoryNames[cat] or nil
  483. end
  484.  
  485. -- Spell list
  486. function Data:GetSpells()
  487. return Data.spells
  488. end
  489.  
  490. -- Seconds before DR resets
  491. function Data:GetResetTime()
  492. return Data.RESET_TIME
  493. end
  494.  
  495. -- Get the category of the spellID
  496. function Data:GetSpellCategory(spellID)
  497. return spellID and Data.spells[spellID] or nil
  498. end
  499.  
  500. -- Does this category DR in PvE?
  501. function Data:IsPVE(cat)
  502. return cat and Data.pveDR[cat] or nil
  503. end
  504.  
  505. -- List of categories
  506. function Data:GetCategories()
  507. return Data.categoryNames
  508. end
  509.  
  510. -- Next DR, if it's 1.0, next is 0.50, if it's 0.[50] = "ctrlroot",next is 0.[25] = "ctrlroot",and such
  511. function Data:NextDR(diminished)
  512. if( diminished == 1 ) then
  513. return 0.50
  514. elseif( diminished == 0.50 ) then
  515. return 0.25
  516. end
  517.  
  518. return 0
  519. end
  520.  
  521. --[[ EXAMPLES ]]--
  522. -- This is how you would track DR easily, you're welcome to do whatever you want with the below functions
  523.  
  524. --[[
  525. local trackedPlayers = {}
  526. local function debuffGained(spellID, destName, destGUID, isEnemy, isPlayer)
  527. -- Not a player, and this category isn't diminished in PVE, as well as make sure we want to track NPCs
  528. local drCat = DRData:GetSpellCategory(spellID)
  529. if( not isPlayer and not DRData:IsPVE(drCat) ) then
  530. return
  531. end
  532.  
  533. if( not trackedPlayers[destGUID] ) then
  534. trackedPlayers[destGUID] = {}
  535. end
  536.  
  537. -- See if we should reset it back to undiminished
  538. local tracked = trackedPlayers[destGUID][drCat]
  539. if( tracked and tracked.reset <= GetTime() ) then
  540. tracked.diminished = 1.0
  541. end
  542. end
  543.  
  544. local function debuffFaded(spellID, destName, destGUID, isEnemy, isPlayer)
  545. local drCat = DRData:GetSpellCategory(spellID)
  546. if( not isPlayer and not DRData:IsPVE(drCat) ) then
  547. return
  548. end
  549.  
  550. if( not trackedPlayers[destGUID] ) then
  551. trackedPlayers[destGUID] = {}
  552. end
  553.  
  554. if( not trackedPlayers[destGUID][drCat] ) then
  555. trackedPlayers[destGUID][drCat] = { reset = 0, diminished = 1.0 }
  556. end
  557.  
  558. local time = GetTime()
  559. local tracked = trackedPlayers[destGUID][drCat]
  560.  
  561. tracked.reset = time + DRData:GetResetTime()
  562. tracked.diminished = DRData:NextDR(tracked.diminished)
  563.  
  564. -- Diminishing returns changed, now you can do an update
  565. end
  566.  
  567. local function resetDR(destGUID)
  568. -- Reset the tracked DRs for this person
  569. if( trackedPlayers[destGUID] ) then
  570. for cat in pairs(trackedPlayers[destGUID]) do
  571. trackedPlayers[destGUID][cat].reset = 0
  572. trackedPlayers[destGUID][cat].diminished = 1.0
  573. end
  574. end
  575. end
  576.  
  577. local COMBATLOG_OBJECT_TYPE_PLAYER = COMBATLOG_OBJECT_TYPE_PLAYER
  578. local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE
  579. local COMBATLOG_OBJECT_CONTROL_PLAYER = COMBATLOG_OBJECT_CONTROL_PLAYER
  580.  
  581. local eventRegistered = {["SPELL_AURA_APPLIED"] = true, ["SPELL_AURA_REFRESH"] = true, ["SPELL_AURA_REMOVED"] = true, ["PARTY_KILL"] = true, ["UNIT_DIED"] = true}
  582. local function COMBAT_LOG_EVENT_UNFILTERED(self, event, timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellID, spellName, spellSchool, auraType)
  583. if( not eventRegistered[eventType] ) then
  584. return
  585. end
  586.  
  587. -- Enemy gained a debuff
  588. if( eventType == "SPELL_AURA_APPLIED" ) then
  589. if( auraType == "DEBUFF" and DRData:GetSpellCategory(spellID) ) then
  590. local isPlayer = ( bit.band(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) == COMBATLOG_OBJECT_TYPE_PLAYER or bit.band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER )
  591. debuffGained(spellID, destName, destGUID, (bit.band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE), isPlayer)
  592. end
  593.  
  594. -- Enemy had a debuff refreshed before it faded, so fade + gain it quickly
  595. elseif( eventType == "SPELL_AURA_REFRESH" ) then
  596. if( auraType == "DEBUFF" and DRData:GetSpellCategory(spellID) ) then
  597. local isPlayer = ( bit.band(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) == COMBATLOG_OBJECT_TYPE_PLAYER or bit.band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER )
  598. local isHostile = (bit.band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE)
  599. debuffFaded(spellID, destName, destGUID, isHostile, isPlayer)
  600. debuffGained(spellID, destName, destGUID, isHostile, isPlayer)
  601. end
  602.  
  603. -- Buff or debuff faded from an enemy
  604. elseif( eventType == "SPELL_AURA_REMOVED" ) then
  605. if( auraType == "DEBUFF" and DRData:GetSpellCategory(spellID) ) then
  606. local isPlayer = ( bit.band(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) == COMBATLOG_OBJECT_TYPE_PLAYER or bit.band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER )
  607. debuffFaded(spellID, destName, destGUID, (bit.band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE), isPlayer)
  608. end
  609.  
  610. -- Don't use UNIT_DIED inside arenas due to accuracy issues, outside of arenas we don't care too much
  611. elseif( ( eventType == "UNIT_DIED" and select(2, IsInInstance()) ~= "arena" ) or eventType == "PARTY_KILL" ) then
  612. resetDR(destGUID)
  613. end
  614. end]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement