Advertisement
Guest User

loot filter

a guest
Jul 16th, 2019
21,189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.86 KB | None | 0 0
  1. function LootFilter() {
  2. function setLoots(j, h) {
  3. var f = {
  4. want: [],
  5. not: [],
  6. must: []
  7. };
  8. var k = g.loots.want;
  9. var c = g.loots.not;
  10. var d = g.loots.must;
  11. for (var e = 0; e < k.length; e++) {
  12. var b = k[e];
  13. if ($("#loot" + b).hasClass("yours")) {
  14. continue
  15. }
  16. if (j != false && b == j) {
  17. f[h].push(j)
  18. } else {
  19. f.want.push(b)
  20. }
  21. }
  22. for (var e = 0; e < c.length; e++) {
  23. var b = c[e];
  24. if ($("#loot" + b).hasClass("yours")) {
  25. continue
  26. }
  27. if (j != false && b == j) {
  28. f[h].push(j)
  29. } else {
  30. f.not.push(b)
  31. }
  32. }
  33. for (var e = 0; e < d.length; e++) {
  34. var b = d[e];
  35. if ($("#loot" + b).hasClass("yours")) {
  36. continue
  37. }
  38. if (j != false && b == j) {
  39. f[h].push(j)
  40. } else {
  41. f.must.push(b)
  42. }
  43. }
  44. g.loots.want = f.want;
  45. g.loots.not = f.not;
  46. g.loots.must = f.must;
  47. }
  48.  
  49. function createLine() {
  50. let newLine = $('<div class="line">').css({
  51. display: 'flex',
  52. lineHeight: '19px',
  53. maxHeight: '19px'
  54. });
  55. for (var i = 0; i < arguments.length; i++) {
  56. newLine.append(arguments[i]);
  57. }
  58. return newLine;
  59. }
  60.  
  61. var __this = this;
  62. var mainBox = $('<div id="ulootfilter"></div>').css({
  63. width: 150,
  64. zIndex: 500,
  65. background: '#000',
  66. border: '2px solid #202020',
  67. color: '#e3e3e3',
  68. fontFamily: 'Arial, sans-serif',
  69. fontSize: '11px',
  70. textAlign: 'left',
  71. position: 'absolute',
  72. padding: '3px',
  73. cursor: 'grab',
  74. height: 38,
  75. overflow: 'hidden',
  76. borderRadius: '4px',
  77. boxShadow: '0 0 8px rgba(0, 0, 0, 0.8)'
  78. }).draggable({
  79. opacity: 0.7,
  80. start: function() {
  81. g.lock.add('dragging');
  82. Tip.disable();
  83. $(this).css({
  84. cursor: 'grabbing'
  85. });
  86. },
  87. stop: function() {
  88. __this.saveSettings();
  89. g.lock.remove('dragging');
  90. Tip.enable();
  91. $(this).css({
  92. cursor: 'grab'
  93. });
  94. }
  95. });
  96. $('<div></div>').attr({
  97. tip: 'Pokaż więcej opcji'
  98. }).css({
  99. backgroundImage: 'url(http://i.imgur.com/JnqHa4K.png)',
  100. backgroundSize: 15,
  101. height: '15px',
  102. width: '15px',
  103. position: 'absolute',
  104. top: '3px',
  105. right: '3px'
  106. }).toggle(function() {
  107. mainBox.stop().animate({
  108. height: 235
  109. }, 500)
  110. }, function() {
  111. mainBox.stop().animate({
  112. height: 38
  113. }, 500)
  114. }).appendTo(mainBox);
  115. var filterInput = $('<input>').css({
  116. backgroundColor: '#000',
  117. border: '1px solid #202020',
  118. padding: '1px',
  119. width: 50,
  120. color: '#e3e3e3',
  121. margin: 'auto 3px',
  122. borderRadius: '3px',
  123. fontSize: '11px'
  124. }).change(function() {
  125. __this.saveSettings()
  126. });
  127. var autoQuitCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_autoQuitCheckbox').change(function() {
  128. __this.saveSettings()
  129. });
  130. var legendaryCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_legendaryCheckbox').change(function() {
  131. __this.saveSettings()
  132. });
  133. var heroicCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_heroicCheckbox').change(function() {
  134. __this.saveSettings()
  135. });
  136. var uniqueCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_uniqueCheckbox').change(function() {
  137. __this.saveSettings()
  138. });
  139. var mixCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_mixCheckbox').change(function() {
  140. __this.saveSettings()
  141. });
  142. var goldCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_goldCheckbox').change(function() {
  143. __this.saveSettings()
  144. });
  145. var arrowCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_arrowCheckbox').change(function() {
  146. __this.saveSettings()
  147. });
  148. var valueCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_valueCheckbox').change(function() {
  149. __this.saveSettings()
  150. });
  151. var tpCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_tpCheckbox').change(function() {
  152. __this.saveSettings()
  153. });
  154. var runesCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_runesCheckbox').change(function() {
  155. __this.saveSettings()
  156. });
  157. var blessCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'LFME_blessCheckbox').change(function() {
  158. __this.saveSettings()
  159. });
  160. mainBox.append(createLine('<span style="font-weight: 700; padding-left: 3px">Loot Filter'));
  161. mainBox.append(createLine(valueCheckbox, '<label for="LFME_valueCheckbox" tip="Łapanie przedmiotów od określonej wartości">Powyżej: </label>', filterInput));
  162. mainBox.append($('<separator style="display: flex; height: 3px; border-bottom: 1px dotted #202020; margin-bottom: 3px">'));
  163. mainBox.append(createLine(legendaryCheckbox, '<label for="LFME_legendaryCheckbox" tip="Łapanie legend" style="color: #fa9a20">Legendarne</label>'));
  164. mainBox.append(createLine(heroicCheckbox, '<label for="LFME_heroicCheckbox" tip="Łapanie heroików" style="color: #2090fe">Heroiczne</label>'));
  165. mainBox.append(createLine(uniqueCheckbox, '<label for="LFME_uniqueCheckbox" tip="Łapanie unikatów" style="color: #daa520">Unikatowe</label>'));
  166. mainBox.append(createLine(mixCheckbox, '<label for="LFME_mixCheckbox" tip="Łapanie miksturek" style="color: #f0032a">Mikstury</label>'));
  167. mainBox.append(createLine(arrowCheckbox, '<label for="LFME_arrowCheckbox" tip="Łapanie strzałek" style="color: brown">Strzały</label>'));
  168. mainBox.append(createLine(tpCheckbox, '<label for="LFME_tpCheckbox" tip="Łapanie teleportów" style="color: green">Teleporty</label>'));
  169. mainBox.append(createLine(goldCheckbox, '<label for="LFME_goldCheckbox" tip="Łapanie złota" style="color: gold">Złoto</label>'));
  170. mainBox.append(createLine(runesCheckbox, '<label for="LFME_runesCheckbox" tip="Łapanie run" style="color: maroon">Runy</label>'));
  171. mainBox.append(createLine(blessCheckbox, '<label for="LFME_blessCheckbox" tip="Łapanie błogosławieństw" style="color: purple">Błogosławieństwa</label>'));
  172. mainBox.append(createLine(autoQuitCheckbox, '<label for="LFME_autoQuitCheckbox" tip="Automatyczne akceptowanie łupów">Akceptowanie łupów</label>'));
  173. $('body').append(mainBox);
  174. $('line > input[type="checkbox"]').css({
  175. margin: 'auto 3px'
  176. });
  177. var tmpLootboxItem = lootboxItem;
  178. var doubleSendBlock = false;
  179. this.saveSettings = function() {
  180. localStorage.lootfilterU = 'top:' + mainBox.offset().top + '|left:' + mainBox.offset().left + '|value:' + filterInput.val() + '|autoQuit:' + (autoQuitCheckbox.attr('checked') ? 1 : 0) + '|leg:' + (legendaryCheckbox.attr('checked') ? 1 : 0) + '|her:' + (heroicCheckbox.attr('checked') ? 1 : 0) + '|uni:' + (uniqueCheckbox.attr('checked') ? 1 : 0) + '|bless:' + (blessCheckbox.attr('checked') ? 1 : 0) + '|mix:' + (mixCheckbox.attr('checked') ? 1 : 0) + '|gold:' + (goldCheckbox.attr('checked') ? 1 : 0) + '|arrow:' + (arrowCheckbox.attr('checked') ? 1 : 0) + '|val:' + (valueCheckbox.attr('checked') ? 1 : 0) + '|tp:' + (tpCheckbox.attr('checked') ? 1 : 0) + '|runes:' + (runesCheckbox.attr('checked') ? 1 : 0);
  181. };
  182. this.readSettings = function() {
  183. var settings = getCookie('lootfiltermbu');
  184. if (!!localStorage.lootfilterU) {
  185. var settings = localStorage.lootfilterU;
  186. }
  187. if (settings) {
  188. settings = settings.split('|');
  189. for (i = 0; i < settings.length; i++) {
  190. var pair = settings[i].split(':');
  191. switch (pair[0]) {
  192. case 'top':
  193. mainBox.css('top', pair[1] + 'px');
  194. break;
  195. case 'left':
  196. mainBox.css('left', pair[1] + 'px');
  197. break;
  198. case 'value':
  199. filterInput.val(pair[1]);
  200. break;
  201. case 'autoQuit':
  202. if (parseInt(pair[1]) == 1)
  203. autoQuitCheckbox.attr('checked', 'checked');
  204. break;
  205. case 'leg':
  206. if (parseInt(pair[1]) == 1)
  207. legendaryCheckbox.attr('checked', 'checked');
  208. break;
  209. case 'her':
  210. if (parseInt(pair[1]) == 1)
  211. heroicCheckbox.attr('checked', 'checked');
  212. break;
  213. case 'uni':
  214. if (parseInt(pair[1]) == 1)
  215. uniqueCheckbox.attr('checked', 'checked');
  216. break;
  217. case 'mix':
  218. if (parseInt(pair[1]) == 1)
  219. mixCheckbox.attr('checked', 'checked');
  220. break;
  221. case 'gold':
  222. if (parseInt(pair[1]) == 1)
  223. goldCheckbox.attr('checked', 'checked');
  224. break;
  225. case 'arrow':
  226. if (parseInt(pair[1]) == 1)
  227. arrowCheckbox.attr('checked', 'checked');
  228. break;
  229. case 'val':
  230. if (parseInt(pair[1]) == 1)
  231. valueCheckbox.attr('checked', 'checked');
  232. break;
  233. case 'tp':
  234. if (parseInt(pair[1]) == 1)
  235. tpCheckbox.attr('checked', 'checked');
  236. break;
  237. case 'runes':
  238. if (parseInt(pair[1]) == 1)
  239. runesCheckbox.attr('checked', 'checked');
  240. break;
  241. case 'bless':
  242. if (parseInt(pair[1]) == 1)
  243. blessCheckbox.attr('checked', 'checked');
  244. break;
  245. }
  246. }
  247. } else {
  248. legendaryCheckbox.attr('checked', 'checked');
  249. heroicCheckbox.attr('checked', 'checked');
  250. uniqueCheckbox.attr('checked', 'checked');
  251. mixCheckbox.attr('checked', 'checked');
  252. goldCheckbox.attr('checked', 'checked');
  253. arrowCheckbox.attr('checked', 'checked');
  254. valueCheckbox.attr('checked', 'checked');
  255. tpCheckbox.attr('checked', 'checked');
  256. runesCheckbox.attr('checked', 'checked');
  257. blessCheckbox.attr('checked', 'checked');
  258. }
  259. };
  260. this.readSettings();
  261. lootboxItem = function(i) {
  262. tmpLootboxItem(i);
  263. var u = parseItemStat(i.stat);
  264. var limit = parseInt(filterInput.val());
  265. if (((isNaN(limit) || (i.pr >= limit)) && valueCheckbox.attr('checked')) || (i.stat.search(/ttl/) >= 0 && blessCheckbox.attr('checked')) || (i.stat.search(/quest/) >= 0) || (i.stat.search(/legendary/) >= 0 && legendaryCheckbox.attr('checked')) || (i.stat.search(/heroic/) >= 0 && heroicCheckbox.attr('checked')) || (i.stat.search(/unique/) >= 0 && uniqueCheckbox.attr('checked')) || ((i.stat.search(/fullheal/) >= 0 || i.stat.search(/leczy/) >= 0 || i.stat.search(/perheal/) >= 0) && mixCheckbox.attr('checked')) || (i.stat.search(/ammo/) >= 0 && arrowCheckbox.attr('checked')) || (i.stat.search(/gold/) >= 0 && goldCheckbox.attr('checked')) || (i.stat.search(/teleport/) >= 0 && tpCheckbox.attr('checked')) || (i.stat.search(/runes/) >= 0 && runesCheckbox.attr('checked'))) {
  266. if (g.party && !(isset(u.reqp) && u.reqp.indexOf(hero.prof) == -1)) {
  267. setLoots(i.id, "must");
  268. setStateOnOneLootItem(i.id, 2);
  269. }
  270. } else {
  271. setLoots(i.id, "not");
  272. setStateOnOneLootItem(i.id, 0);
  273. }
  274. if (!doubleSendBlock && autoQuitCheckbox.attr('checked')) {
  275. doubleSendBlock = true;
  276. setTimeout(function() {
  277. sendLoots(1, false);
  278. doubleSendBlock = false;
  279. }, 300);
  280. }
  281. }
  282. };
  283. g.loadQueue.push({
  284. fun: function() {
  285. var _lfu = new LootFilter();
  286. },
  287. data: ''
  288. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement