Advertisement
gtoilet

d2bs enchant everywhere /TPS/WPS/quests

Dec 3rd, 2015
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.55 KB | None | 0 0
  1. /**
  2. * @filename Enchant.js
  3. * @author kolton , a gtoilet mod
  4. * @desc Enchant WPS/TPS
  5. *
  6. *
  7. * Config.Enchant.Triggers = ["chant","cows","wps","time","give gold","take gold","ng vote","andy","rada","cube","staff","amy","summoner","dury","book","trav","meph","izy","diablo"];
  8. * Config.Enchant.NGVLength = 5; // Game length in minutes
  9. *
  10. *
  11. */
  12.  
  13. function Enchant() {
  14.  
  15.  
  16. var command, hostile, nick, spot, tick, s, m,
  17. startTime = getTickCount(),
  18. shitList = [],
  19. playerLevels = {},
  20. chantList = [],
  21. countYes = 1,
  22. countNo = 0,
  23. voted = false,
  24. greet = [],
  25. a1Areas = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],
  26. a2Areas = [40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74],
  27. a3Areas = [75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102],
  28. a4Areas = [103,104,105,106,107,108],
  29. a5Areas = [109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,135],
  30. i;
  31.  
  32. this.givegold = function (nick) {
  33. var YesFiled = "logs/GaveGold.txt"
  34. var File1d = Misc.fileAction(YesFiled,0)
  35. var resa = File1d.match(nick, "g")
  36. if (resa) {
  37. say("!!" + nick + " I already gave you some gold...");
  38. }
  39. else
  40. {
  41. Misc.fileAction("logs/GaveGold.txt",2,""+nick+"")
  42. Town.move("stash");
  43. if (me.getStat(15) + me.getStat(12) >= 2000000) {
  44. say("!!Giving " + nick + " some gold");
  45. gold(Config.Enchant.GoldDrop)
  46. }
  47. else
  48. {
  49. say("!!Sorry " + nick + " im low on gold please bring me some");
  50. }
  51. }
  52. };
  53.  
  54. this.Vote = function (nick,vote) {
  55. var YesFiled = "logs/Voted.txt"
  56. var File1d = Misc.fileAction(YesFiled,0)
  57. var resa = File1d.match(nick, "g")
  58. if (resa) {
  59. say("!!" + nick + " You have already voted...");
  60. }
  61. else
  62. {
  63. say("!!" + nick + " voted yes");
  64. Misc.fileAction("logs/Voted.txt",2,""+nick+"")
  65. if (vote === "yes") {
  66. countYes++;
  67. }
  68. if (vote === "no") {
  69. countYes++;
  70. }
  71. }
  72. };
  73.  
  74. this.takegold = function (nick) {
  75. var gold, stash1, gid1;
  76. gold = getUnit(4, 523);
  77. stash1 = getUnit(2, 267);
  78. if (gold) {
  79. if (getDistance(me, gold) <= 30) {
  80. gid1 = gold.gid;
  81. say("!!Thanks for the gold.");
  82. Pickit.pickItem(gold);
  83. return me.getItem(-1, -1, gid1);
  84. Town.move("stash");
  85. }
  86. else
  87. {
  88. say("!Put the gold closer to the me.");
  89. }
  90.  
  91. }
  92. else
  93. {
  94. say("!You need to drop some gold first " + nick + "");
  95. }
  96. return true;
  97. };
  98.  
  99.  
  100. this.andy = function (nick) {
  101. say("!starting andariel");
  102. Town.doChores();
  103. Pather.useWaypoint(35, true);
  104. Precast.doPrecast(true);
  105.  
  106. if (!Pather.moveToExit([36, 37], true) || !Pather.moveTo(22582, 9612)) {
  107. throw new Error("andy failed");
  108. }
  109. Pather.makePortal();
  110. say("!theres andy");
  111. Pather.usePortal(null, me.name);
  112. Town.move("waypoint");
  113. Pather.useWaypoint(1, true);
  114. };
  115.  
  116. this.rada = function (nick) {
  117. say("!starting radament");
  118.  
  119. var i, radaCoords, rada, radaPreset, returnSpot,
  120. moveIntoPos = function (unit, range) {
  121. var i, coordx, coordy,
  122. coords = [],
  123. angle = Math.round(Math.atan2(me.y - unit.y, me.x - unit.x) * 180 / Math.PI),
  124. angles = [0, 15, -15, 30, -30, 45, -45, 60, -60, 75, -75, 90, -90, 105, -105, 120, -120, 135, -135, 150, -150, 180];
  125.  
  126. for (i = 0; i < angles.length; i += 1) {
  127. coordx = Math.round((Math.cos((angle + angles[i]) * Math.PI / 180)) * range + unit.x);
  128. coordy = Math.round((Math.sin((angle + angles[i]) * Math.PI / 180)) * range + unit.y);
  129.  
  130. try {
  131. if (!(getCollision(unit.area, coordx, coordy) & 0x1)) {
  132. coords.push({
  133. x: coordx,
  134. y: coordy
  135. });
  136. }
  137. } catch (e) {
  138.  
  139. }
  140. }
  141.  
  142. if (coords.length > 0) {
  143. coords.sort(Sort.units);
  144.  
  145. return Pather.moveToUnit(coords[0]);
  146. }
  147.  
  148. return false;
  149. };
  150.  
  151. Pather.useWaypoint(48, true);
  152. Precast.doPrecast(false);
  153. Pather.moveToExit(49, true);
  154.  
  155. radaPreset = getPresetUnit(49, 2, 355);
  156. radaCoords = {
  157. area: 49,
  158. x: radaPreset.roomx * 5 + radaPreset.x,
  159. y: radaPreset.roomy * 5 + radaPreset.y
  160. };
  161.  
  162. moveIntoPos(radaCoords, 50);
  163.  
  164. for (i = 0; i < 3; i += 1) {
  165. rada = getUnit(1, 229);
  166.  
  167. if (rada) {
  168. break;
  169. }
  170.  
  171. delay(500);
  172. }
  173.  
  174. if (rada) {
  175. moveIntoPos(rada, 60);
  176. } else {
  177. print("radament unit not found");
  178. }
  179.  
  180. Pather.makePortal();
  181. say("!theres rada");
  182. Pather.usePortal(null, null);
  183.  
  184. return true;
  185. };
  186.  
  187.  
  188. this.cube = function (nick) {
  189. if (me.diff === 0) {
  190. say("!starting cube");
  191. Pather.useWaypoint(57, true);
  192. Precast.doPrecast(true);
  193.  
  194. if (!Pather.moveToExit(60, true) || !Pather.moveToPreset(me.area, 2, 354)) {
  195. throw new Error("cube failed");
  196. }
  197. say("!didnt clear portal");
  198. Pather.makePortal();
  199. delay(100);
  200. say("!is hot tp");
  201. Pather.usePortal(null, me.name);
  202. Town.move("waypoint");
  203. Pather.useWaypoint(1, true);
  204. }
  205. };
  206.  
  207. this.amy = function (nick) {
  208. say("!starting amy");
  209. Town.doChores();
  210. Pather.useWaypoint(44, true);
  211. Precast.doPrecast(true);
  212.  
  213. if (!Pather.moveToExit([45, 58, 61], true) || !Pather.moveTo(15044, 14045)) {
  214. throw new Error("amulet failed");
  215. }
  216. Pather.makePortal();
  217. if (me.diff < 2) {
  218. Attack.securePosition(me.x, me.y, 0, 0);
  219. } else {
  220. Attack.securePosition(me.x, me.y, 0, 0, true, true);
  221. }
  222. say("!could be hot tp");
  223. Pather.usePortal(null, me.name);
  224. Town.move("waypoint");
  225. Pather.useWaypoint(1, true);
  226. };
  227.  
  228. this.staff = function (nick) {
  229. say("!starting staff");
  230. Town.doChores();
  231. Pather.useWaypoint(43, true);
  232. Precast.doPrecast(true);
  233.  
  234. if (!Pather.moveToExit([62, 63, 64], true) || !Pather.moveToPreset(me.area, 2, 356)) {
  235. throw new Error("staff failed");
  236. }
  237. say("!is hot tp");
  238. Pather.makePortal();
  239. Pather.usePortal(null, me.name);
  240. Town.move("waypoint");
  241. Pather.useWaypoint(1, true);
  242. delay(1100);
  243. };
  244.  
  245. this.summoner = function (nick) {
  246. // right up 25449 5081 (25431, 5011)
  247. // left up 25081 5446 (25011, 5446)
  248. // right down 25830 5447 (25866, 5431)
  249. // left down 25447 5822 (25431, 5861)
  250. say("!starting summoner");
  251. Town.doChores();
  252. Pather.useWaypoint(74, true);
  253. Precast.doPrecast(true);
  254. var i, journal,
  255. preset = getPresetUnit(me.area, 2, 357),
  256. spot = {};
  257. switch (preset.roomx * 5 + preset.x) {
  258. case 25011:
  259. spot = {x: 25081, y: 5446};
  260. break;
  261. case 25866:
  262. spot = {x: 25830, y: 5447};
  263. break;
  264. case 25431:
  265. switch (preset.roomy * 5 + preset.y) {
  266. case 5011:
  267. spot = {x: 25449, y: 5081};
  268. break;
  269. case 5861:
  270. spot = {x: 25447, y: 5822};
  271. break;}
  272. break;}
  273. if (!Pather.moveToUnit(spot)) {
  274. throw new Error("summoner failed");}
  275. Pather.makePortal();
  276. say("!theres summoner");
  277. Pather.usePortal(null, me.name);
  278. Town.move("waypoint");
  279. Pather.useWaypoint(1, true);
  280. };
  281.  
  282. this.dury = function (nick) {
  283. say("!starting duriel");
  284. if (me.inTown) {
  285. Town.doChores();
  286. Pather.useWaypoint(46, true);}
  287. Precast.doPrecast(true);
  288. if (!Pather.moveToExit(getRoom().correcttomb, true) || !Pather.moveToPreset(me.area, 2, 152)) {
  289. throw new Error("duriel failed");}
  290. Pather.makePortal();
  291. say("!theres dury");
  292. Pather.usePortal(null, me.name);
  293. Town.move("waypoint");
  294. Pather.useWaypoint(1, true);
  295. };
  296.  
  297. this.book = function (nick) {
  298. if (!Town.goToTown() || !Pather.useWaypoint(80, true)) {
  299. throw new Error("Lam Essen quest failed");
  300. }
  301.  
  302. Precast.doPrecast(false);
  303.  
  304. if (!Pather.moveToExit(94, true) || !Pather.moveToPreset(me.area, 2, 193)) {
  305. throw new Error("Lam Essen quest failed");
  306. }
  307.  
  308. Pather.makePortal();
  309. say("!theres the book");
  310. Pather.usePortal(null, null);
  311.  
  312. return true;
  313. };
  314.  
  315. this.trav = function (nick) {
  316. Town.doChores();
  317. Pather.useWaypoint(83, true);
  318. Precast.doPrecast(true);
  319.  
  320. var coords = [me.x, me.y];
  321.  
  322. Pather.moveTo(coords[0] + 60, coords[1] - 130);
  323. Pather.makePortal();
  324. say("!theres trav");
  325. Pather.usePortal(null, me.name);
  326.  
  327. return true;
  328. };
  329.  
  330. this.meph = function (nick) {
  331. say("!starting meph");
  332. Town.doChores();
  333. Pather.useWaypoint(101, true);
  334. Precast.doPrecast(true);
  335. Pather.moveToExit(102, true);
  336. Pather.moveTo(17581, 8091);
  337. Pather.makePortal();
  338. delay(4000);
  339. say("!theres meph");
  340. Pather.usePortal(null, me.name);
  341. Town.move("waypoint");
  342. Pather.useWaypoint(1, true);
  343. };
  344.  
  345. this.izy = function (nick) {
  346. say("!starting izy");
  347. Town.doChores();
  348. var i, izualCoords, izual, izualPreset, returnSpot,
  349. moveIntoPos = function (unit, range) {
  350. var i, coordx, coordy,
  351. coords = [],
  352. angle = Math.round(Math.atan2(me.y - unit.y, me.x - unit.x) * 180 / Math.PI),
  353. angles = [0, 15, -15, 30, -30, 45, -45, 60, -60, 75, -75, 90, -90, 105, -105, 120, -120, 135, -135, 150, -150, 180];
  354. for (i = 0; i < angles.length; i += 1) {
  355. coordx = Math.round((Math.cos((angle + angles[i]) * Math.PI / 180)) * range + unit.x);
  356. coordy = Math.round((Math.sin((angle + angles[i]) * Math.PI / 180)) * range + unit.y);
  357. try {
  358.  
  359. if (!(getCollision(unit.area, coordx, coordy) & 0x1)) {
  360. coords.push({
  361. x: coordx,
  362. y: coordy
  363. });
  364. }
  365. } catch (e) {
  366. }
  367. }
  368.  
  369. if (coords.length > 0) {
  370. coords.sort(Sort.units);
  371. return Pather.moveToUnit(coords[0]);
  372. }
  373. return false;
  374. };
  375. Pather.useWaypoint(106, true);
  376. Precast.doPrecast(false);
  377. Pather.moveToExit(105, true);
  378. izualPreset = getPresetUnit(105, 1, 256);
  379. izualCoords = {
  380. area: 105,
  381. x: izualPreset.roomx * 5 + izualPreset.x,
  382. y: izualPreset.roomy * 5 + izualPreset.y
  383. };
  384. moveIntoPos(izualCoords, 50);
  385. for (i = 0; i < 3; i += 1) {
  386. izual = getUnit(1, 256);
  387.  
  388. if (izual) {
  389. break;
  390. }
  391. delay(500);
  392. }
  393.  
  394. if (izual) {
  395. moveIntoPos(izual, 60);
  396. } else {
  397. print("izual unit not found");
  398. }
  399. returnSpot = {
  400. x: me.x,
  401. y: me.y
  402. };
  403. Pather.makePortal();
  404. say("!could be hot tp");
  405. Pather.usePortal(null, me.name);
  406. Town.move("waypoint");
  407. Pather.useWaypoint(1, true);
  408. };
  409.  
  410. this.diablo = function (nick) {
  411. say("!starting diablo");
  412. Town.doChores();
  413. Pather.useWaypoint(107, true);
  414. Precast.doPrecast(true);
  415. Pather.moveTo(7790, 5544);
  416. Pather.makePortal();
  417. say("!theres star could be hot");
  418. Pather.usePortal(null, me.name);
  419. Town.move("waypoint");
  420. Pather.useWaypoint(1, true);
  421. };
  422. this.ngvt = function () {
  423. say("!vote yes or no");
  424. Misc.fileAction("logs/Voted.txt",1,"")
  425. voted = true;
  426. countYes = 1;
  427. countNo = 0;
  428. delay(15000);
  429. this.ChkVote();
  430. voted = false;
  431. };
  432. this.chatEvent = function (nick, msg) {
  433. if (nick) {
  434. switch (msg) {
  435. case "yes":
  436. if (voted === true) {
  437. this.Vote(nick,"yes");
  438. }
  439. break;
  440. case "no":
  441. if (voted === true) {
  442. this.Vote(nick,"no");
  443. }
  444. break;
  445. }
  446. }
  447. };
  448.  
  449. this.ChkVote = function () {
  450. if (countYes <= countNo) {
  451. say("!no won so were staying here");
  452. }
  453. else
  454. {
  455. say("!yes won going to next game in 15 seconds");
  456. delay(900);
  457. say("!hosted by gtoilet@jsp , i only join normal games");
  458. delay(900);
  459. say("!i will try to join the next game if you make it");
  460. delay(15000);
  461. Misc.fileAction("logs/Voted.txt",1,"")
  462. quit();
  463. }
  464. countYes = 1;
  465. countNo = 0;
  466. Misc.fileAction("logs/Voted.txt",1,"")
  467. };
  468. this.timeleft = function () {
  469. tick = Config.Enchant.GameLength * 6e4 - getTickCount() + startTime;
  470. m = Math.floor(tick / 60000);
  471. s = Math.floor((tick / 1000) % 60);
  472. say("!!Time left: " + (m ? m + " minute" + (m > 1 ? "s" : "") + ", " : "") + s + " second" + (s > 1 ? "s." : "."));
  473. delay(2200);
  474. say("! !vote me out before ending game or you will get shitlisted!");
  475. }; this.enchant = function (nick,id) {
  476. if (!Misc.inMyParty(nick)) {
  477. say("!Accept party invite, noob.");
  478.  
  479. return false;
  480. }
  481.  
  482. var partyUnit,
  483. unit = getUnit(0, nick);
  484.  
  485. if (getDistance(me, unit) > 0) {
  486. say("!You need to be at a WP or any other TP.");
  487.  
  488. return false;
  489. }
  490.  
  491. if (!unit) {
  492. partyUnit = getParty(nick);
  493.  
  494. // wait until party area is readable?
  495.  
  496. if ([3,4,5,6,27,29,32,35,48,42,57,43,44,52,74,46,76,77,78,79,80,81,83,101,106,107,111,112,113,115,123,117,118,129].indexOf(partyUnit.area) > -1) { // Only meet someone at a Waypoint
  497. say("!Stay Near Waypoint.");
  498.  
  499. Pather.useWaypoint(partyUnit.area); // Go to the Waypoint in their area.
  500.  
  501. unit = getUnit(0, nick);
  502. } else {
  503. if ([2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,30,31,33,34,36,37,38,39,40,41,42,43,45,47,48,49,50,51,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,75,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,102,104,105,108110,116,119,120,121,122,123,124,125,126,127,128,130,131,132,133,134,135,].indexOf(partyUnit.area) > -1) { // Only meet someone at a tp if they are in one of these areas.
  504. say("!Stay Near portal.");
  505. if (a1Areas.indexOf(id) > -1 && a1Areas.indexOf(me.area) == -1) Town.goToTown(1);
  506. if (a2Areas.indexOf(id) > -1 && a2Areas.indexOf(me.area) == -1) Town.goToTown(2);
  507. if (a3Areas.indexOf(id) > -1 && a3Areas.indexOf(me.area) == -1) Town.goToTown(3);
  508. if (a4Areas.indexOf(id) > -1 && a4Areas.indexOf(me.area) == -1) Town.goToTown(4);
  509. if (a5Areas.indexOf(id) > -1 && a5Areas.indexOf(me.area) == -1) Town.goToTown(5);
  510. if (me.area != 1 && me.area != 40 && me.area != 75 && me.area != 103 && me.area != 109) Town.goToTown();
  511. Town.move("portalspot");
  512. if (Pather.getPortal(id,nick)) Pather.usePortal(id,nick);
  513. else say("!Do you have a tp up?");
  514. unit = getUnit(0, nick);
  515. }
  516. }
  517. }
  518.  
  519. if (unit) {
  520. do {
  521. if (!unit.dead) { // player is alive
  522. if (getDistance(me, unit) >= 44) {
  523. say("!You went too far away.");
  524.  
  525. return false;
  526. }
  527.  
  528. Skill.setSkill(52, 0);
  529. sendPacket(1, 0x11, 4, unit.type, 4, unit.gid);
  530. delay(500);
  531. }
  532. } while (unit.getNext());
  533. } else {
  534. say("!Couldn't find you, champ.");
  535. }
  536.  
  537. unit = getUnit(1);
  538.  
  539. if (unit) {
  540. do {
  541. if (unit.getParent() && unit.getParent().name === nick) { // merc or any other owned unit
  542. Skill.setSkill(52, 0);
  543. sendPacket(1, 0x11, 4, unit.type, 4, unit.gid);
  544. delay(500);
  545. }
  546. } while (unit.getNext());
  547. }
  548. Pather.usePortal(null, null);
  549. delay(50);
  550. Pather.useWaypoint(1, true);
  551. return true;
  552. };
  553.  
  554. this.autoChant = function () {
  555. var unit,
  556. chanted = [];
  557.  
  558. // Player
  559. unit = getUnit(0);
  560.  
  561. if (unit) {
  562. do {
  563. if (unit.name !== me.name && !unit.dead && shitList.indexOf(unit.name) === -1 && Misc.inMyParty(unit.name) && !unit.getState(16) && getDistance(me, unit) <= 40) {
  564. Skill.setSkill(52, 0);
  565. sendPacket(1, 0x11, 4, unit.type, 4, unit.gid);
  566. delay(500);
  567. chanted.push(unit.name);
  568. }
  569. } while (unit.getNext());
  570. }
  571.  
  572. // Minion
  573. unit = getUnit(1);
  574.  
  575. if (unit) {
  576. do {
  577. if (unit.getParent() && chanted.indexOf(unit.getParent().name) > -1 && !unit.getState(16) && getDistance(me, unit) <= 40) {
  578. Skill.setSkill(52, 0);
  579. sendPacket(1, 0x11, 4, unit.type, 4, unit.gid);
  580. delay(500);
  581. }
  582. } while (unit.getNext());
  583. }
  584.  
  585. return true;
  586. };
  587.  
  588. this.getLeg = function () {
  589. var i, portal, wirt, leg, gid, wrongLeg;
  590.  
  591. if (me.getItem(88)) {
  592. return me.getItem(88);
  593. }
  594.  
  595. if (!Config.Enchant.GetLeg) {
  596. leg = getUnit(4, 88);
  597.  
  598. if (leg) {
  599. do {
  600. if (leg.name.indexOf("�c1") > -1) {
  601. wrongLeg = true;
  602. } else if (getDistance(me, leg) <= 22) {
  603. gid = leg.gid;
  604.  
  605. Pickit.pickItem(leg);
  606.  
  607. return me.getItem(-1, -1, gid);
  608. }
  609. } while (leg.getNext());
  610. }
  611.  
  612. say("!Bring the leg " + (wrongLeg ? "from this difficulty" : "") + " close to me.");
  613.  
  614. return false;
  615. }
  616.  
  617. Pather.useWaypoint(4);
  618. Precast.doPrecast(true);
  619. Pather.moveToPreset(me.area, 1, 737, 8, 8);
  620.  
  621. for (i = 0; i < 6; i += 1) {
  622. portal = Pather.getPortal(38);
  623.  
  624. if (portal) {
  625. Pather.usePortal(null, null, portal);
  626.  
  627. break;
  628. }
  629.  
  630. delay(500);
  631. }
  632.  
  633. if (!portal) {
  634. say("!Failed to enter Tristram :(");
  635. Town.goToTown();
  636.  
  637. return false;
  638. }
  639.  
  640. Pather.moveTo(25048, 5177);
  641.  
  642. wirt = getUnit(2, 268);
  643.  
  644. for (i = 0; i < 8; i += 1) {
  645. wirt.interact();
  646. delay(500);
  647.  
  648. leg = getUnit(4, 88);
  649.  
  650. if (leg) {
  651. gid = leg.gid;
  652.  
  653. Pickit.pickItem(leg);
  654. Town.goToTown();
  655.  
  656. return me.getItem(-1, -1, gid);
  657. }
  658. }
  659.  
  660. Town.goToTown();
  661. say("!Failed to get the leg :(");
  662.  
  663. return false;
  664. };
  665.  
  666. this.getTome = function () {
  667. var tome, akara, myTome;
  668.  
  669. myTome = me.findItem("tbk", 0, 3);
  670. tome = me.getItem("tbk");
  671.  
  672. // In case of 2 tomes or tome stuck in cube
  673. if (tome) {
  674. do {
  675. if (!myTome || tome.gid !== myTome.gid) {
  676. return copyUnit(tome);
  677. }
  678. } while (tome.getNext());
  679. }
  680.  
  681. Town.move("akara");
  682.  
  683. akara = getUnit(1, NPC.Akara);
  684.  
  685. if (!akara || akara.area !== me.area || getDistance(me, akara) > 30) {
  686. say("!Akara not found.");
  687.  
  688. return false;
  689. }
  690.  
  691. myTome = me.findItem("tbk", 0, 3);
  692. tome = me.getItem("tbk");
  693.  
  694. if (tome) {
  695. do {
  696. if (!myTome || tome.gid !== myTome.gid) {
  697. return copyUnit(tome);
  698. }
  699. } while (tome.getNext());
  700. }
  701.  
  702. akara = Town.initNPC("Shop");
  703.  
  704. if (!akara) {
  705. say("!Failed to buy tome :(");
  706.  
  707. return false;
  708. }
  709.  
  710. tome = akara.getItem("tbk");
  711.  
  712. if (tome.buy()) {
  713. tome = me.getItem("tbk");
  714.  
  715. if (tome) {
  716. do {
  717. if (!myTome || tome.gid !== myTome.gid) {
  718. return copyUnit(tome);
  719. }
  720. } while (tome.getNext());
  721. }
  722. }
  723.  
  724. return false;
  725. };
  726.  
  727. this.openPortal = function (nick) {
  728. if (!Misc.inMyParty(nick)) {
  729. say("!Accept party invite, noob.");
  730.  
  731. return true;
  732. }
  733.  
  734. if (Pather.getPortal(39)) {
  735. say("!Cow portal already open.");
  736.  
  737. return true;
  738. }
  739.  
  740. if (me.getQuest(4, 10)) { // king dead or cain not saved
  741. say("!Can't open the portal because I killed Cow King.");
  742.  
  743. return false;
  744. }
  745.  
  746. if (Config.Enchant.GetLeg && !me.getQuest(4, 0)) {
  747. say("!Can't get leg because I don't have Cain quest.");
  748.  
  749. return false;
  750. }
  751.  
  752. switch (me.gametype) {
  753. case 0: // classic
  754. if (!me.getQuest(26, 0)) { // diablo not completed
  755. say("!I don't have Diablo quest.");
  756.  
  757. return false;
  758. }
  759.  
  760. break;
  761. case 1: // expansion
  762. if (!me.getQuest(40, 0)) { // baal not completed
  763. say("!I don't have Baal quest.");
  764.  
  765. return false;
  766. }
  767.  
  768. break;
  769. }
  770.  
  771. var i, leg, tome;
  772.  
  773. leg = this.getLeg();
  774.  
  775. if (!leg) {
  776. return false;
  777. }
  778.  
  779. tome = this.getTome();
  780.  
  781. if (!tome) {
  782. return false;
  783. }
  784.  
  785. if (!Town.move("waypoint") || !Cubing.emptyCube() || !Storage.Cube.MoveTo(leg) || !Storage.Cube.MoveTo(tome) || !Cubing.openCube()) {
  786. return false;
  787. }
  788.  
  789. transmute();
  790. delay(500);
  791.  
  792. for (i = 0; i < 10; i += 1) {
  793. if (Pather.getPortal(39)) {
  794. return true;
  795. }
  796.  
  797. delay(200);
  798. }
  799.  
  800. say("!Failed to open cow portal.");
  801.  
  802. return false;
  803. };
  804.  
  805. this.getWpNick = function (nick) {
  806. if (!this.wpNicks) {
  807. this.wpNicks = {};
  808. }
  809.  
  810. if (this.wpNicks.hasOwnProperty(nick)) {
  811. if (this.wpNicks[nick].requests > 4) {
  812. return "maxrequests";
  813. }
  814.  
  815. if (getTickCount() - this.wpNicks[nick].timer < 60000) {
  816. return "mintime";
  817. }
  818.  
  819. return true;
  820. }
  821.  
  822. return false;
  823. };
  824.  
  825. this.addWpNick = function (nick) {
  826. this.wpNicks[nick] = {timer: getTickCount(), requests: 0};
  827. };
  828.  
  829. this.giveWps = function (nick) {
  830. if (!Misc.inMyParty(nick)) {
  831. say("!Accept party invite, noob.");
  832.  
  833. return false;
  834. }
  835.  
  836. var i, act, timeout, wpList;
  837.  
  838. switch (this.getWpNick(nick)) {
  839. case "maxrequests":
  840. say(nick + ", you have spent all your waypoint requests for this game.");
  841.  
  842. return false;
  843. case "mintime":
  844. say(nick + ", you may request waypoints every 60 seconds.");
  845.  
  846. return false;
  847. case false:
  848. this.addWpNick(nick);
  849.  
  850. break;
  851. }
  852.  
  853. act = this.getPlayerAct(nick);
  854.  
  855. switch (act) {
  856. case 1:
  857. wpList = [4,5,35];
  858.  
  859. break;
  860. case 2:
  861. wpList = [48,57,43,44,74,46];
  862.  
  863. break;
  864. case 3:
  865. wpList = [83,101];
  866.  
  867. break;
  868. case 4:
  869. wpList = [107];
  870.  
  871. break;
  872. case 5:
  873. wpList = [111,112,113,115,123,117,118,129];
  874.  
  875. break;
  876. }
  877.  
  878. MainLoop:
  879. for (i = 0; i < wpList.length; i += 1) {
  880. if (this.checkHostiles()) {
  881. break;
  882. }
  883.  
  884. try {
  885. Pather.useWaypoint(wpList[i], true);
  886. Pather.makePortal();
  887. say(getArea().name + " ");
  888.  
  889. for (timeout = 0; timeout < 20; timeout += 1) {
  890. if (getUnit(0, nick)) {
  891. break;
  892. }
  893.  
  894. delay(1000);
  895. }
  896.  
  897. if (timeout >= 20) {
  898. say("!Aborting wp giving.");
  899. Pather.useWaypoint(1, true);
  900.  
  901. break MainLoop;
  902. }
  903.  
  904. delay(5000);
  905. } catch (error) {
  906.  
  907. }
  908. }
  909. Pather.useWaypoint(1, true);
  910.  
  911. Town.doChores();
  912. Town.goToTown(1);
  913. Town.move("waypoint");
  914. Pather.useWaypoint(1, true);
  915. delay(1100);
  916. Pather.useWaypoint(35, true);
  917. Pather.makePortal();
  918. Pather.useWaypoint(1, true);
  919. this.wpNicks[nick].requests += 1;
  920. this.wpNicks[nick].timer = getTickCount();
  921.  
  922. return true;
  923. };
  924.  
  925. this.getPlayerAct = function (name) {
  926. var unit = getParty();
  927.  
  928. if (unit) {
  929. do {
  930. if (unit.name === name) {
  931. if (unit.area <= 39) {
  932. return 1;
  933. }
  934.  
  935. if (unit.area >= 40 && unit.area <= 74) {
  936. return 2;
  937. }
  938.  
  939. if (unit.area >= 75 && unit.area <= 102) {
  940. return 3;
  941. }
  942.  
  943. if (unit.area >= 103 && unit.area <= 108) {
  944. return 4;
  945. }
  946. if (unit.area >= 109 && unit.area <= 136) {
  947. return 5;
  948. }
  949. return 6;
  950. }
  951. } while (unit.getNext());
  952. }
  953.  
  954. return false;
  955. };
  956.  
  957. this.checkHostiles = function () {
  958. var rval = false,
  959. party = getParty();
  960.  
  961. if (party) {
  962. do {
  963. if (party.name !== me.name && getPlayerFlag(me.gid, party.gid, 8)) {
  964. rval = true;
  965.  
  966. if (Config.ShitList && shitList.indexOf(party.name) === -1) {
  967. shitList.push(party.name);
  968. }
  969. }
  970. } while (party.getNext());
  971. }
  972.  
  973. return rval;
  974. };
  975.  
  976. this.floodCheck = function (command) {
  977. var cmd = command[0],
  978. nick = command[1];
  979.  
  980. if ([ "help", "timeleft",
  981. Config.Enchant.Triggers[0].toLowerCase(),
  982. Config.Enchant.Triggers[1].toLowerCase(),
  983. Config.Enchant.Triggers[2].toLowerCase()
  984. ].indexOf(cmd.toLowerCase()) === -1) {
  985. return false;
  986. }
  987.  
  988. if (!this.cmdNicks) {
  989. this.cmdNicks = {};
  990. }
  991.  
  992. if (!this.cmdNicks.hasOwnProperty(nick)) {
  993. this.cmdNicks[nick] = {
  994. firstCmd: getTickCount(),
  995. commands: 0,
  996. ignored: false
  997. };
  998. }
  999.  
  1000. if (this.cmdNicks[nick].ignored) {
  1001. if (getTickCount() - this.cmdNicks[nick].ignored < 60000) {
  1002. return true; // ignore flooder
  1003. }
  1004.  
  1005. // unignore flooder
  1006. this.cmdNicks[nick].ignored = false;
  1007. this.cmdNicks[nick].commands = 0;
  1008. }
  1009.  
  1010. this.cmdNicks[nick].commands += 1;
  1011.  
  1012. if (getTickCount() - this.cmdNicks[nick].firstCmd < 10000) {
  1013. if (this.cmdNicks[nick].commands > 5) {
  1014. this.cmdNicks[nick].ignored = getTickCount();
  1015.  
  1016. say(nick + ", you are being ignored for 60 seconds because of flooding.");
  1017. }
  1018. } else {
  1019. this.cmdNicks[nick].firstCmd = getTickCount();
  1020. this.cmdNicks[nick].commands = 0;
  1021. }
  1022.  
  1023. return false;
  1024. };
  1025.  
  1026. function ChatEvent(nick, msg) {
  1027. command = [msg, nick];
  1028. }
  1029.  
  1030. function GreetEvent(mode, param1, param2, name1, name2) {
  1031. switch (mode) {
  1032. case 0x02:
  1033. if (me.inTown && me.mode === 5) { // idle in town
  1034. greet.push(name1);
  1035. }
  1036.  
  1037. break;
  1038. }
  1039. }
  1040.  
  1041. // START
  1042. if (Config.ShitList) {
  1043. shitList = ShitList.read();
  1044. }
  1045.  
  1046. addEventListener("chatmsg", ChatEvent);
  1047. addEventListener("gameevent", GreetEvent);
  1048. Town.doChores();
  1049. Town.goToTown(1);
  1050. Town.move("waypoint");
  1051. Pather.useWaypoint(35);
  1052. Pather.makePortal();
  1053. Pather.useWaypoint(1);
  1054.  
  1055. spot = {
  1056. x: me.x,
  1057. y: me.y
  1058. };
  1059.  
  1060. while (true) {
  1061. while (greet.length > 0) {
  1062. nick = greet.shift();
  1063.  
  1064. if (shitList.indexOf(nick) === -1) {
  1065. //say("!Welcome! For a list of commands say 'help' ");
  1066. }
  1067. }
  1068.  
  1069. if (spot && getDistance(me, spot) > 10) {
  1070. Pather.moveTo(spot.x, spot.y);
  1071. }
  1072.  
  1073. if (command && !this.floodCheck(command)) {
  1074. switch (command[0].toLowerCase()) {
  1075. case "help":
  1076. this.checkHostiles();
  1077.  
  1078. if (shitList.indexOf(command[1]) > -1) {
  1079. say("!No " + command[0] + " for the shitlisted.");
  1080.  
  1081. break;
  1082. }
  1083.  
  1084. say("" +
  1085. (Config.Enchant.Triggers[0] ? " | chant: " + Config.Enchant.Triggers[0] : "") +
  1086. (Config.Enchant.Triggers[1] ? " | cows: " + Config.Enchant.Triggers[1] : "") +
  1087. (Config.Enchant.Triggers[2] ? " | wps: " + Config.Enchant.Triggers[2] : "") +
  1088. (Config.Enchant.Triggers[3] ? " | time left: " + Config.Enchant.Triggers[3] : "") +
  1089. (Config.Enchant.Triggers[4] ? " | GiveGold: " + Config.Enchant.Triggers[4] : ""));
  1090. delay(333);
  1091. say(" " +
  1092. (Config.Enchant.Triggers[5] ? " | TakeGold: " + Config.Enchant.Triggers[5] : "") +
  1093. (Config.Enchant.Triggers[6] ? " | ngvote: " + Config.Enchant.Triggers[6] : "") +
  1094. (Config.Enchant.Triggers[7] ? " | andy: " + Config.Enchant.Triggers[7] : "") +
  1095. (Config.Enchant.Triggers[8] ? " | rada: " + Config.Enchant.Triggers[8] : "") +
  1096. (Config.Enchant.Triggers[9] ? " | cube: " + Config.Enchant.Triggers[9] : ""));
  1097. delay(3333);
  1098. say(" " +
  1099. (Config.Enchant.Triggers[10] ? " | staff: " + Config.Enchant.Triggers[10] : "") +
  1100. (Config.Enchant.Triggers[11] ? " | amy: " + Config.Enchant.Triggers[11] : "") +
  1101. (Config.Enchant.Triggers[12] ? " | summoner: " + Config.Enchant.Triggers[12] : "") +
  1102. (Config.Enchant.Triggers[13] ? " | dury: " + Config.Enchant.Triggers[13] : "") +
  1103. (Config.Enchant.Triggers[14] ? " | book: " + Config.Enchant.Triggers[14] : ""));
  1104. delay(3333);
  1105. say(" " +
  1106. (Config.Enchant.Triggers[15] ? " | trav: " + Config.Enchant.Triggers[15] : "") +
  1107. (Config.Enchant.Triggers[16] ? " | meph: " + Config.Enchant.Triggers[16] : "") +
  1108. (Config.Enchant.Triggers[17] ? " | izy: " + Config.Enchant.Triggers[17] : "") +
  1109. (Config.Enchant.Triggers[18] ? " | diablo: " + Config.Enchant.Triggers[18] : ""));
  1110.  
  1111. if (Config.Enchant.AutoChant) {
  1112. say("!Auto enchant is ON");
  1113. }
  1114.  
  1115. break;
  1116. case Config.Enchant.Triggers[0].toLowerCase(): // chant
  1117. this.checkHostiles();
  1118.  
  1119. if (shitList.indexOf(command[1]) > -1) {
  1120. say("!No chant for the shitlisted.");
  1121.  
  1122. break;
  1123. }
  1124.  
  1125. this.enchant(command[1]);
  1126.  
  1127. break;
  1128. case Config.Enchant.Triggers[1].toLowerCase(): // cows
  1129. hostile = this.checkHostiles();
  1130.  
  1131. if (shitList.indexOf(command[1]) > -1) {
  1132. say("!No cows for the shitlisted.");
  1133.  
  1134. break;
  1135. }
  1136.  
  1137. this.openPortal(command[1]);
  1138. me.cancel();
  1139.  
  1140. break;
  1141. case Config.Enchant.Triggers[2].toLowerCase(): // wps
  1142. hostile = this.checkHostiles();
  1143.  
  1144. if (shitList.indexOf(command[1]) > -1) {
  1145. say("!No waypoints for the shitlisted.");
  1146.  
  1147. break;
  1148. }
  1149.  
  1150. if (hostile) {
  1151. say("!Command disabled because of hostiles.");
  1152.  
  1153. break;
  1154. }
  1155.  
  1156. this.giveWps(command[1]);
  1157.  
  1158. break;
  1159. case Config.Enchant.Triggers[3].toLowerCase(): // timeleft
  1160. hostile = this.checkHostiles();
  1161.  
  1162. if (shitList.indexOf(command[1]) > -1) {
  1163. say("!Fk to time.");
  1164.  
  1165. break;
  1166. }
  1167.  
  1168. if (hostile) {
  1169. say("!Command disabled because of hostiles.");
  1170.  
  1171. break;
  1172. }
  1173.  
  1174. this.timeleft(command[1]);
  1175.  
  1176. break;
  1177. case Config.Enchant.Triggers[4].toLowerCase(): // givegold
  1178. hostile = this.checkHostiles();
  1179.  
  1180. if (shitList.indexOf(command[1]) > -1) {
  1181. say("!much appreciated.");
  1182. this.givegold(command[1]);
  1183. break;
  1184. }
  1185.  
  1186. if (hostile) {
  1187. say("!Command disabled because of hostiles.");
  1188.  
  1189. break;
  1190. }
  1191.  
  1192. this.givegold(command[1]);
  1193.  
  1194. break;
  1195.  
  1196. case Config.Enchant.Triggers[5].toLowerCase(): // takegold
  1197. hostile = this.checkHostiles();
  1198.  
  1199. if (shitList.indexOf(command[1]) > -1) {
  1200. say("!much appreciated.");
  1201. this.takegold(command[1]);
  1202. break;
  1203. }
  1204.  
  1205. if (hostile) {
  1206. say("!Command disabled because of hostiles.");
  1207.  
  1208. break;
  1209. }
  1210.  
  1211. this.takegold(command[1]);
  1212.  
  1213. break;
  1214. case Config.Enchant.Triggers[6].toLowerCase(): // ngvote
  1215. hostile = this.checkHostiles();
  1216.  
  1217. if (shitList.indexOf(command[1]) > -1) {
  1218. say("!You wish...");
  1219.  
  1220. break;
  1221. }
  1222.  
  1223. if (hostile) {
  1224. say("!Command disabled because of hostiles.");
  1225.  
  1226. break;
  1227. }
  1228. if (getTickCount() - me.gamestarttime >= Config.Enchant.NGVLength * 6e4) {
  1229. this.ngvt(command[1]);
  1230. break;
  1231. }
  1232. else
  1233. {
  1234. say("!Wait a little more!");
  1235. break;
  1236. }
  1237.  
  1238. break;
  1239.  
  1240.  
  1241. case Config.Enchant.Triggers[7].toLowerCase(): // andy
  1242. hostile = this.checkHostiles();
  1243.  
  1244. if (shitList.indexOf(command[1]) > -1) {
  1245. say("!zzz...");
  1246. break;
  1247. }
  1248.  
  1249. if (hostile) {
  1250. say("!Command disabled because of hostiles.");
  1251.  
  1252. break;
  1253. }
  1254.  
  1255. this.andy(command[1]);
  1256.  
  1257. break;
  1258.  
  1259.  
  1260. case Config.Enchant.Triggers[8].toLowerCase(): // rada
  1261. hostile = this.checkHostiles();
  1262.  
  1263. if (shitList.indexOf(command[1]) > -1) {
  1264. say("!zzz...");
  1265. break;
  1266. }
  1267.  
  1268. if (hostile) {
  1269. say("!Command disabled because of hostiles.");
  1270.  
  1271. break;
  1272. }
  1273.  
  1274. this.rada(command[1]);
  1275.  
  1276. break;
  1277.  
  1278.  
  1279. case Config.Enchant.Triggers[9].toLowerCase(): // cube
  1280. hostile = this.checkHostiles();
  1281.  
  1282. if (shitList.indexOf(command[1]) > -1) {
  1283. say("!zzz...");
  1284. break;
  1285. }
  1286.  
  1287. if (hostile) {
  1288. say("!Command disabled because of hostiles.");
  1289.  
  1290. break;
  1291. }
  1292.  
  1293. this.cube(command[1]);
  1294.  
  1295. break;
  1296. case Config.Enchant.Triggers[10].toLowerCase(): // staff
  1297. hostile = this.checkHostiles();
  1298.  
  1299. if (shitList.indexOf(command[1]) > -1) {
  1300. say("!zzz...");
  1301. break;
  1302. }
  1303.  
  1304. if (hostile) {
  1305. say("!Command disabled because of hostiles.");
  1306.  
  1307. break;
  1308. }
  1309.  
  1310. this.staff(command[1]);
  1311.  
  1312. break;
  1313. case Config.Enchant.Triggers[11].toLowerCase(): // amy
  1314. hostile = this.checkHostiles();
  1315.  
  1316. if (shitList.indexOf(command[1]) > -1) {
  1317. say("!zzz...");
  1318. break;
  1319. }
  1320.  
  1321. if (hostile) {
  1322. say("!Command disabled because of hostiles.");
  1323.  
  1324. break;
  1325. }
  1326.  
  1327. this.amy(command[1]);
  1328.  
  1329. break;
  1330. case Config.Enchant.Triggers[12].toLowerCase(): // summoner
  1331. hostile = this.checkHostiles();
  1332.  
  1333. if (shitList.indexOf(command[1]) > -1) {
  1334. say("!zzz...");
  1335. break;
  1336. }
  1337.  
  1338. if (hostile) {
  1339. say("!Command disabled because of hostiles.");
  1340.  
  1341. break;
  1342. }
  1343.  
  1344. this.summoner(command[1]);
  1345.  
  1346. break;
  1347. case Config.Enchant.Triggers[13].toLowerCase(): // dury
  1348. hostile = this.checkHostiles();
  1349.  
  1350. if (shitList.indexOf(command[1]) > -1) {
  1351. say("!zzz...");
  1352. break;
  1353. }
  1354.  
  1355. if (hostile) {
  1356. say("!Command disabled because of hostiles.");
  1357.  
  1358. break;
  1359. }
  1360.  
  1361. this.dury(command[1]);
  1362.  
  1363. break;
  1364. case Config.Enchant.Triggers[14].toLowerCase(): // book
  1365. hostile = this.checkHostiles();
  1366.  
  1367. if (shitList.indexOf(command[1]) > -1) {
  1368. say("!zzz...");
  1369. break;
  1370. }
  1371.  
  1372. if (hostile) {
  1373. say("!Command disabled because of hostiles.");
  1374.  
  1375. break;
  1376. }
  1377.  
  1378. this.book(command[1]);
  1379.  
  1380. break;
  1381. case Config.Enchant.Triggers[15].toLowerCase(): // trav
  1382. hostile = this.checkHostiles();
  1383.  
  1384. if (shitList.indexOf(command[1]) > -1) {
  1385. say("!zzz...");
  1386. break;
  1387. }
  1388.  
  1389. if (hostile) {
  1390. say("!Command disabled because of hostiles.");
  1391.  
  1392. break;
  1393. }
  1394.  
  1395. this.trav(command[1]);
  1396.  
  1397. break;
  1398. case Config.Enchant.Triggers[16].toLowerCase(): // meph
  1399. hostile = this.checkHostiles();
  1400.  
  1401. if (shitList.indexOf(command[1]) > -1) {
  1402. say("!zzz...");
  1403. break;
  1404. }
  1405.  
  1406. if (hostile) {
  1407. say("!Command disabled because of hostiles.");
  1408.  
  1409. break;
  1410. }
  1411.  
  1412. this.meph(command[1]);
  1413.  
  1414. break;
  1415. case Config.Enchant.Triggers[17].toLowerCase(): // izy
  1416. hostile = this.checkHostiles();
  1417.  
  1418. if (shitList.indexOf(command[1]) > -1) {
  1419. say("!zzz...");
  1420. break;
  1421. }
  1422.  
  1423. if (hostile) {
  1424. say("!Command disabled because of hostiles.");
  1425.  
  1426. break;
  1427. }
  1428.  
  1429. this.izy(command[1]);
  1430.  
  1431. break;
  1432. case Config.Enchant.Triggers[18].toLowerCase(): // diablo
  1433. hostile = this.checkHostiles();
  1434.  
  1435. if (shitList.indexOf(command[1]) > -1) {
  1436. say("!zzz...");
  1437. break;
  1438. }
  1439.  
  1440. if (hostile) {
  1441. say("!Command disabled because of hostiles.");
  1442.  
  1443. break;
  1444. }
  1445.  
  1446. this.diablo(command[1]);
  1447.  
  1448. break;
  1449.  
  1450.  
  1451.  
  1452. }
  1453. }
  1454.  
  1455. command = "";
  1456.  
  1457. if (me.act > 1) {
  1458. Town.goToTown(1);
  1459. }
  1460.  
  1461. if (Config.Enchant.AutoChant) {
  1462. this.autoChant();
  1463. }
  1464.  
  1465. if (getTickCount() - startTime >= Config.Enchant.GameLength * 6e4) {
  1466. say("!hosted by gtoilet@jsp , i only join normal games");
  1467. delay(200);
  1468. say("!i will try to join the next game if you make it");
  1469.  
  1470. delay(20000);
  1471.  
  1472. break;
  1473. }
  1474.  
  1475. delay(200);
  1476. }
  1477.  
  1478. return true;
  1479. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement